MWF.xApplication.Template = MWF.xApplication.Template || {}; //MWF.xDesktop.requireApp("Template", "lp." + MWF.language, null, false); MWF.xApplication.Template.MPopupForm = MPopupForm = new Class({ Extends: MWF.widget.Common, Implements: [Options, Events], options: { "style": "default", "width": 500, "height": 450, "top": null, "left": null, "bottom" : null, "right" : null, "minWidth" : 300, "minHeight" : 220, "isLimitSize": true, "ifFade": true, "hasTop": false, "hasTopIcon" : false, "hasTopContent" : false, "hasIcon": true, "hasMask" : true, "closeByClickMask" : false, "hasScroll" : true, "scrollType" : "", "title": "", "draggable": false, "resizeable" : false, "maxAction" : false, "closeAction": true, "okClass": "", "topClass": "", "relativeToApp" : true, "sizeRelateTo" : "app", //desktop "resultSeparator" : ",", "hasBottom": true, "hideBottomWhenReading": false, "closeByClickMaskWhenReading" : false, "buttonList" : [{ "type":"cancel", "text": "" },{ "type":"ok", "text": "" }] }, initialize: function (explorer, data, options, para) { this.setOptions(options); this.explorer = explorer; if( para ){ if( this.options.relativeToApp ){ this.app = para.app || this.explorer.app; this.container = para.container || this.app.content; this.lp = para.lp || this.explorer.lp || this.app.lp; this.css = para.css || this.explorer.css || this.app.css; this.actions = para.actions || this.explorer.actions || this.app.actions || this.app.restActions; }else{ this.container = para.container; this.lp = para.lp || this.explorer.lp; this.css = para.css || this.explorer.css; this.actions = para.actions || this.explorer.actions; } }else{ if( this.options.relativeToApp ){ this.app = this.explorer.app; this.container = this.app.content; this.lp = this.explorer.lp || this.app.lp; this.css = this.explorer.css || this.app.css; this.actions = this.explorer.actions || this.app.actions || this.app.restActions; }else{ this.container = window.document.body; this.lp = this.explorer.lp; this.css = this.explorer.css; this.actions = this.explorer.actions; } } this.data = data || {}; this.cssPath = "../x_component_Template/$MPopupForm/"+this.options.style+"/css.wcss"; this.load(); }, load: function () { this._loadCss(); }, _loadCss: function(reload){ var css = {}; var key = encodeURIComponent(this.cssPath); if (!reload && o2.widget.css[key]){ css = Object.clone(o2.widget.css[key]); }else{ var r = new Request.JSON({ url: o2.filterUrl(this.cssPath), secure: false, async: false, method: "get", noCache: false, onSuccess: function(responseJSON, responseText){ o2.widget.css[key] = responseJSON; css = Object.clone(responseJSON); }.bind(this), onError: function(text, error){ alert(error + text); } }); r.send(); } var isEmptyObject = true; for( var key in css ){ if(key){ isEmptyObject = false; break; } } if( !isEmptyObject ){ this.css = Object.merge( css, this.css || {}); }else if( !this.css ){ this.css = {}; } }, reload : function( keepData ){ if( keepData ){ this.data = this.form.getResult(false, this.options.resultSeparator, false, false, true); } this.formTopNode = null; if(this.setFormNodeSizeFun && this.app && this.app.removeEvent){ this.app.removeEvent("resize",this.setFormNodeSizeFun); } if( this.formMaskNode )this.formMaskNode.destroy(); if( this.formAreaNode )this.formAreaNode.destroy(); if( this.isNew ){ this.create(); }else if( this.isEdited ){ this.edit(); }else{ this.open(); } }, open: function (e) { this.fireEvent("queryOpen"); this.isNew = false; this.isEdited = false; this._open(); this.fireEvent("postOpen"); }, create: function () { this.fireEvent("queryCreate"); this.isNew = true; this._open(); this.fireEvent("postCreate"); }, edit: function () { this.fireEvent("queryEdit"); this.isEdited = true; this._open(); this.fireEvent("postEdit"); }, _open: function () { this.fireEvent("queryLoad"); if(this._queryLoad)this._queryLoad(); if( this.options.hasMask ){ this.formMaskNode = new Element("div.formMaskNode", { "styles": this.css.formMaskNode, "events": { "mouseover": function (e) { e.stopPropagation(); }, "mouseout": function (e) { e.stopPropagation(); }, "click": function (e) { e.stopPropagation(); }, "mousewheel": function (e) { if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble = true; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; }, "DOMMouseScroll": function (e) { if (e.stopPropagation) e.stopPropagation(); else e.cancelBubble = true; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; } } }).inject( this.container || this.app.content); } this.formAreaNode = new Element("div.formAreaNode", { "styles": this.css.formAreaNode }); this.createFormNode(); if( this.formMaskNode ){ this.formAreaNode.inject(this.formMaskNode , "after"); }else{ this.formAreaNode.inject( this.container || this.app.content ); } if (this.options.ifFade){ this.formAreaNode.fade("in"); }else{ this.formAreaNode.setStyle("opacity", 1); } this.setFormNodeSize(); this.setFormNodeSizeFun = this.setFormNodeSize.bind(this); if( this.app && this.app.addEvent )this.app.addEvent("resize", this.setFormNodeSizeFun); if (this.options.draggable && this.formTopNode) { var size = (this.container || this.app.content).getSize(); var nodeSize = this.formAreaNode.getSize(); this.formAreaNode.makeDraggable({ "handle": this.formTopNode, "limit": { "x": [0, size.x - nodeSize.x], "y": [0, size.y - nodeSize.y] }, "onDrag": function(){ this.fireEvent("drag"); }.bind(this), "onComplete": function(){ this.fireEvent("dragCompleted"); }.bind(this) }); } if( ( this.options.closeByClickMask || (!this.isNew && !this.isEdited && this.options.closeByClickMaskWhenReading) ) && this.formMaskNode ){ this.formMaskNode.addEvent("click", function(e){ this.close(e) }.bind(this)); } if (this.options.resizeable){ this.resizeNode = new Element("div.resizeNode", { "styles": this.css.resizeNode }).inject(this.formNode); this.formAreaNode.makeResizable({ "handle": this.resizeNode, "limit": {x:[ this.options.minWidth, null], y:[this.options.minHeight, null]}, "onDrag": function(){ var size = this.formAreaNode.getComputedSize(); this.setNodesSize( size.width, size.height ); this.fireEvent("resize"); }.bind(this), "onComplete": function(){ var size = this.formAreaNode.getComputedSize(); this.options.width = size.width; this.options.height = size.height; if( this.oldCoordinate ){ this.oldCoordinate.width = size.width; this.oldCoordinate.height = size.height; } this.fireEvent("resizeCompleted"); this.fireEvent("afterResize"); }.bind(this) }); } if(this._postLoad)this._postLoad(); this.fireEvent("postLoad"); }, createFormNode: function () { var _self = this; this.formNode = new Element("div.formNode", { "styles": this.css.formNode }).inject(this.formAreaNode); if (this.options.hasTop) { this.createTopNode(); } if (this.options.hasIcon) { this.formIconNode = new Element("div.formIconNode", { "styles": this.isNew ? this.css.formNewNode : this.css.formIconNode }).inject(this.formNode); } this.createContent(); //formContentNode.set("html", html); if (this.options.hasBottom && (this.isNew || this.isEdited || !this.options.hideBottomWhenReading) ) { this.createBottomNode(); } this._setCustom(); if( this.options.hasScroll ){ //this.setScrollBar(this.formTableContainer) if( this.options.scrollType == "window" ){ this.formContentNode.setStyle("overflow","auto"); this.formTableContainer.setStyle("overflow","visible"); }else{ MWF.require("MWF.widget.ScrollBar", function () { new MWF.widget.ScrollBar(this.formTableContainer, { "indent": false, "style": "xApp_TaskList", "where": "before", "distance": 30, "friction": 4, "axis": {"x": false, "y": true}, "onScroll": function (y) { //var scrollSize = _self.viewContainerNode.getScrollSize(); //var clientSize = _self.viewContainerNode.getSize(); //var scrollHeight = scrollSize.y - clientSize.y; //if (y + 200 > scrollHeight && _self.view && _self.view.loadElementList) { // if (!_self.view.isItemsLoaded) _self.view.loadElementList(); //} } }); }.bind(this)); } } }, _setCustom : function(){ }, createTopNode: function () { this.fireEvent("queryCreateTop"); if (!this.formTopNode) { this.formTopNode = new Element("div.formTopNode", { "styles": this.css.formTopNode }).inject(this.formNode); if( this.options.topClass ){ this.formTopNode.addClass( this.options.topClass ); } if(this.options.hasTopIcon){ this.formTopIconNode = new Element("div", { "styles": this.css.formTopIconNode }).inject(this.formTopNode) } this.formTopTextNode = new Element("div", { "styles": this.css.formTopTextNode, "text": this.options.title }).inject(this.formTopNode); if (this.options.closeAction) { this.formTopCloseActionNode = new Element("div", { "styles": this.css.formTopCloseActionNode, "title" : MWF.xApplication.Template.LP.MPopupForm.close }).inject(this.formTopNode); this.formTopCloseActionNode.addEvent("click", function ( ev ) { this.close(); ev.stopPropagation(); }.bind(this)) } if( this.options.maxAction ){ this.formTopMaxActionNode = new Element("div", { "styles": this.css.formTopMaxActionNode, "title" : MWF.xApplication.Template.LP.MPopupForm.max }).inject(this.formTopNode); this.formTopMaxActionNode.addEvent("click", function () { this.maxSize() }.bind(this)); this.formTopRestoreActionNode = new Element("div", { "styles": this.css.formTopRestoreActionNode, "title": MWF.xApplication.Template.LP.MPopupForm.restore }).inject(this.formTopNode); this.formTopRestoreActionNode.addEvent("click", function () { this.restoreSize() }.bind(this)); this.formTopNode.addEvent("dblclick", function(){ this.switchMax(); }.bind(this)); } if(this.options.hasTopContent){ this.formTopContentNode = new Element("div.formTopContentNode", { "styles": this.css.formTopContentNode }).inject(this.formTopNode); this._createTopContent(); } } this.fireEvent("postCreateTop"); //if (!this.formTopNode) { // this.formTopNode = new Element("div.formTopNode", { // "styles": this.css.formTopNode, // "text": this.options.title // }).inject(this.formNode); // // this._createTopContent(); // // if (this.options.closeAction) { // this.formTopCloseActionNode = new Element("div.formTopCloseActionNode", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode); // this.formTopCloseActionNode.addEvent("click", function () { // this.close() // }.bind(this)) // } //} }, _createTopContent: function () { }, createContent: function () { this.formContentNode = new Element("div.formContentNode", { "styles": this.css.formContentNode }).inject(this.formNode); this.formTableContainer = new Element("div.formTableContainer", { "styles": this.css.formTableContainer }).inject(this.formContentNode); this.formTableArea = new Element("div.formTableArea", { "styles": this.css.formTableArea }).inject(this.formTableContainer); this._createTableContent(); }, _createTableContent: function () { var html = "
申诉处理单 | |
" + " | |
" + " | |
" + " | |
" + " | |
" + " | |
" + " | |
" + " |