Code style

This commit is contained in:
Marco Antonio Nina Mena
2017-11-20 10:14:14 -04:00
parent f841814a7d
commit e07458c721

View File

@@ -1,348 +1,348 @@
Ext.onReady(function() { Ext.onReady(function () {
var store = new Ext.data.JsonStore({ var store = new Ext.data.JsonStore({
proxy : new Ext.data.HttpProxy({ proxy: new Ext.data.HttpProxy({
url : '../adminProxy/getListImage', method: 'POST' url: '../adminProxy/getListImage', method: 'POST'
}), }),
root : 'images', root: 'images',
fields : [ fields: [
'name', 'url', 'name', 'url',
{name : 'size', type : 'float'}, {name: 'size', type: 'float'},
{name : 'lastmod', type : 'date', dateFormat: 'timestamp'}, {name: 'lastmod', type: 'date', dateFormat: 'timestamp'},
'thumb_url' 'thumb_url'
] ]
}); });
store.load(); store.load();
var tpl = new Ext.XTemplate( var tpl = new Ext.XTemplate(
'<ul>', '<ul>',
'<tpl for=".">', '<tpl for=".">',
'<li class="pagedTableDefault" >', '<li class="pagedTableDefault" >',
'<div class="thumb-wrap" id="{name}">', '<div class="thumb-wrap" id="{name}">',
'<img src="{thumb_url}" title="{name}">', '<img src="{thumb_url}" title="{name}">',
'</div>', '</div>',
'</li>', '</li>',
'<span class="x-editable">{shortName}</span></div>', '<span class="x-editable">{shortName}</span></div>',
'</tpl>', '</tpl>',
'<div class="x-clear"></div>', '<div class="x-clear"></div>',
'</ul>' '</ul>'
); );
var tplDetail = new Ext.XTemplate( var tplDetail = new Ext.XTemplate(
'<div class="details">', '<div class="details">',
'<tpl for=".">', '<tpl for=".">',
'<img src="{thumb_url}"><div class="details-info">', '<img src="{thumb_url}"><div class="details-info">',
'<b>Image Name:</b>', '<b>Image Name:</b>',
'<span>{name}</span>', '<span>{name}</span>',
'<span><a href="{url}" target="_blank">view original</a></span></div>', '<span><a href="{url}" target="_blank">view original</a></span></div>',
'</tpl>', '</tpl>',
'</div>' '</div>'
); );
var tbar = new Ext.Toolbar(); var tbar = new Ext.Toolbar();
tbar.add({ tbar.add({
text : _('ID_APPLY'), text: _('ID_APPLY'),
icon : '/images/ext/default/accept.png', icon: '/images/ext/default/accept.png',
id : 'tbarAply', id: 'tbarAply',
disabled: true, disabled: true,
handler : function() { handler: function () {
var records = datav.getSelectedRecords(); var records = datav.getSelectedRecords();
if (records.length != 0) { if (records.length != 0) {
if(records.length == 1) { if (records.length == 1) {
var myMask = new Ext.LoadMask(Ext.getBody(), {msg:_('ID_LOADING')}); var myMask = new Ext.LoadMask(Ext.getBody(), {msg: _('ID_LOADING')});
myMask.show(); myMask.show();
var imageName = records[0].data.name; var imageName = records[0].data.name;
Ext.Ajax.request({ Ext.Ajax.request({
url : '../adminProxy/replacementLogo', url: '../adminProxy/replacementLogo',
method : 'post', method: 'post',
params : {nameFunction: 'replacementLogo', NAMELOGO:imageName}, params: {nameFunction: 'replacementLogo', NAMELOGO: imageName},
success : function() { success: function () {
if (typeof parent.parent.Ext != 'undefined') { if (typeof parent.parent.Ext != 'undefined') {
parent.parent.location.href = '../main?st=admin'; parent.parent.location.href = '../main?st=admin';
} }
else { else {
window.parent.window.parent.location.href = window.parent.window.parent.window.location.href window.parent.window.parent.location.href = window.parent.window.parent.window.location.href
} }
} }
}); });
} }
else { else {
PMExt.notify( _('ID_NOTICE'), _('ID_YOU_ARE_NOT_CAN_SELECT_PHOTO')); PMExt.notify(_('ID_NOTICE'), _('ID_YOU_ARE_NOT_CAN_SELECT_PHOTO'));
} }
}
else {
PMExt.notify( _('ID_NOTICE'), _('ID_SELECT_AN_IMAGE'));
}
}
});
tbar.add({
text : _('ID_DELETE'),
icon : '/images/delete-16x16.gif',
id : 'tbarDelete',
disabled: true,
handler : function() {
var records = datav.getSelectedRecords();
var isCurrentLogo = false;
if (records.length != 0) {
if (records.length == 1) {
var imgName = '';
for (var i = 0; i < records.length; i++) {
imgName = imgName + records[i].data.name + ';';
}
Ext.Ajax.request({
url : '../adminProxy/isCurrentLogo',
method : 'post',
params : { selectLogo : imgName },
success : function(response) {
store.load();
oResponse = Ext.decode( response.responseText );
if (oResponse.success == true) {
Ext.Msg.alert(_('ID_LOGO'), _('ID_SELECTED_IMAGE_IS_LOGO'));
isCurrentLogo = true;
}
} }
}); else {
if(isCurrentLogo == false) { PMExt.notify(_('ID_NOTICE'), _('ID_SELECT_AN_IMAGE'));
Ext.Msg.show({ }
title : _('ID_LOGO'), }
msg : _('ID_DELETE_SELECTED_LOGO'), });
buttons: Ext.Msg.YESNO,
fn : function(btn) {
if(btn == 'yes') {
Ext.Ajax.request({
url : '../adminProxy/deleteImage',
method : 'post',
params : {images : imgName},
success : function(response) {
store.load();
oResponse = Ext.decode( response.responseText );
if (oResponse.success == true) {
PMExt.notify( _('ID_NOTICE'), _('ID_SELECTED_IMAGE_DELETED'));
}
else {
PMExt.notify( _('ID_NOTICE'), _('ID_SELECTED_IMAGE_IS_LOGO'));
}
}
});
} tbar.add({
}, text: _('ID_DELETE'),
animEl : 'elId', icon: '/images/delete-16x16.gif',
icon : Ext.MessageBox.QUESTION id: 'tbarDelete',
disabled: true,
handler: function () {
var records = datav.getSelectedRecords();
var isCurrentLogo = false;
if (records.length != 0) {
if (records.length == 1) {
var imgName = '';
for (var i = 0; i < records.length; i++) {
imgName = imgName + records[i].data.name + ';';
}
Ext.Ajax.request({
url: '../adminProxy/isCurrentLogo',
method: 'post',
params: {selectLogo: imgName},
success: function (response) {
store.load();
oResponse = Ext.decode(response.responseText);
if (oResponse.success == true) {
Ext.Msg.alert(_('ID_LOGO'), _('ID_SELECTED_IMAGE_IS_LOGO'));
isCurrentLogo = true;
}
}
});
if (isCurrentLogo == false) {
Ext.Msg.show({
title: _('ID_LOGO'),
msg: _('ID_DELETE_SELECTED_LOGO'),
buttons: Ext.Msg.YESNO,
fn: function (btn) {
if (btn == 'yes') {
Ext.Ajax.request({
url: '../adminProxy/deleteImage',
method: 'post',
params: {images: imgName},
success: function (response) {
store.load();
oResponse = Ext.decode(response.responseText);
if (oResponse.success == true) {
PMExt.notify(_('ID_NOTICE'), _('ID_SELECTED_IMAGE_DELETED'));
}
else {
PMExt.notify(_('ID_NOTICE'), _('ID_SELECTED_IMAGE_IS_LOGO'));
}
}
});
}
},
animEl: 'elId',
icon: Ext.MessageBox.QUESTION
});
}
}
else {
PMExt.notify(_('ID_NOTICE'), _('ID_YOU_ARE_NOT_CAN_SELECT_PHOTO'));
}
}
else {
PMExt.notify(_('ID_NOTICE'), _('ID_SELECT_AN_IMAGE'));
}
}
});
tbar.add({
text: _('ID_RESTORE_DEFAULT'),
icon: '/images/icon-pmlogo-15x15.png',
handler: function () {
var records = datav.getSelectedRecords();
var myMask = new Ext.LoadMask(Ext.getBody(), {msg: _('ID_LOADING')});
myMask.show();
var imageName = 'name';
Ext.Ajax.request({
url: '../adminProxy/replacementLogo',
method: 'post',
params: {nameFunction: 'restoreLogo', NAMELOGO: imageName},
success: function () {
if (typeof parent.parent.Ext != 'undefined') {
parent.parent.location.href = '../main?st=admin';
}
else {
window.parent.window.parent.location.href = window.parent.window.parent.window.location.href
}
}
}); });
}
} }
else { });
PMExt.notify( _('ID_NOTICE'), _('ID_YOU_ARE_NOT_CAN_SELECT_PHOTO'));
tbar.add('-', {
text: _('ID_UPLOAD'),
iconCls: 'silk-add',
icon: '/images/import.gif',
handler: function () {
uploadWin.show();
} }
} })
else {
PMExt.notify( _('ID_NOTICE'), _('ID_SELECT_AN_IMAGE'));
}
}
});
tbar.add({ var datav = new Ext.DataView({
text : _('ID_RESTORE_DEFAULT'), autoScroll: true,
icon : '/images/icon-pmlogo-15x15.png', store: store,
handler : function() { tpl: tpl,
var records = datav.getSelectedRecords(); autoHeight: false,
var myMask = new Ext.LoadMask(Ext.getBody(), {msg : _('ID_LOADING')}); height: 800,
myMask.show(); multiSelect: true,
var imageName = 'name'; autoScroll: true,
Ext.Ajax.request({ overClass: 'x-view-over',
url : '../adminProxy/replacementLogo', itemSelector: 'div.thumb-wrap',
method : 'post', emptyText: _('ID_NO_IMAGES_TO_DISPLAY'),
params : {nameFunction: 'restoreLogo', NAMELOGO:imageName},
success : function() {
if (typeof parent.parent.Ext != 'undefined') {
parent.parent.location.href = '../main?st=admin';
}
else {
window.parent.window.parent.location.href = window.parent.window.parent.window.location.href
}
}
});
}
});
tbar.add('-', { listeners: {
text : _('ID_UPLOAD'), selectionchange: {
iconCls : 'silk-add', fn: function (dv, nodes) {
icon : '/images/import.gif', var l = nodes.length;
handler : function(){ var s = l != 1 ? 's' : '';
uploadWin.show(); panelLeft.setTitle(_('PHOTO_GALLERY') + '(' + l + ' ' + _('ID_IMAGE') + s + ' ' + _('ID_SELECTED') + ')');
} if (nodes.length > 0) {
}) Ext.getCmp('tbarAply').enable();
Ext.getCmp('tbarDelete').enable();
}
else {
Ext.getCmp('tbarAply').disable();
Ext.getCmp('tbarDelete').disable();
}
var datav = new Ext.DataView({ }
autoScroll : true, }
store : store,
tpl : tpl,
autoHeight : false,
height : 800,
multiSelect : true,
autoScroll: true,
overClass : 'x-view-over',
itemSelector: 'div.thumb-wrap',
emptyText : _('ID_NO_IMAGES_TO_DISPLAY'),
listeners : {
selectionchange : {
fn : function(dv,nodes){
var l = nodes.length;
var s = l != 1 ? 's' : '';
panelLeft.setTitle(_('PHOTO_GALLERY') + '(' + l + ' ' + _('ID_IMAGE') + s + ' ' + _('ID_SELECTED') + ')');
if (nodes.length > 0) {
Ext.getCmp('tbarAply').enable();
Ext.getCmp('tbarDelete').enable();
}
else {
Ext.getCmp('tbarAply').disable();
Ext.getCmp('tbarDelete').disable();
}
}
}
// , // ,
// click : { // click : {
// fn : function() { // fn : function() {
// } // }
// } // }
}
})
var panelLeft = new Ext.Panel({
region : 'center',
id : 'images-view',
frame : true,
width : 520,
autoHeight : true,
layout : 'auto',
title : _('PHOTO_GALLERY') + '(0 ' + _('ID_IMAGES_SELECTED') + ')',
items : [tbar, datav]
});
var panelRightTop = new Ext.FormPanel({
title : _('ID_UPLOAD_IMAGE'),
width : 270,
labelAlign : 'right',
fileUpload : true,
frame : true,
defaults : {
anchor : '90%',
allowBlank : false,
msgTarget : 'side'
},
items:
[
{
xtype : 'fileuploadfield',
emptyText : '',
fieldLabel : _('ID_IMAGE'),
buttonText : _('ID_SELECT_FILE'),
name : 'img',
validator: function (filePath) {
var flag, btn;
btn = Ext.getCmp('btnUpload');
btn.disable();
filePath = filePath.replace(/^\s|\s$/g, ""); //trims string
if (filePath.match(/([^\/\\]+)\.(gif|png|jpg|jpeg|pjpeg|x-png)$/i)) {
flag = true;
btn.enable();
} else {
messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE');
PMExt.notify(_('ID_SUCCESS'), messageError);
flag = false;
}
return flag;
}
}
],
buttons :
[
{
text : _('ID_UPLOAD'),
id : 'btnUpload',
disabled: true,
handler : function() {
panelRightTop.getForm().submit({
url : '../adminProxy/uploadImage',
waitMsg : _('ID_LOADING'),
waitTitle : "&nbsp;",
success : function(form, o) {
obj = Ext.util.JSON.decode(o.response.responseText);
if ((obj.failed == '' || obj.failed == '0') && obj.uploaded != '0') {
PMExt.notify(_('ID_SUCCESS'), _('ID_YOUR_IMAGE_HAS_BEEN_SUCCESSFULLY'));
}
else {
var messageError = "";
if (obj.failed == "1") {
//| 1-> Fail in the type of the image
messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE');
}
else if(obj.failed == "2") {
//| 2-> Fail in the size of the image
messageError = _('ID_UPLOADING_IMAGE_WRONG_SIZE');
}
else if(obj.failed == "3") {
//| 3-> fail in de mime of the image
messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE');
}
PMExt.notify(_('ID_SUCCESS'), messageError);
}
panelRightTop.getForm().reset();
store.load();
uploadWin.hide();
}
});
} }
}, })
{
text : _('ID_CANCEL'),
handler : function() {
uploadWin.hide();
}
}
]
});
uploadWin = new Ext.Window({ var panelLeft = new Ext.Panel({
title : '', region: 'center',
id : 'uploadWin', id: 'images-view',
layout : 'fit', frame: true,
width : 420, width: 520,
height : 140, autoHeight: true,
modal : false, layout: 'auto',
autoScroll : true, title: _('PHOTO_GALLERY') + '(0 ' + _('ID_IMAGES_SELECTED') + ')',
closeAction : 'hide', items: [tbar, datav]
maximizable : false, });
resizable : false,
draggable : false,
items : [panelRightTop]
});
var panelRightBottom = new Ext.Panel({
region : 'east',
title : _('IMAGE_DETAIL'),
frame : true,
width : 200,
height : 255,
split : true,
collapsible : true,
collapseMode : 'mini',
margins : '0 0 0 0',
id : 'panelDetail',
tpl : tplDetail
});
var viewport = new Ext.Viewport({ var panelRightTop = new Ext.FormPanel({
layout : 'border', title: _('ID_UPLOAD_IMAGE'),
autoScroll : false, width: 270,
items : [ panelLeft ] labelAlign: 'right',
}); fileUpload: true,
frame: true,
defaults: {
anchor: '90%',
allowBlank: false,
msgTarget: 'side'
},
items:
[
{
xtype: 'fileuploadfield',
emptyText: '',
fieldLabel: _('ID_IMAGE'),
buttonText: _('ID_SELECT_FILE'),
name: 'img',
validator: function (filePath) {
var flag, btn;
btn = Ext.getCmp('btnUpload');
btn.disable();
filePath = filePath.replace(/^\s|\s$/g, ""); //trims string
if (filePath.match(/([^\/\\]+)\.(gif|png|jpg|jpeg|pjpeg|x-png)$/i)) {
flag = true;
btn.enable();
} else {
messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE');
PMExt.notify(_('ID_SUCCESS'), messageError);
flag = false;
}
return flag;
}
}
],
buttons:
[
{
text: _('ID_UPLOAD'),
id: 'btnUpload',
disabled: true,
handler: function () {
panelRightTop.getForm().submit({
url: '../adminProxy/uploadImage',
waitMsg: _('ID_LOADING'),
waitTitle: "&nbsp;",
success: function (form, o) {
obj = Ext.util.JSON.decode(o.response.responseText);
if ((obj.failed == '' || obj.failed == '0') && obj.uploaded != '0') {
PMExt.notify(_('ID_SUCCESS'), _('ID_YOUR_IMAGE_HAS_BEEN_SUCCESSFULLY'));
}
else {
var messageError = "";
if (obj.failed == "1") {
//| 1-> Fail in the type of the image
messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE');
}
else if (obj.failed == "2") {
//| 2-> Fail in the size of the image
messageError = _('ID_UPLOADING_IMAGE_WRONG_SIZE');
}
else if (obj.failed == "3") {
//| 3-> fail in de mime of the image
messageError = _('ID_ERROR_UPLOADING_IMAGE_TYPE');
}
PMExt.notify(_('ID_SUCCESS'), messageError);
}
panelRightTop.getForm().reset();
store.load();
uploadWin.hide();
}
});
}
},
{
text: _('ID_CANCEL'),
handler: function () {
uploadWin.hide();
}
}
]
});
uploadWin = new Ext.Window({
title: '',
id: 'uploadWin',
layout: 'fit',
width: 420,
height: 140,
modal: false,
autoScroll: true,
closeAction: 'hide',
maximizable: false,
resizable: false,
draggable: false,
items: [panelRightTop]
});
var panelRightBottom = new Ext.Panel({
region: 'east',
title: _('IMAGE_DETAIL'),
frame: true,
width: 200,
height: 255,
split: true,
collapsible: true,
collapseMode: 'mini',
margins: '0 0 0 0',
id: 'panelDetail',
tpl: tplDetail
});
var viewport = new Ext.Viewport({
layout: 'border',
autoScroll: false,
items: [panelLeft]
});
}); });