GO.links.SettingsDialog=function(b){if(!b){b={}}var a=[{xtype:"htmlcomponent",html:GO.links.lang.defaultLinkFolderText}];for(var c=0;c<GO.linkTypes.length;c++){a.push({xtype:"textarea",fieldLabel:GO.linkTypes[c].name,name:"default_folders_"+GO.linkTypes[c].id,anchor:"-20",height:40})}this.defaultFoldersPanel=new Ext.FormPanel({title:GO.links.lang.linkFolders,cls:"go-form-panel",url:GO.settings.modules.links.url+"action.php",baseParams:{task:"save_default_link_folders"},autoScroll:true,items:a,buttonAlign:"right",buttons:[{text:GO.lang.cmdSave,handler:function(){this.defaultFoldersPanel.form.submit()},scope:this}]});b.layout="fit";b.modal=false;b.resizable=false;b.width=750;b.height=500;b.closeAction="hide";b.title=GO.lang.cmdSettings;b.items={xtype:"tabpanel",activeTab:0,border:false,deferredRender:false,enableTabScroll:true,items:[new GO.links.LinkDescriptionsGrid(),this.defaultFoldersPanel]};GO.links.SettingsDialog.superclass.constructor.call(this,b)};Ext.extend(GO.links.SettingsDialog,Ext.Window,{afterRender:function(){GO.links.SettingsDialog.superclass.afterRender.call(this);this.defaultFoldersPanel.load({url:GO.settings.modules.links.url+"json.php",params:{task:"default_link_folders"}})}});GO.links.LinkDescriptionDialog=function(b){if(!b){b={}}this.buildForm();var a=function(){this.formPanel.items.items[0].focus()};b.collapsible=true;b.maximizable=true;b.layout="fit";b.modal=false;b.resizable=false;b.width=300;b.autoHeight=true;b.closeAction="hide";b.title=GO.links.lang.linkDescription;b.items=this.formPanel;b.focus=a.createDelegate(this);b.buttons=[{text:GO.lang.cmdOk,handler:function(){this.submitForm(true)},scope:this},{text:GO.lang.cmdApply,handler:function(){this.submitForm()},scope:this},{text:GO.lang.cmdClose,handler:function(){this.hide()},scope:this}];GO.links.LinkDescriptionDialog.superclass.constructor.call(this,b);this.addEvents({save:true})};Ext.extend(GO.links.LinkDescriptionDialog,Ext.Window,{show:function(b,a){if(!this.rendered){this.render(Ext.getBody())}this.formPanel.form.reset();if(!b){b=0}this.setLinkDescriptionId(b);if(this.link_description_id>0){this.formPanel.load({url:GO.settings.modules.links.url+"json.php",waitMsg:GO.lang.waitMsgLoad,success:function(c,d){GO.links.LinkDescriptionDialog.superclass.show.call(this)},failure:function(c,d){Ext.Msg.alert(GO.lang.strError,d.result.feedback)},scope:this})}else{GO.links.LinkDescriptionDialog.superclass.show.call(this)}},setLinkDescriptionId:function(a){this.formPanel.form.baseParams.link_description_id=a;this.link_description_id=a},submitForm:function(a){this.formPanel.form.submit({url:GO.settings.modules.links.url+"action.php",params:{task:"save_link_description"},waitMsg:GO.lang.waitMsgSave,success:function(b,c){if(c.result.link_description_id){this.setLinkDescriptionId(c.result.link_description_id)}this.fireEvent("save",this,this.link_description_id);if(a){this.hide()}},failure:function(b,c){if(c.failureType=="client"){Ext.MessageBox.alert(GO.lang.strError,GO.lang.strErrorsInForm)}else{Ext.MessageBox.alert(GO.lang.strError,c.result.feedback)}},scope:this})},buildForm:function(){this.formPanel=new Ext.FormPanel({waitMsgTarget:true,baseParams:{task:"link_description"},url:GO.settings.modules.links.url+"action.php",cls:"go-form-panel",layout:"form",autoHeight:true,items:[{xtype:"textfield",name:"description",anchor:"-20",fieldLabel:GO.lang.strDescription}]})}});GO.links.LinkDescriptionsGrid=function(a){if(!a){a={}}a.title=GO.links.lang.linkDescriptions;a.layout="fit";a.autoScroll=true;a.split=true;a.closable=false;a.store=new GO.data.JsonStore({url:GO.settings.config.host+"json.php",baseParams:{task:"link_descriptions"},root:"results",id:"id",totalProperty:"total",fields:["id","description"],remoteSort:true});var b=new Ext.grid.ColumnModel({defaults:{sortable:true},columns:[{header:GO.lang.strDescription,dataIndex:"description"}]});a.cm=b;a.view=new Ext.grid.GridView({autoFill:true,forceFit:true,emptyText:GO.lang.strNoItems});a.sm=new Ext.grid.RowSelectionModel();a.loadMask=true;this.linkDescriptionDialog=new GO.links.LinkDescriptionDialog();this.linkDescriptionDialog.on("save",function(){this.store.reload()},this);a.tbar=[{iconCls:"btn-add",text:GO.lang.cmdAdd,cls:"x-btn-text-icon",handler:function(){this.linkDescriptionDialog.show()},scope:this},{iconCls:"btn-delete",text:GO.lang.cmdDelete,cls:"x-btn-text-icon",handler:function(){this.deleteSelected()},scope:this}];GO.links.LinkDescriptionsGrid.superclass.constructor.call(this,a);this.on("rowdblclick",function(d,e){var c=d.getStore().getAt(e);this.linkDescriptionDialog.show(c.data.id)},this)};Ext.extend(GO.links.LinkDescriptionsGrid,GO.grid.GridPanel,{afterRender:function(){GO.links.LinkDescriptionsGrid.superclass.afterRender.call(this);this.store.load()}});