mirror of
https://gitee.com/ShopeX/OMS
synced 2026-04-05 06:45:32 +08:00
3 lines
3.2 KiB
JavaScript
3 lines
3.2 KiB
JavaScript
|
|
|
|
!function(){var e=this.ModeDialog=new Class({Implements:[Options,Events],options:{onLoad:$empty,onShow:$empty,onHide:$empty,onCallback:$empty,params:{url:null,name:null,type:null},title:"title",handle:null,width:800,height:600,resizable:!0},initialize:function(e,t){if(e){if(window.location.hash)e+="&hash="+encodeURIComponent(window.location.hash);else for(var i=window.location.search,n=(i=i.substring(1,i.length)).split("&"),o=(new Object,0);o<n.length;o++){var s=n[o].split("=");if("_finder[finder_id]"==decodeURIComponent(s[0])){e+="&finder_id="+s[1];break}if("finder_id"==decodeURIComponent(s[0])){e+="&finder_id="+s[1];break}}this.setOptions(t),(t=this.options).resizable=t.resizable?"yes":"no",t.handle&&(this.handle=$(t.handle));var a="modal=yes;dialogWidth={width}px;dialogHeight={height}px;resizable={resizable};status=no;".substitute(t);this.fireEvent("init"),(window.modedialogInstance=this).openwin=window.open(e,t.title,a),this.openwin.modedialogInstance=this}},onLoad:function(e){this.win=e,this.doc=this.win.document,this.fireEvent("load",[this,this.options.pname,this.options.params]),this.onShow.call(this)},submit:function(){},onShow:function(){this.fireEvent("show"),this.doc.getElement(".dialogBtn")&&this.doc.getElement(".dialogBtn").addEvent("click",function(e){try{this.submit.call(this,this.win)}catch(e){}this.onClose.call(this,window.returnValue)}.bind(this))},onClose:function(e){this.win.close(),this.fireEvent("hide",[e])}});finderDialog=new Class({Extends:e,options:{onLoad:function(){var e,t;!$(this.handle)||(e=$(this.handle).getParent().getElement("input[type=hidden]").value)&&((t=this.doc.getElement("form[id^=finder-form-]")).store("rowselected",e.split(",")),this.win.fireEvent("resize"),t.id.slice(-6))},onHide:function(t){if(t&&t.length){for(var i=new Element("div"),e=document.createDocumentFragment(),n=this.options.params,o=0,s=t.length;o<s;o++)e.appendChild(new Element("input",{type:"hidden",name:n.name,value:t[o]}));i.appendChild(e);var a=n.postdata?i.toQueryString()+"&"+n.postdata:i.toQueryString(),a=this.filterData?a+"&filter[advance]="+this.filterData:a;new Request({url:n.url,onSuccess:function(e){i.destroy(),n.type&&this.options.select(n,e,t),this.fireEvent("callback",e)}.bind(this)}).send(a)}},select:function(e,t,i){"radio"==e.type?JSON.decode(t)&&("INPUT"===$(this.handle).tagName?$(this.handle).value=JSON.decode(t).name:$(this.handle).setText(JSON.decode(t).name)):"checkbox"==e.type&&($(this.handle).innerHTML=t),$(this.handle).getParent().getElement("input[type=hidden]").value=i}},submit:function(e){var t=this.doc.getElement("form[id^=finder-form-]"),i=t.retrieve("rowselected",""),n=decodeURI(t.getElement("input[id^=finder-filter-]").value);this.options.params;n&&-1!=i.indexOf("_ALL_")&&(n=(n=n.replace(/&/g,",")).replace(/&/g,","),n=encodeURIComponent(n),this.filterData=n),i&&i.length&&(e.opener.returnValue=i.toString().split(","))}}),imgDialog=new Class({Extends:e,options:{onCallback:function(e,t){var i=$(this.handle).getParent(".image-input"),n=i.getElement("input"),o=i.getElement("img");o.removeProperties("width","height"),n.value=e,o.src=t}},imgcallback:function(e,t){this.fireEvent("callback",[e,t]),this.onClose.call(this,window.returnValue)}})}(); |