/** * Shopex OMS * * Copyright (c) 2025 Shopex (http://www.shopex.cn) * Licensed under Apache-2.0 with additional terms (See LICENSE file) */ (function(){ var ModeDialog=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:true }, initialize:function(url,options){ if(!url)return; if(window.location.hash) { url += '&hash='+encodeURIComponent(window.location.hash); } else { var str = window.location.search; str = str.substring(1, str.length); var arr = str.split("&"); var obj = new Object(); for (var i = 0; i < arr.length; i++) { var tmp_arr = arr[i].split("="); if(decodeURIComponent(tmp_arr[0]) == '_finder[finder_id]') { url += '&finder_id='+tmp_arr[1]; break; } if(decodeURIComponent(tmp_arr[0]) == 'finder_id') { url += '&finder_id='+tmp_arr[1]; break; } } } this.setOptions(options); options=this.options; options.resizable = options.resizable?'yes':'no'; if(options.handle)this.handle=$(options.handle); var config="modal=yes;dialogWidth={width}px;dialogHeight={height}px;resizable={resizable};status=no;"; config=config.substitute(options); this.fireEvent('init'); window.modedialogInstance = this; this.openwin = window.open(url,options.title,config); this.openwin.modedialogInstance = this; }, onLoad:function(win){ this.win=win; 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'); if(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(returnValue){ this.win.close(); this.fireEvent('hide',[returnValue]); } }); finderDialog=new Class({ Extends:ModeDialog, options:{ onLoad:function(){ if(!$(this.handle))return; var data=$(this.handle).getParent().getElement('input[type=hidden]').value; if(!data)return; var form=this.doc.getElement('form[id^=finder-form-]'); form.store('rowselected',data.split(',')); this.win.fireEvent('resize'); var fid=form.id.slice(-6),finder; // if(finder=this.win.finderGroup[fid])finder.refresh(); }, onHide:function(value){ if(!value||!value.length)return; var tmpForm=new Element('div'),fdoc=document.createDocumentFragment(); var params=this.options.params; for(var i=0,l=value.length;i