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",action:"update",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,show_tvs:A.show_tvs}],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;},duplicateResource: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}}});},deleteResource:function(A,B){MODx.msg.confirm({text:_("resource_delete_confirm"),url:MODx.config.connectors_url+"resource/index.php",params:{action:"delete",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||MODx.request.activeSave==1?false:true,keys:[{key:MODx.config.keymap_save||"s",ctrl:true}]});B.push("-");}else{B.push({text:A.lockedText||_("locked"),handler:Ext.emptyFn,disabled:true});B.push("-");}if(A.canCreate==1){B.push({process:"duplicate",text:_("duplicate"),handler:this.duplicateResource,scope:this});B.push("-");}if(A.canDelete==1&&!A.locked){B.push({process:"delete",text:_("delete"),handler:this.deleteResource,scope:this});B.push("-");}B.push({process:"preview",text:_("view"),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);