MODx.grid.Context=function(A){A=A||{};Ext.applyIf(A,{title:_("contexts"),url:MODx.config.connectors_url+"context/index.php",fields:["key","description","perm"],paging:true,autosave:true,remoteSort:true,primaryKey:"key",columns:[{header:_("context_key"),dataIndex:"key",width:150,sortable:true},{header:_("description"),dataIndex:"description",width:575,sortable:false,editor:{xtype:"textfield"}}],tbar:[{text:_("create_new"),handler:{xtype:"modx-window-context-create",blankValues:true}},"->",{xtype:"textfield",name:"search",id:"modx-ctx-search",emptyText:_("search_ellipsis"),listeners:{change:{fn:this.search,scope:this},render:{fn:function(B){new Ext.KeyMap(B.getEl(),{key:Ext.EventObject.ENTER,fn:function(){this.fireEvent("change",this.getValue());this.blur();return true;},scope:B});},scope:this}}},{xtype:"button",id:"modx-filter-clear",text:_("filter_clear"),listeners:{click:{fn:this.clearFilter,scope:this}}}]});MODx.grid.Context.superclass.constructor.call(this,A);};Ext.extend(MODx.grid.Context,MODx.grid.Grid,{updateContext:function(B,A){location.href="index.php?a="+MODx.action["context/update"]+"&key="+this.menu.record.key;},getMenu:function(){var B=this.getSelectionModel().getSelected();var C=B.data.perm;var A=[];if(C.indexOf("pedit")!=-1){A.push({text:_("context_update"),handler:this.updateContext});}if(C.indexOf("premove")!=-1){A.push("-");A.push({text:_("context_remove"),handler:this.remove.createDelegate(this,["context_remove_confirm"])});}return A;},search:function(D,C,B){var A=C||D;this.getStore().baseParams.search=Ext.isEmpty(A)||Ext.isObject(A)?"":A;this.getBottomToolbar().changePage(1);this.refresh();return true;},clearFilter:function(){this.getStore().baseParams={action:"getList"};Ext.getCmp("modx-ctx-search").reset();this.getBottomToolbar().changePage(1);this.refresh();}});Ext.reg("modx-grid-contexts",MODx.grid.Context);MODx.window.CreateContext=function(A){A=A||{};Ext.applyIf(A,{title:_("context_create"),url:MODx.config.connectors_url+"context/index.php",action:"create",fields:[{xtype:"textfield",fieldLabel:_("context_key"),name:"key",anchor:"90%",maxLength:100},{xtype:"textarea",fieldLabel:_("description"),name:"description",anchor:"90%",grow:true}]});MODx.window.CreateContext.superclass.constructor.call(this,A);};Ext.extend(MODx.window.CreateContext,MODx.Window);Ext.reg("modx-window-context-create",MODx.window.CreateContext);MODx.panel.Contexts=function(A){A=A||{};Ext.applyIf(A,{id:"modx-panel-contexts",bodyStyle:"",defaults:{collapsible:false,autoHeight:true},items:[{html:"<h2>"+_("contexts")+"</h2>",border:false,id:"modx-contexts-header",cls:"modx-page-header"},{layout:"form",bodyStyle:"padding: 15px",items:[{html:"<p>"+_("context_management_message")+"</p>",border:false},{xtype:"modx-grid-contexts",preventRender:true}]}]});MODx.panel.Contexts.superclass.constructor.call(this,A);};Ext.extend(MODx.panel.Contexts,MODx.FormPanel);Ext.reg("modx-panel-contexts",MODx.panel.Contexts);