MODx.page.UpdateResource=function(A){A=A||{record:{}};A.record=A.record||{};Ext.apply(A.record,{"parent-cmb":A.record["parent"]});Ext.applyIf(A,{url:MODx.config.connectors_url+"resource/index.php",which_editor:"none",formpanel:"modx-panel-resource",id:"modx-page-update-resource",actions:{"new":MODx.action["resource/create"],edit:MODx.action["resource/update"],preview:MODx.action["resource/preview"],cancel:MODx.action["welcome"]},loadStay:true,components:[{xtype:"modx-panel-resource",renderTo:"modx-panel-resource-div",resource:A.resource,record:A.record||{},publish_document:A.publish_document,access_permissions:A.access_permissions}],buttons:this.getButtons(A)});MODx.page.UpdateResource.superclass.constructor.call(this,A);if(!Ext.isIE){Ext.EventManager.on(window,"beforeunload",function(B){MODx.releaseLock(this.config.resource);MODx.sleep(400);B.browserEvent.returnValue="";return false;},this);}new Ext.KeyMap(Ext.getBody(),{key:"p",alt:true,ctrl:true,fn:this.preview,scope:this});};Ext.extend(MODx.page.UpdateResource,MODx.Component,{preview:function(){window.open(this.config.preview_url);return false;},duplicate:function(A,B){MODx.msg.confirm({text:_("resource_duplicate_confirm"),url:MODx.config.connectors_url+"resource/index.php",params:{action:"duplicate",id:this.config.resource},listeners:{success:{fn:function(C){location.href="?a="+MODx.action["resource/update"]+"&id="+C.object.id;},scope:this}}});},cancel:function(B,C){var A=Ext.getCmp(this.config.formpanel);if(A&&A.isDirty()){Ext.Msg.confirm(_("warning"),_("resource_cancel_dirty_confirm"),function(D){if(D=="yes"){MODx.releaseLock(MODx.request.id);MODx.sleep(400);location.href="?a="+MODx.action["welcome"];}},this);}else{MODx.releaseLock(MODx.request.id);location.href="?a="+MODx.action["welcome"];}},getButtons:function(A){var B=[];if(A.canSave==1){B.push({process:"update",text:_("save"),method:"remote",checkDirty:A.richtext?false:true,keys:[{key:MODx.config.keymap_save||"s",alt:true,ctrl:true}]});B.push("-");}if(A.canCreate==1){B.push({process:"duplicate",text:_("duplicate"),handler:this.duplicate,scope:this});B.push("-");}B.push({process:"preview",text:_("preview"),handler:this.preview,scope:this});B.push("-");B.push({process:"cancel",text:_("cancel"),handler:this.cancel,scope:this});B.push("-");B.push({text:_("help_ex"),handler:MODx.loadHelpPane});return B;}});Ext.reg("modx-page-resource-update",MODx.page.UpdateResource);