| 1 |
- MWF.xApplication.cms.Document=MWF.xApplication.cms.Document||{};MWF.xDesktop.requireApp("Template","MPopupForm",null,false);MWF.require("MWF.widget.ImageClipper",null,false);MWF.xApplication.cms.Document.HotLinkForm=new Class({Extends:MPopupForm,Implements:[Options,Events],options:{style:"default",width:"660",height:"520",hasTop:true,hasIcon:false,hasTopIcon:false,hasTopContent:true,hasBottom:true,title:"设置热点",draggable:true,closeAction:true,toMain:true,documentId:""},_createTableContent:function(){this.actions=MWF.Actions.get("x_hotpic_assemble_control");this.actions.getHotPic("CMS",this.options.documentId,function(t){if(t.data&&t.data.length>0){this.isNew=false}else{this.isNew=true}this.hotPicData=t.data&&t.data.length>0?t.data[0]:{};var e="<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+"<tr>"+" <td styles='formTableValue' item='hotPictureArea'></td>"+"</tr>"+"<tr>"+" <td>"+this.lp.hotLinkDescription+"</td>"+"</tr>"+"</table>";this.formTableArea.set("html",e);MWF.xDesktop.requireApp("Template","MForm",function(){this.form=new MForm(this.formTableArea,this.data,{style:"cms",isEdited:true,itemTemplate:{hotPicture:{text:this.lp.hotPicture}}},this.app,this.css);this.form.load();this.createIconNode()}.bind(this),true)}.bind(this),null,false)},createIconNode:function(){var t=this.formTableArea.getElements("[item='hotPictureArea']")[0];MWF.require("MWF.widget.ImageClipper",function(){this.clipper=new MWF.widget.ImageClipper(t,{aspectRatio:2,fromFileEnable:true,imageUrl:this.hotPicData.picId?MWF.xDesktop.getImageSrc(this.hotPicData.picId):"",reference:this.options.documentId,referenceType:"cmsDocument"});this.clipper.load()}.bind(this))},_createBottomContent:function(){this.closeActionNode=new Element("div.formCancelActionNode",{styles:this.css.formCancelActionNode,text:this.lp.close}).inject(this.formBottomNode);this.closeActionNode.addEvent("click",function(t){this.cancel(t)}.bind(this));if(!this.isNew){this.cancelHotActionNode=new Element("div.formOkActionNode",{styles:this.css.cancelHotPicture,text:this.lp.cancelHotPicture}).inject(this.formBottomNode);this.cancelHotActionNode.addEvent("click",function(t){this.cancelHotPic(t)}.bind(this))}this.okActionNode=new Element("div.formOkActionNode",{styles:this.css.formOkActionNode,text:this.lp.setHotPicture}).inject(this.formBottomNode);this.okActionNode.addEvent("click",function(t){this.ok(t)}.bind(this))},cancelHotPic:function(t){var e=this;this.app.confirm("warn",t,this.lp.cancelHotPicComfirmTitle,this.lp.cancelHotPicComfirmContent,350,120,function(){e._cancelHotPic(e.data,false);this.close()},function(){this.close()})},_cancelHotPic:function(){this.actions.removeHotPic(this.hotPicData.id,function(t){if(t.type=="error"){this.app.notice(t.message,"error")}else{(this.formMaskNode||this.formMarkNode).destroy();this.formAreaNode.destroy();this.app.notice(this.lp.cancelHotLinkSuccess,"success")}}.bind(this))},ok:function(t){this.fireEvent("queryOk");var e=this.clipper.getBase64Image();if(!e||e==""){this.app.notice(this.lp.unselectHotPic,"error");return}this.clipper.uploadImage(function(t){this.hotPicData.infoId=this.options.documentId;this.hotPicData.url=MWF.xDesktop.getImageSrc(t.id);this.hotPicData.picId=t.id;this.hotPicData.title=this.data.title;this.hotPicData.application="CMS";this.hotPicData.creator=layout.desktop.session.user.distinguishedName;this._ok(this.hotPicData,function(t){if(t.type=="error"){this.app.notice(t.message,"error")}else{(this.formMaskNode||this.formMarkNode).destroy();this.formAreaNode.destroy();this.app.notice(this.lp.setHotLinkSuccess,"success");this.fireEvent("postOk",t.data.id)}}.bind(this))}.bind(this))},_ok:function(t,e){this.actions.saveHotPic(t,function(t){if(e)e(t)}.bind(this))},_close:function(){this.clipper.close()}});
|