MWF.xDesktop.requireApp("process.Xform", "$Module", null, false); //MWF.require("MWF.widget.Tree", null, false); /** @class Sidebar 侧边操作条。 * @example * //可以在脚本中获取该组件 * //方法1: * var sidebar = this.form.get("fieldId"); //获取侧边操作条 * //方法2 * var sidebar = this.target; //在侧边操作条和操作本身的事件脚本中获取 * @extends MWF.xApplication.process.Xform.$Module * @o2category FormComponents * @o2range {Process} * @hideconstructor */ MWF.xApplication.process.Xform.Sidebar = MWF.APPSidebar = new Class( /** @lends MWF.xApplication.process.Xform.Sidebar# */ { Extends: MWF.APP$Module, _loadUserInterface: function(){ this.node.setStyles(this.form.css.sidebar); this.toolbarNode = this.node.getFirst("div"); this.toolbarNode.empty(); if (this.form.businessData.task){ MWF.require("MWF.widget.Toolbar", function(){ var toolbars = []; //this.form.businessData.task.routeNameList.each(function(route, i){ // if (!this.json.defaultTools) this.json.defaultTools = []; // var o= { // "type": "MWFToolBarButton", // "img": "submit.png", // "title": route, // "action": "processWork:"+route, // "text": route, // "id": "action_processWork", // "control": "allowProcessing", // "condition": "", // "read": false // }; // toolbars.push(o); //}.bind(this)); ( this.getRouteNameList() || [] ).each(function(route, i){ if (!this.json.defaultTools) this.json.defaultTools = []; var o= { "type": "MWFToolBarButton", "img": "submit.png", "title": route.displayName, "action": "processWork:"+route.routeName, "text": route.displayName, "id": "action_processWork", "control": "allowProcessing", "condition": "", "read": false }; toolbars.push(o); }.bind(this)); this.json.defaultTools = toolbars.concat(this.json.defaultTools); //this.json.defaultTools.unshift(o); /** * @summary Toolbar组件,平台使用该组件生成操作条。 * @member {o2.widget.Toolbar} * @example * //可以在脚本中获取该组件 * var toolbarWidget = this.form.get("fieldId").toolbarWidget; //获取组件对象 */ this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this); //alert(this.readonly) if (this.json.hideSystemTools){ if (this.json.tools.length){ this.setCustomToolbars(this.json.tools, this.toolbarNode); this.toolbarWidget.load(); }else{ this.toolbarNode.setStyle("display", "none"); } }else{ if (this.json.defaultTools.length || this.json.tools.length){ if (this.json.defaultTools){ this.setToolbars(this.json.defaultTools, this.toolbarNode, this.readonly); this.setCustomToolbars(this.json.tools, this.toolbarNode); this.toolbarWidget.load(); }else{ MWF.getJSON(this.form.path+"toolbars.json", function(json){ this.setToolbars(json, this.toolbarNode, this.readonly, true); this.setCustomToolbars(this.json.tools, this.toolbarNode); this.toolbarWidget.load(); }.bind(this), false); } }else{ this.toolbarNode.setStyle("display", "none"); } } if (this.toolbarWidget.children.length){ //this.form.app.addEvent("resize", this.loadPosition.bind(this)); this.node.setStyle("display", "none"); window.setTimeout(this.loadPosition.bind(this), 500); var _self = this; this.form.app.content.getFirst().addEvent("scroll", function(e){ _self.loadPosition(this); }); this.form.app.addEvent("resize", function(e){ _self.loadPosition(this); }); }else{ this.toolbarNode.setStyle("display", "none"); } }.bind(this)); } }, loadPosition: function(){ // this.node.setStyle("display", "block"); // var parent = this.node.getParent(); // while(parent && (!parent.get("MWFtype"))) parent = parent.getParent(); // // var top = this.json.styles.top; // this.sideNode = parent || this.form.node; // // var size = this.form.app.content.getSize(); // var scroll = this.form.app.content.getScroll(); // var sideSize = this.sideNode.getSize(); // // var y = (scroll.y+size.y/2)-sideSize.y/2; // var x = 5; // // var position = "centerRight"; // var edge = "centerLeft"; // if (!parent){ // edge = "centerRight"; // x = 5; // } // // if (this.json.barPosition=="left"){ // position = "centerLeft"; // edge = "centerRight"; // x = -5; // if (!parent){ // edge = "centerLeft"; // x = 5; // } // } // // this.node.position({ // "relativeTo": this.sideNode, // "position": position, // "edge": edge, // "offset" : {"y": y, "x": x} // }); // this.json.styles.top = top; // if (top) this.node.setStyle("top", top); this.node.setStyle("display", "block"); var parent = this.node.getParent(); while(parent && (!parent.get("MWFtype"))) parent = parent.getParent(); this.sideNode = parent || this.form.node; var size = this.form.app.content.getSize(); //var scroll = this.form.designer.designNode.getScroll(); var sideSize = this.sideNode.getSize(); var sidePosition = this.sideNode.getPosition(this.sideNode.getOffsetParent()); var nodeSize = this.node.getSize(); if (sideSize.y>size.y){ var center = (size.y/2-nodeSize.y/2); if (center(sidePosition.y+sideSize.y)){ var tmp = (sidePosition.y+sideSize.y)-nodeSize.y; this.node.setStyle("top", ""+tmp+"px"); }else{ this.node.setStyle("top", ""+center+"px"); } }else{ var top = sidePosition.y+sideSize.y/2-nodeSize.y/2; if (top>size.y){ if (sidePosition.y+nodeSize.y>size.y){ this.node.setStyle("top", ""+sidePosition.y+"px"); }else{ var tmp = size.y-nodeSize.y; this.node.setStyle("top", ""+tmp+"px"); } }else if(top<=0){ if(sidePosition.y+sideSize.y