/**
MODExt Revolution 1.0
Copyright (c) 2007-2011, Shaun McCormick
All rights reserved
MODX-specific JS extension for ExtJS 3.0

-------------

The MODExt JS extension is distributed under the terms of the GNU GPLv3 license.
It extends ExtJS, distributed under the Open Source GPL 3.0 license.

http://www.gnu.org/licenses/gpl.html

-------------

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.
*/
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.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(A){A=A||{};Ext.applyIf(A,{successProperty:"success",totalProperty:"total",root:"data"});MODx.util.JSONReader.superclass.constructor.call(this,A,["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(A,C,B){B=B||_("saving");if(MODx.util.Progress.id===C&&A<11){Ext.MessageBox.updateProgress(A/10,B);}},reset:function(){MODx.util.Progress.id=MODx.util.Progress.id+1;}};MODx.LockMask=function(A){A=A||{};Ext.applyIf(A,{msg:_("locked"),msgCls:"modx-lockmask"});MODx.LockMask.superclass.constructor.call(this,A.el,A);};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(A){A=A||this;A.items.each(function(B){if(!B.getValue){return ;}if(B.items){this.clearDirty(B);}else{if(B.originalValue!=B.getValue()){B.originalValue=B.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(A){this.readOnly=true;this.disabled=!this.initialConfig.submitValue;MODx.StaticBoolean.superclass.onRender.apply(this,arguments);this.on("change",this.onChange,this);},setValue:function(A){if(A===1){this.addClass("green");A=_("yes");}else{this.addClass("red");A=_("no");}MODx.StaticBoolean.superclass.setValue.apply(this,arguments);}});Ext.reg("staticboolean",MODx.StaticBoolean);Ext.override(Ext.form.Checkbox,{setBoxLabel:function(A){this.boxLabel=A;if(this.rendered){this.wrap.child(".x-form-cb-label").update(A);}}});Array.prototype.in_array=function(A){for(var C=0,B=this.length;C<B;C=C+1){if(this[C]===A){return true;}}return false;};Ext.form.setCheckboxValues=function(B,E,A){var C,D=0;while((C=B.findField(E+D))!==null){C.setValue((A&(1<<D))?"true":"false");D=D+1;}};Ext.form.getCheckboxMask=function(D){var B="";if(typeof (D)!=="undefined"){if((typeof (D)==="string")){B=D+"";}else{for(var C=0,A=D.length;C<A;C=C+1){B+=(B!==""?",":"")+(D[C]-0);}}}return B;};Ext.form.BasicForm.prototype.append=function(){var C=new Ext.form.Layout();var A=[];C.stack.push.apply(C.stack,arguments);for(var B=0;B<arguments.length;B=B+1){if(arguments[B].isFormField){A.push(arguments[B]);}}C.render(this.el);if(A.length>0){this.items.addAll(A);for(var D=0;D<A.length;D=D+1){A[D].render("x-form-el-"+A[D].id);}}return this;};Ext.form.AMPMField=function(B,A){return new Ext.form.ComboBox({store:new Ext.data.SimpleStore({fields:["ampm"],data:[["am"],["pm"]]}),displayField:"ampm",hiddenName:B,mode:"local",editable:false,forceSelection:true,triggerAction:"all",width:60,value:A||"am"});};Ext.form.HourField=function(C,B,A){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:A||1,transform:C});};Ext.override(Ext.tree.TreeNodeUI,{hasClass:function(B){var A=Ext.fly(this.elNode);if(!A){return"";}return B&&(" "+A.dom.className+" ").indexOf(" "+B+" ")!==-1;}});Ext.override(Ext.form.Action.Submit,{handleResponse:function(D){var B=Ext.decode(D.responseText);if(this.form.errorReader){var C=this.form.errorReader.read(D);var G=[];if(C.records){for(var E=0,A=C.records.length;E<A;E=E+1){var F=C.records[E];G[E]=F.data;}}if(G.length<1){G=null;}return{success:C.success,message:B.message,object:B.object,errors:G};}return Ext.decode(D.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 A=Ext.form.Field.findLabel(this);if(A){Ext.QuickTips.register({target:A,text:this.description,enabled:true});}}});Ext.applyIf(Ext.form.Field,{findLabel:function(C){var B=null;var A=null;B=C.getEl().up("div.x-form-element");if(B){A=B.child("label");}if(A){return A;}B=C.getEl().up("div.x-form-item");if(B){A=B.child("label");}if(A){return A;}}});MODx.util.Clipboard=function(){return{escape:function(A){A=encodeURIComponent(A);return A.replace(/%0A/g,"%0D%0A");},copy:function(C){if(Ext.isIE){window.clipboardData.setData("Text",C);}else{var B="flashcopier";if(!document.getElementById(B)){var D=document.createElement("div");D.id=B;document.body.appendChild(D);}document.getElementById(B).innerHTML="";var A='<embed src="'+MODx.config.manager_url+'assets/modext/_clipboard.swf" FlashVars="clipboard='+MODx.util.Clipboard.escape(C)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';document.getElementById(B).innerHTML=A;}}};}();Ext.util.Format.trimCommas=function(B){B=B.replace(",,",",");var A=B.length;if(B.substr(A-1,1)==","){B=B.substring(0,A-1);}if(B.substr(0,1)==","){B=B.substring(1);}if(B==","){B="";}return B;};Ext.ns("Ext.ux.grid");if("function"!==typeof RegExp.escape){RegExp.escape=function(A){if("string"!==typeof A){return A;}return A.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(D){this.grid=D;this.id=this.id||Ext.id();var C=D.getColumnModel().lookup;delete (C[undefined]);C[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 B=D.getView();var A={scope:this};A[this.actionEvent]=this.onClick;D.afterRender=D.afterRender.createSequence(function(){B.mainBody.on(A);D.on("destroy",this.purgeListeners,this);},this);if(!this.renderer){this.renderer=function(F,E,J,I,H,G){E.css+=(E.css?" ":"")+"ux-row-action-cell";return this.tpl.apply(this.getData(F,E,J,I,H,G));}.createDelegate(this);}if(B.groupTextTpl&&this.groupActions){B.interceptMouse=B.interceptMouse.createInterceptor(function(E){if(E.getTarget(".ux-grow-action-item")){return false;}});B.groupTextTpl='<div class="ux-grow-action-text">'+B.groupTextTpl+"</div>"+this.processActions(this.groupActions,this.tplGroup).apply();}if(true===this.keepSelection){D.processEvent=D.processEvent.createInterceptor(function(E,F){if("mousedown"===E){return !this.getAction(F);}},this);}},getData:function(B,A,F,E,D,C){return F.data||{};},processActions:function(A,D){var C=[];Ext.each(A,function(E,F){if(E.iconCls&&"function"===typeof (E.callback||E.cb)){this.callbacks=this.callbacks||{};this.callbacks[E.iconCls]=E.callback||E.cb;}var G={cls:E.iconIndex?"{"+E.iconIndex+"}":(E.iconCls?E.iconCls:""),qtip:E.qtipIndex?"{"+E.qtipIndex+"}":(E.tooltip||E.qtip?E.tooltip||E.qtip:""),text:E.textIndex?"{"+E.textIndex+"}":(E.text?E.text:""),hide:E.hideIndex?'<tpl if="'+E.hideIndex+'">'+("display"===this.hideMode?"display:none":"visibility:hidden")+";</tpl>":(E.hide?("display"===this.hideMode?"display:none":"visibility:hidden;"):""),align:E.align||"right",style:E.style?E.style:""};C.push(G);},this);var B=new Ext.XTemplate(D||this.tplRow);return new Ext.XTemplate(B.apply({actions:C}));},getAction:function(C){var A=false;var B=C.getTarget(".ux-row-action-item");if(B){A=B.className.replace(/ux-row-action-item /,"");if(A){A=A.replace(/ ux-row-action-text/,"");A=A.trim();}}return A;},onClick:function(G,K){var J=this.grid.getView();var I=G.getTarget(".x-grid3-row");var H=J.findCellIndex(K.parentNode.parentNode);var F=this.getAction(G);if(false!==I&&false!==H&&false!==F){var E=this.grid.store.getAt(I.rowIndex);if(this.callbacks&&"function"===typeof this.callbacks[F]){this.callbacks[F](this.grid,E,F,I.rowIndex,H);}if(true!==this.eventsSuspended&&false===this.fireEvent("beforeaction",this.grid,E,F,I.rowIndex,H)){return ;}else{if(true!==this.eventsSuspended){this.fireEvent("action",this.grid,E,F,I.rowIndex,H);}}}t=G.getTarget(".ux-grow-action-item");if(t){var D=J.findGroup(K);var C=D?D.id.replace(/ext-gen[0-9]+-gp-/,""):null;var B;if(C){var A=new RegExp(RegExp.escape(C));B=this.grid.store.queryBy(function(L){return L._groupId.match(A);});B=B?B.items:[];}F=t.className.replace(/ux-grow-action-item (ux-action-right )*/,"");if("function"===typeof this.callbacks[F]){this.callbacks[F](this.grid,B,F,C);}if(true!==this.eventsSuspended&&false===this.fireEvent("beforegroupaction",this.grid,B,F,C)){return false;}this.fireEvent("groupaction",this.grid,B,F,C);}}});Ext.reg("rowactions",Ext.ux.grid.RowActions);Ext.SwitchButton=Ext.extend(Ext.Component,{initComponent:function(){Ext.SwitchButton.superclass.initComponent.call(this);var A=new Ext.util.MixedCollection();A.addAll(this.items);this.items=A;this.addEvents("change");if(this.handler){this.on("change",this.handler,this.scope||this);}},onRender:function(K,J){var I=document.createElement("table");I.cellSpacing=0;I.className="x-rbtn";I.id=this.id;var H=document.createElement("tr");I.appendChild(H);var G=this.items.length;var F=G-1;this.activeItem=this.items.get(this.activeItem);for(var C=0;C<G;C++){var E=this.items.itemAt(C);var D=H.appendChild(document.createElement("td"));D.id=this.id+"-rbi-"+C;var B=C===0?"x-rbtn-first":(C==F?"x-rbtn-last":"x-rbtn-item");E.baseCls=B;if(this.activeItem==E){B+="-active";}D.className=B;var A=document.createElement("button");A.innerHTML="&#160;";A.className=E.iconCls;A.title=E.tooltip;D.appendChild(A);E.cell=D;}this.el=Ext.get(K.dom.appendChild(I));this.el.on("click",this.onClick,this);},getActiveItem:function(){return this.activeItem;},setActiveItem:function(B){if(typeof B!="object"&&B!==null){B=this.items.get(B);}var A=this.getActiveItem();if(B!=A){if(A){Ext.fly(A.cell).removeClass(A.baseCls+"-active");}if(B){Ext.fly(B.cell).addClass(B.baseCls+"-active");}this.activeItem=B;this.fireEvent("change",this,B);}return B;},onClick:function(B){var A=B.getTarget("td",2);if(!this.disabled&&A){this.setActiveItem(parseInt(A.id.split("-rbi-")[1],10));}}});Ext.reg("switch",Ext.SwitchButton);Ext.namespace("Ext.ux.form");Ext.ux.form.SuperBoxSelect=function(A){A.listClass="x-superboxselect-list";Ext.ux.form.SuperBoxSelect.superclass.constructor.call(this,A);this.addEvents("beforeadditem","additem","newitem","beforeremoveitem","removeitem","clear");};Ext.ux.form.SuperBoxSelect=Ext.extend(Ext.ux.form.SuperBoxSelect,Ext.form.ComboBox,{addNewDataOnBlur:false,allowAddNewData:false,allowQueryAll:true,backspaceDeletesLastItem:true,classField:null,clearBtnCls:"",clearLastQueryOnEscape:false,clearOnEscape:false,displayFieldTpl:null,extraItemCls:"",extraItemStyle:"",expandBtnCls:"",fixFocusOnTabSelect:true,forceFormValue:true,forceSameValueQuery:false,itemDelimiterKey:Ext.EventObject.ENTER,navigateItemsWithTab:true,pinList:true,preventDuplicates:true,queryFilterRe:"",queryValuesDelimiter:"|",queryValuesIndicator:"valuesqry",removeValuesFromStore:true,renderFieldBtns:true,stackItems:false,styleField:null,supressClearValueRemoveEvents:false,validationEvent:"blur",valueDelimiter:",",initComponent:function(){Ext.apply(this,{items:new Ext.util.MixedCollection(false),usedRecords:new Ext.util.MixedCollection(false),addedRecords:[],remoteLookup:[],hideTrigger:true,grow:false,resizable:false,multiSelectMode:false,preRenderValue:null,filteredQueryData:""});if(this.queryFilterRe){if(Ext.isString(this.queryFilterRe)){this.queryFilterRe=new RegExp(this.queryFilterRe);}}if(this.transform){this.doTransform();}if(this.forceFormValue){this.items.on({add:this.manageNameAttribute,remove:this.manageNameAttribute,clear:this.manageNameAttribute,scope:this});}Ext.ux.form.SuperBoxSelect.superclass.initComponent.call(this);if(this.mode==="remote"&&this.store){this.store.on("load",this.onStoreLoad,this);}},onRender:function(B,A){var C=this.hiddenName;this.hiddenName=null;Ext.ux.form.SuperBoxSelect.superclass.onRender.call(this,B,A);this.hiddenName=C;this.manageNameAttribute();var D=(this.stackItems===true)?"x-superboxselect-stacked":"";if(this.renderFieldBtns){D+=" x-superboxselect-display-btns";}this.el.removeClass("x-form-text").addClass("x-superboxselect-input-field");this.wrapEl=this.el.wrap({tag:"ul"});this.outerWrapEl=this.wrapEl.wrap({tag:"div",cls:"x-form-text x-superboxselect "+D});this.inputEl=this.el.wrap({tag:"li",cls:"x-superboxselect-input"});if(this.renderFieldBtns){this.setupFieldButtons().manageClearBtn();}this.setupFormInterception();},doTransform:function(){var K=Ext.getDom(this.transform),E=[];if(!this.store){this.mode="local";var G=[],A=K.options;for(var D=0,F=A.length;D<F;D++){var C=A[D],J=Ext.get(C),H=J.getAttributeNS(null,"value")||"",I=J.getAttributeNS(null,"className")||"",B=J.getAttributeNS(null,"style")||"";if(C.selected){E.push(H);}G.push([H,C.text,I,typeof (B)==="string"?B:B.cssText]);}this.store=new Ext.data.SimpleStore({id:0,fields:["value","text","cls","style"],data:G});Ext.apply(this,{valueField:"value",displayField:"text",classField:"cls",styleField:"style"});}if(E.length){this.value=E.join(",");}},setupFieldButtons:function(){this.buttonWrap=this.outerWrapEl.createChild({cls:"x-superboxselect-btns"});this.buttonClear=this.buttonWrap.createChild({tag:"div",cls:"x-superboxselect-btn-clear "+this.clearBtnCls});if(this.allowQueryAll){this.buttonExpand=this.buttonWrap.createChild({tag:"div",cls:"x-superboxselect-btn-expand "+this.expandBtnCls});}this.initButtonEvents();return this;},initButtonEvents:function(){this.buttonClear.addClassOnOver("x-superboxselect-btn-over").on("click",function(A){A.stopEvent();if(this.disabled){return ;}this.clearValue();this.el.focus();},this);if(this.allowQueryAll){this.buttonExpand.addClassOnOver("x-superboxselect-btn-over").on("click",function(A){A.stopEvent();if(this.disabled){return ;}if(this.isExpanded()){this.multiSelectMode=false;}else{if(this.pinList){this.multiSelectMode=true;}}this.onTriggerClick();},this);}},removeButtonEvents:function(){this.buttonClear.removeAllListeners();if(this.allowQueryAll){this.buttonExpand.removeAllListeners();}return this;},clearCurrentFocus:function(){if(this.currentFocus){this.currentFocus.onLnkBlur();this.currentFocus=null;}return this;},initEvents:function(){var A=this.el;A.on({click:this.onClick,focus:this.clearCurrentFocus,blur:this.onBlur,keydown:this.onKeyDownHandler,keyup:this.onKeyUpBuffered,scope:this});this.on({collapse:this.onCollapse,expand:this.clearCurrentFocus,scope:this});this.wrapEl.on("click",this.onWrapClick,this);this.outerWrapEl.on("click",this.onWrapClick,this);this.inputEl.focus=function(){A.focus();};Ext.ux.form.SuperBoxSelect.superclass.initEvents.call(this);Ext.apply(this.keyNav,{tab:function(B){if(this.fixFocusOnTabSelect&&this.isExpanded()){B.stopEvent();A.blur();this.onViewClick(false);this.focus(false,10);return true;}this.onViewClick(false);if(A.dom.value!==""){this.setRawValue("");}return true;},down:function(B){if(!this.isExpanded()&&!this.currentFocus){if(this.allowQueryAll){this.onTriggerClick();}}else{this.inKeyMode=true;this.selectNext();}},enter:function(){}});},onClick:function(){this.clearCurrentFocus();this.collapse();this.autoSize();},beforeBlur:function(){if(this.allowAddNewData&&this.addNewDataOnBlur){var A=this.el.dom.value;if(A!==""){this.fireNewItemEvent(A);}}Ext.form.ComboBox.superclass.beforeBlur.call(this);},onFocus:function(){this.outerWrapEl.addClass(this.focusClass);Ext.ux.form.SuperBoxSelect.superclass.onFocus.call(this);},onBlur:function(){this.outerWrapEl.removeClass(this.focusClass);this.clearCurrentFocus();if(this.el.dom.value!==""){this.applyEmptyText();this.autoSize();}Ext.ux.form.SuperBoxSelect.superclass.onBlur.call(this);},onCollapse:function(){this.view.clearSelections();this.multiSelectMode=false;},onWrapClick:function(A){A.stopEvent();this.collapse();this.el.focus();this.clearCurrentFocus();},markInvalid:function(C){var B,A;if(!this.rendered||this.preventMark){return ;}this.outerWrapEl.addClass(this.invalidClass);C=C||this.invalidText;switch(this.msgTarget){case"qtip":Ext.apply(this.el.dom,{qtip:C,qclass:"x-form-invalid-tip"});Ext.apply(this.wrapEl.dom,{qtip:C,qclass:"x-form-invalid-tip"});if(Ext.QuickTips){Ext.QuickTips.enable();}break;case"title":this.el.dom.title=C;this.wrapEl.dom.title=C;this.outerWrapEl.dom.title=C;break;case"under":if(!this.errorEl){B=this.getErrorCt();if(!B){this.el.dom.title=C;break;}this.errorEl=B.createChild({cls:"x-form-invalid-msg"});this.errorEl.setWidth(B.getWidth(true)-20);}this.errorEl.update(C);Ext.form.Field.msgFx[this.msgFx].show(this.errorEl,this);break;case"side":if(!this.errorIcon){B=this.getErrorCt();if(!B){this.el.dom.title=C;break;}this.errorIcon=B.createChild({cls:"x-form-invalid-icon"});}this.alignErrorIcon();Ext.apply(this.errorIcon.dom,{qtip:C,qclass:"x-form-invalid-tip"});this.errorIcon.show();this.on("resize",this.alignErrorIcon,this);break;default:A=Ext.getDom(this.msgTarget);A.innerHTML=C;A.style.display=this.msgDisplay;break;}this.fireEvent("invalid",this,C);},clearInvalid:function(){if(!this.rendered||this.preventMark){return ;}this.outerWrapEl.removeClass(this.invalidClass);switch(this.msgTarget){case"qtip":this.el.dom.qtip="";this.wrapEl.dom.qtip="";break;case"title":this.el.dom.title="";this.wrapEl.dom.title="";this.outerWrapEl.dom.title="";break;case"under":if(this.errorEl){Ext.form.Field.msgFx[this.msgFx].hide(this.errorEl,this);}break;case"side":if(this.errorIcon){this.errorIcon.dom.qtip="";this.errorIcon.hide();this.un("resize",this.alignErrorIcon,this);}break;default:var A=Ext.getDom(this.msgTarget);A.innerHTML="";A.style.display="none";break;}this.fireEvent("valid",this);},alignErrorIcon:function(){if(this.wrap){this.errorIcon.alignTo(this.wrap,"tl-tr",[Ext.isIE?5:2,3]);}},expand:function(){if(this.isExpanded()||!this.hasFocus){return ;}if(this.bufferSize){this.doResize(this.bufferSize);delete this.bufferSize;}this.list.alignTo(this.outerWrapEl,this.listAlign).show();this.innerList.setOverflow("auto");this.mon(Ext.getDoc(),{scope:this,mousewheel:this.collapseIf,mousedown:this.collapseIf});this.fireEvent("expand",this);},restrictHeight:function(){var B=this.innerList.dom,C=B.scrollTop,F=this.list;B.style.height="";var G=F.getFrameWidth("tb")+(this.resizable?this.handleHeight:0)+this.assetHeight,D=Math.max(B.clientHeight,B.offsetHeight,B.scrollHeight),A=this.getPosition()[1]-Ext.getBody().getScroll().top,H=Ext.lib.Dom.getViewHeight()-A-this.getSize().height,E=Math.max(A,H,this.minHeight||0)-F.shadowOffset-G-5;D=Math.min(D,E,this.maxHeight);this.innerList.setHeight(D);F.beginUpdate();F.setHeight(D+G);F.alignTo(this.outerWrapEl,this.listAlign);F.endUpdate();if(this.multiSelectMode){B.scrollTop=C;}},validateValue:function(A){if(this.items.getCount()===0){if(this.allowBlank){this.clearInvalid();return true;}else{this.markInvalid(this.blankText);return false;}}this.clearInvalid();return true;},manageNameAttribute:function(){if(this.items.getCount()===0&&this.forceFormValue){this.el.dom.setAttribute("name",this.hiddenName||this.name);}else{this.el.dom.removeAttribute("name");}},setupFormInterception:function(){var A;this.findParentBy(function(C){if(C.getForm){A=C.getForm();}});if(A){var B=A.getValues;A.getValues=function(D){this.el.dom.disabled=true;var C=this.el.dom.value;this.setRawValue("");var E=B.call(A);this.el.dom.disabled=false;this.setRawValue(C);if(this.forceFormValue&&this.items.getCount()===0){E[this.name]="";}return D?Ext.urlEncode(E):E;}.createDelegate(this);}},onResize:function(A,C,E,B){var D=Ext.isIE6?4:Ext.isIE7?1:Ext.isIE8?1:0;if(this.wrapEl){this._width=A;this.outerWrapEl.setWidth(A-D);if(this.renderFieldBtns){D+=(this.buttonWrap.getWidth()+20);this.wrapEl.setWidth(A-D);}}Ext.ux.form.SuperBoxSelect.superclass.onResize.call(this,A,C,E,B);this.autoSize();},onEnable:function(){Ext.ux.form.SuperBoxSelect.superclass.onEnable.call(this);this.items.each(function(A){A.enable();});if(this.renderFieldBtns){this.initButtonEvents();}},onDisable:function(){Ext.ux.form.SuperBoxSelect.superclass.onDisable.call(this);this.items.each(function(A){A.disable();});if(this.renderFieldBtns){this.removeButtonEvents();}},clearValue:function(A){Ext.ux.form.SuperBoxSelect.superclass.clearValue.call(this);this.preventMultipleRemoveEvents=A||this.supressClearValueRemoveEvents||false;this.removeAllItems();this.preventMultipleRemoveEvents=false;this.fireEvent("clear",this);return this;},fireNewItemEvent:function(A){this.view.clearSelections();this.collapse();this.setRawValue("");if(this.queryFilterRe){A=A.replace(this.queryFilterRe,"");if(!A){return ;}}this.fireEvent("newitem",this,A,this.filteredQueryData);},onKeyUp:function(A){if(this.editable!==false&&(!A.isSpecialKey()||A.getKey()===A.BACKSPACE)&&this.itemDelimiterKey.indexOf!==A.getKey()&&(!A.hasModifier()||A.shiftKey)){this.lastKey=A.getKey();this.dqTask.delay(this.queryDelay);}},onKeyDownHandler:function(F,C){var B,H,A;if(F.getKey()===F.ESC){if(!this.isExpanded()){if(this.el.dom.value!=""&&(this.clearOnEscape||this.clearLastQueryOnEscape)){if(this.clearOnEscape){this.el.dom.value="";}if(this.clearLastQueryOnEscape){this.lastQuery="";}F.stopEvent();}}}if((F.getKey()===F.DELETE||F.getKey()===F.SPACE)&&this.currentFocus){F.stopEvent();B=this.currentFocus;this.on("expand",function(){this.collapse();},this,{single:true});A=this.items.indexOfKey(this.currentFocus.key);this.clearCurrentFocus();if(A<(this.items.getCount()-1)){H=this.items.itemAt(A+1);}B.preDestroy(true);if(H){(function(){H.onLnkFocus();this.currentFocus=H;}).defer(200,this);}return true;}var G=this.el.dom.value,D,E=F.ctrlKey;if(this.itemDelimiterKey===F.getKey()){F.stopEvent();if(G!==""){if(E||!this.isExpanded()){this.fireNewItemEvent(G);}else{this.onViewClick();if(this.unsetDelayCheck){this.delayedCheck=true;this.unsetDelayCheck.defer(10,this);}}}else{if(!this.isExpanded()){return ;}this.onViewClick();if(this.unsetDelayCheck){this.delayedCheck=true;this.unsetDelayCheck.defer(10,this);}}return true;}if(G!==""){this.autoSize();return ;}if(F.getKey()===F.HOME){F.stopEvent();if(this.items.getCount()>0){this.collapse();D=this.items.get(0);D.el.focus();}return true;}if(F.getKey()===F.BACKSPACE){F.stopEvent();if(this.currentFocus){B=this.currentFocus;this.on("expand",function(){this.collapse();},this,{single:true});A=this.items.indexOfKey(B.key);this.clearCurrentFocus();if(A<(this.items.getCount()-1)){H=this.items.itemAt(A+1);}B.preDestroy(true);if(H){(function(){H.onLnkFocus();this.currentFocus=H;}).defer(200,this);}return ;}else{D=this.items.get(this.items.getCount()-1);if(D){if(this.backspaceDeletesLastItem){this.on("expand",function(){this.collapse();},this,{single:true});D.preDestroy(true);}else{if(this.navigateItemsWithTab){D.onElClick();}else{this.on("expand",function(){this.collapse();this.currentFocus=D;this.currentFocus.onLnkFocus.defer(20,this.currentFocus);},this,{single:true});}}}return true;}}if(!F.isNavKeyPress()){this.multiSelectMode=false;this.clearCurrentFocus();return ;}if(F.getKey()===F.LEFT||(F.getKey()===F.UP&&!this.isExpanded())){F.stopEvent();this.collapse();D=this.items.get(this.items.getCount()-1);if(this.navigateItemsWithTab){if(D){D.focus();}}else{if(this.currentFocus){A=this.items.indexOfKey(this.currentFocus.key);this.clearCurrentFocus();if(A!==0){this.currentFocus=this.items.itemAt(A-1);this.currentFocus.onLnkFocus();}}else{this.currentFocus=D;if(D){D.onLnkFocus();}}}return true;}if(F.getKey()===F.DOWN){if(this.currentFocus){this.collapse();F.stopEvent();A=this.items.indexOfKey(this.currentFocus.key);if(A==(this.items.getCount()-1)){this.clearCurrentFocus.defer(10,this);}else{this.clearCurrentFocus();this.currentFocus=this.items.itemAt(A+1);if(this.currentFocus){this.currentFocus.onLnkFocus();}}return true;}}if(F.getKey()===F.RIGHT){this.collapse();D=this.items.itemAt(0);if(this.navigateItemsWithTab){if(D){D.focus();}}else{if(this.currentFocus){A=this.items.indexOfKey(this.currentFocus.key);this.clearCurrentFocus();if(A<(this.items.getCount()-1)){this.currentFocus=this.items.itemAt(A+1);if(this.currentFocus){this.currentFocus.onLnkFocus();}}}else{this.currentFocus=D;if(D){D.onLnkFocus();}}}}},onKeyUpBuffered:function(A){if(!A.isNavKeyPress()){this.autoSize();}},reset:function(){this.killItems();Ext.ux.form.SuperBoxSelect.superclass.reset.call(this);this.addedRecords=[];this.autoSize().setRawValue("");},applyEmptyText:function(){this.setRawValue("");if(this.items.getCount()>0){this.el.removeClass(this.emptyClass);this.setRawValue("");return this;}if(this.rendered&&this.emptyText&&this.getRawValue().length<1){this.setRawValue(this.emptyText);this.el.addClass(this.emptyClass);}return this;},removeAllItems:function(){this.items.each(function(A){A.preDestroy(true);},this);this.manageClearBtn();return this;},killItems:function(){this.items.each(function(A){A.kill();},this);this.resetStore();this.items.clear();this.manageClearBtn();return this;},resetStore:function(){this.store.clearFilter();if(!this.removeValuesFromStore){return this;}this.usedRecords.each(function(A){this.store.add(A);},this);this.usedRecords.clear();if(!this.store.remoteSort){this.store.sort(this.displayField,"ASC");}return this;},sortStore:function(){var A=this.store.getSortState();if(A&&A.field){this.store.sort(A.field,A.direction);}return this;},getCaption:function(C){if(typeof this.displayFieldTpl==="string"){this.displayFieldTpl=new Ext.XTemplate(this.displayFieldTpl);}var B,A=C instanceof Ext.data.Record?C.data:C;if(this.displayFieldTpl){B=this.displayFieldTpl.apply(A);}else{if(this.displayField){B=A[this.displayField];}}return B;},addRecord:function(B){var E=B.data[this.displayField],C=this.getCaption(B),F=B.data[this.valueField],A=this.classField?B.data[this.classField]:"",D=this.styleField?B.data[this.styleField]:"";if(this.removeValuesFromStore){this.usedRecords.add(F,B);this.store.remove(B);}this.addItemBox(F,E,C,A,D);this.fireEvent("additem",this,F,B);},createRecord:function(A){if(!this.recordConstructor){var B=[{name:this.valueField},{name:this.displayField}];if(this.classField){B.push({name:this.classField});}if(this.styleField){B.push({name:this.styleField});}this.recordConstructor=Ext.data.Record.create(B);}return new this.recordConstructor(A);},addItems:function(A){if(Ext.isArray(A)){Ext.each(A,function(B){this.addItem(B);},this);}else{this.addItem(A);}},addNewItem:function(A){this.addItem(A,true);},addItem:function(A,C){var E=A[this.valueField];if(this.disabled){return false;}if(this.preventDuplicates&&this.hasValue(E)){return ;}var B=this.findRecord(this.valueField,E);if(B){this.addRecord(B);return ;}else{if(!this.allowAddNewData){return ;}}if(this.mode==="remote"){this.remoteLookup.push(A);this.doQuery(E,false,false,C);return ;}var D=this.createRecord(A);this.store.add(D);this.addRecord(D);return true;},addItemBox:function(C,E,I,H,D){var F,G=function(K){var J="";switch(typeof K){case"function":J=K.call();break;case"object":for(var L in K){J+=L+":"+K[L]+";";}break;case"string":J=K+";";}return J;},A=Ext.id(null,"sbx-item"),B=new Ext.ux.form.SuperBoxSelectItem({owner:this,disabled:this.disabled,renderTo:this.wrapEl,cls:this.extraItemCls+" "+H,style:G(this.extraItemStyle)+" "+D,caption:I,display:E,value:C,key:A,listeners:{remove:function(J){if(this.fireEvent("beforeremoveitem",this,J.value)===false){return false;}this.items.removeKey(J.key);if(this.removeValuesFromStore){if(this.usedRecords.containsKey(J.value)){this.store.add(this.usedRecords.get(J.value));this.usedRecords.removeKey(J.value);this.sortStore();if(this.view){this.view.render();}}}if(!this.preventMultipleRemoveEvents){this.fireEvent.defer(250,this,["removeitem",this,J.value,this.findInStore(J.value)]);}},destroy:function(){this.collapse();this.autoSize().manageClearBtn().validateValue();},scope:this}});B.render();F={tag:"input",type:"hidden",value:C,name:(this.hiddenName||this.name)};if(this.disabled){Ext.apply(F,{disabled:"disabled"});}B.hidden=this.el.insertSibling(F,"before");this.items.add(A,B);this.applyEmptyText().autoSize().manageClearBtn().validateValue();},manageClearBtn:function(){if(!this.renderFieldBtns||!this.rendered){return this;}var A="x-superboxselect-btn-hide";if(this.items.getCount()===0){this.buttonClear.addClass(A);}else{this.buttonClear.removeClass(A);}return this;},findInStore:function(B){var A=this.store.find(this.valueField,B);if(A>-1){return this.store.getAt(A);}return false;},getSelectedRecords:function(){var A=[];if(this.removeValuesFromStore){A=this.usedRecords.getRange();}else{var B=[];this.items.each(function(C){B.push(C.value);});Ext.each(B,function(C){A.push(this.findInStore(C));},this);}return A;},findSelectedItem:function(B){var A;this.items.each(function(C){if(C.el.dom===B){A=C;return false;}});return A;},findSelectedRecord:function(B){var A,C=this.findSelectedItem(B);if(C){A=this.findSelectedRecordByValue(C.value);}return A;},findSelectedRecordByValue:function(B){var A;if(this.removeValuesFromStore){this.usedRecords.each(function(C){if(C.get(this.valueField)==B){A=C;return false;}},this);}else{A=this.findInStore(B);}return A;},getValue:function(){var A=[];this.items.each(function(B){A.push(B.value);});return A.join(this.valueDelimiter);},getCount:function(){return this.items.getCount();},getValueEx:function(){var A=[];this.items.each(function(C){var B={};B[this.valueField]=C.value;B[this.displayField]=C.display;if(this.classField){B[this.classField]=C.cls||"";}if(this.styleField){B[this.styleField]=C.style||"";}A.push(B);},this);return A;},initValue:function(){if(Ext.isObject(this.value)||Ext.isArray(this.value)){this.setValueEx(this.value);this.originalValue=this.getValue();}else{Ext.ux.form.SuperBoxSelect.superclass.initValue.call(this);}if(this.mode==="remote"){this.setOriginal=true;}},addValue:function(C){if(Ext.isEmpty(C)){return ;}var A=C;if(!Ext.isArray(C)){C=""+C;A=C.split(this.valueDelimiter);}Ext.each(A,function(E){var D=this.findRecord(this.valueField,E);if(D){this.addRecord(D);}else{if(this.mode==="remote"){this.remoteLookup.push(E);}}},this);if(this.mode==="remote"){var B=this.remoteLookup.join(this.queryValuesDelimiter);this.doQuery(B,false,true);}},setValue:function(A){if(!this.rendered){this.value=A;return ;}this.removeAllItems().resetStore();this.remoteLookup=[];this.addValue(A);},setValueEx:function(A){if(!this.rendered){this.value=A;return ;}this.removeAllItems().resetStore();if(!Ext.isArray(A)){A=[A];}this.remoteLookup=[];if(this.allowAddNewData&&this.mode==="remote"){Ext.each(A,function(C){var B=this.findRecord(this.valueField,C[this.valueField])||this.createRecord(C);this.addRecord(B);},this);return ;}Ext.each(A,function(B){this.addItem(B);},this);},hasValue:function(B){var A=false;this.items.each(function(C){if(C.value==B){A=true;return false;}},this);return A;},onSelect:function(A,B){if(this.fireEvent("beforeselect",this,A,B)!==false){var C=A.data[this.valueField];if(this.preventDuplicates&&this.hasValue(C)){return ;}this.setRawValue("");this.lastSelectionText="";if(this.fireEvent("beforeadditem",this,C,A,this.filteredQueryData)!==false){this.addRecord(A);}if(this.store.getCount()===0||!this.multiSelectMode){this.collapse();}else{this.restrictHeight();}}},onDestroy:function(){this.items.purgeListeners();this.killItems();if(this.allowQueryAll){Ext.destroy(this.buttonExpand);}if(this.renderFieldBtns){Ext.destroy(this.buttonClear,this.buttonWrap);}Ext.destroy(this.inputEl,this.wrapEl,this.outerWrapEl);Ext.ux.form.SuperBoxSelect.superclass.onDestroy.call(this);},autoSize:function(){if(!this.rendered){return this;}if(!this.metrics){this.metrics=Ext.util.TextMetrics.createInstance(this.el);}var C=this.el,B=C.dom.value,D=document.createElement("div");if(B===""&&this.emptyText&&this.items.getCount()<1){B=this.emptyText;}D.appendChild(document.createTextNode(B));B=D.innerHTML;D=null;B+="&#160;";var A=Math.max(this.metrics.getWidth(B)+24,24);if(typeof this._width!="undefined"){A=Math.min(this._width,A);}this.el.setWidth(A);if(Ext.isIE){this.el.dom.style.top="0";}this.fireEvent("autosize",this,A);return this;},shouldQuery:function(B){if(this.lastQuery){var A=B.match("^"+this.lastQuery);if(!A||this.store.getCount()){return true;}else{return(A[0]!==this.lastQuery);}}return true;},doQuery:function(F,E,B,D){F=Ext.isEmpty(F)?"":F;if(this.queryFilterRe){this.filteredQueryData="";var A=F.match(this.queryFilterRe);if(A&&A.length){this.filteredQueryData=A[0];}F=F.replace(this.queryFilterRe,"");if(!F&&A){return ;}}var C={query:F,forceAll:E,combo:this,cancel:false};if(this.fireEvent("beforequery",C)===false||C.cancel){return false;}F=C.query;E=C.forceAll;if(E===true||(F.length>=this.minChars)||B&&!Ext.isEmpty(F)){if(D||this.forceSameValueQuery||this.shouldQuery(F)){this.lastQuery=F;if(this.mode=="local"){this.selectedIndex=-1;if(E){this.store.clearFilter();}else{this.store.filter(this.displayField,F);}this.onLoad();}else{this.store.baseParams[this.queryParam]=F;this.store.baseParams[this.queryValuesIndicator]=B;this.store.load({params:this.getParams(F)});if(!D){this.expand();}}}else{this.selectedIndex=-1;this.onLoad();}}},onStoreLoad:function(B,A,C){var F=C.params[this.queryParam]||B.baseParams[this.queryParam]||"",G=C.params[this.queryValuesIndicator]||B.baseParams[this.queryValuesIndicator];if(this.removeValuesFromStore){this.store.each(function(I){if(this.usedRecords.containsKey(I.get(this.valueField))){this.store.remove(I);}},this);}if(G){var H=F.split(this.queryValuesDelimiter);Ext.each(H,function(I){this.remoteLookup.remove(I);var J=this.findRecord(this.valueField,I);if(J){this.addRecord(J);}},this);if(this.setOriginal){this.setOriginal=false;this.originalValue=this.getValue();}}if(F!==""&&this.allowAddNewData){Ext.each(this.remoteLookup,function(I){if(typeof I==="object"&&I[this.valueField]===F){this.remoteLookup.remove(I);if(A.length&&A[0].get(this.valueField)===F){this.addRecord(A[0]);return ;}var J=this.createRecord(I);this.store.add(J);this.addRecord(J);this.addedRecords.push(J);(function(){if(this.isExpanded()){this.collapse();}}).defer(10,this);return ;}},this);}var D=[];if(F===""){Ext.each(this.addedRecords,function(I){if(this.preventDuplicates&&this.usedRecords.containsKey(I.get(this.valueField))){return ;}D.push(I);},this);}else{var E=new RegExp(Ext.escapeRe(F)+".*","i");Ext.each(this.addedRecords,function(I){if(this.preventDuplicates&&this.usedRecords.containsKey(I.get(this.valueField))){return ;}if(E.test(I.get(this.displayField))){D.push(I);}},this);}this.store.add(D);this.sortStore();if(this.store.getCount()===0&&this.isExpanded()){this.collapse();}}});Ext.reg("superboxselect",Ext.ux.form.SuperBoxSelect);Ext.ux.form.SuperBoxSelectItem=function(A){Ext.apply(this,A);Ext.ux.form.SuperBoxSelectItem.superclass.constructor.call(this);};Ext.ux.form.SuperBoxSelectItem=Ext.extend(Ext.ux.form.SuperBoxSelectItem,Ext.Component,{initComponent:function(){Ext.ux.form.SuperBoxSelectItem.superclass.initComponent.call(this);},onElClick:function(B){var C=this.owner;C.clearCurrentFocus().collapse();if(C.navigateItemsWithTab){this.focus();}else{C.el.dom.focus();var A=this;(function(){this.onLnkFocus();C.currentFocus=this;}).defer(10,this);}},onLnkClick:function(A){if(A){A.stopEvent();}this.preDestroy();if(!this.owner.navigateItemsWithTab){this.owner.el.focus();}},onLnkFocus:function(){this.el.addClass("x-superboxselect-item-focus");this.owner.outerWrapEl.addClass("x-form-focus");},onLnkBlur:function(){this.el.removeClass("x-superboxselect-item-focus");this.owner.outerWrapEl.removeClass("x-form-focus");},enableElListeners:function(){this.el.on("click",this.onElClick,this,{stopEvent:true});this.el.addClassOnOver("x-superboxselect-item x-superboxselect-item-hover");},enableLnkListeners:function(){this.lnk.on({click:this.onLnkClick,focus:this.onLnkFocus,blur:this.onLnkBlur,scope:this});},enableAllListeners:function(){this.enableElListeners();this.enableLnkListeners();},disableAllListeners:function(){this.el.removeAllListeners();this.lnk.un("click",this.onLnkClick,this);this.lnk.un("focus",this.onLnkFocus,this);this.lnk.un("blur",this.onLnkBlur,this);},onRender:function(C,A){Ext.ux.form.SuperBoxSelectItem.superclass.onRender.call(this,C,A);var E=this.el;if(E){E.remove();}this.el=E=C.createChild({tag:"li"},C.last());E.addClass("x-superboxselect-item");var D=this.owner.navigateItemsWithTab?(Ext.isSafari?"button":"a"):"span";var F=this.key;Ext.apply(E,{focus:function(){var G=this.down(D+".x-superboxselect-item-close");if(G){G.focus();}},preDestroy:function(){this.preDestroy();}.createDelegate(this)});this.enableElListeners();E.update(this.caption);var B={tag:D,"class":"x-superboxselect-item-close",tabIndex:this.owner.navigateItemsWithTab?"0":"-1"};if(D==="a"){B.href="#";}this.lnk=E.createChild(B);if(!this.disabled){this.enableLnkListeners();}else{this.disableAllListeners();}this.on({disable:this.disableAllListeners,enable:this.enableAllListeners,scope:this});this.setupKeyMap();},setupKeyMap:function(){this.keyMap=new Ext.KeyMap(this.lnk,[{key:[Ext.EventObject.BACKSPACE,Ext.EventObject.DELETE,Ext.EventObject.SPACE],fn:this.preDestroy,scope:this},{key:[Ext.EventObject.RIGHT,Ext.EventObject.DOWN],fn:function(){this.moveFocus("right");},scope:this},{key:[Ext.EventObject.LEFT,Ext.EventObject.UP],fn:function(){this.moveFocus("left");},scope:this},{key:[Ext.EventObject.HOME],fn:function(){var A=this.owner.items.get(0).el.focus();if(A){A.el.focus();}},scope:this},{key:[Ext.EventObject.END],fn:function(){this.owner.el.focus();},scope:this},{key:Ext.EventObject.ENTER,fn:function(){}}]);this.keyMap.stopEvent=true;},moveFocus:function(A){var B=this.el[A=="left"?"prev":"next"]()||this.owner.el;B.focus.defer(100,B);},preDestroy:function(A){if(this.fireEvent("remove",this)===false){return ;}var B=function(){if(this.owner.navigateItemsWithTab){this.moveFocus("right");}this.hidden.remove();this.hidden=null;this.destroy();};if(A){B.call(this);}else{this.el.hide({duration:0.2,callback:B,scope:this});}return this;},kill:function(){this.hidden.remove();this.hidden=null;this.purgeListeners();this.destroy();},onDisable:function(){if(this.hidden){this.hidden.dom.setAttribute("disabled","disabled");}this.keyMap.disable();Ext.ux.form.SuperBoxSelectItem.superclass.onDisable.call(this);},onEnable:function(){if(this.hidden){this.hidden.dom.removeAttribute("disabled");}this.keyMap.enable();Ext.ux.form.SuperBoxSelectItem.superclass.onEnable.call(this);},onDestroy:function(){Ext.destroy(this.lnk,this.el);Ext.ux.form.SuperBoxSelectItem.superclass.onDestroy.call(this);}});Ext.reg("superbox",Ext.ux.form.SuperBoxSelectItem);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(A){A=this.convertValue(A);this.updateHidden(A);Ext.form.XCheckbox.superclass.setValue.apply(this,arguments);},updateHidden:function(A){A=undefined!==A?A:this.checked;A=this.convertValue(A);if(this.hiddenField){this.hiddenField.dom.value=A?this.submitOnValue:this.submitOffValue;this.hiddenField.dom.name=A?"":this.el.dom.name;}},convertValue:function(A){return(A===true||A==="true"||A===this.submitOnValue||String(A).toLowerCase()==="on");}});Ext.reg("xcheckbox",Ext.form.XCheckbox);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>");MODx.Component=function(A){A=A||{};MODx.Component.superclass.constructor.call(this,A);this.config=A;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 A in this.config.fields){if(this.config.fields.hasOwnProperty(A)){var B=this.config.fields[A];if(B.xtype){B=Ext.ComponentMgr.create(B);}this.fields[A]=B;this.form.add(B);}}}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||[],loadStay:this.config.loadStay||false});return this.ab;},_loadTabs:function(){if(!this.config.tabs){return false;}var A=this.config.tabOptions||{};Ext.applyIf(A,{xtype:"modx-tabs",renderTo:this.config.tabs_div||"tabs_div",items:this.config.tabs});return MODx.load(A);},_loadComponents:function(){if(!this.config.components){return false;}var B=this.config.components.length;var D=Ext.getCmp("modx-content");for(var C=0;C<B;C=C+1){var A=MODx.load(this.config.components[C]);if(D){D.add(A);}}if(D){D.doLayout();}return true;},submitForm:function(D,B,A){D=D||{};A=A||{};if(!this.config.formpanel||!this.config.action){return false;}f=Ext.getCmp(this.config.formpanel);if(!f){return false;}for(var C in D){if(typeof D[C]=="function"){f.on(C,D[C],this);}else{if(D[C]&&typeof D[C]=="object"&&D[C].fn){f.on(C,D[C].fn,D[C].scope||this);}}}Ext.apply(f.baseParams,{action:this.config.action});Ext.apply(f.baseParams,A);B=B||{};B.headers={"Powered-By":"MODx",modAuth:MODx.siteId};f.submit(B);return true;}});Ext.reg("modx-component",MODx.Component);MODx.toolbar.ActionButtons=function(A){A=A||{};Ext.applyIf(A,{actions:{close:MODx.action.welcome},formpanel:false,id:"modx-action-buttons",loadStay:false,params:{},items:[],renderTo:"modAB"});if(A.formpanel){this.setupDirtyButtons(A.formpanel);}if(A.loadStay===true){A.items.push("-",this.getStayMenu());}MODx.toolbar.ActionButtons.superclass.constructor.call(this,A);this.config=A;};Ext.extend(MODx.toolbar.ActionButtons,Ext.Toolbar,{id:"",buttons:[],options:{a_close:"welcome"},stay:"stay",checkDirtyBtns:[],add:function(){var J=arguments,D=J.length;for(var F=0;F<D;F++){var C=J[F];var G=["-","->","<-",""," "];if(G.indexOf(C)!=-1||(C.xtype&&C.xtype=="switch")){MODx.toolbar.ActionButtons.superclass.add.call(this,C);continue;}var B=C.id||Ext.id();Ext.applyIf(C,{xtype:"button",cls:(C.icon?"x-btn-icon bmenu":"x-btn-text bmenu"),scope:this,disabled:C.checkDirty?true:false,listeners:{},id:B});if(C.button){MODx.toolbar.ActionButtons.superclass.add.call(this,C);}if(C.handler===null&&C.menu===null){C.handler=this.checkConfirm;}else{if(C.confirm&&C.handler){C.handler=function(){Ext.Msg.confirm(_("warning"),C.confirm,function(K){if(K==="yes"){Ext.callback(C.handler,this);}},C.scope||this);};}else{if(C.handler){}else{C.handler=this.handleClick;}}}if(C.javascript){C.listeners.click={fn:this.evalJS,scope:this};}if(C.xtype=="button"){C.listeners.render={fn:function(K){if(C.checkDirty&&K){this.checkDirtyBtns.push(K);}},scope:this};}MODx.toolbar.ActionButtons.superclass.add.call(this,C);if(C.keys){var A=new Ext.KeyMap(Ext.get(document));var H=C.keys.length;for(var I=0;I<H;I=I+1){var E=C.keys[I];Ext.applyIf(E,{scope:this,stopEvent:true,fn:function(L){var K=Ext.getCmp(B);if(K){this.checkConfirm(K,L);}}});A.addBinding(E);}}delete C;}},evalJS:function(itm,e){if(!eval(itm.javascript)){e.stopEvent();e.preventDefault();}},checkConfirm:function(B,A){if(B.confirm!==null&&B.confirm!==undefined){this.confirm(B,function(){this.handleClick(B,A);},this);}else{this.handleClick(B,A);}return false;},confirm:function(C,B,A){if(C.confirm===null){return true;}Ext.Msg.confirm("",C.confirm,function(D){if(D==="yes"){if(B===null){return true;}if(typeof (B)==="function"){Ext.callback(B,A||this,[C]);}else{location.href=B;}}return true;},this);return true;},reloadPage:function(){location.href=location.href;},handleClick:function(G,D){var E=this.config;if(E.formpanel===false||E.formpanel===undefined||E.formpanel===null){return false;}if(G.method==="remote"){MODx.util.Progress.reset();E.form=Ext.getCmp(E.formpanel);if(!E.form){return false;}var C=E.form.getForm?E.form.getForm():E.form;var F=true;if(C.items&&C.items.items){for(var B in C.items.items){if(C.items.items[B]&&C.items.items[B].validate){var A=C.items.items[B].validate();if(!A){C.items.items[B].markInvalid();F=false;}}}}if(F){Ext.applyIf(E.params,{action:G.process,"modx-ab-stay":MODx.config.stay});Ext.apply(C.baseParams,E.params);E.form.on("success",function(H){if(E.form.clearDirty){E.form.clearDirty();}MODx.msg.status({title:_("success"),message:_("save_successful"),dontHide:H.result.message!=""?true:false});Ext.callback(this.redirectStay,this,[E,G,H.result],1000);},this);E.form.submit({headers:{"Powered-By":"MODx",modAuth:MODx.siteId}});}else{Ext.Msg.alert(_("error"),_("correct_errors"));}}else{Ext.applyIf(G.params||{},E.baseParams||{});location.href="?"+Ext.urlEncode(G.params);}return false;},checkStay:function(B,A){this.stay=B.value;},redirectStay:function(E,F,D){E=this.config;F.params=F.params||{};Ext.applyIf(F.params,E.baseParams);var A=Ext.state.Manager.get("modx.stay."+MODx.request.a,"stay");switch(A){case"new":if(E.form.hasListener("actionNew")){E.form.fireEvent("actionNew",F.params);}else{if(E.actions){if(MODx.request.parent){F.params.parent=MODx.request.parent;}if(MODx.request.context_key){F.params.context_key=MODx.request.context_key;}if(MODx.request.class_key){F.params.class_key=MODx.request.class_key;}var B=Ext.urlEncode(F.params);location.href="?a="+E.actions["new"]+"&"+B;}}break;case"stay":var C;if(E.form.hasListener("actionContinue")){E.form.fireEvent("actionContinue",F.params);}else{if(E.actions){if((F.process==="create"||F.process==="duplicate"||F.reload)&&D.object.id!==null){F.params.id=D.object.id;if(MODx.request.parent){F.params.parent=MODx.request.parent;}if(MODx.request.context_key){F.params.context_key=MODx.request.context_key;}C=Ext.urlEncode(F.params);location.href="?a="+E.actions.edit+"&"+C;}else{if(F.process==="delete"){F.params.a=E.actions.cancel;C=Ext.urlEncode(F.params);location.href="?"+C;}}}}break;case"close":if(E.form.hasListener("actionClose")){E.form.fireEvent("actionClose",F.params);}else{if(E.actions){location.href="?a="+E.actions.cancel+"&"+Ext.encode(F.params);}}break;}},getStayMenu:function(){var A=Ext.state.Manager.get("modx.stay."+MODx.request.a,"stay");var B=0;switch(A){case"new":B=0;break;case"close":B=2;break;case"stay":default:B=1;break;}return{xtype:"switch",id:"modx-stay-menu",activeItem:B,items:[{tooltip:_("stay_new"),value:"new",menuIndex:0,id:"modx-stay-new",iconCls:"icon-list-new"},{tooltip:_("stay"),value:"stay",menuIndex:1,id:"modx-stay-stay",iconCls:"icon-mark-active"},{tooltip:_("close"),value:"close",menuIndex:2,id:"modx-stay-close",iconCls:"icon-mark-complete"}],listeners:{change:function(C,D){Ext.state.Manager.set("modx.stay."+MODx.request.a,D.value);},scope:this,delay:10}};},refreshTreeNode:function(A,D,B){var C=parent.Ext.getCmp(A);C.refreshNode(D,B||false);return false;},setupDirtyButtons:function(B){var A=Ext.getCmp(B);if(A){A.on("fieldChange",function(E){for(var D=0;D<this.checkDirtyBtns.length;D=D+1){var C=this.checkDirtyBtns[D];C.setDisabled(false);}},this);}}});Ext.reg("modx-actionbuttons",MODx.toolbar.ActionButtons);Ext.namespace("MODx.panel");MODx.Panel=function(A){A=A||{};Ext.applyIf(A,{cls:"modx-panel",title:""});MODx.Panel.superclass.constructor.call(this,A);this.config=A;};Ext.extend(MODx.Panel,Ext.Panel);Ext.reg("modx-panel",MODx.Panel);MODx.FormPanel=function(A){A=A||{};Ext.applyIf(A,{autoHeight:true,collapsible:true,bodyStyle:"",layout:"anchor",border:false,header:false,method:"POST",cls:"modx-form",ddGroup:"modx-treedrop-dd",allowDrop:true,errorReader:MODx.util.JSONReader,checkDirty:true,useLoadingMask:false,defaults:{collapsible:false,autoHeight:true,border:false}});if(A.items){this.addChangeEvent(A.items);}MODx.FormPanel.superclass.constructor.call(this,A);this.config=A;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.on("ready",this.onReady);if(this.config.useLoadingMask){this.mask=new Ext.LoadMask(this.getEl(),{msg:_("loading")});this.mask.show();}this.fireEvent("setup",A);this.focusFirstField();};Ext.extend(MODx.FormPanel,Ext.FormPanel,{isReady:false,submit:function(B){var A=this.getForm();if(A.isValid()||B.bypassValidCheck){B=B||{};B.headers={"Powered-By":"MODx",modAuth:MODx.siteId};if(this.fireEvent("beforeSubmit",{form:A,options:B,config:this.config})){A.submit({waitMsg:this.config.saveMsg||_("saving"),scope:this,headers:B.headers,clientValidation:(B.bypassValidCheck?false:true),failure:function(D,C){if(this.fireEvent("failure",{form:D,result:C.result,options:B,config:this.config})){MODx.form.Handler.errorExt(C.result,D);}},success:function(D,C){if(this.config.success){Ext.callback(this.config.success,this.config.scope||this,[D,C]);}this.fireEvent("success",{form:D,result:C.result,options:B,config:this.config});this.clearDirty();this.fireEvent("setup",this.config);}});}}else{return false;}return true;},focusFirstField:function(){if(this.getForm().items.getCount()>0){var A=this.findFirstTextField();if(A){A.focus(false,200);}}},findFirstTextField:function(B){B=B||0;var A=this.getForm().items.itemAt(B);if(!A){return false;}if(A.isXType("combo")||A.isXType("checkbox")||A.isXType("radio")||A.isXType("displayfield")||A.isXType("statictextfield")||A.isXType("hidden")){B=B+1;A=this.findFirstTextField(B);}return A;},addChangeEvent:function(A){if(!A){return false;}if(typeof (A)=="object"&&A.items){A=A.items;}for(var D=0;D<A.length;D++){var C=A[D];if(C.items){this.addChangeEvent(C.items);}else{if(C.xtype){if(!C.listeners){C.listeners={};}var B="change";C.enableKeyEvents=true;switch(C.xtype){case"textfield":case"textarea":B="keydown";break;case"checkbox":case"xcheckbox":case"radio":B="check";break;}C.listeners[B]={fn:this.fieldChangeEvent,scope:this};}}}},fieldChangeEvent:function(C,A,B,D){if(!this.isReady){return false;}var D=this.config.onDirtyForm?Ext.getCmp(this.config.onDirtyForm):this.getForm();this.fireEvent("fieldChange",{field:C,nv:A,ov:B,form:D});},markDirty:function(){this.fireEvent("fieldChange");},isDirty:function(){var A=this.config.onDirtyForm?Ext.getCmp(this.config.onDirtyForm):this.getForm();return A.isDirty();},clearDirty:function(){var A=this.config.onDirtyForm?Ext.getCmp(this.config.onDirtyForm):this.getForm();return A.clearDirty();},onReady:function(A){this.isReady=true;if(this.config.allowDrop){this.loadDropZones();}if(this.config.useLoadingMask&&this.mask){this.mask.hide();}this.fireEvent("postReady");},loadDropZones:function(){var A=this.getForm().items;A.each(function(B){if(B.isFormField&&(B.isXType("textfield")||B.isXType("textarea"))&&!B.isXType("combo")){var C=B.getEl();if(C){new MODx.load({xtype:"modx-treedrop",target:B,targetEl:C.dom});}}});},getField:function(B){var A=false;if(typeof B=="string"){A=this.getForm().findField(B);if(!A){A=Ext.getCmp(B);}}return A;},hideField:function(B){if(!Ext.isArray(B)){B=B[B];}var C;for(var A=0;A<B.length;A++){C=this.getField(B[A]);if(!C){return ;}C.hide();var D=C.getEl().up(".x-form-item");if(D){D.setDisplayed(false);}}},showField:function(B){if(!Ext.isArray(B)){B=B[B];}var C;for(var A=0;A<B.length;A++){C=this.getField(B[A]);if(!C){return ;}C.enable();C.show();var D=C.getEl().up(".x-form-item");if(D){D.setDisplayed(true);}}},setLabel:function(D,F,C){if(!Ext.isArray(D)){D=D[D];}if(!Ext.isArray(F)){F=valss[F];}var E,A;for(var B=0;B<D.length;B++){E=this.getField(D[B]);if(!E){return ;}A=String.format("{0}",F[B]);if((E.xtype=="checkbox"||E.xtype=="radio")&&D[B]=="published"){E.setBoxLabel(A);}else{if(E.label){E.label.update(A);}}}}});Ext.reg("modx-formpanel",MODx.FormPanel);MODx.panel.Wizard=function(A){A=A||{};Ext.applyIf(A,{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:A.txtBack||_("back"),handler:this.navHandler.createDelegate(this,[-1]),scope:this,disabled:true},{id:"pi-btn-fwd",itemId:"btn-fwd",text:A.txtNext||_("next"),handler:this.navHandler.createDelegate(this,[1]),scope:this}]});MODx.panel.Wizard.superclass.constructor.call(this,A);this.config=A;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(B){this.doLayout();var A=this.getLayout().activeItem;if(B==-1){this.proceed(A.config.back||A.config.id);}else{A.submit({scope:this,proceed:this.proceed});}},proceed:function(A){this.doLayout();this.getLayout().setActiveItem(A);if(A==this.config.firstPanel){this.getBottomToolbar().items.item(0).setDisabled(true);this.getBottomToolbar().items.item(1).setText(this.config.txtNext);}else{if(A==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(A){A=A||{};Ext.applyIf(A,{wizard:null,checkDirty:false,bodyStyle:"padding: 3em 3em",hideMode:"offsets"});MODx.panel.WizardPanel.superclass.constructor.call(this,A);};Ext.extend(MODx.panel.WizardPanel,MODx.FormPanel);Ext.reg("modx-wizard-panel",MODx.panel.WizardPanel);MODx.PanelSpacer={html:"<br />",border:false};MODx.Tabs=function(A){A=A||{};Ext.applyIf(A,{enableTabScroll:true,layoutOnTabChange:true,plain:true,deferredRender:true,hideMode:"offsets",defaults:{autoScroll:true,autoHeight:true,hideMode:"offsets",border:true,autoWidth:true},activeTab:0,border:false,autoHeight:true,cls:"modx-tabs"});MODx.Tabs.superclass.constructor.call(this,A);this.config=A;};Ext.extend(MODx.Tabs,Ext.TabPanel);Ext.reg("modx-tabs",MODx.Tabs);MODx.Window=function(A){A=A||{};Ext.applyIf(A,{modal:false,layout:"auto",closeAction:"hide",shadow:true,resizable:true,collapsible:true,maximizable:true,autoHeight:true,allowDrop:true,width:450,cls:"modx-window",buttons:[{text:A.cancelBtnText||_("cancel"),scope:this,handler:function(){this.hide();}},{text:A.saveBtnText||_("save"),scope:this,handler:this.submit}],record:{},keys:[{key:Ext.EventObject.ENTER,fn:this.submit,scope:this}]});MODx.Window.superclass.constructor.call(this,A);this.options=A;this.config=A;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);};Ext.extend(MODx.Window,Ext.Window,{_loadForm:function(){if(this.checkIfLoaded(this.config.record||null)){return false;}var C=this.config.record;if(this.config.fields){var A=this.config.fields.length;for(var B=0;B<A;B++){var D=this.config.fields[B];if(C[D.name]){if(D.xtype=="checkbox"||D.xtype=="radio"){D.checked=C[D.name];}else{D.value=C[D.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 A=this.findFirstTextField();if(A){A.focus(false,200);}}},findFirstTextField:function(B){B=B||0;var A=this.fp.getForm().items.itemAt(B);if(!A){return false;}if(A.isXType("combo")||A.isXType("checkbox")||A.isXType("radio")||A.isXType("displayfield")||A.isXType("statictextfield")||A.isXType("hidden")){B=B+1;A=this.findFirstTextField(B);}return A;},submit:function(B){B=B===false?false:true;var A=this.fp.getForm();if(A.isValid()&&this.fireEvent("beforeSubmit",A.getValues())){A.submit({waitMsg:_("saving"),scope:this,failure:function(D,C){if(this.fireEvent("failure",{f:D,a:C})){MODx.form.Handler.errorExt(C.result,D);}},success:function(D,C){if(this.config.success){Ext.callback(this.config.success,this.config.scope||this,[D,C]);}this.fireEvent("success",{f:D,a:C});if(B){this.hide();}}});}},createForm:function(A){A=A||{};Ext.applyIf(A,{labelAlign:this.config.labelAlign||"right",labelWidth:this.config.labelWidth||100,frame:this.config.formFrame||true,border:false,bodyBorder:false,autoHeight:true,errorReader:MODx.util.JSONReader,url:this.config.url,baseParams:this.config.baseParams||{},fileUpload:this.config.fileUpload||false});return new Ext.FormPanel(A);},renderForm:function(){this.add(this.fp);},checkIfLoaded:function(A){A=A||{};if(this.fp&&this.fp.getForm()){this.fp.getForm().reset();this.fp.getForm().setValues(A);return true;}return false;},setValues:function(A){if(A===null){return false;}this.fp.getForm().setValues(A);},reset:function(){this.fp.getForm().reset();},hideField:function(A){A.disable();A.hide();var B=A.getEl().up(".x-form-item");if(B){B.setDisplayed(false);}},showField:function(A){A.enable();A.show();var B=A.getEl().up(".x-form-item");if(B){B.setDisplayed(true);}},loadDropZones:function(){if(this._dzLoaded){return false;}var A=this.fp.getForm().items;A.each(function(B){if(B.isFormField&&(B.isXType("textfield")||B.isXType("textarea"))&&!B.isXType("combo")){new MODx.load({xtype:"modx-treedrop",target:B,targetEl:B.getEl().dom});}});this._dzLoaded=true;}});Ext.reg("modx-window",MODx.Window);Ext.namespace("MODx.tree");MODx.tree.Tree=function(D){D=D||{};Ext.applyIf(D,{baseParams:{},action:"getNodes",loaderConfig:{}});if(D.action){D.baseParams.action=D.action;}D.loaderConfig.dataUrl=D.url;D.loaderConfig.baseParams=D.baseParams;Ext.applyIf(D.loaderConfig,{preloadChildren:true,clearOnLoad:true});this.config=D;var C,B;if(this.config.url){C=new Ext.tree.TreeLoader(D.loaderConfig);C.on("beforeload",function(F,G){C.dataUrl=this.config.url+"?action="+this.config.action+"&id="+G.attributes.id;if(G.attributes.type){C.dataUrl+="&type="+G.attributes.type;}},this);C.on("load",this.onLoad,this);B={nodeType:"async",text:D.root_name||D.rootName||"",draggable:false,id:D.root_id||D.rootId||"root"};}else{C=new Ext.tree.TreeLoader({preloadChildren:true,baseAttrs:{uiProvider:MODx.tree.CheckboxNodeUI}});B=new Ext.tree.TreeNode({text:this.config.rootName||"",draggable:false,id:this.config.rootId||"root",children:this.config.data||[]});}Ext.applyIf(D,{useArrows:true,autoScroll:true,animate:true,enableDD:true,enableDrop:true,ddAppendOnly:false,containerScroll:true,collapsible:true,border:false,autoHeight:true,rootVisible:true,loader:C,header:false,hideBorders:true,bodyBorder:false,cls:"modx-tree",root:B,preventRender:false,menuConfig:{defaultAlign:"tl-b?",enableScrolling:false}});if(D.remoteToolbar===true&&(D.tbar===undefined||D.tbar===null)){Ext.Ajax.request({url:D.remoteToolbarUrl||D.url,params:{action:D.remoteToolbarAction||"getToolbar"},success:function(I){I=Ext.decode(I.responseText);var H=this._formatToolbar(I.object);var F=this.getTopToolbar();if(F){for(var G=0;G<H.length;G++){F.add(H[G]);}F.doLayout();}},scope:this});D.tbar={bodyStyle:"padding: 0"};}else{var A=this.getToolbar();if(D.tbar&&D.useDefaultToolbar){A.push("-");for(var E=0;E<D.tbar.length;E++){A.push(D.tbar[E]);}}else{if(D.tbar){A=D.tbar;}}Ext.apply(D,{tbar:A});}this.setup(D);this.config=D;};Ext.extend(MODx.tree.Tree,Ext.tree.TreePanel,{menu:null,options:{},disableHref:false,onLoad:function(C,E,F){var D=Ext.decode(F.responseText);if(D.message){var B=this.getTreeEl();B.addClass("modx-tree-load-msg");B.update(D.message);var A=270;if(this.config.width>150){A=this.config.width;}B.setWidth(A);this.doLayout();}},setup:function(A){A.listeners=A.listeners||{};A.listeners.render={fn:function(){this.root.expand();var B=this.getLoader();Ext.apply(B,{fullMask:new Ext.LoadMask(this.getEl(),{msg:_("loading")})});B.fullMask.removeMask=false;B.on({load:function(){this.fullMask.hide();},loadexception:function(){this.fullMask.hide();},beforeload:function(){this.fullMask.show();},scope:B});},scope:this};MODx.tree.Tree.superclass.constructor.call(this,A);this.addEvents("afterSort","beforeSort");this.cm=new Ext.menu.Menu(A.menuConfig);this.on("contextmenu",this._showContextMenu,this);this.on("beforenodedrop",this._handleDrop,this);this.on("nodedragover",this._handleDrop,this);this.on("nodedrop",this._handleDrag,this);this.on("click",this._saveState,this);this.on("contextmenu",this._saveState,this);this.on("click",this._handleClick,this);this.treestate_id=this.config.id||Ext.id();this.on("load",this._initExpand,this,{single:true});this.on("expandnode",this._saveState,this);this.on("collapsenode",this._saveState,this);},_initExpand:function(){var A=Ext.state.Manager.get(this.treestate_id);if(Ext.isEmpty(A)&&this.root){this.root.expand();if(this.root.firstChild&&this.config.expandFirst){this.root.firstChild.select();this.root.firstChild.expand();}}else{for(var B=0;B<A.length;B++){this.expandPath(A[B]);}}},addContextMenuItem:function(C){var B=C,A=B.length;for(var D=0;D<A;D++){B[D].scope=this;this.cm.add(B[D]);}},_showContextMenu:function(B,C){B.select();this.cm.activeNode=B;this.cm.removeAll();var A;if(this.getMenu){A=this.getMenu(B,C);}else{if(B.attributes.menu&&B.attributes.menu.items){A=B.attributes.menu.items;}}this.addContextMenuItem(A);this.cm.showAt(C.xy);C.preventDefault();C.stopEvent();},hasNode:function(A,B){return(A.findChild("id",B.id))||(A.leaf===true&&A.parentNode.findChild("id",B.id));},refresh:function(E,D,B){var A=Ext.state.Manager.get(this.treestate_id);this.root.reload();if(A===undefined){this.root.expand(null,null);}else{for(var C=0;C<A.length;C++){this.expandPath(A[C]);}}if(E){D=D||this;B=B||[];this.root.on("load",function(){Ext.callback(E,D,B);},D);}return true;},removeChildren:function(A){while(A.firstChild){var B=A.firstChild;A.removeChild(B);B.destroy();}},loadRemoteData:function(A){this.removeChildren(this.getRootNode());for(var B in A){if(typeof A[B]==="object"){this.getRootNode().appendChild(A[B]);}}},reloadNode:function(A){this.getLoader().load(A);A.expand();},remove:function(F,D,A){var C=this.cm.activeNode;var G=this._extractId(C.id,D,A);var E={action:this.config.removeAction||"remove"};var B=this.config.primaryKey||"id";E[B]=G;MODx.msg.confirm({title:this.config.removeTitle||_("warning"),text:_(F),url:this.config.url,params:E,listeners:{success:{fn:this.refresh,scope:this}}});},_extractId:function(C,B,A){B=B||false;A=A||false;if(B!==false){C=node.id.substr(B);}if(A!==false){C=node.id.split("_");C=C[A];}return C;},expandNodes:function(){if(this.root){this.root.expand();this.root.expandChildNodes(true);}},collapseNodes:function(){if(this.root){this.root.collapseChildNodes(true);this.root.collapse();}},_saveState:function(F){var C=Ext.state.Manager.get(this.treestate_id);var E=F.getPath();var A;if(!Ext.isObject(C)&&!Ext.isArray(C)){C=[C];}if(Ext.isEmpty(E)||E==undefined){return ;}if(F.expanded){if(Ext.isString(E)&&C.indexOf(E)===-1){var D=false;var B;for(A=0;A<C.length;A++){if(C[A]==undefined||C[A]=="undefined"){C.splice(A,1);continue;}B=C[A].search(E);if(B!==-1&&C[B]){if(C[B].length>C[A].length){D=true;}}}if(!D){C.push(E);}}}else{C=C.remove(E);for(A=0;A<C.length;A++){if(C[A]==undefined||C[A]=="undefined"){C.splice(A,1);continue;}if(C[A].search(E)!==-1){delete C[A];}}}for(A=0;A<C.length;A++){if(C[A]==undefined||C[A]=="undefined"){C.splice(A,1);continue;}}Ext.state.Manager.set(this.treestate_id,C);},_handleClick:function(B,A){A.stopEvent();A.preventDefault();if(this.disableHref){return true;}if(A.ctrlKey){return true;}if(B.attributes.page&&B.attributes.page!==""){location.href=B.attributes.page;}else{B.toggle();}return true;},encode:function(B){if(!B){B=this.getRootNode();}var C=function(G){var D={};var E=G.childNodes;for(var F=0;F<E.length;F=F+1){var H=E[F];D[H.id]={id:H.id,checked:H.ui.isChecked(),type:H.attributes.type||"",data:H.attributes.data||{},children:C(H)};}return D;};var A=C(B);return Ext.encode(A);},_handleDrag:function(A){function C(H){var E={};var F=H.childNodes;var D=F.length;for(var G=0;G<D;G++){E[F[G].id]=C(F[G]);}return E;}var B=Ext.encode(C(A.tree.root));this.fireEvent("beforeSort",B);MODx.Ajax.request({url:this.config.url,params:{data:encodeURIComponent(B),action:this.config.sortAction||"sort"},listeners:{success:{fn:function(E){var D=A.dropNode.getUI().getTextEl();if(D){Ext.get(D).frame();}this.fireEvent("afterSort",{event:A,result:E});},scope:this},failure:{fn:function(D){MODx.form.Handler.errorJSON(D);this.refresh();return false;},scope:this}}});},_handleDrop:function(){},_guid:function(A){return A+(new Date().getTime());},redirect:function(A){location.href=A;},loadAction:function(B){var C=this.cm.activeNode.id.split("_");C=C[1];var A="index.php?id="+C+"&"+B;location.href=A;},_loadToolbar:function(){},refreshNode:function(E,B){var C=this.getNodeById(E);if(C){var D=B?C:C.parentNode;var A=this.getLoader().load(D,function(){D.expand();},this);}},refreshActiveNode:function(){this.getLoader().load(this.cm.activeNode,this.cm.activeNode.expand);},refreshParentNode:function(){this.getLoader().load(this.cm.activeNode.parentNode,this.cm.activeNode.expand);},removeNode:function(B){var A=this.getNodeById(B);if(A){A.remove();}},removeActiveNode:function(){this.cm.activeNode.remove();},getToolbar:function(){var A=MODx.config.template_url+"images/restyle/icons/";return[{icon:A+"arrow_down.png",cls:"x-btn-icon",tooltip:{text:_("tree_expand")},handler:this.expandNodes,scope:this},{icon:A+"arrow_up.png",cls:"x-btn-icon",tooltip:{text:_("tree_collapse")},handler:this.collapseNodes,scope:this},"-",{icon:A+"refresh.png",cls:"x-btn-icon",tooltip:{text:_("tree_refresh")},handler:this.refresh,scope:this}];},_formatToolbar:function(a){var l=a.length;for(var i=0;i<l;i++){if(a[i].handler){a[i].handler=eval(a[i].handler);}Ext.applyIf(a[i],{scope:this,cls:this.config.toolbarItemCls||"x-btn-icon"});}return a;}});Ext.reg("modx-tree",MODx.tree.Tree);Ext.namespace("MODx.combo");Ext.override(Ext.form.ComboBox,{loaded:false,setValue:Ext.form.ComboBox.prototype.setValue.createSequence(function(B){var A=this.store.find(this.valueField,B);if(B&&B!==0&&this.mode=="remote"&&A==-1&&!this.loaded){var C={};C[this.valueField]=B;this.loaded=true;this.store.load({scope:this,params:C,callback:function(){this.setValue(B);this.collapse();}});}})});MODx.combo.ComboBox=function(A,B){A=A||{};Ext.applyIf(A,{displayField:"name",valueField:"id",triggerAction:"all",fields:["id","name"],baseParams:{action:"getList"},width:150,listWidth:300,editable:false,resizable:true,typeAhead:false,forceSelection:true,minChars:3,cls:"modx-combo"});Ext.applyIf(A,{store:new Ext.data.JsonStore({url:A.connector||A.url,root:"results",totalProperty:"total",fields:A.fields,errorReader:MODx.util.JSONReader,baseParams:A.baseParams||{},remoteSort:A.remoteSort||false,autoDestroy:true})});if(B===true){A.store.load();return A.store;}MODx.combo.ComboBox.superclass.constructor.call(this,A);this.config=A;return this;};Ext.extend(MODx.combo.ComboBox,Ext.form.ComboBox);Ext.reg("modx-combo",MODx.combo.ComboBox);MODx.combo.Renderer=function(B){var A=false;return(function(D){var C,F;if(!B.store){return D;}if(!A){if(B.store.proxy!==undefined&&B.store.proxy!==null){B.store.load();}A=true;}var E=B.getValue();C=B.store.find(B.valueField,E?E:D);F=B.store.getAt(C);return(F===undefined||F===null?(E?E:D):F.get(B.displayField));});};MODx.combo.Boolean=function(A){A=A||{};Ext.applyIf(A,{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,A);};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(A){A=A||{};delete A.xtype;Ext.applyIf(A,{xtype:"textfield",inputType:"password"});MODx.util.PasswordField.superclass.constructor.call(this,A);};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(A){A=A||{};Ext.applyIf(A,{name:"user",hiddenName:"user",displayField:"username",valueField:"id",fields:["username","id"],pageSize:20,url:MODx.config.connectors_url+"security/user.php"});MODx.combo.User.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.User,MODx.combo.ComboBox);Ext.reg("modx-combo-user",MODx.combo.User);MODx.combo.UserGroup=function(A){A=A||{};Ext.applyIf(A,{name:"group",hiddenName:"group",displayField:"name",valueField:"id",fields:["name","id","description"],listWidth:300,pageSize:20,url:MODx.config.connectors_url+"security/group.php",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,A);};Ext.extend(MODx.combo.UserGroup,MODx.combo.ComboBox);Ext.reg("modx-combo-usergroup",MODx.combo.UserGroup);MODx.combo.UserGroupRole=function(A){A=A||{};Ext.applyIf(A,{name:"role",hiddenName:"role",displayField:"name",valueField:"id",fields:["name","id"],pageSize:20,url:MODx.config.connectors_url+"security/role.php"});MODx.combo.UserGroupRole.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.UserGroupRole,MODx.combo.ComboBox);Ext.reg("modx-combo-usergrouprole",MODx.combo.UserGroupRole);MODx.combo.ResourceGroup=function(A){A=A||{};Ext.applyIf(A,{name:"resourcegroup",hiddenName:"resourcegroup",displayField:"name",valueField:"id",fields:["name","id"],pageSize:20,url:MODx.config.connectors_url+"security/resourcegroup.php"});MODx.combo.ResourceGroup.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.ResourceGroup,MODx.combo.ComboBox);Ext.reg("modx-combo-resourcegroup",MODx.combo.ResourceGroup);MODx.combo.Context=function(A){A=A||{};Ext.applyIf(A,{name:"context",hiddenName:"context",displayField:"key",valueField:"key",fields:["key"],pageSize:20,url:MODx.config.connectors_url+"context/index.php"});MODx.combo.Context.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.Context,MODx.combo.ComboBox);Ext.reg("modx-combo-context",MODx.combo.Context);MODx.combo.Policy=function(A){A=A||{};Ext.applyIf(A,{name:"policy",hiddenName:"policy",displayField:"name",valueField:"id",fields:["name","id"],allowBlank:false,editable:false,pageSize:20,url:MODx.config.connectors_url+"security/access/policy.php"});MODx.combo.Policy.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.Policy,MODx.combo.ComboBox);Ext.reg("modx-combo-policy",MODx.combo.Policy);MODx.combo.Template=function(A){A=A||{};Ext.applyIf(A,{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.connectors_url+"element/template.php",listWidth:350,allowBlank:true});MODx.combo.Template.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.Template,MODx.combo.ComboBox);Ext.reg("modx-combo-template",MODx.combo.Template);MODx.combo.Category=function(A){A=A||{};Ext.applyIf(A,{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.connectors_url+"element/category.php",baseParams:{action:"getList",showNone:true}});MODx.combo.Category.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.Category,MODx.combo.ComboBox,{_onblur:function(B,C){var A=this.getRawValue();this.setRawValue(A);this.setValue(A,true);}});Ext.reg("modx-combo-category",MODx.combo.Category);MODx.combo.Language=function(A){A=A||{};Ext.applyIf(A,{name:"language",hiddenName:"language",displayField:"name",valueField:"name",fields:["name"],forceSelection:true,typeAhead:false,editable:false,allowBlank:false,pageSize:20,url:MODx.config.connectors_url+"system/language.php"});MODx.combo.Language.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.Language,MODx.combo.ComboBox);Ext.reg("modx-combo-language",MODx.combo.Language);MODx.combo.Charset=function(A){A=A||{};Ext.applyIf(A,{name:"charset",hiddenName:"charset",displayField:"text",valueField:"value",fields:["value","text"],forceSelection:true,typeAhead:false,editable:false,allowBlank:false,listWidth:300,url:MODx.config.connectors_url+"system/charset.php"});MODx.combo.Charset.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.Charset,MODx.combo.ComboBox);Ext.reg("modx-combo-charset",MODx.combo.Charset);MODx.combo.RTE=function(A){A=A||{};Ext.applyIf(A,{name:"rte",hiddenName:"rte",displayField:"value",valueField:"value",fields:["value"],forceSelection:true,typeAhead:false,editable:false,allowBlank:false,listWidth:300,url:MODx.config.connectors_url+"system/rte.php"});MODx.combo.RTE.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.RTE,MODx.combo.ComboBox);Ext.reg("modx-combo-rte",MODx.combo.RTE);MODx.combo.Role=function(A){A=A||{};Ext.applyIf(A,{name:"role",hiddenName:"role",forceSelection:true,typeAhead:false,editable:false,allowBlank:false,listWidth:300,pageSize:20,url:MODx.config.connectors_url+"security/role.php",baseParams:{action:"getList",addNone:true}});MODx.combo.Role.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.Role,MODx.combo.ComboBox);Ext.reg("modx-combo-role",MODx.combo.Role);MODx.combo.ContentType=function(A){A=A||{};Ext.applyIf(A,{name:"content_type",hiddenName:"content_type",forceSelection:true,typeAhead:false,editable:false,allowBlank:false,listWidth:300,pageSize:20,url:MODx.config.connectors_url+"system/contenttype.php",baseParams:{action:"getList"}});MODx.combo.ContentType.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.ContentType,MODx.combo.ComboBox);Ext.reg("modx-combo-content-type",MODx.combo.ContentType);MODx.combo.ContentDisposition=function(A){A=A||{};Ext.applyIf(A,{store:new Ext.data.SimpleStore({fields:["d","v"],data:[[_("inline"),0],[_("attachment"),1]]}),name:"content_dispo",hiddenName:"content_dispo",width:200,displayField:"d",valueField:"v",mode:"local",triggerAction:"all",editable:false,pageSize:20,selectOnFocus:false,preventRender:true});MODx.combo.ContentDisposition.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.ContentDisposition,Ext.form.ComboBox);Ext.reg("modx-combo-content-disposition",MODx.combo.ContentDisposition);MODx.combo.ClassMap=function(A){A=A||{};Ext.applyIf(A,{name:"class",hiddenName:"class",url:MODx.config.connectors_url+"system/classmap.php",displayField:"class",valueField:"class",fields:["class"],editable:false});MODx.combo.ClassMap.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.ClassMap,MODx.combo.ComboBox);Ext.reg("modx-combo-class-map",MODx.combo.ClassMap);MODx.combo.Object=function(A){A=A||{};Ext.applyIf(A,{name:"object",hiddenName:"object",url:MODx.config.connectors_url+"workspace/builder/index.php",baseParams:{action:"getAssocObject",class_key:"modResource"},displayField:"name",valueField:"id",fields:["id","name"],pageSize:10,editable:false});MODx.combo.Object.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.Object,MODx.combo.ComboBox);Ext.reg("modx-combo-object",MODx.combo.Object);MODx.combo.Namespace=function(A){A=A||{};Ext.applyIf(A,{name:"namespace",hiddenName:"namespace",forceSelection:true,typeAhead:false,editable:false,allowBlank:false,listWidth:300,pageSize:20,url:MODx.config.connectors_url+"workspace/namespace.php",fields:["name"],displayField:"name",valueField:"name"});MODx.combo.Namespace.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.Namespace,MODx.combo.ComboBox);Ext.reg("modx-combo-namespace",MODx.combo.Namespace);MODx.combo.Browser=function(A){A=A||{};Ext.applyIf(A,{width:300,triggerAction:"all"});MODx.combo.Browser.superclass.constructor.call(this,A);this.config=A;};Ext.extend(MODx.combo.Browser,Ext.form.TriggerField,{browser:null,onTriggerClick:function(A){if(this.disabled){return false;}if(this.browser===null){this.browser=MODx.load({xtype:"modx-browser",id:Ext.id(),multiple:true,prependPath:this.config.prependPath||null,prependUrl:this.config.prependUrl||null,basePath:this.config.basePath||"",basePathRelative:this.config.basePathRelative||null,baseUrl:this.config.baseUrl||"",baseUrlRelative:this.config.baseUrlRelative||null,hideFiles:this.config.hideFiles||false,rootVisible:this.config.rootVisible||false,allowedFileTypes:this.config.allowedFileTypes||"",wctx:this.config.wctx||"web",openTo:this.config.openTo||"",listeners:{select:{fn:function(B){this.setValue(B.relativeUrl);this.fireEvent("select",B);},scope:this}}});}this.browser.show(A);return true;},onDestroy:function(){MODx.combo.Browser.superclass.onDestroy.call(this);}});Ext.reg("modx-combo-browser",MODx.combo.Browser);MODx.combo.Country=function(A){A=A||{};Ext.applyIf(A,{name:"country",hiddenName:"country",url:MODx.config.connectors_url+"system/country.php",displayField:"value",valueField:"value",fields:["value"],editable:false,value:0});MODx.combo.Country.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.Country,MODx.combo.ComboBox);Ext.reg("modx-combo-country",MODx.combo.Country);MODx.combo.PropertySet=function(A){A=A||{};Ext.applyIf(A,{name:"propertyset",hiddenName:"propertyset",url:MODx.config.connectors_url+"element/propertyset.php",displayField:"name",valueField:"id",fields:["id","name"],editable:false,value:0});MODx.combo.PropertySet.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.PropertySet,MODx.combo.ComboBox);Ext.reg("modx-combo-property-set",MODx.combo.PropertySet);MODx.ChangeParentField=function(A){A=A||{};Ext.applyIf(A,{triggerAction:"all",editable:false,readOnly:false,formpanel:"modx-panel-resource"});MODx.ChangeParentField.superclass.constructor.call(this,A);this.config=A;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(B){var A=Ext.getCmp("modx-resource-tree");if(!A){return ;}B.d=B.d||B.v;A.removeListener("click",this.handleChangeParent,this);A.on("click",A._handleClick,A);A.disableHref=false;MODx.debug("Setting parent to: "+B.v);Ext.getCmp("modx-resource-parent-hidden").setValue(B.v);this.setValue(B.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 A=Ext.getCmp("modx-resource-tree");if(!A){MODx.debug("no tree found, trying to activate");var B=Ext.getCmp("modx-leftbar-tabpanel");if(B){B.on("tabchange",function(C,D){if(D.id=="modx-resource-tree-ct"){this.disableTreeClick();}},this);B.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("modx-resource-parent-hidden").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(C,D){var B=Ext.getCmp("modx-resource-tree");if(!B){return false;}B.disableHref=true;var F=C.id.split("_");F=F[1];if(F==MODx.request.id){MODx.msg.alert("",_("resource_err_own_parent"));return false;}var A=Ext.getCmp("modx-resource-context-key");if(A){var E=A.getValue();if(C.attributes&&C.attributes.ctx!=E){A.setValue(C.attributes.ctx);}}this.fireEvent("end",{v:C.attributes.type!="modContext"?F:C.attributes.pk,d:Ext.util.Format.stripTags(C.text)});D.preventDefault();D.stopEvent();return true;}});Ext.reg("modx-field-parent-change",MODx.ChangeParentField);MODx.combo.TVWidget=function(A){A=A||{};Ext.applyIf(A,{name:"widget",hiddenName:"widget",displayField:"name",valueField:"value",fields:["value","name"],editable:false,url:MODx.config.connectors_url+"element/tv/renders.php",baseParams:{action:"getOutputs"},value:"default"});MODx.combo.TVWidget.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.TVWidget,MODx.combo.ComboBox);Ext.reg("modx-combo-tv-widget",MODx.combo.TVWidget);MODx.combo.TVInputType=function(A){A=A||{};Ext.applyIf(A,{name:"type",hiddenName:"type",displayField:"name",valueField:"value",editable:false,fields:["value","name"],url:MODx.config.connectors_url+"element/tv/renders.php",baseParams:{action:"getInputs"},value:"text"});MODx.combo.TVInputType.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.TVInputType,MODx.combo.ComboBox);Ext.reg("modx-combo-tv-input-type",MODx.combo.TVInputType);MODx.combo.Action=function(A){A=A||{};Ext.applyIf(A,{name:"action",hiddenName:"action",displayField:"controller",valueField:"id",fields:["id","controller"],url:MODx.config.connectors_url+"system/action.php"});MODx.combo.Action.superclass.constructor.call(this,A);};Ext.extend(MODx.combo.Action,MODx.combo.ComboBox);Ext.reg("modx-combo-action",MODx.combo.Action);Ext.namespace("MODx.grid");MODx.grid.Grid=function(A){A=A||{};this.config=A;this._loadStore();this._loadColumnModel();Ext.applyIf(A,{store:this.store,cm:this.cm,sm:new Ext.grid.RowSelectionModel({singleSelect:true}),paging:(A.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:A.emptyText||_("ext_emptymsg")}});if(A.paging){var C=A.showPerPage?["-",_("per_page")+":",{xtype:"textfield",value:A.pageSize||(parseInt(MODx.config.default_per_page)||20),width:40,listeners:{change:{fn:function(G,E,F){if(Ext.isEmpty(E)){return false;}E=parseInt(E);this.getBottomToolbar().pageSize=E;this.store.load({params:{start:0,limit:E}});},scope:this},render:{fn:function(E){new Ext.KeyMap(E.getEl(),{key:Ext.EventObject.ENTER,fn:function(){this.fireEvent("change",this.getValue());this.blur();return true;},scope:E});},scope:this}}}]:[];if(A.pagingItems){for(var B=0;B<A.pagingItems.length;B++){C.push(A.pagingItems[B]);}}Ext.applyIf(A,{bbar:new Ext.PagingToolbar({pageSize:A.pageSize||(parseInt(MODx.config.default_per_page)||20),store:this.getStore(),displayInfo:true,items:C})});}if(A.grouping){Ext.applyIf(A,{view:new Ext.grid.GroupingView({forceFit:true,scrollOffset:0,groupTextTpl:'{text} ({[values.rs.length]} {[values.rs.length > 1 ? "'+(A.pluralText||_("records"))+'" : "'+(A.singleText||_("record"))+'"]})'})});}if(A.tbar){for(var B=0;B<A.tbar.length;B++){var D=A.tbar[B];if(D.handler&&typeof (D.handler)=="object"&&D.handler.xtype){D.handler=this.loadWindow.createDelegate(this,[D.handler],true);}if(!D.scope){D.scope=this;}}}MODx.grid.Grid.superclass.constructor.call(this,A);this._loadMenu(A);this.addEvents("beforeRemoveRow","afterRemoveRow","afterAutoSave");if(!A.preventRender){this.render();}this.on("rowcontextmenu",this._showMenu,this);if(A.autosave){this.on("afteredit",this.saveRecord,this);}if(A.paging&&A.grouping){this.getBottomToolbar().bind(this.store);}this.getStore().load({params:{start:A.pageStart||0,limit:A.pageSize||(parseInt(MODx.config.default_per_page)||20)},scope:this,callback:function(){this.getStore().reload();}});this.getStore().on("exception",this.onStoreException,this);this.config=A;};Ext.extend(MODx.grid.Grid,Ext.grid.EditorGridPanel,{windows:{},onStoreException:function(F,C,A,B,E){var D=Ext.decode(E.responseText);if(D.message){this.getView().emptyText=D.message;this.getView().refresh(false);}},saveRecord:function(C){C.record.data.menu=null;var B=this.config.saveParams||{};Ext.apply(C.record.data,B);var D=Ext.util.JSON.encode(C.record.data);var A=this.config.saveUrl||(this.config.url||this.config.connector);MODx.Ajax.request({url:A,params:{action:this.config.save_action||"updateFromGrid",data:D},listeners:{success:{fn:function(E){if(this.config.save_callback){Ext.callback(this.config.save_callback,this.config.scope||this,[E]);}C.record.commit();if(!this.config.preventSaveRefresh){this.refresh();}this.fireEvent("afterAutoSave",E);},scope:this}}});return true;},loadWindow:function(A,E,D,C){var B=this.menu.record;if(!this.windows[D.xtype]||D.force){Ext.applyIf(D,{record:D.blankValues?{}:B,grid:this,listeners:{success:{fn:D.success||this.refresh,scope:D.scope||this}}});if(C){Ext.apply(D,C);}this.windows[D.xtype]=Ext.ComponentMgr.create(D);}if(this.windows[D.xtype].setValues&&D.blankValues!==true&&B!=undefined){this.windows[D.xtype].setValues(B);}this.windows[D.xtype].show(E.target);},confirm:function(B,D){var C={action:B};var A=this.config.primaryKey||"id";C[A]=this.menu.record[A];MODx.msg.confirm({title:_(B),text:_(D)||_("confirm_remove"),url:this.config.url,params:C,listeners:{success:{fn:this.refresh,scope:this}}});},remove:function(D){var B=this.menu.record;D=D||"confirm_remove";var C=this.config.saveParams||{};Ext.apply(C,{action:"remove"});var A=this.config.primaryKey||"id";C[A]=B[A];if(this.fireEvent("beforeRemoveRow",B)){MODx.msg.confirm({title:_("warning"),text:_(D),url:this.config.url,params:C,listeners:{success:{fn:function(){this.removeActiveRow(B);},scope:this}}});}},removeActiveRow:function(A){if(this.fireEvent("afterRemoveRow",A)){var B=this.getSelectionModel().getSelected();this.getStore().remove(B);}},_loadMenu:function(){this.menu=new Ext.menu.Menu(this.config.menuConfig);},_showMenu:function(C,B,D){D.stopEvent();D.preventDefault();this.menu.record=this.getStore().getAt(B).data;if(!this.getSelectionModel().isSelected(B)){this.getSelectionModel().selectRow(B);}this.menu.removeAll();if(this.getMenu){var A=this.getMenu(C,B,D);if(A&&A.length&&A.length>0){this.addContextMenuItem(A);}}if((!A||A.length<=0)&&this.menu.record.menu){this.addContextMenuItem(this.menu.record.menu);}if(this.menu.items.length>0){this.menu.showAt(D.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?true:false,groupField:this.config.groupBy||"name",storeId:this.config.storeId||Ext.id(),autoDestroy:true});}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});}},_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){c[i].renderer=MODx.combo.Renderer(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 a=items,l=a.length;for(var i=0;i<l;i++){var options=a[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,e){var o=itm.options;var id=this.menu.record.id;if(o.confirm){Ext.Msg.confirm("",o.confirm,function(e){if(e=="yes"){var a=Ext.urlEncode(o.params||{action:o.action});var s="index.php?id="+id+"&"+a;location.href=s;}},this);}else{var a=Ext.urlEncode(o.params||{action:o.action});var s="index.php?id="+id+"&"+a;location.href=s;}};}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(A,B){var C="";for(i=0;i<A.length;i++){C=C+"*";}return C;},rendYesNo:function(A,B){if(A===1||A=="1"){A=true;}if(A===0||A=="0"){A=false;}switch(A){case true:case"true":case 1:B.css="green";return _("yes");case false:case"false":case"":case 0:B.css="red";return _("no");}},getSelectedAsList:function(){var A=this.getSelectionModel().getSelections();if(A.length<=0){return false;}var C="";for(var B=0;B<A.length;B++){C+=","+A[B].data.id;}if(C[0]==","){C=C.substr(1);}return C;},editorYesNo:function(A){A=A||{};Ext.applyIf(A,{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(A);},encodeModified:function(){var C=this.getStore().getModifiedRecords();var A={};for(var B=0;B<C.length;B++){A[C[B].data[this.config.primaryKey||"id"]]=C[B].data;}return Ext.encode(A);},encode:function(){var C=this.getStore().getRange();var A={};for(var B=0;B<C.length;B++){A[C[B].data[this.config.primaryKey||"id"]]=C[B].data;}return Ext.encode(A);},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(A){A=A||{};if(A.grouping){Ext.applyIf(A,{view:new Ext.grid.GroupingView({forceFit:true,scrollOffset:0,hideGroupedColumn:A.hideGroupedColumn?true:false,groupTextTpl:A.groupTextTpl||('{text} ({[values.rs.length]} {[values.rs.length > 1 ? "'+(A.pluralText||_("records"))+'" : "'+(A.singleText||_("record"))+'"]})')})});}if(A.tbar){for(var B=0;B<A.tbar.length;B++){var C=A.tbar[B];if(C.handler&&typeof (C.handler)=="object"&&C.handler.xtype){C.handler=this.loadWindow.createDelegate(this,[C.handler],true);}if(!C.scope){C.scope=this;}}}Ext.applyIf(A,{title:"",store:this._loadStore(A),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:A.emptyText||_("ext_emptymsg")},menuConfig:{defaultAlign:"tl-b?",enableScrolling:false}});this.menu=new Ext.menu.Menu(A.menuConfig);this.config=A;this._loadColumnModel();MODx.grid.LocalGrid.superclass.constructor.call(this,A);this.addEvents({beforeRemoveRow:true,afterRemoveRow:true});this.on("rowcontextmenu",this._showMenu,this);};Ext.extend(MODx.grid.LocalGrid,Ext.grid.EditorGridPanel,{windows:{},_loadStore:function(A){if(A.grouping){this.store=new Ext.data.GroupingStore({data:A.data||[],reader:new Ext.data.ArrayReader({},A.fields||[]),sortInfo:A.sortInfo||{field:A.sortBy||"name",direction:A.sortDir||"ASC"},groupField:A.groupBy||"name"});}else{this.store=new Ext.data.SimpleStore({fields:A.fields,data:A.data||[]});}return this.store;},loadWindow:function(A,E,D,C){var B=this.menu.record;if(!this.windows[D.xtype]){Ext.applyIf(D,{scope:this,success:this.refresh,record:D.blankValues?{}:B});if(C){Ext.apply(D,C);}this.windows[D.xtype]=Ext.ComponentMgr.create(D);}if(this.windows[D.xtype].setValues&&D.blankValues!==true&&B!=undefined){this.windows[D.xtype].setValues(B);}this.windows[D.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){c[i].renderer=MODx.combo.Renderer(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==="local"&&typeof (c[i].renderer)=="string"){c[i].renderer=eval(c[i].renderer);}}}}}}this.cm=new Ext.grid.ColumnModel(c);}},_showMenu:function(C,B,D){D.stopEvent();D.preventDefault();this.menu.recordIndex=B;this.menu.record=this.getStore().getAt(B).data;if(!this.getSelectionModel().isSelected(B)){this.getSelectionModel().selectRow(B);}this.menu.removeAll();var A=this.getMenu(C,B);if(A){this.addContextMenuItem(A);this.menu.showAt(D.xy);}},getMenu:function(){return this.menu.record.menu;},addContextMenuItem:function(items){var a=items,l=a.length;for(var i=0;i<l;i++){var options=a[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,e){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="index.php?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="index.php?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(A){var B=this.getSelectionModel().getSelected();if(this.fireEvent("beforeRemoveRow",B)){Ext.Msg.confirm(A.title||"",A.text||"",function(C){if(C=="yes"){this.getStore().remove(B);this.fireEvent("afterRemoveRow",B);}},this);}},encode:function(){var D=this.getStore();var C=D.getCount();var A=this.config.encodeByPk?{}:[];var E;for(var B=0;B<C;B++){E=D.getAt(B).data;E.menu=null;if(this.config.encodeAssoc){A[E[this.config.encodeByPk||"id"]]=E;}else{A.push(E);}}return Ext.encode(A);},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(A,B){switch(A){case"":return"-";case false:B.css="red";return _("no");case true:B.css="green";return _("yes");}}});Ext.reg("grid-local",MODx.grid.LocalGrid);Ext.reg("modx-grid-local",MODx.grid.LocalGrid);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,menuDisabled:true,dataIndex:"",id:"expander",lazyRender:true,enableCaching:false,constructor:function(A){Ext.apply(this,A);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(B,A,C,E){C.cols=C.cols-1;var D=this.bodyContent[B.id];if(!D&&!this.lazyRender){D=this.getBodyContent(B,A);}if(D){C.body=D;}return this.state[B.id]?"x-grid3-row-expanded":"x-grid3-row-collapsed";},init:function(B){this.grid=B;var A=B.getView();A.getRowClass=this.getRowClass.createDelegate(this);A.enableRowBody=true;B.on("render",this.onRender,this);B.on("destroy",this.onDestroy,this);},onRender:function(){var B=this.grid;var A=B.getView().mainBody;A.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){B.on("rowdblclick",this.onRowDblClick,this);}},onDestroy:function(){this.keyNav.disable();delete this.keyNav;var A=this.grid.getView().mainBody;A.un("mousedown",this.onMouseDown,this);},onRowDblClick:function(B,A,C){this.toggleRow(A);},onEnter:function(F){var E=this.grid;var C=E.getSelectionModel();var B=C.getSelections();for(var D=0,A=B.length;D<A;D++){var G=E.getStore().indexOf(B[D]);this.toggleRow(G);}},getBodyContent:function(B,A){if(!this.enableCaching){return this.tpl.apply(B.data);}var C=this.bodyContent[B.id];if(!C){C=this.tpl.apply(B.data);this.bodyContent[B.id]=C;}return C;},onMouseDown:function(C,B){C.stopEvent();var A=C.getTarget(".x-grid3-row");this.toggleRow(A);},renderer:function(B,C,A){C.cellAttr='rowspan="2"';if(A.data.description!==null&&A.data.description===""){return"";}return'<div class="x-grid3-row-expander">&#160;</div>';},beforeExpand:function(B,A,C){if(this.fireEvent("beforeexpand",this,B,A,C)!==false){if(this.tpl&&this.lazyRender){A.innerHTML=this.getBodyContent(B,C);}return true;}else{return false;}},toggleRow:function(A){if(typeof A=="number"){A=this.grid.view.getRow(A);}this[Ext.fly(A).hasClass("x-grid3-row-collapsed")?"expandRow":"collapseRow"](A);},expandRow:function(B){if(typeof B=="number"){B=this.grid.view.getRow(B);}var A=this.grid.store.getAt(B.rowIndex);var C=Ext.DomQuery.selectNode("tr:nth(2) div.x-grid3-row-body",B);if(this.beforeExpand(A,C,B.rowIndex)){this.state[A.id]=true;Ext.fly(B).replaceClass("x-grid3-row-collapsed","x-grid3-row-expanded");this.fireEvent("expand",this,A,C,B.rowIndex);}},collapseRow:function(B){if(typeof B=="number"){B=this.grid.view.getRow(B);}var A=this.grid.store.getAt(B.rowIndex);var C=Ext.fly(B).child("tr:nth(1) div.x-grid3-row-body",true);if(this.fireEvent("beforecollapse",this,A,C,B.rowIndex)!==false){this.state[A.id]=false;Ext.fly(B).replaceClass("x-grid3-row-expanded","x-grid3-row-collapsed");this.fireEvent("collapse",this,A,C,B.rowIndex);}},expandAll:function(){var A=this.grid.getView().getRows();for(var B=0;B<A.length;B++){this.expandRow(A[B]);}},collapseAll:function(){var A=this.grid.getView().getRows();for(var B=0;B<A.length;B++){this.collapseRow(A[B]);}}});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(A){this.grid=A;this.grid.on("render",function(){var B=this.grid.getView();B.mainBody.on("mousedown",this.onMouseDown,this);},this);},onMouseDown:function(D,C){this.grid.fireEvent("rowclick");if(C.className&&C.className.indexOf("x-grid3-cc-"+this.id)!=-1){D.stopEvent();var B=this.grid.getView().findRowIndex(C);var A=this.grid.store.getAt(B);A.set(this.dataIndex,!A.data[this.dataIndex]);this.grid.fireEvent("afteredit");}},renderer:function(B,C,A){C.css+=" x-grid3-check-col-td";return'<div class="x-grid3-check-col'+(B?"-on":"")+" x-grid3-cc-"+this.id+'">&#160;</div>';}};Ext.preg("checkcolumn",Ext.ux.grid.CheckColumn);Ext.grid.CheckColumn=Ext.ux.grid.CheckColumn;Ext.grid.PropertyColumnModel=function(B,A){var C=Ext.grid,D=Ext.form;this.grid=B;C.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=A;var E=new D.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 C.GridEditor(new D.DateField({selectOnFocus:true})),string:new C.GridEditor(new D.TextField({selectOnFocus:true})),number:new C.GridEditor(new D.NumberField({selectOnFocus:true,style:"text-align:left;"})),"boolean":new C.GridEditor(E)};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(B,A){return B==1;},getRenderer:function(A){return A==1?this.renderCellDelegate:this.renderPropDelegate;},renderProp:function(A){return this.getPropertyName(A);},renderCell:function(B){var A=B;if(Ext.isDate(B)){A=this.renderDate(B);}else{if(typeof B=="boolean"){A=this.renderBool(B);}}return Ext.util.Format.htmlEncode(A);},getPropertyName:function(B){var A=this.grid.propertyNames;return A&&A[B]?A[B]:B;},getCellEditor:function(B,A){var C=this.store.getProperty(A),E=C.data.name,D=C.data.value;if(this.grid.customEditors[E]){return this.grid.customEditors[E];}if(Ext.isDate(D)){return this.editors.date;}else{if(typeof D=="number"){return this.editors.number;}else{if(typeof D=="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);}}});MODx.Console=function(A){A=A||{};Ext.Updater.defaults.showLoadIndicator=false;Ext.applyIf(A,{title:_("console"),modal:Ext.isIE?false:true,shadow:true,resizable:false,collapsible:false,closable:false,maximizable:true,autoScroll:true,height:400,width:650,refreshRate:2,cls:"modx-window modx-console",items:[{itemId:"header",cls:"modx-console-text",html:_("console_running"),border:false},{xtype:"panel",itemId:"body",cls:"x-form-text modx-console-text"}],buttons:[{text:_("console_download_output"),handler:this.download,scope:this},{text:_("ok"),id:"modx-console-ok",itemId:"okBtn",disabled:true,scope:this,handler:this.hideConsole}]});MODx.Console.superclass.constructor.call(this,A);this.config=A;this.addEvents({shutdown:true,complete:true});this.on("show",this.init,this);this.on("hide",function(){this.getComponent("body").el.update("");});this.on("complete",this.onComplete,this);};Ext.extend(MODx.Console,Ext.Window,{mgr:null,running:false,init:function(){Ext.Msg.hide();this.fbar.getComponent("okBtn").setDisabled(true);this.getComponent("body").el.dom.innerHTML="";this.provider=new Ext.direct.PollingProvider({type:"polling",url:MODx.config.connectors_url+"system/index.php",interval:1000,baseParams:{action:"console",register:this.config.register||"",topic:this.config.topic||"",show_filename:this.config.show_filename||0,format:this.config.format||"html_log"}});Ext.Direct.addProvider(this.provider);Ext.Direct.on("message",function(C,B){var A=this.getComponent("body");if(A){A.el.insertHtml("beforeEnd",C.data);C.data="";A.el.scroll("b",A.el.getHeight(),true);}if(C.complete){this.fireEvent("complete");}delete C;},this);},onComplete:function(){this.provider.disconnect();this.fbar.getComponent("okBtn").setDisabled(false);},download:function(){var A=this.getComponent("body").getEl().dom.innerHTML||"&nbsp;";MODx.Ajax.request({url:MODx.config.connectors_url+"system/index.php",params:{action:"downloadOutput",data:A},listeners:{success:{fn:function(B){location.href=MODx.config.connectors_url+"system/index.php?action=downloadOutput&HTTP_MODAUTH="+MODx.siteId+"&download="+B.message;},scope:this}}});},setRegister:function(B,A){this.config.register=B;this.config.topic=A;},hideConsole:function(){if(this.provider&&this.provider.disconnect){try{this.provider.disconnect();}catch(A){}}this.fireEvent("shutdown");this.hide();}});Ext.reg("modx-console",MODx.Console);Ext.namespace("MODx.portal");Ext.ux.Portal=Ext.extend(Ext.Panel,{layout:"column",cls:"x-portal",defaultType:"portalcolumn",initComponent:function(){Ext.ux.Portal.superclass.initComponent.call(this);this.addEvents({validatedrop:true,beforedragover:true,dragover:true,beforedrop:true,drop:true});},initEvents:function(){Ext.ux.Portal.superclass.initEvents.call(this);this.dd=new Ext.ux.Portal.DropZone(this,this.dropConfig);},beforeDestroy:function(){if(this.dd){this.dd.unreg();}Ext.ux.Portal.superclass.beforeDestroy.call(this);}});Ext.reg("portal",Ext.ux.Portal);Ext.ux.Portal.DropZone=function(B,A){this.portal=B;Ext.dd.ScrollManager.register(B.body);Ext.ux.Portal.DropZone.superclass.constructor.call(this,B.bwrap.dom,A);B.body.ddScrollConfig=this.ddScrollConfig;};Ext.extend(Ext.ux.Portal.DropZone,Ext.dd.DropTarget,{ddScrollConfig:{vthresh:50,hthresh:-1,animate:true,increment:200},createEvent:function(B,D,A,E,F,C){return{portal:this.portal,panel:A.panel,columnIndex:E,column:F,position:C,data:A,source:B,rawEvent:D,status:this.dropAllowed};},notifyOver:function(S,O,R){var P=O.getXY(),A=this.portal,G=S.proxy;if(!this.grid){this.grid=this.getGrid();}var N=A.body.dom.clientWidth;if(!this.lastCW){this.lastCW=N;}else{if(this.lastCW!=N){this.lastCW=N;A.doLayout();this.grid=this.getGrid();}}var M=0,E=this.grid.columnX,F=false;for(var K=E.length;M<K;M++){if(P[0]<(E[M].x+E[M].w)){F=true;break;}}if(!F){M--;}var I,D=false,B=0,Q=A.items.itemAt(M),H=Q.items.items,C=false;for(var K=H.length;B<K;B++){I=H[B];var L=I.el.getHeight();if(L===0){C=true;}else{if((I.el.getY()+(L/2))>P[1]){D=true;break;}}}B=(D&&I?B:Q.items.getCount())+(C?-1:0);var J=this.createEvent(S,O,R,M,Q,B);if(A.fireEvent("validatedrop",J)!==false&&A.fireEvent("beforedragover",J)!==false){G.getProxy().setWidth("auto");if(I){G.moveProxy(I.el.dom.parentNode,D?I.el.dom:null);}else{G.moveProxy(Q.el.dom,null);}this.lastPos={c:Q,col:M,p:C||(D&&I)?B:false};this.scrollPos=A.body.getScroll();A.fireEvent("dragover",J);return J.status;}else{return J.status;}},notifyOut:function(){delete this.grid;},notifyDrop:function(I,D,H){delete this.grid;if(!this.lastPos){return ;}var F=this.lastPos.c,A=this.lastPos.col,G=this.lastPos.p;var C=this.createEvent(I,D,H,A,F,G!==false?G:F.items.getCount());if(this.portal.fireEvent("validatedrop",C)!==false&&this.portal.fireEvent("beforedrop",C)!==false){I.proxy.getProxy().remove();I.panel.el.dom.parentNode.removeChild(I.panel.el.dom);if(G!==false){if(F==I.panel.ownerCt&&(F.items.items.indexOf(I.panel)<=G)){G++;}F.insert(G,I.panel);}else{F.add(I.panel);}F.doLayout();this.portal.fireEvent("drop",C);var B=this.scrollPos.top;if(B){var E=this.portal.body.dom;setTimeout(function(){E.scrollTop=B;},10);}}delete this.lastPos;},getGrid:function(){var A=this.portal.bwrap.getBox();A.columnX=[];this.portal.items.each(function(B){A.columnX.push({x:B.el.getX(),w:B.el.getWidth()});});return A;},unreg:function(){Ext.ux.Portal.DropZone.superclass.unreg.call(this);}});MODx.portal.Column=Ext.extend(Ext.Container,{layout:"anchor",defaultType:"portlet",cls:"x-portal-column",style:"padding:10px;",columnWidth:1,defaults:{collapsible:true,autoHeight:true,titleCollapse:true,draggable:true,style:"padding: 5px 0;",bodyStyle:"padding: 15px;"}});Ext.reg("portalcolumn",MODx.portal.Column);MODx.portal.Portlet=Ext.extend(Ext.Panel,{anchor:Ext.isSafari?"98%":"100%",frame:true,collapsible:true,draggable:true,cls:"x-portlet",stateful:false,layout:"form"});Ext.reg("portlet",MODx.portal.Portlet);MODx.TreeDrop=function(A){A=A||{};Ext.applyIf(A,{id:"modx-treedrop",ddGroup:"modx-treedrop-dd"});MODx.TreeDrop.superclass.constructor.call(this,A);this.config=A;this.setup();};Ext.extend(MODx.TreeDrop,Ext.Component,{setup:function(){var C=this.config.target;var B=this.config.targetEl;var A=this.config;this.targetEl=new Ext.dd.DropTarget(this.config.targetEl,{ddGroup:this.config.ddGroup,notifyEnter:function(G,F,E){if(C.getEl){var D=C.getEl();if(D){D.frame();}}},notifyDrop:function(J,I,F){if(!F.node||!F.node.attributes||!F.node.attributes.type){return false;}if(F.node.attributes.type!="modResource"&&F.node.attributes.leaf!=true){return false;}var D="";var H=false;switch(F.node.attributes.type){case"modResource":D="[[~"+F.node.attributes.pk+"]]";break;case"snippet":H=true;break;case"chunk":H=true;break;case"tv":H=true;break;case"file":D=F.node.attributes.url;break;default:return false;break;}if(H){MODx.loadInsertElement({pk:F.node.attributes.pk,classKey:F.node.attributes.classKey,name:F.node.attributes.name,output:D,ddTargetEl:B,cfg:A,iframe:A.iframe,iframeEl:A.iframeEl,onInsert:A.onInsert,panel:A.panel});}else{if(A.iframe){MODx.insertForRTE(D,A);}else{var E=Ext.get(B);if(E.dom.id=="modx-static-content"){D=D.substring(1);Ext.getCmp(E.dom.id).setValue("");}if(E.dom.id=="modx-symlink-content"||E.dom.id=="modx-weblink-content"){Ext.getCmp(E.dom.id).setValue("");MODx.insertAtCursor(B,F.node.attributes.pk,A.onInsert);}else{if(E.dom.id=="modx-resource-parent"){D=F.node.attributes.pk;Ext.getCmp("modx-resource-parent").setValue(D);Ext.getCmp("modx-resource-parent-hidden").setValue(D);var G=Ext.getCmp("modx-panel-resource");if(G){G.markDirty();}}else{MODx.insertAtCursor(B,D,A.onInsert);}}if(A.panel){var G=Ext.getCmp(A.panel);if(G){G.markDirty();}}}}return true;}});}});Ext.reg("modx-treedrop",MODx.TreeDrop);MODx.loadInsertElement=function(A){if(MODx.InsertElementWindow){MODx.InsertElementWindow.hide();MODx.InsertElementWindow.destroy();}MODx.InsertElementWindow=MODx.load({xtype:"modx-window-insert-element",record:A,listeners:{success:{fn:function(){},scope:this},hide:{fn:function(){this.destroy();}}}});MODx.InsertElementWindow.setValues(A);MODx.InsertElementWindow.show();};MODx.insertAtCursor=function(E,C,D){if(!Ext.isEmpty(D)){var F=D(C);if(F!=undefined){C=F;}}if(document.selection){E.focus();sel=document.selection.createRange();sel.text=C;}else{if(E.selectionStart||E.selectionStart=="0"){var B=E.selectionStart;var A=E.selectionEnd;E.value=E.value.substring(0,B)+C+E.value.substring(A,E.value.length);}else{E.value+=C;}}};MODx.insertForRTE=function(B,A){var C=A.onInsert||false;if(C){C(B,A);}else{if(typeof A.iframeEl=="object"){var D=A.iframeEl;}else{var D=window.frames[0].document.getElementById(A.iframeEl);}if(D.value){D.value=D.value+B;}else{D.innerHTML=D.innerHTML+B;}}};MODx.window.InsertElement=function(A){A=A||{};Ext.applyIf(A,{title:_("select_el_opts"),id:"modx-window-insert-element",width:600,url:MODx.config.connectors_url+"element/template.php",action:"create",fields:[{xtype:"hidden",name:"pk",id:"modx-dise-pk"},{xtype:"hidden",name:"classKey",id:"modx-dise-classkey"},{xtype:"xcheckbox",fieldLabel:_("cached"),name:"cached",id:"modx-dise-cached",inputValue:1,checked:true},{xtype:"modx-combo-property-set",fieldLabel:_("property_set"),name:"propertyset",id:"modx-dise-propset",baseParams:{action:"getList",showAssociated:true,elementId:A.record.pk,elementType:A.record.classKey},listeners:{select:{fn:this.changePropertySet,scope:this}}},{id:"modx-dise-proplist",autoLoad:{url:MODx.config.connectors_url+"element/index.php",params:{action:"getInsertProperties",classKey:A.record.classKey,pk:A.record.pk,propertySet:0},scripts:true,callback:this.onPropFormLoad,scope:this},style:"display: none;"},{xtype:"fieldset",title:_("properties"),autoHeight:true,collapsible:true,autoScroll:true,items:[{html:'<div id="modx-iprops-form"></div>',height:400,autoScroll:true}]}]});MODx.window.InsertElement.superclass.constructor.call(this,A);this.on("show",function(){this.center();},this);};Ext.extend(MODx.window.InsertElement,MODx.Window,{changePropertySet:function(A){var C=Ext.getCmp("modx-iprops-fp");if(C){C.destroy();}var B=Ext.getCmp("modx-dise-proplist").getUpdater();B.update({url:MODx.config.connectors_url+"element/index.php",params:{action:"getInsertProperties",classKey:this.config.record.classKey,pk:this.config.record.pk,propertySet:A.getValue()},scripts:true,callback:this.onPropFormLoad,scope:this});this.modps=[];},createStore:function(A){return new Ext.data.SimpleStore({fields:["v","d"],data:A});},onPropFormLoad:function(C,B,D){var E=Ext.decode(D.responseText);if(!E||E.length<=0){return false;}for(var A=0;A<E.length;A++){if(E[A].store){E[A].store=this.createStore(E[A].store);}}MODx.load({xtype:"panel",id:"modx-iprops-fp",layout:"form",autoHeight:true,autoScroll:true,labelWidth:150,border:false,items:E,renderTo:"modx-iprops-form"});},submit:function(){var A="[[";var G=this.config.record.name;var D=this.fp.getForm();if(D.findField("cached").getValue()!=true){A=A+"!";}switch(this.config.record.classKey){case"modSnippet":A=A+G;break;case"modChunk":A=A+"$"+G;break;case"modTemplateVar":A=A+"*"+G;break;}var F=D.findField("propertyset").getValue();if(F!==0&&F!==""){A=A+"@"+D.findField("propertyset").getRawValue();}A=A+"?";for(var C=0;C<this.modps.length;C++){var B=this.modps[C];var E=Ext.getCmp("modx-iprop-"+B).getValue();if(E==true){E=1;}if(E==false){E=0;}A=A+" &"+B+"=`"+E+"`";}A=A+"]]";if(this.config.record.iframe){MODx.insertForRTE(A,this.config.record.cfg);}else{MODx.insertAtCursor(this.config.record.ddTargetEl,A);}this.hide();return true;},modps:[],changeProp:function(A){if(this.modps.indexOf(A)==-1){this.modps.push(A);}}});Ext.reg("modx-window-insert-element",MODx.window.InsertElement);MODx.window.DuplicateResource=function(A){A=A||{};this.ident=A.ident||"dupres"+Ext.id();Ext.applyIf(A,{title:_("duplication_options"),id:this.ident,width:400});MODx.window.DuplicateResource.superclass.constructor.call(this,A);};Ext.extend(MODx.window.DuplicateResource,MODx.Window,{_loadForm:function(){if(this.checkIfLoaded(this.config.record)){this.fp.getForm().baseParams={action:"duplicate",prefixDuplicate:true,id:this.config.resource};return false;}var A=[];if(this.config.hasChildren){A.push({xtype:"xcheckbox",fieldLabel:_("duplicate_children"),name:"duplicate_children",id:"modx-"+this.ident+"-duplicate-children",checked:true,listeners:{check:{fn:function(B,C){if(C){this.fp.getForm().findField("modx-"+this.ident+"-name").disable();}else{this.fp.getForm().findField("modx-"+this.ident+"-name").enable();}},scope:this}}});}A.push({xtype:"textfield",id:"modx-"+this.ident+"-name",fieldLabel:_("resource_name_new"),name:"name",anchor:"90%",value:""});this.fp=this.createForm({url:this.config.url||MODx.config.connectors_url+"resource/index.php",baseParams:this.config.baseParams||{action:"duplicate",id:this.config.resource,prefixDuplicate:true},labelWidth:125,defaultType:"textfield",autoHeight:true,items:A});this.renderForm();}});Ext.reg("modx-window-resource-duplicate",MODx.window.DuplicateResource);MODx.window.CreateCategory=function(A){A=A||{};this.ident=A.ident||"ccat"+Ext.id();Ext.applyIf(A,{title:_("new_category"),id:this.ident,height:150,width:350,url:MODx.config.connectors_url+"element/category.php",action:"create",fields:[{fieldLabel:_("name"),name:"category",id:"modx-"+this.ident+"-category",xtype:"textfield",anchor:"90%"},{fieldLabel:_("parent"),name:"parent",hiddenName:"parent",id:"modx-"+this.ident+"-parent",xtype:"modx-combo-category",anchor:"90%"}]});MODx.window.CreateCategory.superclass.constructor.call(this,A);};Ext.extend(MODx.window.CreateCategory,MODx.Window);Ext.reg("modx-window-category-create",MODx.window.CreateCategory);MODx.window.CreateNamespace=function(A){A=A||{};var B=A.record;this.ident=A.ident||"cns"+Ext.id();Ext.applyIf(A,{title:_("namespace_create"),id:this.ident,width:600,url:MODx.config.connectors_url+"workspace/namespace.php",action:"create",fields:[{xtype:"textfield",fieldLabel:_("name"),name:"name",id:"modx-"+this.ident+"-name",anchor:"90%",maxLength:100},{xtype:"textfield",fieldLabel:_("path"),description:_("namespace_path_desc"),name:"path",id:"modx-"+this.ident+"-path",anchor:"97%"}]});MODx.window.CreateNamespace.superclass.constructor.call(this,A);};Ext.extend(MODx.window.CreateNamespace,MODx.Window);Ext.reg("modx-window-namespace-create",MODx.window.CreateNamespace);MODx.window.QuickCreateChunk=function(A){A=A||{};this.ident=A.ident||"qcc"+Ext.id();Ext.applyIf(A,{title:_("quick_create_chunk"),id:this.ident,width:600,url:MODx.config.connectors_url+"element/chunk.php",action:"create",fields:[{xtype:"textfield",name:"name",id:"modx-"+this.ident+"-name",fieldLabel:_("name"),anchor:"90%"},{xtype:"modx-combo-category",name:"category",fieldLabel:_("category"),id:"modx-"+this.ident+"-category",anchor:"90%"},{xtype:"textarea",name:"description",id:"modx-"+this.ident+"-description",fieldLabel:_("description"),anchor:"97%",rows:2},{xtype:"textarea",name:"snippet",id:"modx-"+this.ident+"-snippet",fieldLabel:_("code"),anchor:"97%",grow:true,growMax:380}],keys:[{key:Ext.EventObject.ENTER,shift:true,fn:this.submit,scope:this}]});MODx.window.QuickCreateChunk.superclass.constructor.call(this,A);};Ext.extend(MODx.window.QuickCreateChunk,MODx.Window);Ext.reg("modx-window-quick-create-chunk",MODx.window.QuickCreateChunk);MODx.window.QuickUpdateChunk=function(A){A=A||{};this.ident=A.ident||"quc"+Ext.id();Ext.applyIf(A,{title:_("quick_update_chunk"),id:this.ident,width:600,url:MODx.config.connectors_url+"element/chunk.php",action:"update",fields:[{xtype:"hidden",name:"id",id:"modx-"+this.ident+"-id"},{xtype:"textfield",name:"name",id:"modx-"+this.ident+"-name",fieldLabel:_("name"),anchor:"90%"},{xtype:"modx-combo-category",name:"category",fieldLabel:_("category"),id:"modx-"+this.ident+"-category",anchor:"90%"},{xtype:"textarea",name:"description",id:"modx-"+this.ident+"-description",fieldLabel:_("description"),anchor:"97%",rows:2},{xtype:"xcheckbox",name:"clearCache",id:"modx-"+this.ident+"-clearcache",fieldLabel:_("clear_cache_on_save"),description:_("clear_cache_on_save_msg"),inputValue:1,checked:true},{xtype:"textarea",name:"snippet",id:"modx-"+this.ident+"-snippet",fieldLabel:_("code"),anchor:"97%",grow:true,growMax:380}],keys:[{key:Ext.EventObject.ENTER,shift:true,fn:this.submit,scope:this}],buttons:[{text:A.cancelBtnText||_("cancel"),scope:this,handler:function(){this.hide();}},{text:A.saveBtnText||_("save"),scope:this,handler:function(){this.submit(false);}},{text:A.saveBtnText||_("save_and_close"),scope:this,handler:this.submit}]});MODx.window.QuickUpdateChunk.superclass.constructor.call(this,A);};Ext.extend(MODx.window.QuickUpdateChunk,MODx.Window);Ext.reg("modx-window-quick-update-chunk",MODx.window.QuickUpdateChunk);MODx.window.QuickCreateTemplate=function(A){A=A||{};this.ident=A.ident||"qct"+Ext.id();Ext.applyIf(A,{title:_("quick_create_template"),id:this.ident,width:600,url:MODx.config.connectors_url+"element/template.php",action:"create",fields:[{xtype:"textfield",name:"templatename",id:"modx-"+this.ident+"-name",fieldLabel:_("name"),anchor:"90%"},{xtype:"modx-combo-category",name:"category",fieldLabel:_("category"),id:"modx-"+this.ident+"-category",anchor:"90%"},{xtype:"textarea",name:"description",id:"modx-"+this.ident+"-description",fieldLabel:_("description"),anchor:"97%",rows:2},{xtype:"textarea",name:"content",id:"modx-"+this.ident+"-content",fieldLabel:_("code"),anchor:"97%",grow:true,growMax:380}],keys:[{key:Ext.EventObject.ENTER,shift:true,fn:this.submit,scope:this}]});MODx.window.QuickCreateTemplate.superclass.constructor.call(this,A);};Ext.extend(MODx.window.QuickCreateTemplate,MODx.Window);Ext.reg("modx-window-quick-create-template",MODx.window.QuickCreateTemplate);MODx.window.QuickUpdateTemplate=function(A){A=A||{};this.ident=A.ident||"qut"+Ext.id();Ext.applyIf(A,{title:_("quick_update_template"),id:this.ident,width:600,url:MODx.config.connectors_url+"element/template.php",action:"update",fields:[{xtype:"hidden",name:"id",id:"modx-"+this.ident+"-id"},{xtype:"textfield",name:"templatename",id:"modx-"+this.ident+"-name",fieldLabel:_("name"),anchor:"90%"},{xtype:"modx-combo-category",name:"category",fieldLabel:_("category"),id:"modx-"+this.ident+"-category",anchor:"90%"},{xtype:"textarea",name:"description",id:"modx-"+this.ident+"-description",fieldLabel:_("description"),anchor:"97%",rows:2},{xtype:"xcheckbox",name:"clearCache",id:"modx-"+this.ident+"-clearcache",fieldLabel:_("clear_cache_on_save"),description:_("clear_cache_on_save_msg"),inputValue:1,checked:true},{xtype:"textarea",name:"content",id:"modx-"+this.ident+"-content",fieldLabel:_("code"),anchor:"97%",grow:true,growMax:380}],keys:[{key:Ext.EventObject.ENTER,shift:true,fn:this.submit,scope:this}],buttons:[{text:A.cancelBtnText||_("cancel"),scope:this,handler:function(){this.hide();}},{text:A.saveBtnText||_("save"),scope:this,handler:function(){this.submit(false);}},{text:A.saveBtnText||_("save_and_close"),scope:this,handler:this.submit}]});MODx.window.QuickUpdateTemplate.superclass.constructor.call(this,A);};Ext.extend(MODx.window.QuickUpdateTemplate,MODx.Window);Ext.reg("modx-window-quick-update-template",MODx.window.QuickUpdateTemplate);MODx.window.QuickCreateSnippet=function(A){A=A||{};this.ident=A.ident||"qcs"+Ext.id();Ext.applyIf(A,{title:_("quick_create_snippet"),id:this.ident,width:600,url:MODx.config.connectors_url+"element/snippet.php",action:"create",fields:[{xtype:"textfield",name:"name",id:"modx-"+this.ident+"-name",fieldLabel:_("name"),anchor:"90%"},{xtype:"modx-combo-category",name:"category",fieldLabel:_("category"),id:"modx-"+this.ident+"-category",anchor:"90%"},{xtype:"textarea",name:"description",id:"modx-"+this.ident+"-description",fieldLabel:_("description"),anchor:"97%",rows:2},{xtype:"textarea",name:"snippet",id:"modx-"+this.ident+"-snippet",fieldLabel:_("code"),anchor:"97%",grow:true,growMax:380}],keys:[{key:Ext.EventObject.ENTER,shift:true,fn:this.submit,scope:this}]});MODx.window.QuickCreateSnippet.superclass.constructor.call(this,A);};Ext.extend(MODx.window.QuickCreateSnippet,MODx.Window);Ext.reg("modx-window-quick-create-snippet",MODx.window.QuickCreateSnippet);MODx.window.QuickUpdateSnippet=function(A){A=A||{};this.ident=A.ident||"qus"+Ext.id();Ext.applyIf(A,{title:_("quick_update_snippet"),id:this.ident,width:600,url:MODx.config.connectors_url+"element/snippet.php",action:"update",fields:[{xtype:"hidden",name:"id",id:"modx-"+this.ident+"-id"},{xtype:"textfield",name:"name",id:"modx-"+this.ident+"-name",fieldLabel:_("name"),anchor:"90%"},{xtype:"modx-combo-category",name:"category",fieldLabel:_("category"),id:"modx-"+this.ident+"-category",anchor:"90%"},{xtype:"textarea",name:"description",id:"modx-"+this.ident+"-description",fieldLabel:_("description"),anchor:"97%",rows:2},{xtype:"xcheckbox",name:"clearCache",id:"modx-"+this.ident+"-clearcache",fieldLabel:_("clear_cache_on_save"),description:_("clear_cache_on_save_msg"),inputValue:1,checked:true},{xtype:"textarea",name:"snippet",id:"modx-"+this.ident+"-snippet",fieldLabel:_("code"),anchor:"97%",grow:true,growMax:380}],keys:[{key:Ext.EventObject.ENTER,shift:true,fn:this.submit,scope:this}],buttons:[{text:A.cancelBtnText||_("cancel"),scope:this,handler:function(){this.hide();}},{text:A.saveBtnText||_("save"),scope:this,handler:function(){this.submit(false);}},{text:A.saveBtnText||_("save_and_close"),scope:this,handler:this.submit}]});MODx.window.QuickUpdateSnippet.superclass.constructor.call(this,A);};Ext.extend(MODx.window.QuickUpdateSnippet,MODx.Window);Ext.reg("modx-window-quick-update-snippet",MODx.window.QuickUpdateSnippet);MODx.window.QuickCreatePlugin=function(A){A=A||{};this.ident=A.ident||"qcp"+Ext.id();Ext.applyIf(A,{title:_("quick_create_plugin"),id:this.ident,width:600,url:MODx.config.connectors_url+"element/plugin.php",action:"create",fields:[{xtype:"textfield",name:"name",id:"modx-"+this.ident+"-name",fieldLabel:_("name"),anchor:"90%"},{xtype:"modx-combo-category",name:"category",fieldLabel:_("category"),id:"modx-"+this.ident+"-category",anchor:"90%"},{xtype:"textarea",name:"description",id:"modx-"+this.ident+"-description",fieldLabel:_("description"),anchor:"97%",rows:2},{xtype:"xcheckbox",name:"disabled",id:"modx-"+this.ident+"-disabled",fieldLabel:_("disabled"),inputValue:1,checked:false},{xtype:"textarea",name:"plugincode",id:"modx-"+this.ident+"-plugincode",fieldLabel:_("code"),anchor:"97%",grow:true,growMax:380}],keys:[{key:Ext.EventObject.ENTER,shift:true,fn:this.submit,scope:this}]});MODx.window.QuickCreatePlugin.superclass.constructor.call(this,A);};Ext.extend(MODx.window.QuickCreatePlugin,MODx.Window);Ext.reg("modx-window-quick-create-plugin",MODx.window.QuickCreatePlugin);MODx.window.QuickUpdatePlugin=function(A){A=A||{};this.ident=A.ident||"qup"+Ext.id();Ext.applyIf(A,{title:_("quick_update_plugin"),id:this.ident,width:600,url:MODx.config.connectors_url+"element/plugin.php",action:"update",fields:[{xtype:"hidden",name:"id",id:"modx-"+this.ident+"-id"},{xtype:"textfield",name:"name",id:"modx-"+this.ident+"-name",fieldLabel:_("name"),anchor:"90%"},{xtype:"modx-combo-category",name:"category",fieldLabel:_("category"),id:"modx-"+this.ident+"-category",anchor:"90%"},{xtype:"textarea",name:"description",id:"modx-"+this.ident+"-description",fieldLabel:_("description"),anchor:"97%",rows:2},{xtype:"xcheckbox",name:"disabled",id:"modx-"+this.ident+"-disabled",fieldLabel:_("disabled"),inputValue:1,checked:false},{xtype:"xcheckbox",name:"clearCache",id:"modx-"+this.ident+"-clearcache",fieldLabel:_("clear_cache_on_save"),description:_("clear_cache_on_save_msg"),inputValue:1,checked:true},{xtype:"textarea",name:"plugincode",id:"modx-"+this.ident+"-plugincode",fieldLabel:_("code"),anchor:"97%",grow:true,growMax:380}],keys:[{key:Ext.EventObject.ENTER,shift:true,fn:this.submit,scope:this}],buttons:[{text:A.cancelBtnText||_("cancel"),scope:this,handler:function(){this.hide();}},{text:A.saveBtnText||_("save"),scope:this,handler:function(){this.submit(false);}},{text:A.saveBtnText||_("save_and_close"),scope:this,handler:this.submit}]});MODx.window.QuickUpdatePlugin.superclass.constructor.call(this,A);};Ext.extend(MODx.window.QuickUpdatePlugin,MODx.Window);Ext.reg("modx-window-quick-update-plugin",MODx.window.QuickUpdatePlugin);MODx.window.QuickCreateTV=function(A){A=A||{};this.ident=A.ident||"qctv"+Ext.id();Ext.applyIf(A,{title:_("quick_create_tv"),id:this.ident,width:600,url:MODx.config.connectors_url+"element/tv.php",action:"create",fields:[{xtype:"textfield",name:"name",id:"modx-"+this.ident+"-name",fieldLabel:_("name"),anchor:"90%"},{xtype:"textfield",name:"caption",id:"modx-"+this.ident+"-caption",fieldLabel:_("caption"),anchor:"90%"},{xtype:"modx-combo-category",name:"category",fieldLabel:_("category"),id:"modx-"+this.ident+"-category",anchor:"90%"},{xtype:"textarea",name:"description",id:"modx-"+this.ident+"-description",fieldLabel:_("description"),anchor:"97%",rows:2},{xtype:"modx-combo-tv-input-type",fieldLabel:_("tv_type"),name:"type",id:"modx-"+this.ident+"-type",anchor:"70%"},{xtype:"textfield",fieldLabel:_("tv_elements"),name:"els",id:"modx-"+this.ident+"-elements",anchor:"80%"},{xtype:"textarea",fieldLabel:_("tv_default"),name:"default_text",id:"modx-"+this.ident+"-default-text",anchor:"97%",grow:true,growMax:380}],keys:[{key:Ext.EventObject.ENTER,shift:true,fn:this.submit,scope:this}]});MODx.window.QuickCreateTV.superclass.constructor.call(this,A);};Ext.extend(MODx.window.QuickCreateTV,MODx.Window);Ext.reg("modx-window-quick-create-tv",MODx.window.QuickCreateTV);MODx.window.QuickUpdateTV=function(A){A=A||{};this.ident=A.ident||"qutv"+Ext.id();Ext.applyIf(A,{title:_("quick_update_tv"),id:this.ident,width:600,url:MODx.config.connectors_url+"element/tv.php",action:"update",fields:[{xtype:"hidden",name:"id",id:"modx-"+this.ident+"-id"},{xtype:"textfield",name:"name",id:"modx-"+this.ident+"-name",fieldLabel:_("name"),anchor:"90%"},{xtype:"textfield",name:"caption",id:"modx-"+this.ident+"-caption",fieldLabel:_("caption"),anchor:"90%"},{xtype:"modx-combo-category",name:"category",fieldLabel:_("category"),id:"modx-"+this.ident+"-category",anchor:"90%"},{xtype:"textarea",name:"description",id:"modx-"+this.ident+"-description",fieldLabel:_("description"),anchor:"97%",rows:2},{xtype:"xcheckbox",name:"clearCache",id:"modx-"+this.ident+"-clearcache",fieldLabel:_("clear_cache_on_save"),description:_("clear_cache_on_save_msg"),inputValue:1,checked:true},{xtype:"modx-combo-tv-input-type",fieldLabel:_("tv_type"),name:"type",id:"modx-"+this.ident+"-type",anchor:"70%"},{xtype:"textfield",fieldLabel:_("tv_elements"),name:"els",id:"modx-"+this.ident+"-elements",anchor:"80%"},{xtype:"textarea",fieldLabel:_("tv_default"),name:"default_text",id:"modx-"+this.ident+"-default-text",anchor:"97%",grow:true,growMax:380}],keys:[{key:Ext.EventObject.ENTER,shift:true,fn:this.submit,scope:this}],buttons:[{text:A.cancelBtnText||_("cancel"),scope:this,handler:function(){this.hide();}},{text:A.saveBtnText||_("save"),scope:this,handler:function(){this.submit(false);}},{text:A.saveBtnText||_("save_and_close"),scope:this,handler:this.submit}]});MODx.window.QuickUpdateTV.superclass.constructor.call(this,A);};Ext.extend(MODx.window.QuickUpdateTV,MODx.Window);Ext.reg("modx-window-quick-update-tv",MODx.window.QuickUpdateTV);MODx.window.DuplicateContext=function(A){A=A||{};this.ident=A.ident||"dupctx"+Ext.id();Ext.Ajax.timeout=0;Ext.applyIf(A,{title:_("context_duplicate"),id:this.ident,url:MODx.config.connectors_url+"context/index.php",action:"duplicate",width:400,fields:[{xtype:"statictextfield",id:"modx-"+this.ident+"-key",fieldLabel:_("old_key"),name:"key",anchor:"90%",submitValue:true},{xtype:"textfield",id:"modx-"+this.ident+"-newkey",fieldLabel:_("new_key"),name:"newkey",anchor:"90%",value:""}]});MODx.window.DuplicateContext.superclass.constructor.call(this,A);};Ext.extend(MODx.window.DuplicateContext,MODx.Window);Ext.reg("modx-window-context-duplicate",MODx.window.DuplicateContext);MODx.tree.Resource=function(A){A=A||{};Ext.applyIf(A,{url:MODx.config.connectors_url+"resource/index.php",title:"",rootVisible:false,expandFirst:true,enableDD:!Ext.isEmpty(MODx.config.enable_dragdrop)?true:false,ddGroup:"modx-treedrop-dd",remoteToolbar:true,sortBy:MODx.config.tree_default_sort||"menuindex",tbarCfg:{id:A.id?A.id+"-tbar":"modx-tree-resource-tbar"},baseParams:{action:"getNodes",sortBy:MODx.config.tree_default_sort||"menuindex",currentResource:MODx.request.id||0}});MODx.tree.Resource.superclass.constructor.call(this,A);this.getLoader().baseParams.sortBy=Ext.state.Manager.get(this.treestate_id+"-sort")||(MODx.config.tree_default_sort||"menuindex");this.on("render",function(){var B=Ext.get("modx-resource-tree");B.createChild({tag:"div",id:"modx-resource-tree_tb"});B.createChild({tag:"div",id:"modx-resource-tree_filter"});});this.addEvents("loadCreateMenus");this.on("afterSort",this._handleAfterDrop,this);};Ext.extend(MODx.tree.Resource,MODx.tree.Tree,{forms:{},windows:{},stores:{},_initExpand:function(){var A=Ext.state.Manager.get(this.treestate_id);if((Ext.isString(A)||Ext.isEmpty(A))&&this.root){if(this.root){this.root.expand();}var C=this.getNodeById("web_0");if(C&&this.config.expandFirst){C.select();C.expand();}}else{for(var B=0;B<A.length;B++){this.expandPath(A[B]);}}},_showContextMenu:function(C,B){C.select();this.cm.activeNode=C;this.cm.removeAll();if(C.attributes.menu&&C.attributes.menu.items){this.addContextMenuItem(C.attributes.menu.items);this.cm.show(C.getUI().getEl(),"t?");}else{var A=[];switch(C.attributes.type){case"modResource":A=this._getModResourceMenu(C);break;case"modContext":A=this._getModContextMenu(C);break;}this.addContextMenuItem(A);this.cm.showAt(B.xy);}B.stopEvent();},duplicateResource:function(D,E){var C=this.cm.activeNode;var F=C.id.split("_");F=F[1];var B={resource:F,is_folder:C.getUI().hasClass("folder")};var A=MODx.load({xtype:"modx-window-resource-duplicate",resource:F,hasChildren:C.attributes.hasChildren,listeners:{success:{fn:function(){this.refreshNode(C.id);},scope:this}}});A.config.hasChildren=C.attributes.hasChildren;A.setValues(B);A.show(E.target);},duplicateContext:function(E,D){var C=this.cm.activeNode;var A=C.attributes.pk;var B={key:A,newkey:""};if(!this.windows.duplicateContext){this.windows.duplicateContext=MODx.load({xtype:"modx-window-context-duplicate",record:B,listeners:{success:{fn:function(){this.refresh();},scope:this}}});}this.windows.duplicateContext.setValues(B);this.windows.duplicateContext.show(D.target);},removeContext:function(D,C){var B=this.cm.activeNode;var A=B.attributes.pk;MODx.msg.confirm({title:_("context_remove"),text:_("context_remove_confirm"),url:MODx.config.connectors_url+"context/index.php",params:{action:"remove",key:A},listeners:{success:{fn:function(){this.refresh();},scope:this}}});},preview:function(){window.open(this.cm.activeNode.attributes.preview_url);},deleteDocument:function(D,B){var A=this.cm.activeNode;var C=A.id.split("_");C=C[1];MODx.msg.confirm({title:_("resource_delete"),text:_("resource_delete_confirm"),url:MODx.config.connectors_url+"resource/index.php",params:{action:"delete",id:C},listeners:{success:{fn:function(){var F=this.cm.activeNode;var E=F.getUI();E.addClass("deleted");F.cascade(function(G){G.getUI().addClass("deleted");},this);Ext.get(E.getEl()).frame();},scope:this}}});},undeleteDocument:function(D,B){var A=this.cm.activeNode;var C=A.id.split("_");C=C[1];MODx.Ajax.request({url:MODx.config.connectors_url+"resource/index.php",params:{action:"undelete",id:C},listeners:{success:{fn:function(){var F=this.cm.activeNode;var E=F.getUI();E.removeClass("deleted");F.cascade(function(G){G.getUI().removeClass("deleted");},this);Ext.get(E.getEl()).frame();},scope:this}}});},publishDocument:function(D,B){var A=this.cm.activeNode;var C=A.id.split("_");C=C[1];MODx.msg.confirm({title:_("resource_publish"),text:_("resource_publish_confirm"),url:MODx.config.connectors_url+"resource/index.php",params:{action:"publish",id:C},listeners:{success:{fn:function(){var E=this.cm.activeNode.getUI();E.removeClass("unpublished");Ext.get(E.getEl()).frame();},scope:this}}});},unpublishDocument:function(D,B){var A=this.cm.activeNode;var C=A.id.split("_");C=C[1];MODx.msg.confirm({title:_("resource_unpublish"),text:_("resource_unpublish_confirm"),url:MODx.config.connectors_url+"resource/index.php",params:{action:"unpublish",id:C},listeners:{success:{fn:function(){var E=this.cm.activeNode.getUI();E.addClass("unpublished");Ext.get(E.getEl()).frame();},scope:this}}});},emptyRecycleBin:function(){MODx.msg.confirm({title:_("empty_recycle_bin"),text:_("empty_recycle_bin_confirm"),url:MODx.config.connectors_url+"resource/index.php",params:{action:"emptyRecycleBin"},listeners:{success:{fn:function(){Ext.select("div.deleted",this.getRootNode()).remove();MODx.msg.status({title:_("success"),message:_("empty_recycle_bin_emptied")});},scope:this}}});},showFilter:function(F,E){if(this._filterVisible){return false;}var C=Ext.get(this.config.id+"-tbar");var D=C.createChild({tag:"div",cls:"modx-formpanel",autoHeight:true});var B=new Ext.Toolbar({applyTo:D,autoHeight:true,width:"100%"});var A=new Ext.form.ComboBox({store:new Ext.data.SimpleStore({fields:["name","value"],data:[[_("menu_order"),"menuindex"],[_("page_title"),"pagetitle"],[_("publish_date"),"pub_date"],[_("createdon"),"createdon"],[_("editedon"),"editedon"],[_("publishedon"),"publishedon"]]}),displayField:"name",valueField:"value",editable:false,mode:"local",id:"modx-resource-tree-sortby",triggerAction:"all",selectOnFocus:false,width:100,value:this.config.sortBy||(Ext.state.Manager.get(this.treestate_id+"-sort")||MODx.config.tree_default_sort),listeners:{select:{fn:this.filterSort,scope:this}}});B.add(_("sort_by")+":");B.addField(A);B.add("-",{scope:this,cls:"x-btn-text",text:_("close"),handler:this.hideFilter});B.doLayout();this.filterBar=B;this._filterVisible=true;return true;},filterSort:function(A,C,B){Ext.state.Manager.set(this.treestate_id+"-sort",A.getValue());this.config.sortBy=A.getValue();this.getLoader().baseParams={action:this.config.action,sortBy:this.config.sortBy};this.refresh();},hideFilter:function(B,A){this.filterBar.destroy();this._filterVisible=false;},_handleAfterDrop:function(D,A){var C=D.event.target;if(D.event.point=="append"&&C){var B=C.getUI();B.addClass("haschildren");B.removeClass("icon-resource");}},_handleDrop:function(D){var A=D.dropNode;var C=D.target;if(C.findChild("id",A.attributes.id)!==null){return false;}var B=true;if(C.attributes.type=="context"&&D.point!="append"){B=false;}return A.attributes.text!="root"&&A.attributes.text!==""&&C.attributes.text!="root"&&C.attributes.text!==""&&B;},quickCreate:function(G,F,C,B,E){C=C||"modResource";var D={class_key:C,context_key:B||"web",parent:E||0};var A=MODx.load({xtype:"modx-window-quick-create-modResource",record:D,listeners:{success:{fn:function(){var H=this.getNodeById(this.cm.activeNode.id);if(H){var I=H.parentNode?H.parentNode:H;this.getLoader().load(I,function(){I.expand();},this);}},scope:this},hide:{fn:function(){this.destroy();}},show:{fn:function(){this.center();}}}});A.setValues(D);A.show(F.target,function(){Ext.isSafari?A.setPosition(null,30):A.center();},this);},quickUpdate:function(C,B,A){MODx.Ajax.request({url:MODx.config.connectors_url+"resource/index.php",params:{action:"get",id:this.cm.activeNode.attributes.pk},listeners:{success:{fn:function(E){var F=E.object;F.class_key=A;var D=MODx.load({xtype:"modx-window-quick-update-modResource",record:F,listeners:{success:{fn:function(){this.refreshNode(this.cm.activeNode.id);},scope:this},hide:{fn:function(){this.destroy();}}}});D.setValues(E.object);D.show(B.target,function(){Ext.isSafari?D.setPosition(null,30):D.center();},this);},scope:this}}});},_getModContextMenu:function(D){var B=D.attributes;var C=D.getUI();var A=[];A.push({text:"<b>"+B.text+"</b>",handler:function(){return false;},header:true});A.push("-");if(C.hasClass("pedit")){A.push({text:_("edit_context"),handler:function(){var E=this.cm.activeNode.attributes;this.loadAction("a="+MODx.action["context/update"]+"&key="+E.pk);}});}A.push({text:_("context_refresh"),handler:function(){this.refreshNode(this.cm.activeNode.id,true);}});if(C.hasClass("pnewdoc")){A.push("-");this._getCreateMenus(A,"0",C);}if(C.hasClass("pnew")){A.push({text:_("context_duplicate"),handler:this.duplicateContext});}if(C.hasClass("pdelete")){A.push("-");A.push({text:_("context_remove"),handler:this.removeContext});}return A;},_getModResourceMenu:function(D){var B=D.attributes;var C=D.getUI();var A=[];A.push({text:"<b>"+B.text+"</b>",handler:function(){return false;},header:true});A.push("-");if(C.hasClass("pview")){A.push({text:_("resource_overview"),handler:function(){this.loadAction("a="+MODx.action["resource/data"]);}});}if(C.hasClass("pedit")){A.push({text:_("resource_edit"),handler:function(){this.loadAction("a="+MODx.action["resource/update"]);}});}if(C.hasClass("pqupdate")){A.push({text:_("quick_update_resource"),classKey:B.classKey,handler:function(F,E){Ext.getCmp("modx-resource-tree").quickUpdate(F,E,F.classKey);}});}if(C.hasClass("pnew")){A.push({text:_("resource_duplicate"),handler:this.duplicateResource});}A.push({text:_("resource_refresh"),handler:function(){this.refreshNode(this.cm.activeNode.id);},scope:this});if(C.hasClass("pnew")){A.push("-");this._getCreateMenus(A,null,C);}if(C.hasClass("psave")){A.push("-");if(C.hasClass("ppublish")&&C.hasClass("unpublished")){A.push({text:_("resource_publish"),handler:this.publishDocument});}else{if(C.hasClass("punpublish")){A.push({text:_("resource_unpublish"),handler:this.unpublishDocument});}}if(C.hasClass("pundelete")&&C.hasClass("deleted")){A.push({text:_("resource_undelete"),handler:this.undeleteDocument});}else{if(C.hasClass("pdelete")&&!C.hasClass("deleted")){A.push({text:_("resource_delete"),handler:this.deleteDocument});}}}if(C.hasClass("pview")){A.push("-");A.push({text:_("resource_view"),handler:this.preview});}return A;},_getCreateMenus:function(C,E,I){var H=MODx.resourceTypes||{document:"modDocument",weblink:"modWebLink",symlink:"modSymLink",static_resource:"modStaticResource"};if(MODx.config.custom_resource_classes){var G=MODx.config.custom_resource_classes;if(!Ext.isEmpty(G)){for(var D in G){H[D]=G[D];}}}var B=this.fireEvent("loadCreateMenus",H);if(Ext.isObject(B)){Ext.apply(H,B);}var F=[];var A=[];for(var D in H){F.push({text:_(D+"_create_here"),classKey:H[D],usePk:E?E:false,handler:function(L){var J=this.cm.activeNode.attributes;var K=L.usePk?L.usePk:J.pk;Ext.getCmp("modx-resource-tree").loadAction("a="+MODx.action["resource/create"]+"&class_key="+L.classKey+"&parent="+K+(J.ctx?"&context_key="+J.ctx:""));},scope:this});if(I&&I.hasClass("pqcreate")){A.push({text:_(D),classKey:H[D],handler:function(M,L){var J=this.cm.activeNode.attributes;var K=M.usePk?M.usePk:J.pk;Ext.getCmp("modx-resource-tree").quickCreate(M,L,M.classKey,J.ctx,K);},scope:this});}}C.push({text:_("create"),handler:function(){return false;},menu:{items:F}});if(I&&I.hasClass("pqcreate")){C.push({text:_("quick_create"),handler:function(){return false;},menu:{items:A}});}return C;}});Ext.reg("modx-tree-resource",MODx.tree.Resource);MODx.window.QuickCreateResource=function(A){A=A||{};this.ident=A.ident||"qcr"+Ext.id();Ext.applyIf(A,{title:_("quick_create_resource"),id:this.ident,width:620,url:MODx.config.connectors_url+"resource/index.php",action:"create",shadow:false,fields:[{xtype:"modx-tabs",bodyStyle:{background:"transparent"},deferredRender:false,autoHeight:true,items:[{title:_("resource"),layout:"form",cls:"modx-panel",bodyStyle:{background:"transparent",padding:"10px"},autoHeight:true,labelWidth:100,items:[{xtype:"modx-combo-template",name:"template",id:"modx-"+this.ident+"-template",fieldLabel:_("template"),editable:false,anchor:"100%",baseParams:{action:"getList",combo:"1"},value:MODx.config.default_template},{xtype:"textfield",name:"pagetitle",id:"modx-"+this.ident+"-pagetitle",fieldLabel:_("pagetitle"),anchor:"100%"},{xtype:"textfield",name:"longtitle",id:"modx-"+this.ident+"-longtitle",fieldLabel:_("long_title"),anchor:"100%"},{xtype:"textarea",name:"description",id:"modx-"+this.ident+"-description",fieldLabel:_("description"),anchor:"100%",grow:false,height:50},{xtype:"textfield",name:"alias",id:"modx-"+this.ident+"-alias",fieldLabel:_("alias"),anchor:"100%"},{xtype:"textarea",name:"introtext",id:"modx-"+this.ident+"-introtext",fieldLabel:_("introtext"),anchor:"100%",height:50},{xtype:"textfield",name:"menutitle",id:"modx-"+this.ident+"-menutitle",fieldLabel:_("resource_menutitle"),anchor:"100%"},MODx.getQRContentField(this.ident,A.record.class_key)]},{id:"modx-"+this.ident+"-settings",title:_("settings"),layout:"form",cls:"modx-panel",autoHeight:true,forceLayout:true,labelWidth:100,defaults:{autoHeight:true,border:false},style:"background: transparent;",bodyStyle:{background:"transparent",padding:"10px"},items:MODx.getQRSettings(this.ident,A.record)}]}],keys:[{key:Ext.EventObject.ENTER,shift:true,fn:this.submit,scope:this}]});MODx.window.QuickCreateResource.superclass.constructor.call(this,A);};Ext.extend(MODx.window.QuickCreateResource,MODx.Window);Ext.reg("modx-window-quick-create-modResource",MODx.window.QuickCreateResource);MODx.window.QuickUpdateResource=function(A){A=A||{};this.ident=A.ident||"qur"+Ext.id();Ext.applyIf(A,{title:_("quick_update_resource"),id:this.ident,width:620,url:MODx.config.connectors_url+"resource/index.php",action:"update",autoHeight:true,shadow:false,fields:[{xtype:"modx-tabs",bodyStyle:{background:"transparent"},autoHeight:true,deferredRender:false,items:[{title:_("resource"),layout:"form",cls:"modx-panel",bodyStyle:{background:"transparent",padding:"10px"},autoHeight:true,labelWidth:100,items:[{xtype:"hidden",name:"id",id:"modx-"+this.ident+"-id"},{xtype:"modx-combo-template",name:"template",id:"modx-"+this.ident+"-template",fieldLabel:_("template"),editable:false,anchor:"100%",baseParams:{action:"getList",combo:"1"}},{xtype:"textfield",name:"pagetitle",id:"modx-"+this.ident+"-pagetitle",fieldLabel:_("pagetitle"),anchor:"100%"},{xtype:"textfield",name:"longtitle",id:"modx-"+this.ident+"-longtitle",fieldLabel:_("long_title"),anchor:"100%"},{xtype:"textarea",name:"description",id:"modx-"+this.ident+"-description",fieldLabel:_("description"),anchor:"100%",grow:false,height:50},{xtype:"textfield",name:"alias",id:"modx-"+this.ident+"-alias",fieldLabel:_("alias"),anchor:"100%"},{xtype:"textfield",name:"menutitle",id:"modx-"+this.ident+"-menutitle",fieldLabel:_("resource_menutitle"),anchor:"100%"},{xtype:"textarea",name:"introtext",id:"modx-"+this.ident+"-introtext",fieldLabel:_("introtext"),anchor:"100%",height:50},MODx.getQRContentField(this.ident,A.record.class_key)]},{id:"modx-"+this.ident+"-settings",title:_("settings"),layout:"form",cls:"modx-panel",autoHeight:true,forceLayout:true,labelWidth:100,defaults:{autoHeight:true,border:false},style:"background: transparent;",bodyStyle:{background:"transparent",padding:"10px"},items:MODx.getQRSettings(this.ident,A.record)}]}],keys:[{key:Ext.EventObject.ENTER,shift:true,fn:this.submit,scope:this}],buttons:[{text:A.cancelBtnText||_("cancel"),scope:this,handler:function(){this.hide();}},{text:A.saveBtnText||_("save"),scope:this,handler:function(){this.submit(false);}},{text:A.saveBtnText||_("save_and_close"),scope:this,handler:this.submit}]});MODx.window.QuickUpdateResource.superclass.constructor.call(this,A);};Ext.extend(MODx.window.QuickUpdateResource,MODx.Window);Ext.reg("modx-window-quick-update-modResource",MODx.window.QuickUpdateResource);MODx.getQRContentField=function(C,A){C=C||"qur";A=A||"modResource";var B={};switch(A){case"modSymLink":B={xtype:"textfield",fieldLabel:_("symlink"),name:"content",id:"modx-"+C+"-content",anchor:"100%",maxLength:255,allowBlank:false};break;case"modWebLink":B={xtype:"textfield",fieldLabel:_("weblink"),name:"content",id:"modx-"+C+"-content",anchor:"100%",maxLength:255,value:"http://",allowBlank:false};break;case"modStaticResource":B={xtype:"modx-combo-browser",browserEl:"modx-browser",prependPath:false,prependUrl:false,hideFiles:true,fieldLabel:_("static_resource"),name:"content",id:"modx-"+C+"-content",anchor:"100%",maxLength:255,value:"",listeners:{select:{fn:function(D){if(D.url.substring(0,1)=="/"){Ext.getCmp("modx-"+C+"-content").setValue(D.url.substring(1));}},scope:this}}};break;case"modResource":default:B={xtype:"textarea",name:"content",id:"modx-"+C+"-content",hideLabel:true,labelSeparator:"",anchor:"100%",height:300};break;}return B;};MODx.getQRSettings=function(B,A){B=B||"qur";return[{xtype:"hidden",name:"parent",id:"modx-"+B+"-parent",value:A.parent},{xtype:"hidden",name:"context_key",id:"modx-"+B+"-context_key",value:A.context_key},{xtype:"hidden",name:"class_key",id:"modx-"+B+"-class_key",value:A.class_key},{xtype:"hidden",name:"publishedon",id:"modx-"+B+"-publishedon",value:A.publishedon},{xtype:"xcheckbox",name:"published",id:"modx-"+B+"-published",fieldLabel:_("resource_published"),description:_("resource_published_help"),inputValue:1,checked:A.published!==undefined?A.published:(MODx.config.publish_default=="1"?1:0)},{xtype:"xcheckbox",fieldLabel:_("resource_folder"),description:_("resource_folder_help"),name:"isfolder",id:"modx-"+B+"-isfolder",inputValue:1,checked:A.isfolder!=undefined?A.isfolder:false},{xtype:"xcheckbox",fieldLabel:_("resource_richtext"),description:_("resource_richtext_help"),name:"richtext",id:"modx-"+B+"-richtext",inputValue:1,checked:A.richtext!==undefined?(A.richtext?1:0):(MODx.config.richtext_default=="1"?1:0)},{xtype:"xcheckbox",fieldLabel:_("resource_searchable"),description:_("resource_searchable_help"),name:"searchable",id:"modx-"+B+"-searchable",inputValue:1,checked:A.searchable!=undefined?A.searchable:(MODx.config.search_default=="1"?1:0),listeners:{check:{fn:MODx.handleQUCB}}},{xtype:"xcheckbox",fieldLabel:_("resource_hide_from_menus"),description:_("resource_hide_from_menus_help"),name:"hidemenu",id:"modx-"+B+"-hidemenu",inputValue:1,checked:A.hidemenu!=undefined?A.hidemenu:(MODx.config.hidemenu_default=="1"?1:0)},{xtype:"xcheckbox",fieldLabel:_("resource_cacheable"),description:_("resource_cacheable_help"),name:"cacheable",id:"modx-"+B+"-cacheable",inputValue:1,checked:A.cacheable!=undefined?A.cacheable:(MODx.config.cache_default=="1"?1:0)},{xtype:"xcheckbox",name:"clearCache",id:"modx-"+B+"-clearcache",fieldLabel:_("clear_cache_on_save"),description:_("clear_cache_on_save_msg"),inputValue:1,checked:true},{xtype:"modx-combo-content-type",fieldLabel:_("resource_content_type"),name:"content_type",hiddenName:"content_type",id:"modx-"+this.ident+"-type",anchor:"70%",value:A.content_type!=undefined?A.content_type:1},{xtype:"modx-combo-content-disposition",fieldLabel:_("resource_contentdispo"),name:"content_dispo",hiddenName:"content_dispo",id:"modx-"+this.ident+"-dispo",anchor:"70%",value:A.content_dispo!=undefined?A.content_dispo:0}];};MODx.handleQUCB=function(A){var B=Ext.getCmp(A.id+"-hd");if(A.checked&&B){A.setValue(1);B.setValue(1);}else{if(B){A.setValue(0);B.setValue(0);}}};MODx.tree.Element=function(A){A=A||{};Ext.applyIf(A,{rootVisible:false,enableDD:!Ext.isEmpty(MODx.config.enable_dragdrop)?true:false,ddGroup:"modx-treedrop-dd",title:"",url:MODx.config.connectors_url+"element/index.php",useDefaultToolbar:true,tbar:[{icon:MODx.config.template_url+"images/restyle/icons/template.png",cls:"x-btn-icon",tooltip:{text:_("new")+" "+_("template")},handler:function(){this.redirect("index.php?a="+MODx.action["element/template/create"]);},scope:this,hidden:MODx.perm.new_template?false:true},{icon:MODx.config.template_url+"images/restyle/icons/tv.png",cls:"x-btn-icon",tooltip:{text:_("new")+" "+_("tv")},handler:function(){this.redirect("index.php?a="+MODx.action["element/tv/create"]);},scope:this,hidden:MODx.perm.new_tv?false:true},{icon:MODx.config.template_url+"images/restyle/icons/chunk.png",cls:"x-btn-icon",tooltip:{text:_("new")+" "+_("chunk")},handler:function(){this.redirect("index.php?a="+MODx.action["element/chunk/create"]);},scope:this,hidden:MODx.perm.new_chunk?false:true},{icon:MODx.config.template_url+"images/restyle/icons/snippet.png",cls:"x-btn-icon",tooltip:{text:_("new")+" "+_("snippet")},handler:function(){this.redirect("index.php?a="+MODx.action["element/snippet/create"]);},scope:this,hidden:MODx.perm.new_snippet?false:true},{icon:MODx.config.template_url+"images/restyle/icons/plugin.png",cls:"x-btn-icon",tooltip:{text:_("new")+" "+_("plugin")},handler:function(){this.redirect("index.php?a="+MODx.action["element/plugin/create"]);},scope:this,hidden:MODx.perm.new_plugin?false:true}]});MODx.tree.Element.superclass.constructor.call(this,A);this.on("afterSort",this.afterSort);};Ext.extend(MODx.tree.Element,MODx.tree.Tree,{forms:{},windows:{},stores:{},createCategory:function(C,B){var A={};if(this.cm.activeNode.attributes.data){A.parent=this.cm.activeNode.attributes.data.id;}if(!this.windows.createCategory){this.windows.createCategory=MODx.load({xtype:"modx-window-category-create",record:A,listeners:{success:{fn:function(){this.refreshNode(this.cm.activeNode.id,true);},scope:this}}});}this.windows.createCategory.reset();this.windows.createCategory.setValues(A);this.windows.createCategory.show(B.target);},renameCategory:function(C,B){var A=this.cm.activeNode.attributes.data;if(!this.windows.renameCategory){this.windows.renameCategory=MODx.load({xtype:"modx-window-category-rename",record:A,listeners:{success:{fn:function(D){var F=D.a.result.object;var E=this.cm.activeNode;E.setText(F.category+" ("+F.id+")");Ext.get(E.getUI().getEl()).frame();E.attributes.data.id=F.id;E.attributes.data.category=F.category;},scope:this}}});}this.windows.renameCategory.setValues(A);this.windows.renameCategory.show(B.target);},removeCategory:function(C,A){var B=this.cm.activeNode.attributes.data.id;MODx.msg.confirm({title:_("warning"),text:_("category_confirm_delete"),url:MODx.config.connectors_url+"element/category.php",params:{action:"remove",id:B},listeners:{success:{fn:function(){this.cm.activeNode.remove();},scope:this}}});},duplicateElement:function(H,E,G,C){var D={id:G,type:C,name:_("duplicate_of",{name:this.cm.activeNode.attributes.name})};if(!this.windows.duplicateElement){this.windows.duplicateElement=MODx.load({xtype:"modx-window-element-duplicate",record:D,listeners:{success:{fn:function(){this.refreshNode(this.cm.activeNode.id);},scope:this}}});}else{var A=MODx.config.connectors_url+"element/"+C+".php";this.windows.duplicateElement.fp.getForm().url=A;var B=this.windows.duplicateElement.fp.getForm().findField("duplicateValues");if(B){if(C!="tv"){B.hide();var F=B.getEl().up(".x-form-item");if(F){F.setDisplayed(false);}}else{B.show();var F=B.getEl().up(".x-form-item");if(F){F.setDisplayed(true);}}}}this.windows.duplicateElement.setValues(D);this.windows.duplicateElement.show(E.target);},removeElement:function(D,A){var C=this.cm.activeNode.id.substr(2);var B=C.split("_");MODx.msg.confirm({title:_("warning"),text:_("remove_this_confirm",{type:B[0],name:this.cm.activeNode.attributes.name}),url:MODx.config.connectors_url+"element/"+B[0]+".php",params:{action:"remove",id:B[2]},listeners:{success:{fn:function(){this.cm.activeNode.remove();},scope:this}}});},quickCreate:function(E,D,B){var C={category:this.cm.activeNode.attributes.pk||""};var A=MODx.load({xtype:"modx-window-quick-create-"+B,record:C,listeners:{success:{fn:function(){this.refreshNode(this.cm.activeNode.id);},scope:this}}});A.setValues(C);A.show(D.target);A.on("hide",function(){delete A;},this);},quickUpdate:function(C,B,A){MODx.Ajax.request({url:MODx.config.connectors_url+"element/"+A+".php",params:{action:"get",id:this.cm.activeNode.attributes.pk},listeners:{success:{fn:function(E){var D=MODx.load({xtype:"modx-window-quick-update-"+A,record:E.object,listeners:{success:{fn:function(F){this.refreshNode(this.cm.activeNode.id);},scope:this}}});D.setValues(E.object);D.show(B.target);},scope:this}}});},_createElement:function(G,C,B){var F=this.cm.activeNode.id.substr(2);var E=F.split("_");var B=E[0]=="type"?E[1]:E[0];var D=E[0]=="type"?0:(E[1]=="category"?E[2]:E[3]);var A=MODx.action["element/"+B+"/create"];this.redirect("index.php?a="+A+"&category="+D);this.cm.hide();return false;},afterSort:function(C){var A=C.event.target.attributes;if(A.type=="category"){var B=C.event.dropNode.attributes;if(A.id!="n_category"&&B.type=="category"){C.event.target.expand();}else{this.refreshNode(C.event.target.attributes.id,true);this.refreshNode("n_type_"+C.event.dropNode.attributes.type,true);}}},_handleDrop:function(B){var A=B.target;if(B.point=="above"||B.point=="below"){return false;}if(A.attributes.classKey!="modCategory"&&A.attributes.classKey!="root"){return false;}if(!this.isCorrectType(B.dropNode,A)){return false;}if(A.attributes.type=="category"&&B.point=="append"){return true;}return A.getDepth()>0;},isCorrectType:function(A,C){var B=false;if(C.attributes.type==A.attributes.type){if(!(C.parentNode&&((A.attributes.cls=="folder"&&C.attributes.cls=="folder"&&A.parentNode.id==C.parentNode.id)||C.attributes.cls=="file"))){B=true;}}return B;},_showContextMenu:function(C,B){C.select();this.cm.activeNode=C;this.cm.removeAll();if(C.attributes.menu&&C.attributes.menu.items){this.addContextMenuItem(C.attributes.menu.items);this.cm.show(C.getUI().getEl(),"t?");}else{var A=[];switch(C.attributes.classKey){case"root":A=this._getRootMenu(C);break;case"modCategory":A=this._getCategoryMenu(C);break;default:A=this._getElementMenu(C);break;}this.addContextMenuItem(A);this.cm.showAt(B.xy);}B.stopEvent();},_getQuickCreateMenu:function(G,A){var E=G.getUI();var F=[];var D=["template","tv","chunk","snippet","plugin"];var C;for(var B=0;B<D.length;B++){C=D[B];if(E.hasClass("pnew_"+C)){F.push({text:_(C),scope:this,type:C,handler:function(I,H){this.quickCreate(I,H,I.type);}});}}A.push({text:_("quick_create"),handler:function(){return false;},menu:{items:F}});return A;},_getElementMenu:function(D){var B=D.attributes;var C=D.getUI();var A=[];A.push({text:"<b>"+B.text+"</b>",handler:function(){return false;},header:true});A.push("-");if(C.hasClass("pedit")){A.push({text:_("edit")+" "+B.elementType,type:B.type,pk:B.pk,handler:function(F,E){location.href="index.php?a="+MODx.action["element/"+F.type+"/update"]+"&id="+F.pk;}});A.push({text:_("quick_update_"+B.type),type:B.type,handler:function(F,E){this.quickUpdate(F,E,F.type);}});}if(C.hasClass("pnew")){A.push({text:_("duplicate")+" "+B.elementType,pk:B.pk,type:B.type,handler:function(F,E){this.duplicateElement(F,E,F.pk,F.type);}});}if(C.hasClass("pdelete")){A.push({text:_("remove")+" "+B.elementType,handler:this.removeElement});}A.push("-");if(C.hasClass("pnew")){A.push({text:_("add_to_category_this",{type:B.elementType}),handler:this._createElement});}if(C.hasClass("pnewcat")){A.push({text:_("new_category"),handler:this.createCategory});}return A;},_getCategoryMenu:function(D){var B=D.attributes;var C=D.getUI();var A=[];A.push({text:"<b>"+B.text+"</b>",handler:function(){return false;},header:true});A.push("-");if(C.hasClass("pnewcat")){A.push({text:_("category_create"),handler:this.createCategory});}if(C.hasClass("peditcat")){A.push({text:_("category_rename"),handler:this.renameCategory});}if(A.length>2){A.push("-");}if(B.elementType){A.push({text:_("add_to_category_this",{type:Ext.util.Format.capitalize(B.type)}),handler:this._createElement});}this._getQuickCreateMenu(D,A);if(C.hasClass("pdelcat")){A.push("-");A.push({text:_("category_remove"),handler:this.removeCategory});}return A;},_getRootMenu:function(D){var B=D.attributes;var C=D.getUI();var A=[];if(C.hasClass("pnew")){A.push({text:_("new_"+B.type),handler:this._createElement});A.push({text:_("quick_create_"+B.type),type:B.type,handler:function(F,E){this.quickCreate(F,E,F.type);}});}if(C.hasClass("pnewcat")){if(C.hasClass("pnew")){A.push("-");}A.push({text:_("new_category"),handler:this.createCategory});}return A;}});Ext.reg("modx-tree-element",MODx.tree.Element);MODx.window.DuplicateElement=function(A){A=A||{};this.ident=A.ident||"dupeel-"+Ext.id();var B=[{xtype:"hidden",name:"id",id:"modx-"+this.ident+"-id"},{xtype:"textfield",fieldLabel:_("element_name_new"),name:"name",id:"modx-"+this.ident+"-name",anchor:"90%"}];if(A.record.type=="tv"){B.push({xtype:"xcheckbox",fieldLabel:_("element_duplicate_values"),labelSeparator:"",name:"duplicateValues",id:"modx-"+this.ident+"-duplicate-values",anchor:"95%",inputValue:1,checked:false});}Ext.applyIf(A,{title:_("element_duplicate"),url:MODx.config.connectors_url+"element/"+A.record.type+".php",action:"duplicate",fields:B,labelWidth:150});MODx.window.DuplicateElement.superclass.constructor.call(this,A);};Ext.extend(MODx.window.DuplicateElement,MODx.Window);Ext.reg("modx-window-element-duplicate",MODx.window.DuplicateElement);MODx.window.RenameCategory=function(A){A=A||{};this.ident=A.ident||"rencat-"+Ext.id();Ext.applyIf(A,{title:_("category_rename"),height:150,width:350,url:MODx.config.connectors_url+"element/category.php",action:"update",fields:[{xtype:"hidden",name:"id",id:"modx-"+this.ident+"-id",value:A.record.id},{xtype:"textfield",fieldLabel:_("name"),name:"category",id:"modx-"+this.ident+"-category",width:150,value:A.record.category,anchor:"90%"}]});MODx.window.RenameCategory.superclass.constructor.call(this,A);};Ext.extend(MODx.window.RenameCategory,MODx.Window);Ext.reg("modx-window-category-rename",MODx.window.RenameCategory);MODx.tree.Directory=function(A){A=A||{};Ext.applyIf(A,{rootVisible:true,rootName:_("files"),rootId:"/",title:_("files"),ddAppendOnly:true,enableDrag:true,enableDrop:true,ddGroup:"modx-treedrop-dd",url:MODx.config.connectors_url+"browser/directory.php",baseParams:{prependPath:A.prependPath||null,basePath:A.basePath||"",basePathRelative:A.basePathRelative||null,baseUrl:A.baseUrl||"",baseUrlRelative:A.baseUrlRelative||null,hideFiles:A.hideFiles||false,wctx:MODx.ctx||"web"},action:"getList",primaryKey:"dir",useDefaultToolbar:true,tbar:[{icon:MODx.config.template_url+"images/restyle/icons/folder.png",cls:"x-btn-icon",tooltip:{text:_("file_folder_create")},handler:this.createDirectory,scope:this,hidden:MODx.perm.directory_create?false:true},{icon:MODx.config.template_url+"images/restyle/icons/file_upload.png",cls:"x-btn-icon",tooltip:{text:_("upload_files")},handler:this.uploadFiles,scope:this,hidden:MODx.perm.file_upload?false:true},"->",{icon:MODx.config.template_url+"images/restyle/icons/file_manager.png",cls:"x-btn-icon",tooltip:{text:_("modx_browser")},handler:this.loadFileManager,scope:this,hidden:MODx.perm.file_manager&&!MODx.browserOpen?false:true}]});MODx.tree.Directory.superclass.constructor.call(this,A);this.addEvents({beforeUpload:true,afterUpload:true,fileBrowserSelect:true});this.on("click",function(C,B){C.select();this.cm.activeNode=C;},this);};Ext.extend(MODx.tree.Directory,MODx.tree.Tree,{windows:{},_initExpand:function(){if(!Ext.isEmpty(this.config.openTo)){var A=Ext.state.Manager.get(this.treestate_id);this.selectPath("/"+_("files")+"/"+this.config.openTo,"text");}else{var A=Ext.state.Manager.get(this.treestate_id);this.selectPath(A,"text");}},_saveState:function(B){var A=B.getPath("text");Ext.state.Manager.set(this.treestate_id,A);},_handleDrop:function(A){return false;},_showContextMenu:function(C,B){C.select();this.cm.activeNode=C;this.cm.removeAll();if(C.attributes.menu&&C.attributes.menu.items){this.addContextMenuItem(C.attributes.menu.items);this.cm.show(C.getUI().getEl(),"t?");}else{var A=[];switch(C.attributes.type){case"dir":A=this._getDirectoryMenu(C);break;default:A=this._getFileMenu(C);break;}if(A.length>0){this.addContextMenuItem(A);this.cm.showAt(B.xy);}}B.stopEvent();},_getFileMenu:function(D){var B=D.attributes;var C=D.getUI();var A=[];if(C.hasClass("pupdate")){if(B.page){A.push({text:_("file_edit"),file:B.file,handler:function(F,E){this.loadAction("a="+MODx.action["system/file/edit"]+"&file="+F.file);}});}A.push({text:_("rename"),handler:this.renameFile});}if(C.hasClass("premove")){if(A.length>0){A.push("-");}A.push({text:_("file_remove"),handler:this.removeFile});}return A;},_getDirectoryMenu:function(C){var B=C.getUI();var A=[];if(B.hasClass("pcreate")){A.push({text:_("file_folder_create_here"),handler:this.createDirectory});}if(B.hasClass("pchmod")){A.push({text:_("file_folder_chmod"),handler:this.chmodDirectory});}if(B.hasClass("pupdate")){A.push({text:_("rename"),handler:this.renameFile});}A.push({text:_("directory_refresh"),handler:this.refreshActiveNode});if(B.hasClass("pupload")){A.push("-");A.push({text:_("upload_files"),handler:this.uploadFiles});}if(B.hasClass("premove")){A.push("-");A.push({text:_("file_folder_remove"),handler:this.removeDirectory});}return A;},getPath:function(B){var D,C,A;if(B!==this.root){C=B.parentNode;A=[B.text];while(C&&C!==this.root){A.unshift(C.text);C=C.parentNode;}A.unshift(this.root.attributes.path||"");D=A.join(this.pathSeparator);}else{D=B.attributes.path||"";}D=D.replace(/^[\/\.]*/,"");return D+"/";},browser:null,loadFileManager:function(A,B){if(this.browser===null){this.browser=MODx.load({xtype:"modx-browser",hideFiles:true,rootVisible:false,wctx:MODx.ctx,listeners:{select:{fn:function(C){this.fireEvent("fileBrowserSelect",C);},scope:this}}});}if(this.browser){this.browser.show();}},renameNode:function(C,A,B){MODx.Ajax.request({url:MODx.config.connectors_url+"browser/index.php",params:{action:"rename",new_name:A,old_name:B,prependPath:this.config.prependPath||null,file:this.treeEditor.editNode.id,wctx:MODx.ctx||""},listeners:{success:{fn:this.refreshActiveNode,scope:this}}});},renameFile:function(C,D){var B=this.cm.activeNode;var A={oldname:B.text,newname:B.text,path:B.id};if(!this.windows.rename){this.windows.rename=MODx.load({xtype:"modx-window-file-rename",record:A,listeners:{success:{fn:this.refreshParentNode,scope:this}}});}this.windows.rename.setValues(A);this.windows.rename.show(D.target);},createDirectory:function(C,D){var B=this.cm&&this.cm.activeNode?this.cm.activeNode:false;var A={parent:B&&B.attributes.type=="dir"?B.id:"/"};if(!this.windows.create){this.windows.create=MODx.load({xtype:"modx-window-directory-create",record:A,prependPath:this.config.prependPath||null,listeners:{success:{fn:this.refreshActiveNode,scope:this}}});}this.windows.create.setValues(A);this.windows.create.show(D?D.target:Ext.getBody());},chmodDirectory:function(C,D){var B=this.cm.activeNode;var A={dir:B.id,mode:B.attributes.perms};if(!this.windows.chmod){this.windows.chmod=MODx.load({xtype:"modx-window-directory-chmod",record:A,prependPath:this.config.prependPath||null,listeners:{success:{fn:this.refreshActiveNode,scope:this}}});}this.windows.chmod.setValues(A);this.windows.chmod.show(D.target);},removeDirectory:function(B,C){var A=this.cm.activeNode;MODx.msg.confirm({text:_("file_folder_remove_confirm"),url:MODx.config.connectors_url+"browser/directory.php",params:{action:"remove",dir:A.id,prependPath:this.config.prependPath||null,wctx:MODx.ctx||""},listeners:{success:{fn:this.refreshParentNode,scope:this}}});},removeFile:function(B,C){var A=this.cm.activeNode;MODx.msg.confirm({text:_("file_confirm_remove"),url:MODx.config.connectors_url+"browser/file.php",params:{action:"remove",file:A.id,prependPath:this.config.prependPath||null,wctx:MODx.ctx||""},listeners:{success:{fn:this.refreshParentNode,scope:this}}});},uploadFiles:function(A,B){if(!this.uploader){this.uploader=new Ext.ux.UploadDialog.Dialog({url:MODx.config.connectors_url+"browser/file.php",base_params:{action:"upload",prependPath:this.config.prependPath||null,prependUrl:this.config.prependUrl||null,basePath:this.config.basePath||"",basePathRelative:this.config.basePathRelative||null,baseUrl:this.config.baseUrl||"",baseUrlRelative:this.config.baseUrlRelative||null,wctx:MODx.ctx||""},reset_on_hide:true,width:550,cls:"ext-ux-uploaddialog-dialog modx-upload-window"});this.uploader.on("show",this.beforeUpload,this);this.uploader.on("uploadsuccess",this.uploadSuccess,this);this.uploader.on("uploaderror",this.uploadError,this);this.uploader.on("uploadfailed",this.uploadFailed,this);}this.uploader.show(A);},uploadError:function(D,A,B,C){},uploadFailed:function(C,A,B){},uploadSuccess:function(){if(this.cm.activeNode){var B=this.cm.activeNode;if(B.isLeaf){var A=(B.isLeaf()?B.parentNode:B);if(A){A.reload();}else{this.refreshActiveNode();}this.fireEvent("afterUpload",B);}else{this.refreshActiveNode();}}else{this.refresh();}},beforeUpload:function(){var A;if(this.cm.activeNode){A=this.getPath(this.cm.activeNode);if(this.cm.activeNode.isLeaf()){A=this.getPath(this.cm.activeNode.parentNode);}}else{A="/";}this.uploader.setBaseParams({action:"upload",prependPath:this.config.prependPath||null,prependUrl:this.config.prependUrl||null,basePath:this.config.basePath||"",basePathRelative:this.config.basePathRelative||null,baseUrl:this.config.baseUrl||"",baseUrlRelative:this.config.baseUrlRelative||null,path:A,wctx:MODx.ctx||""});this.fireEvent("beforeUpload",this.cm.activeNode);}});Ext.reg("modx-tree-directory",MODx.tree.Directory);MODx.window.CreateDirectory=function(A){A=A||{};Ext.applyIf(A,{width:430,height:200,title:_("file_folder_create"),url:MODx.config.connectors_url+"browser/directory.php",action:"create",fields:[{xtype:"hidden",name:"wctx",value:MODx.ctx||""},{xtype:"hidden",name:"prependPath",value:A.prependPath||null},{fieldLabel:_("name"),name:"name",xtype:"textfield",anchor:"90%",allowBlank:false},{fieldLabel:_("file_folder_parent"),name:"parent",xtype:"textfield",anchor:"95%"}]});MODx.window.CreateDirectory.superclass.constructor.call(this,A);};Ext.extend(MODx.window.CreateDirectory,MODx.Window);Ext.reg("modx-window-directory-create",MODx.window.CreateDirectory);MODx.window.ChmodDirectory=function(A){A=A||{};Ext.applyIf(A,{title:_("file_folder_chmod"),width:430,height:200,url:MODx.config.connectors_url+"browser/directory.php",action:"chmod",fields:[{xtype:"hidden",name:"wctx",value:MODx.ctx||""},{xtype:"hidden",name:"prependPath",value:A.prependPath||null},{fieldLabel:_("mode"),name:"mode",xtype:"textfield",anchor:"90%",allowBlank:false},{name:"dir",xtype:"hidden"}]});MODx.window.ChmodDirectory.superclass.constructor.call(this,A);};Ext.extend(MODx.window.ChmodDirectory,MODx.Window);Ext.reg("modx-window-directory-chmod",MODx.window.ChmodDirectory);MODx.window.RenameFile=function(A){A=A||{};Ext.applyIf(A,{title:_("rename"),width:430,height:200,url:MODx.config.connectors_url+"browser/index.php",action:"rename",fields:[{xtype:"hidden",name:"wctx",value:MODx.ctx||""},{xtype:"hidden",name:"prependPath",value:A.prependPath||null},{fieldLabel:_("path"),name:"path",xtype:"statictextfield",submitValue:true,anchor:"95%"},{fieldLabel:_("old_name"),name:"oldname",xtype:"statictextfield",anchor:"90%"},{fieldLabel:_("new_name"),name:"newname",xtype:"textfield",anchor:"90%",allowBlank:false},{name:"dir",xtype:"hidden"}]});MODx.window.RenameFile.superclass.constructor.call(this,A);};Ext.extend(MODx.window.RenameFile,MODx.Window);Ext.reg("modx-window-file-rename",MODx.window.RenameFile);Ext.namespace("Ext.ux.Utils");Ext.ux.Utils.EventQueue=function(B,A){if(!B){throw"Handler is required.";}this.handler=B;this.scope=A||window;this.queue=[];this.is_processing=false;this.postEvent=function(C,D){D=D||null;this.queue.push({event:C,data:D});if(!this.is_processing){this.process();}};this.flushEventQueue=function(){this.queue=[];},this.process=function(){while(this.queue.length>0){this.is_processing=true;var C=this.queue.shift();this.handler.call(this.scope,C.event,C.data);}this.is_processing=false;};};Ext.ux.Utils.FSA=function(C,B,A){this.current_state=C;this.trans_table=B||{};this.trans_table_scope=A||window;Ext.ux.Utils.FSA.superclass.constructor.call(this,this.processEvent,this);};Ext.extend(Ext.ux.Utils.FSA,Ext.ux.Utils.EventQueue,{current_state:null,trans_table:null,trans_table_scope:null,state:function(){return this.current_state;},processEvent:function(A,D){var H=this.currentStateEventTransitions(A);if(!H){throw"State '"+this.current_state+"' has no transition for event '"+A+"'.";}for(var E=0,F=H.length;E<F;E++){var G=H[E];var I=G.predicate||G.p||true;var C=G.action||G.a||Ext.emptyFn;var B=G.state||G.s||this.current_state;var J=G.scope||this.trans_table_scope;if(this.computePredicate(I,J,D,A)){this.callAction(C,J,D,A);this.current_state=B;return ;}}throw"State '"+this.current_state+"' has no transition for event '"+A+"' in current context";},currentStateEventTransitions:function(A){return this.trans_table[this.current_state]?this.trans_table[this.current_state][A]||false:false;},computePredicate:function(C,E,G,F){var B=false;switch(Ext.type(C)){case"function":B=C.call(E,G,F,this);break;case"array":B=true;for(var D=0,A=C.length;B&&(D<A);D++){if(Ext.type(C[D])=="function"){B=C[D].call(E,G,F,this);}else{throw ["Predicate: ",C[D],' is not callable in "',this.current_state,'" state for event "',F].join("");}}break;case"boolean":B=C;break;default:throw ["Predicate: ",C,' is not callable in "',this.current_state,'" state for event "',F].join("");}return B;},callAction:function(F,C,E,D){switch(Ext.type(F)){case"array":for(var B=0,A=F.length;B<A;B++){if(Ext.type(F[B])=="function"){F[B].call(C,E,D,this);}else{throw ["Action: ",F[B],' is not callable in "',this.current_state,'" state for event "',D].join("");}}break;case"function":F.call(C,E,D,this);break;default:throw ["Action: ",F,' is not callable in "',this.current_state,'" state for event "',D].join("");}}});Ext.namespace("Ext.ux.UploadDialog");Ext.ux.UploadDialog.BrowseButton=Ext.extend(Ext.Button,{input_name:"file",input_file:null,original_handler:null,original_scope:null,initComponent:function(){Ext.ux.UploadDialog.BrowseButton.superclass.initComponent.call(this);this.original_handler=this.handler||null;this.original_scope=this.scope||window;this.handler=null;this.scope=null;},onRender:function(B,A){Ext.ux.UploadDialog.BrowseButton.superclass.onRender.call(this,B,A);this.createInputFile();},createInputFile:function(){var C=this.el.child("tbody");C.position("relative");this.wrap=this.el.wrap({cls:"tbody"});this.input_file=this.wrap.createChild({tag:"input",type:"file",size:1,name:this.input_name||Ext.id(this.el),style:"position: absolute; display: block; border: none; cursor: pointer"});this.input_file.setOpacity(0);var B=C.getBox();this.input_file.setStyle("font-size",(B.width*0.5)+"px");var D=this.input_file.getBox();var A={x:3,y:3};if(Ext.isIE){A={x:0,y:3};}this.input_file.setLeft(B.width-D.width+A.x+"px");this.input_file.setTop(B.height-D.height+A.y+"px");this.input_file.setOpacity(0);if(this.handleMouseEvents){this.input_file.on("mouseover",this.onMouseOver,this);this.input_file.on("mousedown",this.onMouseDown,this);}if(this.tooltip){if(typeof this.tooltip=="object"){Ext.QuickTips.register(Ext.apply({target:this.input_file},this.tooltip));}else{this.input_file.dom[this.tooltipType]=this.tooltip;}}this.input_file.on("change",this.onInputFileChange,this);this.input_file.on("click",function(E){E.stopPropagation();});},detachInputFile:function(B){var A=this.input_file;B=B||false;if(typeof this.tooltip=="object"){Ext.QuickTips.unregister(this.input_file);}else{this.input_file.dom[this.tooltipType]=null;}this.input_file.removeAllListeners();this.input_file=null;if(!B){this.createInputFile();}return A;},getInputFile:function(){return this.input_file;},disable:function(){Ext.ux.UploadDialog.BrowseButton.superclass.disable.call(this);this.input_file.dom.disabled=true;},enable:function(){Ext.ux.UploadDialog.BrowseButton.superclass.enable.call(this);this.input_file.dom.disabled=false;},destroy:function(){var A=this.detachInputFile(true);A.remove();A=null;Ext.ux.UploadDialog.BrowseButton.superclass.destroy.call(this);},onInputFileChange:function(){if(this.original_handler){this.original_handler.call(this.original_scope,this);}}});Ext.ux.UploadDialog.TBBrowseButton=Ext.extend(Ext.ux.UploadDialog.BrowseButton,{hideParent:true,onDestroy:function(){Ext.ux.UploadDialog.TBBrowseButton.superclass.onDestroy.call(this);if(this.container){this.container.remove();}}});Ext.ux.UploadDialog.FileRecord=Ext.data.Record.create([{name:"filename"},{name:"state",type:"int"},{name:"note"},{name:"input_element"}]);Ext.ux.UploadDialog.FileRecord.STATE_QUEUE=0;Ext.ux.UploadDialog.FileRecord.STATE_FINISHED=1;Ext.ux.UploadDialog.FileRecord.STATE_FAILED=2;Ext.ux.UploadDialog.FileRecord.STATE_PROCESSING=3;Ext.ux.UploadDialog.Dialog=function(A){var B={border:false,width:450,height:350,minWidth:450,minHeight:350,plain:true,constrainHeader:true,draggable:true,closable:true,maximizable:false,minimizable:false,resizable:true,layout:"fit",region:"center",autoDestroy:true,closeAction:"hide",title:this.i18n.title,cls:"ext-ux-uploaddialog-dialog",url:"",base_params:{},permitted_extensions:[],reset_on_hide:true,allow_close_on_upload:false,upload_autostart:false,Make_Reload:false,post_var_name:"file"};A=Ext.applyIf(A||{},B);A.layout="absolute";Ext.ux.UploadDialog.Dialog.superclass.constructor.call(this,A);};Ext.extend(Ext.ux.UploadDialog.Dialog,Ext.Window,{fsa:null,state_tpl:null,form:null,grid_panel:null,progress_bar:null,is_uploading:false,initial_queued_count:0,upload_frame:null,initComponent:function(){Ext.ux.UploadDialog.Dialog.superclass.initComponent.call(this);var A={created:{"window-render":[{action:[this.createForm,this.createProgressBar,this.createGrid],state:"rendering"}],destroy:[{action:this.flushEventQueue,state:"destroyed"}]},rendering:{"grid-render":[{action:[this.fillToolbar,this.updateToolbar],state:"ready"}],destroy:[{action:this.flushEventQueue,state:"destroyed"}]},ready:{"file-selected":[{predicate:[this.fireFileTestEvent,this.isPermittedFile],action:this.addFileToUploadQueue,state:"adding-file"},{}],"grid-selection-change":[{action:this.updateToolbar}],"remove-files":[{action:[this.removeFiles,this.fireFileRemoveEvent]}],"reset-queue":[{action:[this.resetQueue,this.fireResetQueueEvent]}],"start-upload":[{predicate:this.hasUnuploadedFiles,action:[this.setUploadingFlag,this.saveInitialQueuedCount,this.updateToolbar,this.updateProgressBar,this.prepareNextUploadTask,this.fireUploadStartEvent],state:"uploading"},{}],"stop-upload":[{}],hide:[{predicate:[this.isNotEmptyQueue,this.getResetOnHide],action:[this.resetQueue,this.fireResetQueueEvent]},{}],destroy:[{action:this.flushEventQueue,state:"destroyed"}]},"adding-file":{"file-added":[{predicate:this.isUploading,action:[this.incInitialQueuedCount,this.updateProgressBar,this.fireFileAddEvent],state:"uploading"},{predicate:this.getUploadAutostart,action:[this.startUpload,this.fireFileAddEvent],state:"ready"},{action:[this.updateToolbar,this.fireFileAddEvent],state:"ready"}]},uploading:{"file-selected":[{predicate:[this.fireFileTestEvent,this.isPermittedFile],action:this.addFileToUploadQueue,state:"adding-file"},{}],"grid-selection-change":[{}],"start-upload":[{}],"stop-upload":[{predicate:this.hasUnuploadedFiles,action:[this.resetUploadingFlag,this.abortUpload,this.updateToolbar,this.updateProgressBar,this.fireUploadStopEvent],state:"ready"},{action:[this.resetUploadingFlag,this.abortUpload,this.updateToolbar,this.updateProgressBar,this.fireUploadStopEvent,this.fireUploadCompleteEvent],state:"ready"}],"file-upload-start":[{action:[this.uploadFile,this.findUploadFrame,this.fireFileUploadStartEvent]}],"file-upload-success":[{predicate:this.hasUnuploadedFiles,action:[this.resetUploadFrame,this.updateRecordState,this.updateProgressBar,this.prepareNextUploadTask,this.fireUploadSuccessEvent]},{action:[this.resetUploadFrame,this.resetUploadingFlag,this.updateRecordState,this.updateToolbar,this.updateProgressBar,this.fireUploadSuccessEvent,this.fireUploadCompleteEvent],state:"ready"}],"file-upload-error":[{predicate:this.hasUnuploadedFiles,action:[this.resetUploadFrame,this.updateRecordState,this.updateProgressBar,this.prepareNextUploadTask,this.fireUploadErrorEvent]},{action:[this.resetUploadFrame,this.resetUploadingFlag,this.updateRecordState,this.updateToolbar,this.updateProgressBar,this.fireUploadErrorEvent,this.fireUploadCompleteEvent],state:"ready"}],"file-upload-failed":[{predicate:this.hasUnuploadedFiles,action:[this.resetUploadFrame,this.updateRecordState,this.updateProgressBar,this.prepareNextUploadTask,this.fireUploadFailedEvent]},{action:[this.resetUploadFrame,this.resetUploadingFlag,this.updateRecordState,this.updateToolbar,this.updateProgressBar,this.fireUploadFailedEvent,this.fireUploadCompleteEvent],state:"ready"}],hide:[{predicate:this.getResetOnHide,action:[this.stopUpload,this.repostHide]},{}],destroy:[{predicate:this.hasUnuploadedFiles,action:[this.resetUploadingFlag,this.abortUpload,this.fireUploadStopEvent,this.flushEventQueue],state:"destroyed"},{action:[this.resetUploadingFlag,this.abortUpload,this.fireUploadStopEvent,this.fireUploadCompleteEvent,this.flushEventQueue],state:"destroyed"}]},destroyed:{}};this.fsa=new Ext.ux.Utils.FSA("created",A,this);this.addEvents({filetest:true,fileadd:true,fileremove:true,resetqueue:true,uploadsuccess:true,uploaderror:true,uploadfailed:true,uploadstart:true,uploadstop:true,uploadcomplete:true,fileuploadstart:true});this.on("render",this.onWindowRender,this);this.on("beforehide",this.onWindowBeforeHide,this);this.on("hide",this.onWindowHide,this);this.on("destroy",this.onWindowDestroy,this);this.state_tpl=new Ext.Template("<div class='ext-ux-uploaddialog-state ext-ux-uploaddialog-state-{state}'> </div>").compile();},createForm:function(){this.form=Ext.DomHelper.append(this.body,{tag:"form",method:"post",action:this.url,style:"position: absolute; left: -100px; top: -100px; width: 100px; height: 100px; clear: both;"});},createProgressBar:function(){this.progress_bar=this.add(new Ext.ProgressBar({x:0,y:0,anchor:"0",value:0,text:this.i18n.progress_waiting_text}));},createGrid:function(){var B=new Ext.data.Store({proxy:new Ext.data.MemoryProxy([]),reader:new Ext.data.JsonReader({},Ext.ux.UploadDialog.FileRecord),sortInfo:{field:"state",direction:"DESC"},pruneModifiedRecords:true});var A=new Ext.grid.ColumnModel([{header:this.i18n.state_col_title,width:this.i18n.state_col_width,resizable:false,dataIndex:"state",sortable:true,renderer:this.renderStateCell.createDelegate(this)},{header:this.i18n.filename_col_title,width:this.i18n.filename_col_width,dataIndex:"filename",sortable:true,renderer:this.renderFilenameCell.createDelegate(this)},{header:this.i18n.note_col_title,width:this.i18n.note_col_width,dataIndex:"note",sortable:true,renderer:this.renderNoteCell.createDelegate(this)}]);this.grid_panel=new Ext.grid.GridPanel({ds:B,cm:A,layout:"fit",height:this.height-100,region:"center",x:0,y:22,border:true,viewConfig:{autoFill:true,forceFit:true},bbar:new Ext.Toolbar()});this.grid_panel.on("render",this.onGridRender,this);this.add(this.grid_panel);this.grid_panel.getSelectionModel().on("selectionchange",this.onGridSelectionChange,this);},fillToolbar:function(){var A=this.grid_panel.getBottomToolbar();A.x_buttons={};A.x_buttons.add=A.addItem(new Ext.ux.UploadDialog.TBBrowseButton({input_name:this.post_var_name,text:this.i18n.add_btn_text,tooltip:this.i18n.add_btn_tip,iconCls:"ext-ux-uploaddialog-addbtn",handler:this.onAddButtonFileSelected,scope:this}));A.x_buttons.remove=A.addButton({text:this.i18n.remove_btn_text,tooltip:this.i18n.remove_btn_tip,iconCls:"ext-ux-uploaddialog-removebtn",handler:this.onRemoveButtonClick,scope:this});A.x_buttons.reset=A.addButton({text:this.i18n.reset_btn_text,tooltip:this.i18n.reset_btn_tip,iconCls:"ext-ux-uploaddialog-resetbtn",handler:this.onResetButtonClick,scope:this});A.add("-");A.x_buttons.upload=A.addButton({text:this.i18n.upload_btn_start_text,tooltip:this.i18n.upload_btn_start_tip,iconCls:"ext-ux-uploaddialog-uploadstartbtn",handler:this.onUploadButtonClick,scope:this});A.add("-");A.x_buttons.close=A.addButton({text:this.i18n.close_btn_text,tooltip:this.i18n.close_btn_tip,handler:this.onCloseButtonClick,scope:this});},renderStateCell:function(F,A,B,D,E,C){return this.state_tpl.apply({state:F});},renderFilenameCell:function(H,A,C,E,G,D){var B=this.grid_panel.getView();var F=function(){try{Ext.fly(B.getCell(E,G)).child(".x-grid3-cell-inner").dom.qtip=H;}catch(I){}};F.defer(1000);return H;},renderNoteCell:function(H,A,C,E,G,D){var B=this.grid_panel.getView();var F=function(){try{Ext.fly(B.getCell(E,G)).child(".x-grid3-cell-inner").dom.qtip=H;}catch(I){}};F.defer(1000);return H;},getFileExtension:function(B){var A=null;var C=B.split(".");if(C.length>1){A=C.pop();}return A;},isPermittedFileType:function(B){var A=true;if(this.permitted_extensions.length>0){A=this.permitted_extensions.indexOf(this.getFileExtension(B))!=-1;}return A;},isPermittedFile:function(C){var A=false;var B=C.getInputFile().dom.value;if(this.isPermittedFileType(B)){A=true;}else{Ext.Msg.alert(this.i18n.error_msgbox_title,String.format(this.i18n.err_file_type_not_permitted,B,this.permitted_extensions.join(this.i18n.permitted_extensions_join_str)));A=false;}return A;},fireFileTestEvent:function(A){return this.fireEvent("filetest",this,A.getInputFile().dom.value)!==false;},addFileToUploadQueue:function(C){var A=C.detachInputFile();A.appendTo(this.form);A.setStyle("width","100px");A.dom.disabled=true;var B=this.grid_panel.getStore();B.add(new Ext.ux.UploadDialog.FileRecord({state:Ext.ux.UploadDialog.FileRecord.STATE_QUEUE,filename:A.dom.value,note:this.i18n.note_queued_to_upload,input_element:A}));this.fsa.postEvent("file-added",A.dom.value);},fireFileAddEvent:function(A){this.fireEvent("fileadd",this,A);},updateProgressBar:function(){if(this.is_uploading){var B=this.getQueuedCount(true);var A=1-B/this.initial_queued_count;this.progress_bar.updateProgress(A,String.format(this.i18n.progress_uploading_text,this.initial_queued_count-B,this.initial_queued_count));}else{this.progress_bar.updateProgress(0,this.i18n.progress_waiting_text);}},updateToolbar:function(){var A=this.grid_panel.getBottomToolbar();if(this.is_uploading){A.x_buttons.remove.disable();A.x_buttons.reset.disable();A.x_buttons.upload.enable();if(!this.getAllowCloseOnUpload()){A.x_buttons.close.disable();}A.x_buttons.upload.setIconClass("ext-ux-uploaddialog-uploadstopbtn");A.x_buttons.upload.setText(this.i18n.upload_btn_stop_text);A.x_buttons.upload.getEl().child(A.x_buttons.upload.buttonSelector).dom[A.x_buttons.upload.tooltipType]=this.i18n.upload_btn_stop_tip;}else{A.x_buttons.remove.enable();A.x_buttons.reset.enable();A.x_buttons.close.enable();A.x_buttons.upload.setIconClass("ext-ux-uploaddialog-uploadstartbtn");A.x_buttons.upload.setText(this.i18n.upload_btn_start_text);if(this.getQueuedCount()>0){A.x_buttons.upload.enable();}else{A.x_buttons.upload.disable();}if(this.grid_panel.getSelectionModel().hasSelection()){A.x_buttons.remove.enable();}else{A.x_buttons.remove.disable();}if(this.grid_panel.getStore().getCount()>0){A.x_buttons.reset.enable();}else{A.x_buttons.reset.disable();}}},saveInitialQueuedCount:function(){this.initial_queued_count=this.getQueuedCount();},incInitialQueuedCount:function(){this.initial_queued_count++;},setUploadingFlag:function(){this.is_uploading=true;},resetUploadingFlag:function(){this.is_uploading=false;},prepareNextUploadTask:function(){var B=this.grid_panel.getStore();var A=null;B.each(function(C){if(!A&&C.get("state")==Ext.ux.UploadDialog.FileRecord.STATE_QUEUE){A=C;}else{C.get("input_element").dom.disabled=true;}});A.get("input_element").dom.disabled=false;A.set("state",Ext.ux.UploadDialog.FileRecord.STATE_PROCESSING);A.set("note",this.i18n.note_processing);A.commit();this.fsa.postEvent("file-upload-start",A);},fireUploadStartEvent:function(){this.fireEvent("uploadstart",this);},removeFiles:function(E){var B=this.grid_panel.getStore();for(var C=0,A=E.length;C<A;C++){var D=E[C];D.get("input_element").remove();B.remove(D);}},fireFileRemoveEvent:function(C){for(var B=0,A=C.length;B<A;B++){this.fireEvent("fileremove",this,C[B].get("filename"));}},resetQueue:function(){var A=this.grid_panel.getStore();A.each(function(B){B.get("input_element").remove();});A.removeAll();},fireResetQueueEvent:function(){this.fireEvent("resetqueue",this);},uploadFile:function(A){Ext.Ajax.request({url:this.url,params:this.base_params||this.baseParams||this.params,method:"POST",form:this.form,isUpload:true,success:this.onAjaxSuccess,failure:this.onAjaxFailure,scope:this,record:A});},fireFileUploadStartEvent:function(A){this.fireEvent("fileuploadstart",this,A.get("filename"));},updateRecordState:function(A){if("success" in A.response&&A.response.success){A.record.set("state",Ext.ux.UploadDialog.FileRecord.STATE_FINISHED);A.record.set("note",A.response.message||A.response.error||this.i18n.note_upload_success);}else{A.record.set("state",Ext.ux.UploadDialog.FileRecord.STATE_FAILED);A.record.set("note",A.response.message||A.response.error||this.i18n.note_upload_error);}A.record.commit();},fireUploadSuccessEvent:function(A){this.fireEvent("uploadsuccess",this,A.record.get("filename"),A.response);},fireUploadErrorEvent:function(A){this.fireEvent("uploaderror",this,A.record.get("filename"),A.response);},fireUploadFailedEvent:function(A){this.fireEvent("uploadfailed",this,A.record.get("filename"));},fireUploadCompleteEvent:function(){this.fireEvent("uploadcomplete",this);},findUploadFrame:function(){this.upload_frame=Ext.getBody().child("iframe.x-hidden:last");},resetUploadFrame:function(){this.upload_frame=null;},removeUploadFrame:function(){if(this.upload_frame){this.upload_frame.removeAllListeners();this.upload_frame.dom.src="about:blank";this.upload_frame.remove();}this.upload_frame=null;},abortUpload:function(){this.removeUploadFrame();var B=this.grid_panel.getStore();var A=null;B.each(function(C){if(C.get("state")==Ext.ux.UploadDialog.FileRecord.STATE_PROCESSING){A=C;return false;}});A.set("state",Ext.ux.UploadDialog.FileRecord.STATE_FAILED);A.set("note",this.i18n.note_aborted);A.commit();},fireUploadStopEvent:function(){this.fireEvent("uploadstop",this);},repostHide:function(){this.fsa.postEvent("hide");},flushEventQueue:function(){this.fsa.flushEventQueue();},onWindowRender:function(){this.fsa.postEvent("window-render");},onWindowBeforeHide:function(){return this.isUploading()?this.getAllowCloseOnUpload():true;},onWindowHide:function(){this.fsa.postEvent("hide");},onWindowDestroy:function(){this.fsa.postEvent("destroy");},onGridRender:function(){this.fsa.postEvent("grid-render");},onGridSelectionChange:function(){this.fsa.postEvent("grid-selection-change");},onAddButtonFileSelected:function(A){this.fsa.postEvent("file-selected",A);},onUploadButtonClick:function(){if(this.is_uploading){this.fsa.postEvent("stop-upload");}else{this.fsa.postEvent("start-upload");}},onRemoveButtonClick:function(){var A=this.grid_panel.getSelectionModel().getSelections();this.fsa.postEvent("remove-files",A);},onResetButtonClick:function(){this.fsa.postEvent("reset-queue");},onCloseButtonClick:function(){this[this.closeAction].call(this);if(this.Make_Reload==true){document.location.reload();}},onAjaxSuccess:function(C,D){var A={success:false,error:this.i18n.note_upload_error};try{var B=C.responseText;var E=B.match(/^<pre>((?:.|\n)*)<\/pre>$/i);if(E){B=E[1];}A=Ext.util.JSON.decode(B);}catch(G){}var F={record:D.record,response:A};if("success" in A&&A.success){this.fsa.postEvent("file-upload-success",F);}else{this.fsa.postEvent("file-upload-error",F);}},onAjaxFailure:function(A,B){var C={record:B.record,response:{success:false,error:this.i18n.note_upload_failed}};this.fsa.postEvent("file-upload-failed",C);},startUpload:function(){this.fsa.postEvent("start-upload");},stopUpload:function(){this.fsa.postEvent("stop-upload");},getUrl:function(){return this.url;},setUrl:function(A){this.url=A;},getBaseParams:function(){return this.base_params;},setBaseParams:function(A){this.base_params=A;},getUploadAutostart:function(){return this.upload_autostart;},setUploadAutostart:function(A){this.upload_autostart=A;},getMakeReload:function(){return this.Make_Reload;},setMakeReload:function(A){this.Make_Reload=A;},getAllowCloseOnUpload:function(){return this.allow_close_on_upload;},setAllowCloseOnUpload:function(A){this.allow_close_on_upload;},getResetOnHide:function(){return this.reset_on_hide;},setResetOnHide:function(A){this.reset_on_hide=A;},getPermittedExtensions:function(){return this.permitted_extensions;},setPermittedExtensions:function(A){this.permitted_extensions=A;},isUploading:function(){return this.is_uploading;},isNotEmptyQueue:function(){return this.grid_panel.getStore().getCount()>0;},getQueuedCount:function(B){var C=0;var A=this.grid_panel.getStore();A.each(function(D){if(D.get("state")==Ext.ux.UploadDialog.FileRecord.STATE_QUEUE){C++;}if(B&&D.get("state")==Ext.ux.UploadDialog.FileRecord.STATE_PROCESSING){C++;}});return C;},hasUnuploadedFiles:function(){return this.getQueuedCount()>0;}});var p=Ext.ux.UploadDialog.Dialog.prototype;p.i18n={title:_("upload_files"),state_col_title:_("upf_state"),state_col_width:70,filename_col_title:_("upf_filename"),filename_col_width:230,note_col_title:_("upf_note"),note_col_width:150,add_btn_text:_("upf_add"),add_btn_tip:_("upf_add_desc"),remove_btn_text:_("upf_remove"),remove_btn_tip:_("upf_remove_desc"),reset_btn_text:_("upf_reset"),reset_btn_tip:_("upf_reset_desc"),upload_btn_start_text:_("upf_upload"),upload_btn_start_tip:_("upf_upload_desc"),upload_btn_stop_text:_("upf_abort"),upload_btn_stop_tip:_("upf_abort_desc"),close_btn_text:_("upf_close"),close_btn_tip:_("upf_close_desc"),progress_waiting_text:_("upf_progress_wait"),progress_uploading_text:_("upf_uploading_desc"),error_msgbox_title:_("upf_error"),permitted_extensions_join_str:",",err_file_type_not_permitted:_("upf_err_filetype"),note_queued_to_upload:_("upf_queued"),note_processing:_("upf_uploading"),note_upload_failed:_("upf_err_failed"),note_upload_success:_("upf_success"),note_upload_error:_("upf_upload_err"),note_aborted:_("upf_aborted")};MODx.DataView=function(A){A=A||{};this._loadStore(A);Ext.applyIf(A.listeners||{},{loadexception:{fn:this.onLoadException,scope:this},beforeselect:{fn:function(B){return B.store.getRange().length>0;}},contextmenu:{fn:this._showContextMenu,scope:this}});Ext.applyIf(A,{store:this.store,singleSelect:true,overClass:"x-view-over",itemSelector:"div.modx-pb-thumb-wrap",emptyText:'<div style="padding:10px;">'+_("file_err_filter")+"</div>"});MODx.DataView.superclass.constructor.call(this,A);this.config=A;this.cm=new Ext.menu.Menu();};Ext.extend(MODx.DataView,Ext.DataView,{lookup:{},onLoadException:function(){this.getEl().update('<div style="padding:10px;">'+_("data_err_load")+"</div>");},_addContextMenuItem:function(items){var a=items,l=a.length;for(var i=0;i<l;i=i+1){var options=a[i];if(options==="-"){this.cm.add("-");continue;}var h=Ext.emptyFn;if(options.handler){h=eval(options.handler);}else{h=function(itm,e){var o=itm.options;var id=this.cm.activeNode.id.split("_");id=id[1];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="index.php?id="+id+"&"+a;if(w===null){location.href=s;}else{w.dom.src=s;}}},this);}else{var a=Ext.urlEncode(o.params);var s="index.php?id="+id+"&"+a;if(w===null){location.href=s;}else{w.dom.src=s;}}};}this.cm.add({id:options.id,text:options.text,scope:this,options:options,handler:h});}},_loadStore:function(A){this.store=new Ext.data.JsonStore({url:A.url,baseParams:A.baseParams||{action:"getList",prependPath:A.prependPath||null,prependUrl:A.prependUrl||null,wctx:A.wctx||MODx.ctx,dir:A.openTo||"",basePath:A.basePath||"",basePathRelative:A.basePathRelative||null,baseUrl:A.baseUrl||"",baseUrlRelative:A.baseUrlRelative||null},root:A.root||"results",fields:A.fields,totalProperty:"total",listeners:{load:{fn:function(){this.select(0);},scope:this,single:true}}});this.store.load();},_showContextMenu:function(B,C,F,E){E.preventDefault();var D=this.lookup[F.id];var A=this.cm;A.removeAll();if(D.menu){this._addContextMenuItem(D.menu);A.show(F,"tl-c?");}A.activeNode=F;}});Ext.reg("modx-dataview",MODx.DataView);Ext.namespace("MODx.browser");MODx.Browser=function(A){if(MODx.browserOpen&&!A.multiple){return false;}if(!A.multiple){MODx.browserOpen=true;}A=A||{};Ext.applyIf(A,{onSelect:function(B){},scope:this,cls:"modx-browser"});MODx.Browser.superclass.constructor.call(this,A);this.config=A;this.win=new MODx.browser.Window(A);this.win.reset();};Ext.extend(MODx.Browser,Ext.Component,{show:function(A){if(this.win){this.win.show(A);}},hide:function(){if(this.win){this.win.hide();}}});Ext.reg("modx-browser",MODx.Browser);MODx.browser.Window=function(A){A=A||{};this.ident=Ext.id();this.view=MODx.load({xtype:"modx-browser-view",onSelect:{fn:this.onSelect,scope:this},prependPath:A.prependPath||null,prependUrl:A.prependUrl||null,basePath:A.basePath||"",basePathRelative:A.basePathRelative||null,baseUrl:A.baseUrl||"",baseUrlRelative:A.baseUrlRelative||null,allowedFileTypes:A.allowedFileTypes||"",wctx:A.wctx||"web",openTo:A.openTo||"",ident:this.ident});this.tree=MODx.load({xtype:"modx-tree-directory",onUpload:function(){this.view.run();},scope:this,prependPath:A.prependPath||null,basePath:A.basePath||"",basePathRelative:A.basePathRelative||null,baseUrl:A.baseUrl||"",baseUrlRelative:A.baseUrlRelative||null,hideFiles:A.hideFiles||false,openTo:A.openTo||"",ident:this.ident,rootId:"/",rootName:_("files"),rootVisible:true,listeners:{afterUpload:{fn:function(){this.view.run();},scope:this}}});this.tree.on("click",function(B,C){this.load(B.id);},this);Ext.applyIf(A,{title:_("modx_browser")+" ("+(MODx.ctx?MODx.ctx:"web")+")",cls:"modx-pb-win",layout:"border",minWidth:500,minHeight:300,width:"90%",height:500,modal:false,closeAction:"hide",border:false,items:[{id:this.ident+"-browser-tree",cls:"modx-pb-browser-tree",region:"west",width:250,height:"100%",items:this.tree,autoScroll:true},{id:this.ident+"-browser-view",cls:"modx-pb-view-ct",region:"center",autoScroll:true,width:450,items:this.view,tbar:this.getToolbar()},{id:this.ident+"-img-detail-panel",cls:"modx-pb-details-ct",region:"east",split:true,width:150,minWidth:150,maxWidth:250}],buttons:[{id:this.ident+"-ok-btn",text:_("ok"),handler:this.onSelect,scope:this},{id:this.ident+"-cancel-btn",text:_("cancel"),handler:this.hide,scope:this}],keys:{key:27,handler:this.hide,scope:this}});MODx.browser.Window.superclass.constructor.call(this,A);this.config=A;this.addEvents({select:true});};Ext.extend(MODx.browser.Window,Ext.Window,{returnEl:null,filter:function(){var A=Ext.getCmp(this.ident+"filter");this.view.store.filter("name",A.getValue(),true);this.view.select(0);},setReturn:function(A){this.returnEl=A;},load:function(A){A=A||(Ext.isEmpty(this.config.openTo)?"":this.config.openTo);this.view.run({dir:A,basePath:this.config.basePath||"",basePathRelative:this.config.basePathRelative||null,baseUrl:this.config.baseUrl||"",baseUrlRelative:this.config.baseUrlRelative||null,allowedFileTypes:this.config.allowedFileTypes||"",wctx:this.config.wctx||"web"});},sortImages:function(){var A=Ext.getCmp(this.ident+"sortSelect").getValue();this.view.store.sort(A,A=="name"?"asc":"desc");this.view.select(0);},reset:function(){if(this.rendered){Ext.getCmp(this.ident+"filter").reset();this.view.getEl().dom.scrollTop=0;}this.view.store.clearFilter();this.view.select(0);},getToolbar:function(){return[{text:_("filter")+":"},{xtype:"textfield",id:this.ident+"filter",selectOnFocus:true,width:100,listeners:{render:{fn:function(){Ext.getCmp(this.ident+"filter").getEl().on("keyup",function(){this.filter();},this,{buffer:500});},scope:this}}}," ","-",{text:_("sort_by")+":"},{id:this.ident+"sortSelect",xtype:"combo",typeAhead:true,triggerAction:"all",width:100,editable:false,mode:"local",displayField:"desc",valueField:"name",lazyInit:false,value:"name",store:new Ext.data.SimpleStore({fields:["name","desc"],data:[["name",_("name")],["size",_("file_size")],["lastmod",_("last_modified")]]}),listeners:{select:{fn:this.sortImages,scope:this}}}];},onSelect:function(C){var B=this.view.getSelectedNodes()[0];var E=this.config.onSelect||this.onSelectHandler;var D=this.view.lookup;var A=this.config.scope;this.hide(this.config.animEl||null,function(){if(B&&E){var F=D[B.id];Ext.callback(E,A||this,[F]);this.fireEvent("select",F);if(window.top.opener){window.top.close();window.top.opener.focus();}}},A);},onSelectHandler:function(A){Ext.get(this.returnEl).dom.value=unescape(A.url);}});Ext.reg("modx-browser-window",MODx.browser.Window);MODx.browser.View=function(A){A=A||{};this.ident=A.ident+"-view"||"modx-browser-"+Ext.id()+"-view";this._initTemplates();Ext.applyIf(A,{url:MODx.config.connectors_url+"browser/directory.php",id:this.ident,fields:["name","cls","url","relativeUrl","fullRelativeUrl","image","image_width","image_height","thumb","thumb_width","thumb_height","pathname","ext","disabled",{name:"size",type:"float"},{name:"lastmod",type:"date",dateFormat:"timestamp"},"menu"],baseParams:{action:"getFiles",prependPath:A.prependPath||null,prependUrl:A.prependUrl||null,basePath:A.basePath||"",basePathRelative:A.basePathRelative||null,baseUrl:A.baseUrl||"",baseUrlRelative:A.baseUrlRelative||null,allowedFileTypes:A.allowedFileTypes||"",wctx:A.wctx||"web",dir:A.openTo||""},tpl:this.templates.thumb,listeners:{selectionchange:{fn:this.showDetails,scope:this,buffer:100},dblclick:A.onSelect||{fn:Ext.emptyFn,scope:this}},prepareData:this.formatData.createDelegate(this)});MODx.browser.View.superclass.constructor.call(this,A);};Ext.extend(MODx.browser.View,MODx.DataView,{templates:{},removeFile:function(B,D){var A=this.cm.activeNode;var C=this.lookup[A.id];var E="";if(typeof (this.dir)!="object"){E=this.dir;}MODx.msg.confirm({text:_("file_remove_confirm"),url:MODx.config.connectors_url+"browser/file.php",params:{action:"remove",file:E+"/"+A.id,prependPath:this.config.prependPath,basePath:this.config.basePath||"",basePathRelative:this.config.basePathRelative||null,baseUrl:this.config.baseUrl||"",baseUrlRelative:this.config.baseUrlRelative||null,wctx:this.config.wctx||"web"},listeners:{success:{fn:function(F){this.run({ctx:MODx.ctx});},scope:this}}});},run:function(A){A=A||{};if(A.dir){this.dir=A.dir;}Ext.applyIf(A,{action:"getFiles",dir:this.dir,basePath:this.config.basePath||"",basePathRelative:this.config.basePathRelative||null,baseUrl:this.config.baseUrl||"",baseUrlRelative:this.config.baseUrlRelative||null});this.store.load({params:A});},showDetails:function(){var B=this.getSelectedNodes();var C=Ext.getCmp(this.config.ident+"-img-detail-panel").body;if(B&&B.length>0){B=B[0];Ext.getCmp(this.ident+"-ok-btn").enable();var A=this.lookup[B.id];C.hide();this.templates.details.overwrite(C,A);C.slideIn("l",{stopFx:true,duration:".2"});}else{Ext.getCmp(this.config.ident+"-ok-btn").disable();C.update("");}},formatData:function(B){var A=function(C){if(C<1024){return C+" bytes";}else{return(Math.round(((C*10)/1024))/10)+" KB";}};B.shortName=Ext.util.Format.ellipsis(B.name,18);B.sizeString=A(B.size);B.dateString=new Date(B.lastmod).format("m/d/Y g:i a");this.lookup[B.name]=B;return B;},_initTemplates:function(){this.templates.thumb=new Ext.XTemplate('<tpl for=".">','<div class="modx-pb-thumb-wrap" id="{name}">','<div class="modx-pb-thumb"><img src="{thumb}" title="{name}" width="90" height="90" /></div>',"<span>{shortName}</span></div>","</tpl>");this.templates.thumb.compile();this.templates.details=new Ext.XTemplate('<div class="details">','<tpl for=".">','<div class="modx-pb-detail-thumb"><img src="{thumb}" alt="" width="80" height="60" onclick="Ext.getCmp(\''+this.ident+"').showFullView('{name}','"+this.ident+"'); return false;\" /></div>",'<div class="modx-pb-details-info">',"<b>"+_("file_name")+":</b>","<span>{name}</span>","<b>"+_("file_size")+":</b>","<span>{sizeString}</span>","<b>"+_("last_modified")+":</b>","<span>{dateString}</span></div>","</tpl>","</div>");this.templates.details.compile();},showFullView:function(B,E){var D=this.lookup[B];if(!D){return false;}if(!this.fvWin){this.fvWin=new Ext.Window({layout:"fit",width:600,height:450,closeAction:"hide",plain:true,items:[{id:this.ident+"modx-view-item-full",cls:"modx-pb-fullview",html:""}],buttons:[{text:_("close"),handler:function(){this.fvWin.hide();},scope:this}]});}this.fvWin.show();var A=D.image_width<250?250:D.image_width;var C=D.image_height<200?200:D.image_height;this.fvWin.setSize(A,C);this.fvWin.center();this.fvWin.setTitle(D.name);Ext.get(this.ident+"modx-view-item-full").update('<img src="'+D.image+'" alt="" class="modx-pb-fullview-img" onclick="Ext.getCmp(\''+E+"').fvWin.hide();\" />");}});Ext.reg("modx-browser-view",MODx.browser.View);