/* * @author: Erik A. Ortiz * Aug 20th, 2010 */ new Ext.KeyMap(document, { key: Ext.EventObject.F5, fn: function(keycode, e) { if (! e.ctrlKey) { if (Ext.isIE) { // IE6 doesn't allow cancellation of the F5 key, so trick it into // thinking some other key was pressed (backspace in this case) e.browserEvent.keyCode = 8; } e.stopEvent(); document.location = document.location; } else Ext.Msg.alert('Refresh', 'You clicked: CTRL-F5'); } }); var removeOption; var installOption; var exportOption; Ext.Ajax.timeout = 300000; Ext.onReady(function(){ //Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); Ext.QuickTips.init(); installOption = new Ext.Action({ text: _('ID_LANG_INSTALL_UPDATE'), iconCls: 'silk-add', icon: '/images/import.gif', handler: function(){ var w = new Ext.Window({ title: '', width: 420, height: 140, modal: true, autoScroll: false, maximizable: false, resizable: false, items: [ new Ext.FormPanel({ /*renderTo: 'form-panel',*/ id:'uploader', fileUpload: true, width: 400, frame: true, title: _('ID_LAN_UPLOAD_TITLE'), autoHeight: false, bodyStyle: 'padding: 10px 10px 0 10px;', labelWidth: 50, defaults: { anchor: '90%', allowBlank: false, msgTarget: 'side' }, items: [{ xtype: 'fileuploadfield', id: 'form-file', emptyText: _('ID_LAN_FILE_WATER_LABEL'), fieldLabel: _('ID_LAN_FILE'), name: 'form[LANGUAGE_FILENAME]', buttonText: '', buttonCfg: { iconCls: 'upload-icon' } }], buttons: [{ text: _('ID_UPLOAD'), handler: function(){ var uploader = Ext.getCmp('uploader'); if(uploader.getForm().isValid()){ uploader.getForm().submit({ url: 'languages_Import', waitTitle:' ', waitMsg: _('ID_UPLOADING_TRANSLATION_FILE'), success: function(o, resp){ w.close(); infoGrid.store.reload(); Ext.MessageBox.show({ title: '', width: 500, height: 500, msg: "
"+resp.result.msg+"", buttons: Ext.MessageBox.OK, animEl: 'mb9', fn: function(){}, icon: Ext.MessageBox.INFO }); }, failure: function(o, resp){ w.close(); //alert('ERROR "'+resp.result.msg+'"'); Ext.MessageBox.show({title: '', msg: resp.result.msg, buttons: Ext.MessageBox.OK, animEl: 'mb9', fn: function(){}, icon: Ext.MessageBox.ERROR}); //setTimeout(function(){Ext.MessageBox.hide(); }, 2000); } }); } } }/*,{ text: 'Reset', handler: function(){ uploader = Ext.getCmp('uploader'); uploader.getForm().reset(); } }*/,{ text: _('ID_CANCEL'), handler: function(){ w.close(); } }] }) ]/*, listeners:{ show:function() { this.loadMask = new Ext.LoadMask(this.body, { msg:'Loading. Please wait...' }); } }*/ }); w.show(); } }); exportOption = new Ext.Action({ text: _('ID_EXPORT'), iconCls: 'silk-add', icon: '/images/export.png', handler: function(){ iGrid = Ext.getCmp('infoGrid'); var rowSelected = iGrid.getSelectionModel().getSelected(); if( rowSelected ) { location.href = 'languages_Export?LOCALE='+rowSelected.data.LOCALE+'&rand='+Math.random() } else { Ext.Msg.show({ title:'', msg: _('ID_SELECT_LANGUAGE_FROM_LIST'), buttons: Ext.Msg.INFO, fn: function(){}, animEl: 'elId', icon: Ext.MessageBox.INFO, buttons: Ext.MessageBox.OK }); } } }); removeOption = new Ext.Action({ text: _('ID_DELETE_LANGUAGE'), iconCls: 'silk-add', icon: '/images/delete-16x16.gif', handler: function(){ iGrid = Ext.getCmp('infoGrid'); var rowSelected = iGrid.getSelectionModel().getSelected(); if( rowSelected ) { langId = rowSelected.data.LAN_ID; langName = rowSelected.data.LAN_NAME; countryName = rowSelected.data.COUNTRY_NAME; locale = rowSelected.data.LOCALE; confirmMsg = _('ID_DELETE_LANGUAGE_CONFIRM'); confirmMsg = confirmMsg.replace('{0}', locale); Ext.Msg.show({ title:'', msg: confirmMsg, buttons: Ext.Msg.YESNO, fn: function(btn){ if( btn == 'yes' ) { Ext.Ajax.request({ url: 'language_Ajax', success: function(response){ infoGrid.store.reload(); Ext.Msg.show({ title:'', msg: response.responseText, buttons: Ext.Msg.INFO, fn: function(){}, animEl: 'elId', icon: Ext.MessageBox.INFO, buttons: Ext.MessageBox.OK }); }, failure: function(){}, params: { 'function': 'delete', 'LOCALE': locale, 'LAN_ID': langId } }); } }, animEl: 'elId', icon: Ext.MessageBox.QUESTION }); } else { Ext.Msg.show({ title:'', msg: _('ID_DELETE_LANGUAGE_WARNING'), buttons: Ext.Msg.INFO, fn: function(){}, animEl: 'elId', icon: Ext.MessageBox.INFO, buttons: Ext.MessageBox.OK }); } } }); var infoGrid = new Ext.grid.GridPanel( { /*renderTo: 'list-panel',*/ region: 'center', layout: 'fit', id: 'infoGrid', stripeRows : true, autoHeight : true, autoWidth : true, title : '', stateful : true, stateId : 'gridSetupLanguage', enableColumnHide: false, enableColumnResize: true, enableHdMenu: false, collapsible: false, animCollapse: false, view: new Ext.grid.GroupingView({ forceFit:true, //groupTextTpl: '{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})' groupTextTpl: '{text}' }), columns : [ { dataIndex : 'LAN_FLAG', id : 'LAN_FLAG', header : '', width : 30, sortable : false, renderer: function (value, p, r){ //return String.format("{0}", value, 'color:green;' ); var e = (value == 'international') ? 'png': 'gif'; return String.format("