/* Minify: at least one missing file. See http://code.google.com/p/minify/wiki/Debugging */

;Ext.onReady(function(){if(MODx.config.manager_language=='en')return false;Date.dayNames=[_('sunday'),_('monday'),_('tuesday'),_('wednesday'),_('thursday'),_('friday'),_('saturday')];Date.monthNames=[_('january'),_('february'),_('march'),_('april'),_('may'),_('june'),_('july'),_('august'),_('september'),_('october'),_('november'),_('december')];Ext.apply(Ext.grid.GridView.prototype,{sortAscText:_('ext_sortasc'),sortDescText:_('ext_sortdesc'),lockText:_('ext_column_lock'),unlockText:_('ext_column_unlock'),columnsText:_('ext_columns'),emptyText:_('ext_emptymsg')});Ext.apply(Ext.DatePicker.prototype,{todayText:_('today'),todayTip:_('ext_today_tip'),minText:_('ext_mindate'),maxText:_('ext_maxdate'),monthNames:Date.monthNames,dayNames:Date.dayNames,nextText:_('ext_nextmonth'),prevText:_('ext_prevmonth'),monthYearText:_('ext_choosemonth')});Ext.MessageBox.buttonText={yes:_('yes'),no:_('no'),ok:_('ok'),cancel:_('cancel')};Ext.apply(Ext.PagingToolbar.prototype,{afterPageText:_('ext_afterpage'),beforePageText:_('ext_beforepage'),displayMsg:_('ext_displaying'),emptyMsg:_('ext_emptymsg'),firstText:_('ext_first'),prevText:_('ext_prev'),nextText:_('ext_next'),lastText:_('ext_last'),refreshText:_('ext_refresh')});Ext.apply(Ext.Updater.prototype,{text:_('loading')});Ext.apply(Ext.LoadMask.prototype,{msg:_('loading')});Ext.apply(Ext.layout.BorderLayout.SplitRegion.prototype,{splitTip:_('ext_splittip')});Ext.apply(Ext.form.BasicForm.prototype,{waitTitle:_('please_wait')});Ext.apply(Ext.form.ComboBox.prototype,{loadingText:_('loading')});Ext.apply(Ext.form.Field.prototype,{invalidText:_('ext_invalidfield')});Ext.apply(Ext.form.TextField.prototype,{minLengthText:_('ext_minlenfield'),maxLengthText:_('ext_maxlenfield'),invalidText:_('ext_invalidfield'),blankText:_('field_required')});Ext.apply(Ext.form.NumberField.prototype,{minText:_('ext_minvalfield'),maxText:_('ext_maxvalfield'),nanText:_('ext_nanfield')});Ext.apply(Ext.form.DateField.prototype,{disabledDaysText:_('disabled'),disabledDatesText:_('disabled'),minText:_('ext_datemin'),maxText:_('ext_datemax'),invalidText:_('ext_dateinv')});Ext.apply(Ext.form.VTypes,{emailText:_('ext_inv_email'),urlText:_('ext_inv_url'),alphaText:_('ext_inv_alpha'),alphanumText:_('ext_inv_alphanum')});Ext.apply(Ext.grid.GroupingView.prototype,{emptyGroupText:_('ext_emptygroup'),groupByText:_('ext_groupby'),showGroupsText:_('ext_showgroups')});Ext.apply(Ext.grid.PropertyColumnModel.prototype,{nameText:_('name'),valueText:_('value')});Ext.apply(Ext.form.CheckboxGroup.prototype,{blankText:_('ext_checkboxinv')});Ext.apply(Ext.form.RadioGroup.prototype,{blankText:_('ext_checkboxinv')});Ext.apply(Ext.form.TimeField.prototype,{minText:_('ext_timemin'),maxText:_('ext_timemax'),invalidText:_('ext_timeinv')});});;Ext.namespace('MODx.util.Progress');MODx.util.JSONReader=function(config){config=config||{};Ext.applyIf(config,{successProperty:'success',totalProperty:'total',root:'data'});MODx.util.JSONReader.superclass.constructor.call(this,config,['id','msg']);};Ext.extend(MODx.util.JSONReader,Ext.data.JsonReader);Ext.reg('modx-json-reader',MODx.util.JSONReader);MODx.util.Progress={id:0,time:function(v,id,msg){msg=msg||_('saving');if(MODx.util.Progress.id===id&&v<11){Ext.MessageBox.updateProgress(v/10,msg);}},reset:function(){MODx.util.Progress.id=MODx.util.Progress.id+1;}};MODx.LockMask=function(config){config=config||{};Ext.applyIf(config,{msg:_('locked'),msgCls:'modx-lockmask'});MODx.LockMask.superclass.constructor.call(this,config.el,config);};Ext.extend(MODx.LockMask,Ext.LoadMask,{locked:false,toggle:function(){if(this.locked){this.hide();this.locked=false;}else{this.show();this.locked=true;}},lock:function(){this.locked=true;this.show();},unlock:function(){this.locked=false;this.hide();}});Ext.reg('modx-lockmask',MODx.LockMask);Ext.override(Ext.form.BasicForm,{clearDirty:function(nodeToRecurse){nodeToRecurse=nodeToRecurse||this;nodeToRecurse.items.each(function(f){if(!f.getValue)return;if(f.items){this.clearDirty(f);}else if(f.originalValue!=f.getValue()){f.originalValue=f.getValue();}},this);}});MODx.StaticTextField=Ext.extend(Ext.form.TextField,{fieldClass:'x-static-text-field',onRender:function(){this.readOnly=true;this.disabled=!this.initialConfig.submitValue;MODx.StaticTextField.superclass.onRender.apply(this,arguments);}});Ext.reg('statictextfield',MODx.StaticTextField);MODx.StaticBoolean=Ext.extend(Ext.form.TextField,{fieldClass:'x-static-text-field',onRender:function(tf){this.readOnly=true;this.disabled=!this.initialConfig.submitValue;MODx.StaticBoolean.superclass.onRender.apply(this,arguments);this.on('change',this.onChange,this);},setValue:function(v){if(v===1){this.addClass('green');v=_('yes');}else{this.addClass('red');v=_('no');}
MODx.StaticBoolean.superclass.setValue.apply(this,arguments);}});Ext.reg('staticboolean',MODx.StaticBoolean);Ext.override(Ext.form.Checkbox,{setBoxLabel:function(boxLabel){this.boxLabel=boxLabel;if(this.rendered){this.wrap.child('.x-form-cb-label').update(boxLabel);}}});Array.prototype.in_array=function(p_val){for(var i=0,l=this.length;i<l;i=i+1){if(this[i]===p_val){return true;}}
return false;};Ext.form.setCheckboxValues=function(form,id,mask){var f,n=0;while((f=form.findField(id+n))!==null){f.setValue((mask&(1<<n))?'true':'false');n=n+1;}};Ext.form.getCheckboxMask=function(cbgroup){var mask='';if(typeof(cbgroup)!=='undefined'){if((typeof(cbgroup)==='string')){mask=cbgroup+'';}else{for(var i=0,len=cbgroup.length;i<len;i=i+1){mask+=(mask!==''?',':'')+(cbgroup[i]-0);}}}
return mask;};Ext.form.BasicForm.prototype.append=function(){var layout=new Ext.form.Layout();var fields=[];layout.stack.push.apply(layout.stack,arguments);for(var i=0;i<arguments.length;i=i+1){if(arguments[i].isFormField){fields.push(arguments[i]);}}
layout.render(this.el);if(fields.length>0){this.items.addAll(fields);for(var f=0;f<fields.length;f=f+1){fields[f].render('x-form-el-'+fields[f].id);}}
return this;};Ext.form.AMPMField=function(id,v){return new Ext.form.ComboBox({store:new Ext.data.SimpleStore({fields:['ampm'],data:[['am'],['pm']]}),displayField:'ampm',hiddenName:id,mode:'local',editable:false,forceSelection:true,triggerAction:'all',width:60,value:v||'am'});};Ext.form.HourField=function(id,name,v){return new Ext.form.ComboBox({store:new Ext.data.SimpleStore({fields:['hour'],data:[[1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12]]}),displayField:'hour',mode:'local',triggerAction:'all',width:60,forceSelection:true,rowHeight:false,editable:false,value:v||1,transform:id});};Ext.override(Ext.tree.TreeNodeUI,{hasClass:function(className){var el=Ext.fly(this.elNode);if(!el)return'';return className&&(' '+el.dom.className+' ').indexOf(' '+className+' ')!==-1;},renderElements:function(n,a,targetNode,bulkRender){this.indentMarkup=n.parentNode?n.parentNode.ui.getChildIndent():'';var cb=Ext.isBoolean(a.checked),nel,href=this.getHref(a.href),iconMarkup='<i class="icon'+(a.icon?" x-tree-node-inline-icon":"")+(a.iconCls?" "+a.iconCls:"")+'" unselectable="on"></i>',elbowMarkup=n.attributes.pseudoroot?'<i class="icon-sort-down expanded-icon"></i>':'<i class="x-tree-ec-icon x-tree-elbow"></i>',buf=['<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ',a.cls,'" unselectable="on">','<span class="x-tree-node-indent">',this.indentMarkup,"</span>",elbowMarkup,iconMarkup,cb?('<input class="x-tree-node-cb" type="checkbox" '+(a.checked?'checked="checked" />':'/>')):'','<a hidefocus="on" class="x-tree-node-anchor" href="',href,'" tabIndex="1" ',a.hrefTarget?' target="'+a.hrefTarget+'"':"",'><span unselectable="on">',n.text,"</span></a></div>",'<ul class="x-tree-node-ct" style="display:none;"></ul>',"</li>"].join('');if(bulkRender!==true&&n.nextSibling&&(nel=n.nextSibling.ui.getEl())){this.wrap=Ext.DomHelper.insertHtml("beforeBegin",nel,buf);}else{this.wrap=Ext.DomHelper.insertHtml("beforeEnd",targetNode,buf);}
this.elNode=this.wrap.childNodes[0];this.ctNode=this.wrap.childNodes[1];var cs=this.elNode.childNodes;this.indentNode=cs[0];this.ecNode=cs[1];this.iconNode=cs[2];var index=3;if(cb){this.checkbox=cs[3];this.checkbox.defaultChecked=this.checkbox.checked;index++;}
this.anchor=cs[index];this.textNode=cs[index].firstChild;},getChildIndent:function(){if(!this.childIndent){var buf=[],p=this.node;while(p){if((!p.isRoot||(p.isRoot&&p.ownerTree.rootVisible))&&!p.attributes.pseudoroot){if(!p.isLast()){buf.unshift('<img alt="" src="'+this.emptyIcon+'" class="x-tree-elbow-line" />');}else{buf.unshift('<img alt="" src="'+this.emptyIcon+'" class="x-tree-icon" />');}}
p=p.parentNode;}
this.childIndent=buf.join("");}
return this.childIndent;}});Ext.override(Ext.form.Action.Submit,{handleResponse:function(response){var m=Ext.decode(response.responseText);if(this.form.errorReader){var rs=this.form.errorReader.read(response);var errors=[];if(rs.records){for(var i=0,len=rs.records.length;i<len;i=i+1){var r=rs.records[i];errors[i]=r.data;}}
if(errors.length<1){errors=null;}
return{success:rs.success,message:m.message,object:m.object,errors:errors};}
return Ext.decode(response.responseText);}});Ext.form.Field.prototype.afterRender=Ext.form.Field.prototype.afterRender.createSequence(function(){if(this.description){Ext.QuickTips.register({target:this.getEl(),text:this.description,enabled:true});var label=Ext.form.Field.findLabel(this);if(label){Ext.QuickTips.register({target:label,text:this.description,enabled:true});}}});Ext.applyIf(Ext.form.Field,{findLabel:function(field){var wrapDiv=null;var label=null;wrapDiv=field.getEl().up('div.x-form-element');if(wrapDiv){label=wrapDiv.child('label');}
if(label){return label;}
wrapDiv=field.getEl().up('div.x-form-item');if(wrapDiv){label=wrapDiv.child('label');}
if(label){return label;}}});MODx.util.Clipboard=function(){return{escape:function(text){text=encodeURIComponent(text);return text.replace(/%0A/g,"%0D%0A");},copy:function(text){if(Ext.isIE){window.clipboardData.setData("Text",text);}else{var flashcopier='flashcopier';if(!document.getElementById(flashcopier)){var divholder=document.createElement('div');divholder.id=flashcopier;document.body.appendChild(divholder);}
document.getElementById(flashcopier).innerHTML='';var divinfo='<embed src="'+MODx.config.manager_url
+'assets/modext/_clipboard.swf" FlashVars="clipboard='
+MODx.util.Clipboard.escape(text)
+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';document.getElementById(flashcopier).innerHTML=divinfo;}}};}();Ext.util.Format.trimCommas=function(s){s=s.replace(',,',',');var len=s.length;if(s.substr(len-1,1)==","){s=s.substring(0,len-1);}
if(s.substr(0,1)==","){s=s.substring(1);}
if(s==','){s='';}
return s;};Ext.ns('Ext.ux.grid');if('function'!==typeof RegExp.escape){RegExp.escape=function(s){if('string'!==typeof s){return s}return s.replace(/([.*+?\^=!:${}()|\[\]\/\\])/g,'\\$1')}}Ext.ux.grid.RowActions=function(a){Ext.apply(this,a);this.addEvents('beforeaction','action','beforegroupaction','groupaction');Ext.ux.grid.RowActions.superclass.constructor.call(this)};Ext.extend(Ext.ux.grid.RowActions,Ext.util.Observable,{actionEvent:'click',autoWidth:true,dataIndex:'',editable:false,header:'',isColumn:true,keepSelection:false,menuDisabled:true,sortable:false,tplGroup:'<tpl for="actions">'+'<div class="ux-grow-action-item<tpl if="\'right\'===align"> ux-action-right</tpl> '+'{cls}" style="{style}" qtip="{qtip}">{text}</div>'+'</tpl>',tplRow:'<div class="ux-row-action">'+'<tpl for="actions">'+'<div class="ux-row-action-item {cls} <tpl if="text">'+'ux-row-action-text</tpl>" style="{hide}{style}" qtip="{qtip}">'+'<tpl if="text"><span qtip="{qtip}">{text}</span></tpl></div>'+'</tpl>'+'</div>',hideMode:'visibility',widthIntercept:4,widthSlope:21,init:function(g){this.grid=g;this.id=this.id||Ext.id();var h=g.getColumnModel().lookup;delete(h[undefined]);h[this.id]=this;if(!this.tpl){this.tpl=this.processActions(this.actions)}if(this.autoWidth){this.width=this.widthSlope*this.actions.length+this.widthIntercept;this.fixed=true}var i=g.getView();var j={scope:this};j[this.actionEvent]=this.onClick;g.afterRender=g.afterRender.createSequence(function(){i.mainBody.on(j);g.on('destroy',this.purgeListeners,this)},this);if(!this.renderer){this.renderer=function(a,b,c,d,e,f){b.css+=(b.css?' ':'')+'ux-row-action-cell';return this.tpl.apply(this.getData(a,b,c,d,e,f))}.createDelegate(this)}if(i.groupTextTpl&&this.groupActions){i.interceptMouse=i.interceptMouse.createInterceptor(function(e){if(e.getTarget('.ux-grow-action-item')){return false}});i.groupTextTpl='<div class="ux-grow-action-text">'+i.groupTextTpl+'</div>'+this.processActions(this.groupActions,this.tplGroup).apply()}if(true===this.keepSelection){g.processEvent=g.processEvent.createInterceptor(function(a,e){if('mousedown'===a){return!this.getAction(e)}},this)}},getData:function(a,b,c,d,e,f){return c.data||{}},processActions:function(b,c){var d=[];Ext.each(b,function(a,i){if(a.iconCls&&'function'===typeof(a.callback||a.cb)){this.callbacks=this.callbacks||{};this.callbacks[a.iconCls]=a.callback||a.cb}var o={cls:a.iconIndex?'{'+a.iconIndex+'}':(a.iconCls?a.iconCls:''),qtip:a.qtipIndex?'{'+a.qtipIndex+'}':(a.tooltip||a.qtip?a.tooltip||a.qtip:''),text:a.textIndex?'{'+a.textIndex+'}':(a.text?a.text:''),hide:a.hideIndex?'<tpl if="'+a.hideIndex+'">'+('display'===this.hideMode?'display:none':'visibility:hidden')+';</tpl>':(a.hide?('display'===this.hideMode?'display:none':'visibility:hidden;'):''),align:a.align||'right',style:a.style?a.style:''};d.push(o)},this);var e=new Ext.XTemplate(c||this.tplRow);return new Ext.XTemplate(e.apply({actions:d}))},getAction:function(e){var a=false;var t=e.getTarget('.ux-row-action-item');if(t){a=t.className.replace(/ux-row-action-item /,'');if(a){a=a.replace(/ ux-row-action-text/,'');a=a.trim()}}return a},onClick:function(e,a){var b=this.grid.getView();var c=e.getTarget('.x-grid3-row');var d=b.findCellIndex(a.parentNode.parentNode);var f=this.getAction(e);if(false!==c&&false!==d&&false!==f){var g=this.grid.store.getAt(c.rowIndex);if(this.callbacks&&'function'===typeof this.callbacks[f]){this.callbacks[f](this.grid,g,f,c.rowIndex,d)}if(true!==this.eventsSuspended&&false===this.fireEvent('beforeaction',this.grid,g,f,c.rowIndex,d)){return}else if(true!==this.eventsSuspended){this.fireEvent('action',this.grid,g,f,c.rowIndex,d)}}t=e.getTarget('.ux-grow-action-item');if(t){var h=b.findGroup(a);var i=h?h.id.replace(/ext-gen[0-9]+-gp-/,''):null;var j;if(i){var k=new RegExp(RegExp.escape(i));j=this.grid.store.queryBy(function(r){return r._groupId.match(k)});j=j?j.items:[]}f=t.className.replace(/ux-grow-action-item (ux-action-right )*/,'');if('function'===typeof this.callbacks[f]){this.callbacks[f](this.grid,j,f,i)}if(true!==this.eventsSuspended&&false===this.fireEvent('beforegroupaction',this.grid,j,f,i)){return false}this.fireEvent('groupaction',this.grid,j,f,i)}}});Ext.reg('rowactions',Ext.ux.grid.RowActions);Ext.SwitchButton=Ext.extend(Ext.Component,{initComponent:function(){Ext.SwitchButton.superclass.initComponent.call(this);var mc=new Ext.util.MixedCollection();mc.addAll(this.items);this.items=mc;this.addEvents('change');if(this.handler){this.on('change',this.handler,this.scope||this);}},onRender:function(ct,position){var el=document.createElement('table');el.cellSpacing=0;el.className='x-rbtn';el.id=this.id;var row=document.createElement('tr');el.appendChild(document.createElement('tbody')).appendChild(row);var count=this.items.length;var last=count-1;this.activeItem=this.items.get(this.activeItem);for(var i=0;i<count;i++){var item=this.items.itemAt(i);var cell=row.appendChild(document.createElement('td'));cell.id=this.id+'-rbi-'+i;var cls=i==0?'x-rbtn-first':(i==last?'x-rbtn-last':'x-rbtn-item');item.baseCls=cls;if(this.activeItem==item){cls+='-active';}
cell.className=cls;var button=document.createElement('button');button.innerHTML='&#160;';button.className=item.iconCls;button.qtip=item.tooltip;cell.appendChild(button);item.cell=cell;}
this.el=Ext.get(ct.dom.appendChild(el));this.el.on('click',this.onClick,this);},getActiveItem:function(){return this.activeItem;},setActiveItem:function(item){if(typeof item!='object'&&item!==null){item=this.items.get(item);}
var current=this.getActiveItem();if(item!=current){if(current){Ext.fly(current.cell).removeClass(current.baseCls+'-active');}
if(item){Ext.fly(item.cell).addClass(item.baseCls+'-active');}
this.activeItem=item;this.fireEvent('change',this,item);}
return item;},onClick:function(e){var target=e.getTarget('td',2);if(!this.disabled&&target){this.setActiveItem(parseInt(target.id.split('-rbi-')[1],10));}}});Ext.reg('switch',Ext.SwitchButton);Ext.onReady(function(){MODx.util.JSONReader=MODx.load({xtype:'modx-json-reader'});MODx.form.Handler=MODx.load({xtype:'modx-form-handler'});MODx.msg=MODx.load({xtype:'modx-msg'});});Ext.form.XCheckbox=Ext.extend(Ext.form.Checkbox,{submitOffValue:0,submitOnValue:1,onRender:function(){this.inputValue=this.submitOnValue;Ext.form.XCheckbox.superclass.onRender.apply(this,arguments);this.hiddenField=this.wrap.insertFirst({tag:'input',type:'hidden'});if(this.tooltip){this.imageEl.set({qtip:this.tooltip})}this.updateHidden()},setValue:function(v){v=this.convertValue(v);this.updateHidden(v);Ext.form.XCheckbox.superclass.setValue.apply(this,arguments)},updateHidden:function(v){v=undefined!==v?v:this.checked;v=this.convertValue(v);if(this.hiddenField){this.hiddenField.dom.value=v?this.submitOnValue:this.submitOffValue;this.hiddenField.dom.name=v?'':this.el.dom.name}},convertValue:function(v){return(v===true||v==='true'||v===this.submitOnValue||String(v).toLowerCase()==='on')}});Ext.reg('xcheckbox',Ext.form.XCheckbox);Ext.namespace('Ext.ux.dd');Ext.ux.dd.GridDragDropRowOrder=Ext.extend(Ext.util.Observable,{copy:false,scrollable:false,constructor:function(config){if(config)Ext.apply(this,config);this.addEvents({beforerowmove:true,afterrowmove:true,beforerowcopy:true,afterrowcopy:true});Ext.ux.dd.GridDragDropRowOrder.superclass.constructor.call(this)},init:function(grid){this.grid=grid;grid.enableDragDrop=true;grid.on({render:{fn:this.onGridRender,scope:this,single:true}})},onGridRender:function(grid){var self=this;this.target=new Ext.dd.DropTarget(grid.getEl(),{ddGroup:grid.ddGroup||'GridDD',grid:grid,gridDropTarget:this,notifyDrop:function(dd,e,data){if(this.currentRowEl){this.currentRowEl.removeClass('grid-row-insert-below');this.currentRowEl.removeClass('grid-row-insert-above')}var t=Ext.lib.Event.getTarget(e);var rindex=this.grid.getView().findRowIndex(t);if(rindex===false||rindex==data.rowIndex){return false}if(this.gridDropTarget.fireEvent(self.copy?'beforerowcopy':'beforerowmove',this.gridDropTarget,data.rowIndex,rindex,data.selections,123)===false){return false}var ds=this.grid.getStore();var selections=new Array();var keys=ds.data.keys;for(var key in keys){for(var i=0;i<data.selections.length;i++){if(keys[key]==data.selections[i].id){if(rindex==key){return false}selections.push(data.selections[i])}}}if(rindex>data.rowIndex&&this.rowPosition<0){rindex--}if(rindex<data.rowIndex&&this.rowPosition>0){rindex++}if(rindex>data.rowIndex&&data.selections.length>1){rindex=rindex-(data.selections.length-1)}if(rindex==data.rowIndex){return false}if(!self.copy){for(var i=0;i<data.selections.length;i++){ds.remove(ds.getById(data.selections[i].id))}}for(var i=selections.length-1;i>=0;i--){var insertIndex=rindex;ds.insert(insertIndex,selections[i])}var sm=this.grid.getSelectionModel();if(sm){sm.selectRecords(data.selections)}this.gridDropTarget.fireEvent(self.copy?'afterrowcopy':'afterrowmove',this.gridDropTarget,data.rowIndex,rindex,data.selections);return true},notifyOver:function(dd,e,data){var t=Ext.lib.Event.getTarget(e);var rindex=this.grid.getView().findRowIndex(t);var ds=this.grid.getStore();var keys=ds.data.keys;for(var key in keys){for(var i=0;i<data.selections.length;i++){if(keys[key]==data.selections[i].id){if(rindex==key){if(this.currentRowEl){this.currentRowEl.removeClass('grid-row-insert-below');this.currentRowEl.removeClass('grid-row-insert-above')}return this.dropNotAllowed}}}}if(rindex<0||rindex===false){this.currentRowEl.removeClass('grid-row-insert-above');return this.dropNotAllowed}try{var currentRow=this.grid.getView().getRow(rindex);var resolvedRow=new Ext.Element(currentRow).getY()-this.grid.getView().scroller.dom.scrollTop;var rowHeight=currentRow.offsetHeight;this.rowPosition=e.getPageY()-resolvedRow-(rowHeight/2);if(this.currentRowEl){this.currentRowEl.removeClass('grid-row-insert-below');this.currentRowEl.removeClass('grid-row-insert-above')}if(this.rowPosition>0){this.currentRowEl=new Ext.Element(currentRow);this.currentRowEl.addClass('grid-row-insert-below')}else{if(rindex-1>=0){var previousRow=this.grid.getView().getRow(rindex-1);this.currentRowEl=new Ext.Element(previousRow);this.currentRowEl.addClass('grid-row-insert-below')}else{this.currentRowEl.addClass('grid-row-insert-above')}}}catch(err){console.warn(err);rindex=false}return(rindex===false)?this.dropNotAllowed:this.dropAllowed},notifyOut:function(dd,e,data){if(this.currentRowEl){this.currentRowEl.removeClass('grid-row-insert-above');this.currentRowEl.removeClass('grid-row-insert-below')}}});if(this.targetCfg){Ext.apply(this.target,this.targetCfg)}if(this.scrollable){Ext.dd.ScrollManager.register(grid.getView().getEditorParent());grid.on({beforedestroy:this.onBeforeDestroy,scope:this,single:true})}},getTarget:function(){return this.target},getGrid:function(){return this.grid},getCopy:function(){return this.copy?true:false},setCopy:function(b){this.copy=b?true:false},onBeforeDestroy:function(grid){Ext.dd.ScrollManager.unregister(grid.getView().getEditorParent())}});if(!Ext.grid.GridView.prototype.templates){Ext.grid.GridView.prototype.templates={};}
Ext.grid.GridView.prototype.templates.cell=new Ext.Template('<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} x-selectable {css}" style="{style}" tabIndex="0" {cellAttr}>','<div class="x-grid3-cell-inner x-grid3-col-{id}" {attr}>{value}</div>','</td>');if(!MODx.grid){MODx.grid={};}
MODx.grid.ComboColumn=Ext.extend(Ext.grid.Column,{gridId:undefined,constructor:function(cfg){MODx.grid.ComboColumn.superclass.constructor.call(this,cfg);this.renderer=(this.editor&&this.editor.triggerAction)?MODx.grid.ComboBoxRenderer(this.editor,this.gridId):function(value){return value;};}});Ext.grid.Column.types['combocolumn']=MODx.grid.ComboColumn;MODx.grid.ComboBoxRenderer=function(combo,gridId){var getValue=function(value){var idx=combo.store.find(combo.valueField,value);var rec=combo.store.getAt(idx);if(rec){return rec.get(combo.displayField);}
return value;};return function(value){if(combo.store.getCount()==0&&gridId){combo.store.on('load',function(){var grid=Ext.getCmp(gridId);if(grid){grid.getView().refresh();}},{single:true});return value;}
return getValue(value);};};Ext.Button.buttonTemplate=new Ext.Template('<span id="{4}" class="x-btn {1} {3}" unselectable="on"><em class="{2}"><button type="{0}"></button></em></span>');Ext.Button.buttonTemplate.compile();Ext.TabPanel.prototype.itemTpl=new Ext.Template('<li class="{cls}" id="{id}"><a class="x-tab-strip-close"></a>','<span class="x-tab-strip-text {iconCls}">{text}</span></li>');Ext.TabPanel.prototype.itemTpl.disableFormats=true;Ext.TabPanel.prototype.itemTpl.compile();;Ext.ns('Ext.ux.form');Ext.ux.form.DateTime=Ext.extend(Ext.form.Field,{dateValidator:null,defaultAutoCreate:{tag:'input',type:'hidden'},dtSeparator:' ',hiddenFormat:'Y-m-d H:i:s',otherToNow:true,timePosition:'right',timeValidator:null,timeWidth:100,dateFormat:'m/d/y',timeFormat:'g:i A',maxDateValue:'',minDateValue:'',timeIncrement:15,maxTimeValue:null,minTimeValue:null,disabledDates:null,initComponent:function(){Ext.ux.form.DateTime.superclass.initComponent.call(this);if(!this.hasOwnProperty('offset_time')||isNaN(this.offset_time)){this.offset_time=0;}
var dateConfig=Ext.apply({},{id:this.id+'-date',format:this.dateFormat||Ext.form.DateField.prototype.format,width:this.timeWidth,selectOnFocus:this.selectOnFocus,validator:this.dateValidator,disabledDates:this.disabledDates||null,disabledDays:this.disabledDays||[],showToday:this.showToday||true,maxValue:this.maxDateValue||'',minValue:this.minDateValue||'',startDay:this.startDay||0,listeners:{blur:{scope:this,fn:this.onBlur},focus:{scope:this,fn:this.onFocus}}},this.dateConfig);this.df=new Ext.form.DateField(dateConfig);this.df.ownerCt=this;delete(this.dateFormat);delete(this.disabledDates);delete(this.disabledDays);delete(this.maxDateValue);delete(this.minDateValue);delete(this.startDay);var timeConfig=Ext.apply({},{id:this.id+'-time',format:this.timeFormat||Ext.form.TimeField.prototype.format,width:this.timeWidth,selectOnFocus:this.selectOnFocus,validator:this.timeValidator,increment:this.timeIncrement||15,maxValue:this.maxTimeValue||null,minValue:this.minTimeValue||null,listeners:{blur:{scope:this,fn:this.onBlur},focus:{scope:this,fn:this.onFocus}}},this.timeConfig);this.tf=new Ext.form.TimeField(timeConfig);this.tf.ownerCt=this;delete(this.timeFormat);delete(this.maxTimeValue);delete(this.minTimeValue);delete(this.timeIncrement);this.relayEvents(this.df,['focus','specialkey','invalid','valid']);this.relayEvents(this.tf,['focus','specialkey','invalid','valid']);this.on('specialkey',this.onSpecialKey,this);},onRender:function(ct,position){if(this.isRendered){return;}
Ext.ux.form.DateTime.superclass.onRender.call(this,ct,position);var t;if('below'===this.timePosition||'bellow'===this.timePosition){t=Ext.DomHelper.append(ct,{tag:'table',style:'border-collapse:collapse',children:[{tag:'tr',children:[{tag:'td',style:'padding-bottom:1px',cls:'ux-datetime-date'}]},{tag:'tr',children:[{tag:'td',cls:'ux-datetime-time'}]}]},true);}
else{t=Ext.DomHelper.append(ct,{tag:'table',style:'border-collapse:collapse',children:[{tag:'tr',children:[{tag:'td',style:'padding-right:4px',cls:'ux-datetime-date'},{tag:'td',cls:'ux-datetime-time'}]}]},true);}
this.tableEl=t;this.wrap=t.wrap({cls:'x-form-field-wrap x-datetime-wrap'});this.wrap.on("mousedown",this.onMouseDown,this,{delay:10});this.df.render(t.child('td.ux-datetime-date'));this.tf.render(t.child('td.ux-datetime-time'));this.df.el.swallowEvent(['keydown','keypress']);this.tf.el.swallowEvent(['keydown','keypress']);if('side'===this.msgTarget){var elp=this.el.findParent('.x-form-element',10,true);if(elp){this.errorIcon=elp.createChild({cls:'x-form-invalid-icon'});}
var o={errorIcon:this.errorIcon,msgTarget:'side',alignErrorIcon:this.alignErrorIcon.createDelegate(this)};Ext.apply(this.df,o);Ext.apply(this.tf,o);}
this.el.dom.name=this.hiddenName||this.name||this.id;this.df.el.dom.removeAttribute("name");this.tf.el.dom.removeAttribute("name");this.isRendered=true;this.updateHidden();},adjustSize:Ext.BoxComponent.prototype.adjustSize,alignErrorIcon:function(){this.errorIcon.alignTo(this.tableEl,'tl-tr',[2,0]);},initDateValue:function(){this.dateValue=this.otherToNow?new Date():new Date(1970,0,1,0,0,0);},clearInvalid:function(){this.df.clearInvalid();this.tf.clearInvalid();},markInvalid:function(msg){this.df.markInvalid(msg);this.tf.markInvalid(msg);},beforeDestroy:function(){if(this.isRendered){this.wrap.removeAllListeners();this.wrap.remove();this.tableEl.remove();this.df.destroy();this.tf.destroy();}},disable:function(){if(this.isRendered){this.df.disabled=this.disabled;this.df.onDisable();this.tf.onDisable();}
this.disabled=true;this.df.disabled=true;this.tf.disabled=true;this.fireEvent("disable",this);return this;},enable:function(){if(this.rendered){this.df.onEnable();this.tf.onEnable();}
this.disabled=false;this.df.disabled=false;this.tf.disabled=false;this.fireEvent("enable",this);return this;},focus:function(){this.df.focus();},getPositionEl:function(){return this.wrap;},getResizeEl:function(){return this.wrap;},getValue:function(){return this.dateValue?new Date(this.dateValue):'';},isValid:function(){return this.df.isValid()&&this.tf.isValid();},isVisible:function(){return this.df.rendered&&this.df.getActionEl().isVisible();},onBlur:function(f){if(this.wrapClick){f.focus();this.wrapClick=false;}
if(f===this.df){this.updateDate();}
else{this.updateTime();}
this.updateHidden();this.validate();(function(){if(!this.df.hasFocus&&!this.tf.hasFocus){var v=this.getValue();if(String(v)!==String(this.startValue)){this.fireEvent("change",this,v,this.startValue);}
this.hasFocus=false;this.fireEvent('blur',this);}}).defer(100,this);},onFocus:function(){if(!this.hasFocus){this.hasFocus=true;this.startValue=this.getValue();this.fireEvent("focus",this);}},onMouseDown:function(e){if(!this.disabled){this.wrapClick='td'===e.target.nodeName.toLowerCase();}},onSpecialKey:function(t,e){var key=e.getKey();if(key===e.TAB){if(t===this.df&&!e.shiftKey){e.stopEvent();this.tf.focus();}
if(t===this.tf&&e.shiftKey){e.stopEvent();this.df.focus();}
this.updateValue();}
if(key===e.ENTER){this.updateValue();}},reset:function(){this.df.setValue(this.originalValue);this.tf.setValue(this.originalValue);},setDate:function(date){if(date&&this.offset_time!=0){date=date.add(Date.MINUTE,60*new Number(this.offset_time));}
this.df.setValue(date);},setTime:function(date){if(date&&this.offset_time!=0){date=date.add(Date.MINUTE,60*new Number(this.offset_time));}
this.tf.setValue(date);},setSize:function(w,h){if(!w){return;}
if('below'===this.timePosition){this.df.setSize(w,h);this.tf.setSize(w,h);if(Ext.isIE){this.df.el.up('td').setWidth(w);this.tf.el.up('td').setWidth(w);}}
else{this.df.setSize(w-this.timeWidth-4,h);this.tf.setSize(this.timeWidth,h);if(Ext.isIE){this.df.el.up('td').setWidth(w-this.timeWidth-4);this.tf.el.up('td').setWidth(this.timeWidth);}}},setValue:function(val){if(!val&&true===this.emptyToNow){this.setValue(new Date());return;}
else if(!val){this.setDate('');this.setTime('');this.updateValue();return;}
if('number'===typeof val){val=new Date(val);}
else if('string'===typeof val&&this.hiddenFormat){val=Date.parseDate(val,this.hiddenFormat);}
val=val?val:new Date(1970,0,1,0,0,0);var da;if(val instanceof Date){this.setDate(val);this.setTime(val);this.dateValue=new Date(Ext.isIE?val.getTime():val);}
else{da=val.split(this.dtSeparator);this.setDate(da[0]);if(da[1]){if(da[2]){da[1]+=da[2];}
this.setTime(da[1]);}}
this.updateValue();},setVisible:function(visible){if(visible){this.df.show();this.tf.show();}else{this.df.hide();this.tf.hide();}
return this;},show:function(){return this.setVisible(true);},hide:function(){return this.setVisible(false);},updateDate:function(){var d=this.df.getValue();if(d){if(!(this.dateValue instanceof Date)){this.initDateValue();if(!this.tf.getValue()){this.setTime(this.dateValue);}}
this.dateValue.setMonth(0);this.dateValue.setFullYear(d.getFullYear());this.dateValue.setMonth(d.getMonth(),d.getDate());}
else{this.dateValue='';this.setTime('');}},updateTime:function(){var t=this.tf.getValue();if(t&&!(t instanceof Date)){t=Date.parseDate(t,this.tf.format);}
if(t&&!this.df.getValue()){this.initDateValue();this.setDate(this.dateValue);}
if(this.dateValue instanceof Date){if(t){this.dateValue.setHours(t.getHours());this.dateValue.setMinutes(t.getMinutes());this.dateValue.setSeconds(t.getSeconds());}
else{this.dateValue.setHours(0);this.dateValue.setMinutes(0);this.dateValue.setSeconds(0);}}},updateHidden:function(){if(this.isRendered){var value='';if(this.dateValue instanceof Date){value=this.dateValue.add(Date.MINUTE,0-60*new Number(this.offset_time)).format(this.hiddenFormat);}
this.el.dom.value=value;}},updateValue:function(){this.updateDate();this.updateTime();this.updateHidden();return;},validate:function(){return this.df.validate()&&this.tf.validate();},renderer:function(field){var format=field.editor.dateFormat||Ext.ux.form.DateTime.prototype.dateFormat;format+=' '+(field.editor.timeFormat||Ext.ux.form.DateTime.prototype.timeFormat);var renderer=function(val){var retval=Ext.util.Format.date(val,format);return retval;};return renderer;}});Ext.reg('xdatetime',Ext.ux.form.DateTime);;MODx.Component=function(config){config=config||{};MODx.Component.superclass.constructor.call(this,config);this.config=config;this._loadForm();if(this.config.tabs){this._loadTabs();}
this._loadComponents();this._loadActionButtons();MODx.activePage=this;};Ext.extend(MODx.Component,Ext.Component,{fields:{},form:null,action:false,_loadForm:function(){if(!this.config.form){return false;}
this.form=new Ext.form.BasicForm(Ext.get(this.config.form),{errorReader:MODx.util.JSONReader});if(this.config.fields){for(var i in this.config.fields){if(this.config.fields.hasOwnProperty(i)){var f=this.config.fields[i];if(f.xtype){f=Ext.ComponentMgr.create(f);}
this.fields[i]=f;this.form.add(f);}}}
return this.form.render();},_loadActionButtons:function(){if(!this.config.buttons){return false;}
this.ab=MODx.load({xtype:'modx-actionbuttons',form:this.form||null,formpanel:this.config.formpanel||null,actions:this.config.actions||null,items:this.config.buttons||[]});return this.ab;},_loadTabs:function(){if(!this.config.tabs){return false;}
var o=this.config.tabOptions||{};Ext.applyIf(o,{xtype:'modx-tabs',renderTo:this.config.tabs_div||'tabs_div',items:this.config.tabs});return MODx.load(o);},_loadComponents:function(){if(!this.config.components){return false;}
var l=this.config.components.length;var cp=Ext.getCmp('modx-content');for(var i=0;i<l;i=i+1){var a=MODx.load(this.config.components[i]);if(cp){cp.add(a);}}
if(cp){cp.doLayout();}
return true;},submitForm:function(listeners,options,otherParams){listeners=listeners||{};otherParams=otherParams||{};if(!this.config.formpanel||!this.config.action){return false;}
f=Ext.getCmp(this.config.formpanel);if(!f){return false;}
for(var i in listeners){if(typeof listeners[i]=='function'){f.on(i,listeners[i],this);}else if(listeners[i]&&typeof listeners[i]=='object'&&listeners[i].fn){f.on(i,listeners[i].fn,listeners[i].scope||this);}}
Ext.apply(f.baseParams,{'action':this.config.action});Ext.apply(f.baseParams,otherParams);options=options||{};options.headers={'Powered-By':'MODx','modAuth':MODx.siteId};f.submit(options);return true;}});Ext.reg('modx-component',MODx.Component);MODx.toolbar.ActionButtons=function(config){config=config||{};Ext.applyIf(config,{actions:{'close':'welcome'},formpanel:false,id:'modx-action-buttons',params:{},items:[],renderTo:'modx-container'});if(config.formpanel){this.setupDirtyButtons(config.formpanel);}
this.checkDirtyBtns=[];MODx.toolbar.ActionButtons.superclass.constructor.call(this,config);this.config=config;};Ext.extend(MODx.toolbar.ActionButtons,Ext.Toolbar,{id:'',buttons:[],options:{a_close:'welcome'},add:function(){var a=arguments,l=a.length;for(var i=0;i<l;i++){var el=a[i];var ex=['-','->','<-','',' '];if(ex.indexOf(el)!=-1||(el.xtype&&el.xtype=='switch')){MODx.toolbar.ActionButtons.superclass.add.call(this,el);continue;}
var id=el.id||Ext.id();Ext.applyIf(el,{xtype:'button',cls:(el.icon?'x-btn-icon bmenu':'x-btn-text bmenu'),scope:this,disabled:el.checkDirty?true:false,listeners:{},id:id});if(el.button){MODx.toolbar.ActionButtons.superclass.add.call(this,el);}
if(el.handler===null&&el.menu===null){el.handler=this.checkConfirm;}else if(el.confirm&&el.handler){el.handler=function(){Ext.Msg.confirm(_('warning'),el.confirm,function(e){if(e==='yes'){Ext.callback(el.handler,this);}},el.scope||this);};}else if(el.handler){}else{el.handler=this.handleClick;}
if(el.javascript){el.listeners['click']={fn:this.evalJS,scope:this};}
if(el.xtype=='button'){el.listeners['render']={fn:function(btn){if(el.checkDirty&&btn){this.checkDirtyBtns.push(btn);}},scope:this}}
if(el.keys){el.keyMap=new Ext.KeyMap(Ext.get(document));for(var j=0;j<el.keys.length;j++){var key=el.keys[j];Ext.applyIf(key,{scope:this,stopEvent:true,fn:function(e){var b=Ext.getCmp(id);if(b)this.checkConfirm(b,e);}});el.keyMap.addBinding(key);}
el.listeners['destroy']={fn:function(btn){btn.keyMap.disable();},scope:this}}
MODx.toolbar.ActionButtons.superclass.add.call(this,el);}},evalJS:function(itm,e){if(!eval(itm.javascript)){e.stopEvent();e.preventDefault();}},checkConfirm:function(itm,e){if(itm.confirm!==null&&itm.confirm!==undefined){this.confirm(itm,function(){this.handleClick(itm,e);},this);}else{this.handleClick(itm,e);}
return false;},confirm:function(itm,callback,scope){if(itm.confirm===null){return true;}
Ext.Msg.confirm('',itm.confirm,function(e){if(e==='yes'){if(callback===null){return true;}
if(typeof(callback)==='function'){Ext.callback(callback,scope||this,[itm]);}else{location.href=callback;}}
return true;},this);return true;},reloadPage:function(){location.href=location.href;},handleClick:function(itm,e){var o=this.config;if(o.formpanel===false||o.formpanel===undefined||o.formpanel===null)return false;if(itm.method==='remote'){MODx.util.Progress.reset();o.form=Ext.getCmp(o.formpanel);if(!o.form)return false;var f=o.form.getForm?o.form.getForm():o.form;var isv=true;if(f.items&&f.items.items){for(var fld in f.items.items){if(f.items.items[fld]&&f.items.items[fld].validate){var fisv=f.items.items[fld].validate();if(!fisv){f.items.items[fld].markInvalid();isv=false;}}}}
if(isv){Ext.applyIf(o.params,{action:itm.process});Ext.apply(f.baseParams,o.params);o.form.on('success',function(r){if(o.form.clearDirty)o.form.clearDirty();MODx.msg.status({title:_('success'),message:r.result.message||_('save_successful'),dontHide:r.result.message!=''?true:false});Ext.callback(this.redirect,this,[o,itm,r.result],1000);this.resetDirtyButtons(r.result);},this);o.form.submit({headers:{'Powered-By':'MODx','modAuth':MODx.siteId}});}else{Ext.Msg.alert(_('error'),_('correct_errors'));}}else{var params=itm.params||{};Ext.applyIf(params,o.baseParams||{});MODx.loadPage('?'+Ext.urlEncode(params));}
return false;},resetDirtyButtons:function(r){for(var i=0;i<this.checkDirtyBtns.length;i=i+1){var btn=this.checkDirtyBtns[i];btn.setDisabled(true);}},redirect:function(o,itm,res){o=this.config;itm.params=itm.params||{};Ext.applyIf(itm.params,o.baseParams);var url;var process=itm.process.substr(itm.process.lastIndexOf('/')+1);if((process==='create'||process==='duplicate'||itm.reload)&&res.object.id){itm.params.id=res.object.id;if(MODx.request.parent){itm.params.parent=MODx.request.parent;}
if(MODx.request.context_key){itm.params.context_key=MODx.request.context_key;}
url=Ext.urlEncode(itm.params);var action;if(o.actions&&o.actions.edit){action=o.actions.edit;}else{action=itm.process.replace('create','update');}
MODx.loadPage(action,url);}else if(process==='delete'){itm.params.a=o.actions.cancel;url=Ext.urlEncode(itm.params);MODx.loadPage('?'+url);}},refreshTreeNode:function(tree,node,self){var t=parent.Ext.getCmp(tree);t.refreshNode(node,self||false);return false;},setupDirtyButtons:function(f){var fp=Ext.getCmp(f);if(fp){fp.on('fieldChange',function(o){for(var i=0;i<this.checkDirtyBtns.length;i=i+1){var btn=this.checkDirtyBtns[i];btn.setDisabled(false);}},this);}}});Ext.reg('modx-actionbuttons',MODx.toolbar.ActionButtons);;Ext.namespace('MODx.panel');MODx.Panel=function(config){config=config||{};Ext.applyIf(config,{cls:'modx-panel',title:''});MODx.Panel.superclass.constructor.call(this,config);this.config=config;};Ext.extend(MODx.Panel,Ext.Panel);Ext.reg('modx-panel',MODx.Panel);MODx.FormPanel=function(config){config=config||{};Ext.applyIf(config,{autoHeight:true,collapsible:true,bodyStyle:'',layout:'anchor',border:false,header:false,method:'POST',cls:'modx-form',allowDrop:true,errorReader:MODx.util.JSONReader,checkDirty:true,useLoadingMask:false,defaults:{collapsible:false,autoHeight:true,border:false}});if(config.items){this.addChangeEvent(config.items);}
MODx.FormPanel.superclass.constructor.call(this,config);this.config=config;this.addEvents({setup:true,fieldChange:true,ready:true,beforeSubmit:true,success:true,failure:true,save:true,actionNew:true,actionContinue:true,actionClose:true,postReady:true});this.getForm().addEvents({success:true,failure:true});this.dropTargets=[];this.on('ready',this.onReady);if(this.config.useLoadingMask){this.on('render',function(){this.mask=new Ext.LoadMask(this.getEl());this.mask.show();});}
if(this.fireEvent('setup',config)){this.clearDirty();}
this.focusFirstField();};Ext.extend(MODx.FormPanel,Ext.FormPanel,{isReady:false,defaultValues:[],initialized:false,submit:function(o){var fm=this.getForm();if(fm.isValid()||o.bypassValidCheck){o=o||{};o.headers={'Powered-By':'MODx','modAuth':MODx.siteId};if(this.fireEvent('beforeSubmit',{form:fm,options:o,config:this.config})){fm.submit({waitMsg:this.config.saveMsg||_('saving'),scope:this,headers:o.headers,clientValidation:(o.bypassValidCheck?false:true),failure:function(f,a){if(this.fireEvent('failure',{form:f,result:a.result,options:o,config:this.config})){MODx.form.Handler.errorExt(a.result,f);}},success:function(f,a){if(this.config.success){Ext.callback(this.config.success,this.config.scope||this,[f,a]);}
this.fireEvent('success',{form:f,result:a.result,options:o,config:this.config});this.clearDirty();this.fireEvent('setup',this.config);}});}}else{return false;}
return true;},focusFirstField:function(){if(this.getForm().items.getCount()>0){var fld=this.findFirstTextField();if(fld){fld.focus(false,200);}}},findFirstTextField:function(i){i=i||0;var fld=this.getForm().items.itemAt(i);if(!fld)return false;if(fld.isXType('combo')||fld.isXType('checkbox')||fld.isXType('radio')||fld.isXType('displayfield')||fld.isXType('statictextfield')||fld.isXType('hidden')){i=i+1;fld=this.findFirstTextField(i);}
return fld;},addChangeEvent:function(items){if(!items){return false;}
if(typeof(items)=='object'&&items.items){items=items.items;}
for(var f=0;f<items.length;f++){var cmp=items[f];if(cmp.items){this.addChangeEvent(cmp.items);}else if(cmp.xtype){if(!cmp.listeners){cmp.listeners={};}
var ctypes=['change'];cmp.enableKeyEvents=true;switch(cmp.xtype){case'numberfield':case'textfield':case'textarea':ctypes=['keydown','change'];break;case'checkbox':case'xcheckbox':case'radio':ctypes=['check'];break;}
if(cmp.xtype&&cmp.xtype.indexOf('modx-combo')==0){ctypes=['select'];}
var that=this;Ext.iterate(ctypes,function(ctype){if(cmp.listeners[ctype]&&cmp.listeners[ctype].fn){cmp.listeners[ctype]={fn:that.fieldChangeEvent.createSequence(cmp.listeners[ctype].fn,cmp.listeners[ctype].scope),scope:that}}else{cmp.listeners[ctype]={fn:that.fieldChangeEvent,scope:that};}});}}},fieldChangeEvent:function(fld,nv,ov,f){if(!this.isReady){return false;}
var f=this.config.onDirtyForm?Ext.getCmp(this.config.onDirtyForm):this.getForm();this.fireEvent('fieldChange',{field:fld,nv:nv,ov:ov,form:f});},markDirty:function(){this.fireEvent('fieldChange');},isDirty:function(){var f=this.config.onDirtyForm?Ext.getCmp(this.config.onDirtyForm):this.getForm();return f.isDirty();},clearDirty:function(){var f=this.config.onDirtyForm?Ext.getCmp(this.config.onDirtyForm):this.getForm();return f.clearDirty();},onReady:function(r){this.isReady=true;if(this.config.allowDrop){this.loadDropZones();}
if(this.config.useLoadingMask&&this.mask){this.mask.hide();}
this.fireEvent('postReady');},loadDropZones:function(){var dropTargets=this.dropTargets;var flds=this.getForm().items;flds.each(function(fld){if(fld.isFormField&&(fld.isXType('textfield')||fld.isXType('textarea'))&&!fld.isXType('combo')){var el=fld.getEl();if(el){var target=new MODx.load({xtype:'modx-treedrop',target:fld,targetEl:el.dom});dropTargets.push(target);}}});},getField:function(f){var fld=false;if(typeof f=='string'){fld=this.getForm().findField(f);if(!fld){fld=Ext.getCmp(f);}}
return fld;},hideField:function(flds){if(!Ext.isArray(flds)){flds=flds[flds];}
var f;for(var i=0;i<flds.length;i++){f=this.getField(flds[i]);if(!f)return;f.hide();var d=f.getEl().up('.x-form-item');if(d){d.setDisplayed(false);}}},showField:function(flds){if(!Ext.isArray(flds)){flds=flds[flds];}
var f;for(var i=0;i<flds.length;i++){f=this.getField(flds[i]);if(!f)return;f.enable();f.show();var d=f.getEl().up('.x-form-item');if(d){d.setDisplayed(true);}}},setLabel:function(flds,vals,bp){if(!Ext.isArray(flds)){flds=flds[flds];}
if(!Ext.isArray(vals)){vals=valss[vals];}
var f,v;for(var i=0;i<flds.length;i++){f=this.getField(flds[i]);if(!f)return;v=String.format('{0}',vals[i]);if((f.xtype=='checkbox'||f.xtype=='xcheckbox'||f.xtype=='radio')&&flds[i]=='published'){f.setBoxLabel(v);}else if(f.label){f.label.update(v);}}},destroy:function(){for(var i=0;i<this.dropTargets.length;i++){this.dropTargets[i].destroy();}
MODx.FormPanel.superclass.destroy.call(this);}});Ext.reg('modx-formpanel',MODx.FormPanel);MODx.panel.Wizard=function(config){config=config||{};Ext.applyIf(config,{layout:'card',activeItem:0,resizable:true,collapsible:true,maximizable:true,autoHeight:true,width:750,firstPanel:'',lastPanel:'',defaults:{border:false},modal:true,txtFinish:_('finish'),txtNext:_('next'),txtBack:_('back'),bbar:[{id:'pi-btn-bck',itemId:'btn-back',text:config.txtBack||_('back'),handler:this.navHandler.createDelegate(this,[-1]),scope:this,disabled:true},{id:'pi-btn-fwd',itemId:'btn-fwd',text:config.txtNext||_('next'),handler:this.navHandler.createDelegate(this,[1]),scope:this}]});MODx.panel.Wizard.superclass.constructor.call(this,config);this.config=config;this.lastActiveItem=this.config.firstPanel;this._go();};Ext.extend(MODx.panel.Wizard,Ext.Panel,{windows:{},_go:function(){this.getBottomToolbar().items.item(1).setText(this.config.txtNext);this.proceed(this.config.firstPanel);},navHandler:function(dir){this.doLayout();var a=this.getLayout().activeItem;if(dir==-1){this.proceed(a.config.back||a.config.id);}else{a.submit({scope:this,proceed:this.proceed});}},proceed:function(id){this.doLayout();this.getLayout().setActiveItem(id);if(id==this.config.firstPanel){this.getBottomToolbar().items.item(0).setDisabled(true);this.getBottomToolbar().items.item(1).setText(this.config.txtNext);}else if(id==this.config.lastPanel){this.getBottomToolbar().items.item(1).setText(this.config.txtFinish);}else{this.getBottomToolbar().items.item(0).setDisabled(false);this.getBottomToolbar().items.item(1).setText(this.config.txtNext);}}});Ext.reg('modx-panel-wizard',MODx.panel.Wizard);MODx.panel.WizardPanel=function(config){config=config||{};Ext.applyIf(config,{wizard:null,checkDirty:false,bodyStyle:'padding: 3em 3em',hideMode:'offsets'});MODx.panel.WizardPanel.superclass.constructor.call(this,config);};Ext.extend(MODx.panel.WizardPanel,MODx.FormPanel);Ext.reg('modx-wizard-panel',MODx.panel.WizardPanel);MODx.PanelSpacer={html:'<br />',border:false};MODx.TemplatePanel=function(config){config=config||{};Ext.applyIf(config,{frame:false,startingMarkup:'<tpl for=".">'
+'<div class="empty-text-wrapper"><p>{text}</p></div>'
+'</tpl>',startingText:'Loading...',markup:null,plain:true,border:false});MODx.TemplatePanel.superclass.constructor.call(this,config);this.on('render',this.init,this);}
Ext.extend(MODx.TemplatePanel,Ext.Panel,{init:function(){this.defaultMarkup=new Ext.XTemplate(this.startingMarkup,{compiled:true});this.reset();this.tpl=new Ext.XTemplate(this.markup,{compiled:true});},reset:function(){this.body.hide();this.defaultMarkup.overwrite(this.body,{text:this.startingText});this.body.slideIn('r',{stopFx:true,duration:.2});setTimeout(function(){Ext.getCmp('modx-content').doLayout();},500);},updateDetail:function(data){this.body.hide();this.tpl.overwrite(this.body,data);this.body.slideIn('r',{stopFx:true,duration:.2});setTimeout(function(){Ext.getCmp('modx-content').doLayout();},500);}});Ext.reg('modx-template-panel',MODx.TemplatePanel);MODx.BreadcrumbsPanel=function(config){config=config||{};Ext.applyIf(config,{frame:false,plain:true,border:false,desc:'This the description part of this panel',bdMarkup:'<tpl if="typeof(trail) != &quot;undefined&quot;">'
+'<div class="crumb_wrapper"><ul class="crumbs">'
+'<tpl for="trail">'
+'<li{[values.className != undefined ? \' class="\'+values.className+\'"\' : \'\' ]}>'
+'<tpl if="typeof pnl != \'undefined\'">'
+'<button type="button" class="controlBtn {pnl}{[values.root ? \' root\' : \'\' ]}">{text}</button>'
+'</tpl>'
+'<tpl if="typeof pnl == \'undefined\'"><span class="text{[values.root ? \' root\' : \'\' ]}">{text}</span></tpl>'
+'</li>'
+'</tpl>'
+'</ul></div>'
+'</tpl>'
+'<tpl if="typeof(text) != &quot;undefined&quot;">'
+'<div class="panel-desc{[values.className != undefined ? \' \'+values.className+\'"\' : \'\' ]}"><p>{text}</p></div>'
+'</tpl>',root:{text:'Home',className:'first',root:true,pnl:''},bodyCssClass:'breadcrumbs'});MODx.BreadcrumbsPanel.superclass.constructor.call(this,config);this.on('render',this.init,this);}
Ext.extend(MODx.BreadcrumbsPanel,Ext.Panel,{init:function(){this.tpl=new Ext.XTemplate(this.bdMarkup,{compiled:true});this.reset(this.desc);this.body.on('click',this.onClick,this);},getResetText:function(srcInstance){if(typeof(srcInstance)!='object'||srcInstance==null){return srcInstance;}
var newInstance=srcInstance.constructor();for(var i in srcInstance){newInstance[i]=this.getResetText(srcInstance[i]);}
if(newInstance.hasOwnProperty('pnl')){delete newInstance['pnl'];}
return newInstance;},updateDetail:function(data){if(data.hasOwnProperty('trail')){var trail=data.trail;trail.unshift(this.root);}
this._updatePanel(data);},reset:function(msg){if(typeof(this.resetText)=="undefined"){this.resetText=this.getResetText(this.root);}
var data={text:msg,trail:[this.resetText]};this._updatePanel(data);},onClick:function(e){var target=e.getTarget();elm=target.className.split(' ')[0];if(elm!=""&&elm=='controlBtn'){var panel=target.className.split(' ')[1];Ext.getCmp(panel).activate();}},_updatePanel:function(data){this.body.hide();this.tpl.overwrite(this.body,data);this.body.slideIn('r',{stopFx:true,duration:.2});setTimeout(function(){Ext.getCmp('modx-content').doLayout();},500);}});Ext.reg('modx-breadcrumbs-panel',MODx.BreadcrumbsPanel);;MODx.Tabs=function(config){config=config||{};Ext.applyIf(config,{enableTabScroll:true,layoutOnTabChange:true,plain:true,deferredRender:true,hideMode:'offsets',defaults:{autoHeight:true,hideMode:'offsets',border:true,autoWidth:true,bodyCssClass:'tab-panel-wrapper'},activeTab:0,border:false,autoScroll:true,autoHeight:true,cls:'modx-tabs'});MODx.Tabs.superclass.constructor.call(this,config);this.config=config;};Ext.extend(MODx.Tabs,Ext.TabPanel);Ext.reg('modx-tabs',MODx.Tabs);MODx.VerticalTabs=function(config){config=config||{};Ext.applyIf(config,{cls:'vertical-tabs-panel',headerCfg:{tag:'div',cls:'x-tab-panel-header vertical-tabs-header'},bwrapCfg:{tag:'div',cls:'x-tab-panel-bwrap vertical-tabs-bwrap'},defaults:{bodyCssClass:'vertical-tabs-body',autoScroll:true,autoHeight:true,autoWidth:true,layout:'form'}});MODx.VerticalTabs.superclass.constructor.call(this,config);this.config=config;};Ext.extend(MODx.VerticalTabs,MODx.Tabs);Ext.reg('modx-vtabs',MODx.VerticalTabs);;Ext.Window.prototype.floating={shadow:false};Ext.override(Ext.Window,{animShow:function(){this.afterShow();var win=this;setTimeout(function(){if(!win.el.hasClass('anim-ready')){win.el.addClass('anim-ready');setTimeout(function(){if(win.mask!==undefined){if(win.mask instanceof Ext.Element){win.mask.addClass('fade-in');}else{win.mask.el.addClass('fade-in');}}
win.el.addClass('zoom-in');},250);}},300);},animHide:function(){this.afterHide();},onShow:function(){if(!this.el.hasClass('x-window-dlg')){this.addClass('anim-ready');var win=this;setTimeout(function(){if(win.mask!==undefined){if(win.mask instanceof Ext.Element){win.mask.addClass('fade-in');}else{win.mask.el.addClass('fade-in');}}
win.el.addClass('zoom-in');},250);}else{this.mask.addClass('fade-in');this.el.applyStyles({'opacity':1});}},onHide:function(){if(this.el.hasClass('zoom-in')){this.el.removeClass('zoom-in');if(this.mask!==undefined){if(this.mask instanceof Ext.Element){this.mask.removeClass('fade-in');}else{this.mask.el.removeClass('fade-in');}}
this.addClass('zoom-out');var win=this;setTimeout(function(){if(!win.isDestroyed){win.el.hide();win.el.removeClass('zoom-out');win.el.removeClass('anim-ready');}},250);}else if(this.el.hasClass('x-window-dlg')){this.el.applyStyles({'opacity':0});if(this.mask!==undefined){if(this.mask instanceof Ext.Element){this.mask.removeClass('fade-in');}else{this.mask.el.removeClass('fade-in');}}}}});MODx.Window=function(config){config=config||{};Ext.applyIf(config,{modal:false,layout:'auto',closeAction:'hide',shadow:true,resizable:true,collapsible:true,maximizable:true,autoHeight:false,autoScroll:true,allowDrop:true,width:400,cls:'modx-window',buttons:[{text:config.cancelBtnText||_('cancel'),scope:this,handler:function(){config.closeAction!=='close'?this.hide():this.close();}},{text:config.saveBtnText||_('save'),cls:'primary-button',scope:this,handler:this.submit}],record:{},keys:[{key:Ext.EventObject.ENTER,fn:this.submit,scope:this}]});MODx.Window.superclass.constructor.call(this,config);this.options=config;this.config=config;this.addEvents({success:true,failure:true,beforeSubmit:true});this._loadForm();this.on('show',function(){if(this.config.blankValues){this.fp.getForm().reset();}
if(this.config.allowDrop){this.loadDropZones();}
this.syncSize();this.focusFirstField();},this);this.on('afterrender',function(){this.originalHeight=this.el.getHeight();this.toolsHeight=this.originalHeight-this.body.getHeight()+50;this.resizeWindow();});Ext.EventManager.onWindowResize(this.resizeWindow,this);};Ext.extend(MODx.Window,Ext.Window,{_loadForm:function(){if(this.checkIfLoaded(this.config.record||null)){return false;}
var r=this.config.record;if(this.config.fields){var l=this.config.fields.length;for(var i=0;i<l;i++){var f=this.config.fields[i];if(r[f.name]){if(f.xtype=='checkbox'||f.xtype=='radio'){f.checked=r[f.name];}else{f.value=r[f.name];}}}}
this.fp=this.createForm({url:this.config.url,baseParams:this.config.baseParams||{action:this.config.action||''},items:this.config.fields||[]});this.renderForm();},focusFirstField:function(){if(this.fp&&this.fp.getForm()&&this.fp.getForm().items.getCount()>0){var fld=this.findFirstTextField();if(fld){fld.focus(false,200);}}},findFirstTextField:function(i){i=i||0;var fld=this.fp.getForm().items.itemAt(i);if(!fld)return false;if(fld.isXType('combo')||fld.isXType('checkbox')||fld.isXType('radio')||fld.isXType('displayfield')||fld.isXType('statictextfield')||fld.isXType('hidden')){i=i+1;fld=this.findFirstTextField(i);}
return fld;},submit:function(close){close=close===false?false:true;var f=this.fp.getForm();if(f.isValid()&&this.fireEvent('beforeSubmit',f.getValues())){f.submit({waitMsg:_('saving'),scope:this,failure:function(frm,a){if(this.fireEvent('failure',{f:frm,a:a})){MODx.form.Handler.errorExt(a.result,frm);}},success:function(frm,a){if(this.config.success){Ext.callback(this.config.success,this.config.scope||this,[frm,a]);}
this.fireEvent('success',{f:frm,a:a});if(close){this.config.closeAction!=='close'?this.hide():this.close();}}});}},createForm:function(config){Ext.applyIf(this.config,{formFrame:true,border:false,bodyBorder:false,autoHeight:true});config=config||{};Ext.applyIf(config,{labelAlign:this.config.labelAlign||'top',labelWidth:this.config.labelWidth||100,labelSeparator:this.config.labelSeparator||'',frame:this.config.formFrame,border:this.config.border,bodyBorder:this.config.bodyBorder,autoHeight:this.config.autoHeight,anchor:'100% 100%',errorReader:MODx.util.JSONReader,defaults:this.config.formDefaults||{msgTarget:this.config.msgTarget||'under'},url:this.config.url,baseParams:this.config.baseParams||{},fileUpload:this.config.fileUpload||false});return new Ext.FormPanel(config);},renderForm:function(){this.add(this.fp);},checkIfLoaded:function(r){r=r||{};if(this.fp&&this.fp.getForm()){this.fp.getForm().reset();this.fp.getForm().setValues(r);return true;}
return false;},setValues:function(r){if(r===null){return false;}
this.fp.getForm().setValues(r);},reset:function(){this.fp.getForm().reset();},hideField:function(f){f.disable();f.hide();var d=f.getEl().up('.x-form-item');if(d){d.setDisplayed(false);}},showField:function(f){f.enable();f.show();var d=f.getEl().up('.x-form-item');if(d){d.setDisplayed(true);}},loadDropZones:function(){if(this._dzLoaded)return false;var flds=this.fp.getForm().items;flds.each(function(fld){if(fld.isFormField&&(fld.isXType('textfield')||fld.isXType('textarea'))&&!fld.isXType('combo')){new MODx.load({xtype:'modx-treedrop',target:fld,targetEl:fld.getEl().dom});}});this._dzLoaded=true;},resizeWindow:function(){var viewHeight=Ext.getBody().getViewSize().height;var el=this.fp.getForm().el;if(viewHeight<this.originalHeight){el.setStyle('overflow-y','scroll');el.setHeight(viewHeight-this.toolsHeight);}else{el.setStyle('overflow-y','auto');el.setHeight('auto');}}});Ext.reg('modx-window',MODx.Window);;Ext.namespace('MODx.combo');Ext.form.ComboBox.prototype.shadow=false;Ext.override(Ext.form.TriggerField,{onRender:function(ct,position){this.doc=Ext.isIE?Ext.getBody():Ext.getDoc();Ext.form.TriggerField.superclass.onRender.call(this,ct,position);this.wrap=this.el.wrap({cls:'x-form-field-wrap x-form-field-trigger-wrap'});this.trigger=this.wrap.createChild(this.triggerConfig||{tag:'div',cls:'x-form-trigger '+(this.triggerClass||'')});this.initTrigger();if(!this.width){this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());}
this.resizeEl=this.positionEl=this.wrap;}});var originalComboBoxOnLoad=Ext.form.ComboBox.prototype.onLoad;Ext.override(Ext.form.ComboBox,{loaded:false,setValue:Ext.form.ComboBox.prototype.setValue.createSequence(function(v){var a=this.store.find(this.valueField,v);if(typeof v!=='undefined'&&v!==null&&this.mode=='remote'&&a==-1&&!this.loaded){var p={};p[this.valueField]=v;this.loaded=true;this.store.load({scope:this,params:p,callback:function(){this.setValue(v);this.collapse()}})}}),onLoad:function(){var ret=originalComboBoxOnLoad.apply(this,arguments);var maxwidth=Math.max(this.minListWidth||0,this.wrap.getWidth(true));this.list.setWidth(maxwidth);return ret;}});MODx.combo.ComboBox=function(config,getStore){config=config||{};Ext.applyIf(config,{displayField:'name',valueField:'id',triggerAction:'all',fields:['id','name'],baseParams:{action:'getList'},width:150,editable:false,resizable:true,typeAhead:false,forceSelection:true,minChars:3,cls:'modx-combo',tries:0});Ext.applyIf(config,{store:new Ext.data.JsonStore({url:config.connector||config.url,root:'results',totalProperty:'total',fields:config.fields,errorReader:MODx.util.JSONReader,baseParams:config.baseParams||{},remoteSort:config.remoteSort||false,autoDestroy:true,listeners:{'loadexception':{fn:function(o,trans,resp){var status=_('code')+': '+resp.status+' '+resp.statusText+'<br/>';MODx.msg.alert(_('error'),status+resp.responseText);}}}})});if(getStore===true){config.store.load();return config.store;}
MODx.combo.ComboBox.superclass.constructor.call(this,config);this.config=config;this.on('collapse',function(){this.wrap.removeClass('x-trigger-wrap-open');});this.store.on('load',function(){this.loaded=true;},this,{single:true});return this;};Ext.extend(MODx.combo.ComboBox,Ext.form.ComboBox,{expand:function(){if(this.isExpanded()||!this.hasFocus){return;}
this.wrap.addClass('x-trigger-wrap-open');if(this.mode=='remote'&&!this.loaded&&this.tries<4){this.tries+=1;Ext.defer(this.expand,250,this);return false;}
this.tries=0;if(this.title||this.pageSize){this.assetHeight=0;if(this.title){this.assetHeight+=this.header.getHeight();}
if(this.pageSize<this.store.getTotalCount()){this.assetHeight+=this.footer.getHeight();}else{this.list.setHeight(this.list.getHeight()-this.footer.getHeight());this.pageTb.hide();}}
if(this.bufferSize){this.doResize(this.bufferSize);delete this.bufferSize;}
this.list.alignTo.apply(this.list,[this.el].concat(this.listAlign));this.list.setZIndex(this.getZIndex());this.list.show();if(Ext.isGecko2){this.innerList.setOverflow('auto');}
this.mon(Ext.getDoc(),{scope:this,mousewheel:this.collapseIf,mousedown:this.collapseIf});this.fireEvent('expand',this);}});Ext.reg('modx-combo',MODx.combo.ComboBox);Ext.util.Format.comboRenderer=function(combo,val){return function(v,md,rec,ri,ci,s){if(!s)return v;if(!combo.findRecord)return v;var record=combo.findRecord(combo.valueField,v);return record?record.get(combo.displayField):val;}};MODx.combo.Renderer=function(combo){var loaded=false;return(function(v){var idx,rec;if(!combo.store)return v;if(!loaded){if(combo.store.proxy!==undefined&&combo.store.proxy!==null){combo.store.load();}
loaded=true;}
var v2=combo.getValue();idx=combo.store.find(combo.valueField,v2?v2:v);rec=combo.store.getAt(idx);return(rec===undefined||rec===null?(v2?v2:v):rec.get(combo.displayField));});};MODx.combo.Boolean=function(config){config=config||{};Ext.applyIf(config,{store:new Ext.data.SimpleStore({fields:['d','v'],data:[[_('yes'),true],[_('no'),false]]}),displayField:'d',valueField:'v',mode:'local',triggerAction:'all',editable:false,selectOnFocus:false,preventRender:true,forceSelection:true,enableKeyEvents:true});MODx.combo.Boolean.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Boolean,MODx.combo.ComboBox);Ext.reg('combo-boolean',MODx.combo.Boolean);Ext.reg('modx-combo-boolean',MODx.combo.Boolean);MODx.util.PasswordField=function(config){config=config||{};delete config.xtype;Ext.applyIf(config,{xtype:'textfield',inputType:'password'});MODx.util.PasswordField.superclass.constructor.call(this,config);};Ext.extend(MODx.util.PasswordField,Ext.form.TextField);Ext.reg('text-password',MODx.util.PasswordField);Ext.reg('modx-text-password',MODx.util.PasswordField);MODx.combo.User=function(config){config=config||{};Ext.applyIf(config,{name:'user',hiddenName:'user',displayField:'username',valueField:'id',fields:['username','id'],pageSize:20,url:MODx.config.connector_url,baseParams:{action:'security/user/getlist'},typeAhead:true,editable:true});MODx.combo.User.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.User,MODx.combo.ComboBox);Ext.reg('modx-combo-user',MODx.combo.User);MODx.combo.UserGroup=function(config){config=config||{};Ext.applyIf(config,{name:'group',hiddenName:'group',displayField:'name',valueField:'id',fields:['name','id','description'],pageSize:20,url:MODx.config.connector_url,baseParams:{action:'security/group/getlist'},tpl:new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item"><span style="font-weight: bold">{name}</span>','<br />{description}</div></tpl>')});MODx.combo.UserGroup.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.UserGroup,MODx.combo.ComboBox);Ext.reg('modx-combo-usergroup',MODx.combo.UserGroup);MODx.combo.UserGroupRole=function(config){config=config||{};Ext.applyIf(config,{name:'role',hiddenName:'role',displayField:'name',valueField:'id',fields:['name','id'],pageSize:20,url:MODx.config.connector_url,baseParams:{action:'security/role/getlist'}});MODx.combo.UserGroupRole.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.UserGroupRole,MODx.combo.ComboBox);Ext.reg('modx-combo-usergrouprole',MODx.combo.UserGroupRole);MODx.combo.ResourceGroup=function(config){config=config||{};Ext.applyIf(config,{name:'resourcegroup',hiddenName:'resourcegroup',displayField:'name',valueField:'id',fields:['name','id'],pageSize:20,url:MODx.config.connector_url,baseParams:{action:'security/resourcegroup/getlist'}});MODx.combo.ResourceGroup.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.ResourceGroup,MODx.combo.ComboBox);Ext.reg('modx-combo-resourcegroup',MODx.combo.ResourceGroup);MODx.combo.Context=function(config){config=config||{};Ext.applyIf(config,{name:'context',hiddenName:'context',displayField:'name',valueField:'key',fields:['key','name'],pageSize:20,url:MODx.config.connector_url,baseParams:{action:'context/getlist'}});MODx.combo.Context.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Context,MODx.combo.ComboBox);Ext.reg('modx-combo-context',MODx.combo.Context);MODx.combo.Policy=function(config){config=config||{};Ext.applyIf(config,{name:'policy',hiddenName:'policy',displayField:'name',valueField:'id',fields:['id','name','permissions'],allowBlank:false,editable:false,pageSize:20,url:MODx.config.connector_url,baseParams:{action:'security/access/policy/getlist'}});MODx.combo.Policy.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Policy,MODx.combo.ComboBox);Ext.reg('modx-combo-policy',MODx.combo.Policy);MODx.combo.Template=function(config){config=config||{};Ext.applyIf(config,{name:'template',hiddenName:'template',displayField:'templatename',valueField:'id',pageSize:20,fields:['id','templatename','description','category_name'],tpl:new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item"><span style="font-weight: bold">{templatename}</span>','<tpl if="category_name"> - <span style="font-style:italic">{category_name}</span></tpl>','<br />{description}</div></tpl>'),url:MODx.config.connector_url,baseParams:{action:'element/template/getlist'},allowBlank:true});MODx.combo.Template.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Template,MODx.combo.ComboBox);Ext.reg('modx-combo-template',MODx.combo.Template);MODx.combo.Category=function(config){config=config||{};Ext.applyIf(config,{name:'category',hiddenName:'category',displayField:'name',valueField:'id',mode:'remote',fields:['id','category','parent','name'],forceSelection:true,typeAhead:false,allowBlank:true,editable:false,enableKeyEvents:true,url:MODx.config.connector_url,baseParams:{action:'element/category/getlist',showNone:true}});MODx.combo.Category.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Category,MODx.combo.ComboBox,{_onblur:function(t,e){var v=this.getRawValue();this.setRawValue(v);this.setValue(v,true);}});Ext.reg('modx-combo-category',MODx.combo.Category);MODx.combo.Language=function(config){config=config||{};Ext.applyIf(config,{name:'language',hiddenName:'language',displayField:'name',valueField:'name',fields:['name'],typeAhead:true,minChars:1,editable:true,allowBlank:true,url:MODx.config.connector_url,baseParams:{action:'system/language/getlist'}});MODx.combo.Language.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Language,MODx.combo.ComboBox);Ext.reg('modx-combo-language',MODx.combo.Language);MODx.combo.Charset=function(config){config=config||{};Ext.applyIf(config,{name:'charset',hiddenName:'charset',displayField:'text',valueField:'value',fields:['value','text'],forceSelection:true,typeAhead:false,editable:false,allowBlank:false,url:MODx.config.connector_url,baseParams:{action:'system/charset/getlist'}});MODx.combo.Charset.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Charset,MODx.combo.ComboBox);Ext.reg('modx-combo-charset',MODx.combo.Charset);MODx.combo.RTE=function(config){config=config||{};Ext.applyIf(config,{name:'rte',hiddenName:'rte',displayField:'value',valueField:'value',fields:['value'],forceSelection:true,typeAhead:false,editable:false,allowBlank:false,url:MODx.config.connector_url,baseParams:{action:'system/rte/getlist'}});MODx.combo.RTE.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.RTE,MODx.combo.ComboBox);Ext.reg('modx-combo-rte',MODx.combo.RTE);MODx.combo.Role=function(config){config=config||{};Ext.applyIf(config,{name:'role',hiddenName:'role',forceSelection:true,typeAhead:false,editable:false,allowBlank:false,pageSize:20,url:MODx.config.connector_url,baseParams:{action:'security/role/getlist',addNone:true}});MODx.combo.Role.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Role,MODx.combo.ComboBox);Ext.reg('modx-combo-role',MODx.combo.Role);MODx.combo.ContentType=function(config){config=config||{};Ext.applyIf(config,{name:'content_type',hiddenName:'content_type',forceSelection:true,typeAhead:false,editable:false,allowBlank:false,pageSize:20,url:MODx.config.connector_url,baseParams:{action:'system/contenttype/getlist'}});MODx.combo.ContentType.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.ContentType,MODx.combo.ComboBox);Ext.reg('modx-combo-content-type',MODx.combo.ContentType);MODx.combo.ContentDisposition=function(config){config=config||{};Ext.applyIf(config,{store:new Ext.data.SimpleStore({fields:['d','v'],data:[[_('inline'),0],[_('attachment'),1]]}),name:'content_dispo',hiddenName:'content_dispo',displayField:'d',valueField:'v',mode:'local',triggerAction:'all',editable:false,pageSize:20,selectOnFocus:false,preventRender:true});MODx.combo.ContentDisposition.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.ContentDisposition,MODx.combo.ComboBox);Ext.reg('modx-combo-content-disposition',MODx.combo.ContentDisposition);MODx.combo.ClassMap=function(config){config=config||{};Ext.applyIf(config,{name:'class',hiddenName:'class',url:MODx.config.connector_url,baseParams:{action:'system/classmap/getlist'},displayField:'class',valueField:'class',fields:['class'],editable:false,pageSize:20});MODx.combo.ClassMap.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.ClassMap,MODx.combo.ComboBox);Ext.reg('modx-combo-class-map',MODx.combo.ClassMap);MODx.combo.ClassDerivatives=function(config){config=config||{};Ext.applyIf(config,{name:'class',hiddenName:'class',url:MODx.config.connector_url,baseParams:{action:'system/derivatives/getList',skip:'modXMLRPCResource','class':'modResource'},displayField:'name',valueField:'id',fields:['id','name'],forceSelection:true,typeAhead:false,editable:false,allowBlank:false,pageSize:20});MODx.combo.ClassDerivatives.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.ClassDerivatives,MODx.combo.ComboBox);Ext.reg('modx-combo-class-derivatives',MODx.combo.ClassDerivatives);MODx.combo.Object=function(config){config=config||{};Ext.applyIf(config,{name:'object',hiddenName:'object',url:MODx.config.connector_url,baseParams:{action:'workspace/builder/getAssocObject',class_key:'modResource'},displayField:'name',valueField:'id',fields:['id','name'],pageSize:10,editable:false});MODx.combo.Object.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Object,MODx.combo.ComboBox);Ext.reg('modx-combo-object',MODx.combo.Object);MODx.combo.Namespace=function(config){config=config||{};Ext.applyIf(config,{name:'namespace',hiddenName:'namespace',typeAhead:true,minChars:1,queryParam:'search',editable:true,allowBlank:true,pageSize:20,url:MODx.config.connector_url,baseParams:{action:'workspace/namespace/getlist'},fields:['name'],displayField:'name',valueField:'name'});MODx.combo.Namespace.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Namespace,MODx.combo.ComboBox);Ext.reg('modx-combo-namespace',MODx.combo.Namespace);MODx.combo.Browser=function(config){config=config||{};Ext.applyIf(config,{width:400,triggerAction:'all',triggerClass:'x-form-file-trigger',source:config.source||MODx.config.default_media_source});MODx.combo.Browser.superclass.constructor.call(this,config);this.config=config;};Ext.extend(MODx.combo.Browser,Ext.form.TriggerField,{browser:null,onTriggerClick:function(btn){if(this.disabled){return false;}
this.browser=MODx.load({xtype:'modx-browser',closeAction:'close',id:Ext.id(),multiple:true,source:this.config.source||1,hideFiles:this.config.hideFiles||false,rootVisible:this.config.rootVisible||false,allowedFileTypes:this.config.allowedFileTypes||'',wctx:this.config.wctx||'web',openTo:this.config.openTo||'',rootId:this.config.rootId||'/',hideSourceCombo:this.config.hideSourceCombo||false,listeners:{'select':{fn:function(data){this.setValue(data.relativeUrl);this.fireEvent('select',data);},scope:this}}});this.browser.show(btn);return true;},onDestroy:function(){MODx.combo.Browser.superclass.onDestroy.call(this);}});Ext.reg('modx-combo-browser',MODx.combo.Browser);MODx.combo.Country=function(config){config=config||{};Ext.applyIf(config,{name:'country',hiddenName:'country',url:MODx.config.connector_url,baseParams:{action:'system/country/getlist'},displayField:'value',valueField:'value',fields:['value'],editable:true,value:0,typeAhead:true});MODx.combo.Country.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Country,MODx.combo.ComboBox);Ext.reg('modx-combo-country',MODx.combo.Country);MODx.combo.PropertySet=function(config){config=config||{};Ext.applyIf(config,{name:'propertyset',hiddenName:'propertyset',url:MODx.config.connector_url,baseParams:{action:'element/propertyset/getlist'},displayField:'name',valueField:'id',fields:['id','name'],editable:false,value:0,pageSize:20});MODx.combo.PropertySet.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.PropertySet,MODx.combo.ComboBox);Ext.reg('modx-combo-property-set',MODx.combo.PropertySet);MODx.ChangeParentField=function(config){config=config||{};Ext.applyIf(config,{triggerAction:'all',editable:false,readOnly:false,formpanel:'modx-panel-resource',parentcmp:'modx-resource-parent-hidden',contextcmp:'modx-resource-context-key',currentid:MODx.request.id});MODx.ChangeParentField.superclass.constructor.call(this,config);this.config=config;this.on('click',this.onTriggerClick,this);this.addEvents({end:true});this.on('end',this.end,this);};Ext.extend(MODx.ChangeParentField,Ext.form.TriggerField,{oldValue:false,oldDisplayValue:false,end:function(p){var t=Ext.getCmp('modx-resource-tree');if(!t)return;p.d=p.d||p.v;t.removeListener('click',this.handleChangeParent,this);t.on('click',t._handleClick,t);t.disableHref=false;MODx.debug('Setting parent to: '+p.v);Ext.getCmp(this.config.parentcmp).setValue(p.v);this.setValue(p.d);this.oldValue=false;Ext.getCmp(this.config.formpanel).fireEvent('fieldChange');},onTriggerClick:function(){if(this.disabled){return false;}
if(this.oldValue){this.fireEvent('end',{v:this.oldValue,d:this.oldDisplayValue});return false;}
MODx.debug('onTriggerClick');var t=Ext.getCmp('modx-resource-tree');if(!t){MODx.debug('no tree found, trying to activate');var tp=Ext.getCmp('modx-leftbar-tabpanel');if(tp){tp.on('tabchange',function(tbp,tab){if(tab.id=='modx-resource-tree-ct'){this.disableTreeClick();}},this);tp.activate('modx-resource-tree-ct');}else{MODx.debug('no tabpanel');}
return false;}
this.disableTreeClick();},disableTreeClick:function(){MODx.debug('Disabling tree click');t=Ext.getCmp('modx-resource-tree');if(!t){MODx.debug('No tree found in disableTreeClick!');return false;}
this.oldDisplayValue=this.getValue();this.oldValue=Ext.getCmp(this.config.parentcmp).getValue();this.setValue(_('resource_parent_select_node'));t.expand();t.removeListener('click',t._handleClick);t.on('click',this.handleChangeParent,this);t.disableHref=true;return true;},handleChangeParent:function(node,e){var t=Ext.getCmp('modx-resource-tree');if(!t){return false;}
t.disableHref=true;var id=node.id.split('_');id=id[1];if(id==this.config.currentid){MODx.msg.alert('',_('resource_err_own_parent'));return false;}
var ctxf=Ext.getCmp(this.config.contextcmp);if(ctxf){var ctxv=ctxf.getValue();if(node.attributes&&node.attributes.ctx!=ctxv){ctxf.setValue(node.attributes.ctx);}}
this.fireEvent('end',{v:node.attributes.type!='modContext'?id:node.attributes.pk,d:Ext.util.Format.stripTags(node.text)});e.preventDefault();e.stopEvent();return true;}});Ext.reg('modx-field-parent-change',MODx.ChangeParentField);MODx.combo.TVWidget=function(config){config=config||{};Ext.applyIf(config,{name:'widget',hiddenName:'widget',displayField:'name',valueField:'value',fields:['value','name'],editable:false,url:MODx.config.connector_url,baseParams:{action:'element/tv/renders/getOutputs'},value:'default'});MODx.combo.TVWidget.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.TVWidget,MODx.combo.ComboBox);Ext.reg('modx-combo-tv-widget',MODx.combo.TVWidget);MODx.combo.TVInputType=function(config){config=config||{};Ext.applyIf(config,{name:'type',hiddenName:'type',displayField:'name',valueField:'value',editable:false,fields:['value','name'],url:MODx.config.connector_url,baseParams:{action:'element/tv/renders/getInputs'},value:'text'});MODx.combo.TVInputType.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.TVInputType,MODx.combo.ComboBox);Ext.reg('modx-combo-tv-input-type',MODx.combo.TVInputType);MODx.combo.Action=function(config){config=config||{};Ext.applyIf(config,{name:'action',hiddenName:'action',displayField:'controller',valueField:'id',fields:['id','controller','namespace'],pageSize:20,url:MODx.config.connector_url,baseParams:{action:'system/action/getlist'},tpl:new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item"><tpl if="namespace">{namespace} - </tpl>{controller}</div></tpl>')});MODx.combo.Action.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Action,MODx.combo.ComboBox);Ext.reg('modx-combo-action',MODx.combo.Action);MODx.combo.Dashboard=function(config){config=config||{};Ext.applyIf(config,{name:'dashboard',hiddenName:'dashboard',displayField:'name',valueField:'id',fields:['id','name','description'],pageSize:20,url:MODx.config.connector_url,baseParams:{action:'system/dashboard/getlist'},tpl:new Ext.XTemplate('<tpl for=".">','<div class="x-combo-list-item">','<h4 class="modx-combo-title">{name}</h4>','<p class="modx-combo-desc">{description}</p>','</div></tpl>')});MODx.combo.Dashboard.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Dashboard,MODx.combo.ComboBox);Ext.reg('modx-combo-dashboard',MODx.combo.Dashboard);MODx.combo.MediaSource=function(config){config=config||{};Ext.applyIf(config,{name:'source',hiddenName:'source',displayField:'name',valueField:'id',fields:['id','name','description'],pageSize:20,url:MODx.config.connector_url,baseParams:{action:'source/getlist'},tpl:new Ext.XTemplate('<tpl for=".">','<div class="x-combo-list-item">','<h4 class="modx-combo-title">{name}</h4>','<p class="modx-combo-desc">{description}</p>','</div></tpl>')});MODx.combo.MediaSource.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.MediaSource,MODx.combo.ComboBox);Ext.reg('modx-combo-source',MODx.combo.MediaSource);MODx.combo.MediaSourceType=function(config){config=config||{};Ext.applyIf(config,{name:'class_key',hiddenName:'class_key',displayField:'name',valueField:'class',fields:['id','class','name','description'],pageSize:20,url:MODx.config.connector_url,baseParams:{action:'source/type/getlist'},tpl:new Ext.XTemplate('<tpl for=".">','<div class="x-combo-list-item">','<h4 class="modx-combo-title">{name}</h4>','<p class="modx-combo-desc">{description}</p>','</div></tpl>')});MODx.combo.MediaSourceType.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.MediaSourceType,MODx.combo.ComboBox);Ext.reg('modx-combo-source-type',MODx.combo.MediaSourceType);MODx.combo.Authority=function(config){config=config||{};Ext.applyIf(config,{name:'authority',hiddenName:'authority',forceSelection:true,typeAhead:false,editable:false,allowBlank:false,pageSize:20,url:MODx.config.connector_url,baseParams:{action:'security/role/getAuthorityList',addNone:true}});MODx.combo.Authority.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.Authority,MODx.combo.ComboBox);Ext.reg('modx-combo-authority',MODx.combo.Authority);MODx.combo.ManagerTheme=function(config){config=config||{};Ext.applyIf(config,{name:'theme',hiddenName:'theme',displayField:'theme',valueField:'theme',fields:['theme'],url:MODx.config.connector_url,baseParams:{action:'workspace/theme/getlist'},typeAhead:false,editable:false});MODx.combo.ManagerTheme.superclass.constructor.call(this,config);};Ext.extend(MODx.combo.ManagerTheme,MODx.combo.ComboBox);Ext.reg('modx-combo-manager-theme',MODx.combo.ManagerTheme);;Ext.namespace('MODx.grid');MODx.grid.Grid=function(config){config=config||{};this.config=config;this._loadStore();this._loadColumnModel();Ext.applyIf(config,{store:this.store,cm:this.cm,sm:new Ext.grid.RowSelectionModel({singleSelect:true}),paging:(config.bbar?true:false),loadMask:true,autoHeight:true,collapsible:true,stripeRows:true,header:false,cls:'modx-grid',preventRender:true,preventSaveRefresh:true,showPerPage:true,stateful:false,menuConfig:{defaultAlign:'tl-b?',enableScrolling:false},viewConfig:{forceFit:true,enableRowBody:true,autoFill:true,showPreview:true,scrollOffset:0,emptyText:config.emptyText||_('ext_emptymsg')}});if(config.paging){var pgItms=config.showPerPage?[_('per_page')+':',{xtype:'textfield',cls:'x-tbar-page-size',value:config.pageSize||(parseInt(MODx.config.default_per_page)||20),listeners:{'change':{fn:this.onChangePerPage,scope:this},'render':{fn:function(cmp){new Ext.KeyMap(cmp.getEl(),{key:Ext.EventObject.ENTER,fn:this.blur,scope:cmp});},scope:this}}}]:[];if(config.pagingItems){for(var i=0;i<config.pagingItems.length;i++){pgItms.push(config.pagingItems[i]);}}
Ext.applyIf(config,{bbar:new Ext.PagingToolbar({pageSize:config.pageSize||(parseInt(MODx.config.default_per_page)||20),store:this.getStore(),displayInfo:true,items:pgItms})});}
if(config.grouping){Ext.applyIf(config,{view:new Ext.grid.GroupingView({forceFit:true,scrollOffset:0,groupTextTpl:'{text} ({[values.rs.length]} {[values.rs.length > 1 ? "'
+(config.pluralText||_('records'))+'" : "'
+(config.singleText||_('record'))+'"]})'})});}
if(config.tbar){for(var ix=0;ix<config.tbar.length;ix++){var itm=config.tbar[ix];if(itm.handler&&typeof(itm.handler)=='object'&&itm.handler.xtype){itm.handler=this.loadWindow.createDelegate(this,[itm.handler],true);}
if(!itm.scope){itm.scope=this;}}}
MODx.grid.Grid.superclass.constructor.call(this,config);this._loadMenu(config);this.addEvents('beforeRemoveRow','afterRemoveRow','afterAutoSave');if(!config.preventRender){this.render();}
this.on('rowcontextmenu',this._showMenu,this);if(config.autosave){this.on('afteredit',this.saveRecord,this);}
if(config.paging&&config.grouping){this.getBottomToolbar().bind(this.store);}
if(!config.paging&&!config.hasOwnProperty('pageSize')){config.pageSize=0;}
this.getStore().load({params:{start:config.pageStart||0,limit:config.hasOwnProperty('pageSize')?config.pageSize:(parseInt(MODx.config.default_per_page)||20)}});this.getStore().on('exception',this.onStoreException,this);this.config=config;};Ext.extend(MODx.grid.Grid,Ext.grid.EditorGridPanel,{windows:{},onStoreException:function(dp,type,act,opt,resp){var r=Ext.decode(resp.responseText);if(r.message){this.getView().emptyText=r.message;this.getView().refresh(false);}},saveRecord:function(e){e.record.data.menu=null;var p=this.config.saveParams||{};Ext.apply(e.record.data,p);var d=Ext.util.JSON.encode(e.record.data);var url=this.config.saveUrl||(this.config.url||this.config.connector);MODx.Ajax.request({url:url,params:{action:this.config.save_action||'updateFromGrid',data:d},listeners:{success:{fn:function(r){if(this.config.save_callback){Ext.callback(this.config.save_callback,this.config.scope||this,[r]);}
e.record.commit();if(!this.config.preventSaveRefresh){this.refresh();}
this.fireEvent('afterAutoSave',r);},scope:this},failure:{fn:function(r){e.record.reject();this.fireEvent('afterAutoSave',r);},scope:this}}});},onChangePerPage:function(tf,nv){if(Ext.isEmpty(nv))return false;nv=parseInt(nv);this.getBottomToolbar().pageSize=nv;this.store.load({params:{start:0,limit:nv}});},loadWindow:function(btn,e,win,or){var r=this.menu.record;if(!this.windows[win.xtype]||win.force){Ext.applyIf(win,{record:win.blankValues?{}:r,grid:this,listeners:{'success':{fn:win.success||this.refresh,scope:win.scope||this}}});if(or){Ext.apply(win,or);}
this.windows[win.xtype]=Ext.ComponentMgr.create(win);}
if(this.windows[win.xtype].setValues&&win.blankValues!==true&&r!=undefined){this.windows[win.xtype].setValues(r);}
this.windows[win.xtype].show(e.target);},confirm:function(type,text){var p={action:type};var k=this.config.primaryKey||'id';p[k]=this.menu.record[k];MODx.msg.confirm({title:_(type),text:_(text)||_('confirm_remove'),url:this.config.url,params:p,listeners:{'success':{fn:this.refresh,scope:this}}});},remove:function(text,action){if(this.destroying){return MODx.grid.Grid.superclass.remove.apply(this,arguments);}
var r=this.menu.record;text=text||'confirm_remove';var p=this.config.saveParams||{};Ext.apply(p,{action:action||'remove'});var k=this.config.primaryKey||'id';p[k]=r[k];if(this.fireEvent('beforeRemoveRow',r)){MODx.msg.confirm({title:_('warning'),text:_(text,r),url:this.config.url,params:p,listeners:{'success':{fn:function(){this.removeActiveRow(r);},scope:this}}});}},removeActiveRow:function(r){if(this.fireEvent('afterRemoveRow',r)){var rx=this.getSelectionModel().getSelected();this.getStore().remove(rx);}},_loadMenu:function(){this.menu=new Ext.menu.Menu(this.config.menuConfig);},_showMenu:function(g,ri,e){e.stopEvent();e.preventDefault();this.menu.record=this.getStore().getAt(ri).data;if(!this.getSelectionModel().isSelected(ri)){this.getSelectionModel().selectRow(ri);}
this.menu.removeAll();if(this.getMenu){var m=this.getMenu(g,ri,e);if(m&&m.length&&m.length>0){this.addContextMenuItem(m);}}
if((!m||m.length<=0)&&this.menu.record.menu){this.addContextMenuItem(this.menu.record.menu);}
if(this.menu.items.length>0){this.menu.showAt(e.xy);}},_loadStore:function(){if(this.config.grouping){this.store=new Ext.data.GroupingStore({url:this.config.url,baseParams:this.config.baseParams||{action:this.config.action||'getList'},reader:new Ext.data.JsonReader({totalProperty:'total',root:'results',fields:this.config.fields}),sortInfo:{field:this.config.sortBy||'id',direction:this.config.sortDir||'ASC'},remoteSort:this.config.remoteSort||false,groupField:this.config.groupBy||'name',storeId:this.config.storeId||Ext.id(),autoDestroy:true,listeners:{load:function(){Ext.getCmp('modx-content').doLayout();}}});}else{this.store=new Ext.data.JsonStore({url:this.config.url,baseParams:this.config.baseParams||{action:this.config.action||'getList'},fields:this.config.fields,root:'results',totalProperty:'total',remoteSort:this.config.remoteSort||false,storeId:this.config.storeId||Ext.id(),autoDestroy:true,listeners:{load:function(){Ext.getCmp('modx-content').doLayout();}}});}},_loadColumnModel:function(){if(this.config.columns){var c=this.config.columns;for(var i=0;i<c.length;i++){if(typeof(c[i].editor)=='string'){c[i].editor=eval(c[i].editor);}
if(typeof(c[i].renderer)=='string'){c[i].renderer=eval(c[i].renderer);}
if(typeof(c[i].editor)=='object'&&c[i].editor.xtype){var r=c[i].editor.renderer;if(Ext.isEmpty(c[i].editor.id)){c[i].editor.id=Ext.id();}
c[i].editor=Ext.ComponentMgr.create(c[i].editor);if(r===true){if(c[i].editor&&c[i].editor.store&&!c[i].editor.store.isLoaded&&c[i].editor.config.mode!='local'){c[i].editor.store.load();c[i].editor.store.isLoaded=true;}
c[i].renderer=Ext.util.Format.comboRenderer(c[i].editor);}else if(c[i].editor.initialConfig.xtype==='datefield'){c[i].renderer=Ext.util.Format.dateRenderer(c[i].editor.initialConfig.format||'Y-m-d');}else if(r==='boolean'){c[i].renderer=this.rendYesNo;}else if(r==='password'){c[i].renderer=this.rendPassword;}else if(r==='local'&&typeof(c[i].renderer)=='string'){c[i].renderer=eval(c[i].renderer);}}}
this.cm=new Ext.grid.ColumnModel(c);}},addContextMenuItem:function(items){var l=items.length;for(var i=0;i<l;i++){var options=items[i];if(options=='-'){this.menu.add('-');continue;}
var h=Ext.emptyFn;if(options.handler){h=eval(options.handler);if(h&&typeof(h)=='object'&&h.xtype){h=this.loadWindow.createDelegate(this,[h],true);}}else{h=function(itm){var o=itm.options;var id=this.menu.record.id;if(o.confirm){Ext.Msg.confirm('',o.confirm,function(e){if(e=='yes'){var act=Ext.urlEncode(o.params||{action:o.action});location.href='?id='+id+'&'+act;}},this);}else{var act=Ext.urlEncode(o.params||{action:o.action});location.href='?id='+id+'&'+act;}};}
this.menu.add({id:options.id||Ext.id(),text:options.text,scope:options.scope||this,options:options,handler:h});}},refresh:function(){this.getStore().reload();},rendPassword:function(v){var z='';for(var i=0;i<v.length;i++){z=z+'*';}
return z;},rendYesNo:function(v,md){if(v===1||v=='1'){v=true;}
if(v===0||v=='0'){v=false;}
switch(v){case true:case'true':case 1:md.css='green';return _('yes');case false:case'false':case'':case 0:md.css='red';return _('no');}},getSelectedAsList:function(){var sels=this.getSelectionModel().getSelections();if(sels.length<=0)return false;var cs='';for(var i=0;i<sels.length;i++){cs+=','+sels[i].data[this.config.primaryKey||'id'];}
if(cs[0]==','){cs=cs.substr(1);}
return cs;},editorYesNo:function(r){r=r||{};Ext.applyIf(r,{store:new Ext.data.SimpleStore({fields:['d','v'],data:[[_('yes'),true],[_('no'),false]]}),displayField:'d',valueField:'v',mode:'local',triggerAction:'all',editable:false,selectOnFocus:false});return new Ext.form.ComboBox(r);},encodeModified:function(){var p=this.getStore().getModifiedRecords();var rs={};for(var i=0;i<p.length;i++){rs[p[i].data[this.config.primaryKey||'id']]=p[i].data;}
return Ext.encode(rs);},encode:function(){var p=this.getStore().getRange();var rs={};for(var i=0;i<p.length;i++){rs[p[i].data[this.config.primaryKey||'id']]=p[i].data;}
return Ext.encode(rs);},expandAll:function(){if(!this.exp)return false;this.exp.expandAll();this.tools['plus'].hide();this.tools['minus'].show();return true;},collapseAll:function(){if(!this.exp)return false;this.exp.collapseAll();this.tools['minus'].hide();this.tools['plus'].show();return true;}});MODx.grid.LocalGrid=function(config){config=config||{};if(config.grouping){Ext.applyIf(config,{view:new Ext.grid.GroupingView({forceFit:true,scrollOffset:0,hideGroupedColumn:config.hideGroupedColumn?true:false,groupTextTpl:config.groupTextTpl||('{text} ({[values.rs.length]} {[values.rs.length > 1 ? "'
+(config.pluralText||_('records'))+'" : "'
+(config.singleText||_('record'))+'"]})')})});}
if(config.tbar){for(var i=0;i<config.tbar.length;i++){var itm=config.tbar[i];if(itm.handler&&typeof(itm.handler)=='object'&&itm.handler.xtype){itm.handler=this.loadWindow.createDelegate(this,[itm.handler],true);}
if(!itm.scope){itm.scope=this;}}}
Ext.applyIf(config,{title:'',store:this._loadStore(config),sm:new Ext.grid.RowSelectionModel({singleSelect:false}),loadMask:true,collapsible:true,stripeRows:true,enableColumnMove:true,header:false,cls:'modx-grid',viewConfig:{forceFit:true,enableRowBody:true,autoFill:true,showPreview:true,scrollOffset:0,emptyText:config.emptyText||_('ext_emptymsg')},menuConfig:{defaultAlign:'tl-b?',enableScrolling:false}});this.menu=new Ext.menu.Menu(config.menuConfig);this.config=config;this._loadColumnModel();MODx.grid.LocalGrid.superclass.constructor.call(this,config);this.addEvents({beforeRemoveRow:true,afterRemoveRow:true});this.on('rowcontextmenu',this._showMenu,this);};Ext.extend(MODx.grid.LocalGrid,Ext.grid.EditorGridPanel,{windows:{},_loadStore:function(config){if(config.grouping){this.store=new Ext.data.GroupingStore({data:config.data||[],reader:new Ext.data.ArrayReader({},config.fields||[]),sortInfo:config.sortInfo||{field:config.sortBy||'name',direction:config.sortDir||'ASC'},groupField:config.groupBy||'name'});}else{this.store=new Ext.data.SimpleStore({fields:config.fields,data:config.data||[]})}
return this.store;},loadWindow:function(btn,e,win,or){var r=this.menu.record;if(!this.windows[win.xtype]){Ext.applyIf(win,{scope:this,success:this.refresh,record:win.blankValues?{}:r});if(or){Ext.apply(win,or);}
this.windows[win.xtype]=Ext.ComponentMgr.create(win);}
if(this.windows[win.xtype].setValues&&win.blankValues!==true&&r!=undefined){this.windows[win.xtype].setValues(r);}
this.windows[win.xtype].show(e.target);},_loadColumnModel:function(){if(this.config.columns){var c=this.config.columns;for(var i=0;i<c.length;i++){if(typeof(c[i].editor)=='string'){c[i].editor=eval(c[i].editor);}
if(typeof(c[i].renderer)=='string'){c[i].renderer=eval(c[i].renderer);}
if(typeof(c[i].editor)=='object'&&c[i].editor.xtype){var r=c[i].editor.renderer;c[i].editor=Ext.ComponentMgr.create(c[i].editor);if(r===true){if(c[i].editor&&c[i].editor.store&&!c[i].editor.store.isLoaded&&c[i].editor.config.mode!='local'){c[i].editor.store.load();c[i].editor.store.isLoaded=true;}
c[i].renderer=Ext.util.Format.comboRenderer(c[i].editor);}else if(c[i].editor.initialConfig.xtype==='datefield'){c[i].renderer=Ext.util.Format.dateRenderer(c[i].editor.initialConfig.format||'Y-m-d');}else if(r==='boolean'){c[i].renderer=this.rendYesNo;}else if(r==='password'){c[i].renderer=this.rendPassword;}else if(r==='local'&&typeof(c[i].renderer)=='string'){c[i].renderer=eval(c[i].renderer);}}}
this.cm=new Ext.grid.ColumnModel(c);}},_showMenu:function(g,ri,e){e.stopEvent();e.preventDefault();this.menu.recordIndex=ri;this.menu.record=this.getStore().getAt(ri).data;if(!this.getSelectionModel().isSelected(ri)){this.getSelectionModel().selectRow(ri);}
this.menu.removeAll();var m=this.getMenu(g,ri);if(m){this.addContextMenuItem(m);this.menu.showAt(e.xy);}},getMenu:function(){return this.menu.record.menu;},addContextMenuItem:function(items){var l=items.length;for(var i=0;i<l;i++){var options=items[i];if(options=='-'){this.menu.add('-');continue;}
var h=Ext.emptyFn;if(options.handler){h=eval(options.handler);if(h&&typeof(h)=='object'&&h.xtype){h=this.loadWindow.createDelegate(this,[h],true);}}else{h=function(itm){var o=itm.options;var id=this.menu.record.id;var w=Ext.get('modx_content');if(o.confirm){Ext.Msg.confirm('',o.confirm,function(e){if(e=='yes'){var a=Ext.urlEncode(o.params||{action:o.action});var s='?id='+id+'&'+a;if(w===null){location.href=s;}else{w.dom.src=s;}}},this);}else{var a=Ext.urlEncode(o.params||{action:o.action});var s='?id='+id+'&'+a;if(w===null){location.href=s;}else{w.dom.src=s;}}};}
this.menu.add({id:options.id||Ext.id(),text:options.text,scope:this,options:options,handler:h});}},remove:function(config){if(this.destroying){return MODx.grid.LocalGrid.superclass.remove.apply(this,arguments);}
var r=this.getSelectionModel().getSelected();if(this.fireEvent('beforeRemoveRow',r)){Ext.Msg.confirm(config.title||'',config.text||'',function(e){if(e=='yes'){this.getStore().remove(r);this.fireEvent('afterRemoveRow',r);}},this);}},encode:function(){var s=this.getStore();var ct=s.getCount();var rs=this.config.encodeByPk?{}:[];var r;for(var j=0;j<ct;j++){r=s.getAt(j).data;r.menu=null;if(this.config.encodeAssoc){rs[r[this.config.encodeByPk||'id']]=r;}else{rs.push(r);}}
return Ext.encode(rs);},expandAll:function(){if(!this.exp)return false;this.exp.expandAll();this.tools['plus'].hide();this.tools['minus'].show();return true;},collapseAll:function(){if(!this.exp)return false;this.exp.collapseAll();this.tools['minus'].hide();this.tools['plus'].show();return true;},rendYesNo:function(d,c){switch(d){case'':return'-';case false:c.css='red';return _('no');case true:c.css='green';return _('yes');}},rendPassword:function(v){var z='';for(var i=0;i<v.length;i++){z=z+'*';}
return z;}});Ext.reg('grid-local',MODx.grid.LocalGrid);Ext.reg('modx-grid-local',MODx.grid.LocalGrid);
/*!
 * Ext JS Library 3.4.0
 * Copyright(c) 2006-2011 Sencha Inc.
 * licensing@sencha.com
 * http://www.sencha.com/license
 */
Ext.ns('Ext.ux.grid');Ext.ux.grid.RowExpander=Ext.extend(Ext.util.Observable,{expandOnEnter:true,expandOnDblClick:true,header:'',width:20,sortable:false,fixed:true,hideable:false,menuDisabled:true,dataIndex:'',id:'expander',lazyRender:true,enableCaching:true,constructor:function(config){Ext.apply(this,config);this.addEvents({beforeexpand:true,expand:true,beforecollapse:true,collapse:true});Ext.ux.grid.RowExpander.superclass.constructor.call(this);if(this.tpl){if(typeof this.tpl=='string'){this.tpl=new Ext.Template(this.tpl);}
this.tpl.compile();}
this.state={};this.bodyContent={};},getRowClass:function(record,rowIndex,p,ds){p.cols=p.cols-1;var content=this.bodyContent[record.id];if(!content&&!this.lazyRender){content=this.getBodyContent(record,rowIndex);}
if(content){p.body=content;}
return this.state[record.id]?'x-grid3-row-expanded':'x-grid3-row-collapsed';},init:function(grid){this.grid=grid;var view=grid.getView();view.getRowClass=this.getRowClass.createDelegate(this);view.enableRowBody=true;grid.on('render',this.onRender,this);grid.on('destroy',this.onDestroy,this);},onRender:function(){var grid=this.grid;var mainBody=grid.getView().mainBody;mainBody.on('mousedown',this.onMouseDown,this,{delegate:'.x-grid3-row-expander'});if(this.expandOnEnter){this.keyNav=new Ext.KeyNav(this.grid.getGridEl(),{'enter':this.onEnter,scope:this});}
if(this.expandOnDblClick){grid.on('rowdblclick',this.onRowDblClick,this);}},onDestroy:function(){if(this.keyNav){this.keyNav.disable();delete this.keyNav;}
var mainBody=this.grid.getView().mainBody;if(mainBody){mainBody.un('mousedown',this.onMouseDown,this);}},onRowDblClick:function(grid,rowIdx,e){this.toggleRow(rowIdx);},onEnter:function(e){var g=this.grid;var sm=g.getSelectionModel();var sels=sm.getSelections();for(var i=0,len=sels.length;i<len;i++){var rowIdx=g.getStore().indexOf(sels[i]);this.toggleRow(rowIdx);}},getBodyContent:function(record,index){if(!this.enableCaching){return this.tpl.apply(record.data);}
var content=this.bodyContent[record.id];if(!content){content=this.tpl.apply(record.data);this.bodyContent[record.id]=content;}
return content;},onMouseDown:function(e,t){e.stopEvent();var row=e.getTarget('.x-grid3-row');this.toggleRow(row);},renderer:function(v,p,record){p.cellAttr='rowspan="2"';return'<div class="x-grid3-row-expander">&#160;</div>';},beforeExpand:function(record,body,rowIndex){if(this.fireEvent('beforeexpand',this,record,body,rowIndex)!==false){if(this.tpl&&this.lazyRender){body.innerHTML=this.getBodyContent(record,rowIndex);}
return true;}else{return false;}},toggleRow:function(row){if(typeof row=='number'){row=this.grid.view.getRow(row);}
this[Ext.fly(row).hasClass('x-grid3-row-collapsed')?'expandRow':'collapseRow'](row);},expandRow:function(row){if(typeof row=='number'){row=this.grid.view.getRow(row);}
var record=this.grid.store.getAt(row.rowIndex);var body=Ext.DomQuery.selectNode('tr:nth(2) div.x-grid3-row-body',row);if(this.beforeExpand(record,body,row.rowIndex)){this.state[record.id]=true;Ext.fly(row).replaceClass('x-grid3-row-collapsed','x-grid3-row-expanded');this.fireEvent('expand',this,record,body,row.rowIndex);}},collapseRow:function(row){if(typeof row=='number'){row=this.grid.view.getRow(row);}
var record=this.grid.store.getAt(row.rowIndex);var body=Ext.fly(row).child('tr:nth(1) div.x-grid3-row-body',true);if(this.fireEvent('beforecollapse',this,record,body,row.rowIndex)!==false){this.state[record.id]=false;Ext.fly(row).replaceClass('x-grid3-row-expanded','x-grid3-row-collapsed');this.fireEvent('collapse',this,record,body,row.rowIndex);}}});Ext.preg('rowexpander',Ext.ux.grid.RowExpander);Ext.grid.RowExpander=Ext.ux.grid.RowExpander;Ext.ns('Ext.ux.grid');Ext.ux.grid.CheckColumn=function(a){Ext.apply(this,a);if(!this.id){this.id=Ext.id()}this.renderer=this.renderer.createDelegate(this)};Ext.ux.grid.CheckColumn.prototype={init:function(b){this.grid=b;this.grid.on('render',function(){var a=this.grid.getView();a.mainBody.on('mousedown',this.onMouseDown,this)},this);this.grid.on('destroy',this.onDestroy,this)},onMouseDown:function(e,t){this.grid.fireEvent('rowclick');if(t.className&&t.className.indexOf('x-grid3-cc-'+this.id)!=-1){e.stopEvent();var a=this.grid.getView().findRowIndex(t);var b=this.grid.store.getAt(a);b.set(this.dataIndex,!b.data[this.dataIndex]);this.grid.fireEvent('afteredit')}},renderer:function(v,p,a){p.css+=' x-grid3-check-col-td';return'<div class="x-grid3-check-col'+(v?'-on':'')+' x-grid3-cc-'+this.id+'">&#160;</div>'},onDestroy:function(){var mainBody=this.grid.getView().mainBody;if(mainBody){mainBody.un('mousedown',this.onMouseDown,this);}}};Ext.preg('checkcolumn',Ext.ux.grid.CheckColumn);Ext.grid.CheckColumn=Ext.ux.grid.CheckColumn;Ext.grid.PropertyColumnModel=function(a,b){var g=Ext.grid,f=Ext.form;this.grid=a;g.PropertyColumnModel.superclass.constructor.call(this,[{header:this.nameText,width:50,sortable:true,dataIndex:'name',id:'name',menuDisabled:true},{header:this.valueText,width:50,resizable:false,dataIndex:'value',id:'value',menuDisabled:true}]);this.store=b;var c=new f.Field({autoCreate:{tag:'select',children:[{tag:'option',value:'true',html:'true'},{tag:'option',value:'false',html:'false'}]},getValue:function(){return this.el.dom.value=='true'}});this.editors={'date':new g.GridEditor(new f.DateField({selectOnFocus:true})),'string':new g.GridEditor(new f.TextField({selectOnFocus:true})),'number':new g.GridEditor(new f.NumberField({selectOnFocus:true,style:'text-align:left;'})),'boolean':new g.GridEditor(c)};this.renderCellDelegate=this.renderCell.createDelegate(this);this.renderPropDelegate=this.renderProp.createDelegate(this)};Ext.extend(Ext.grid.PropertyColumnModel,Ext.grid.ColumnModel,{nameText:'Name',valueText:'Value',dateFormat:'m/j/Y',renderDate:function(a){return a.dateFormat(this.dateFormat)},renderBool:function(a){return a?'true':'false'},isCellEditable:function(a,b){return a==1},getRenderer:function(a){return a==1?this.renderCellDelegate:this.renderPropDelegate},renderProp:function(v){return this.getPropertyName(v)},renderCell:function(a){var b=a;if(Ext.isDate(a)){b=this.renderDate(a)}else if(typeof a=='boolean'){b=this.renderBool(a)}return Ext.util.Format.htmlEncode(b)},getPropertyName:function(a){var b=this.grid.propertyNames;return b&&b[a]?b[a]:a},getCellEditor:function(a,b){var p=this.store.getProperty(b),n=p.data.name,val=p.data.value;if(this.grid.customEditors[n]){return this.grid.customEditors[n]}if(Ext.isDate(val)){return this.editors.date}else if(typeof val=='number'){return this.editors.number}else if(typeof val=='boolean'){return this.editors['boolean']}else{return this.editors.string}},destroy:function(){Ext.grid.PropertyColumnModel.superclass.destroy.call(this);for(var a in this.editors){Ext.destroy(a)}}});