MWF.xApplication.process = MWF.xApplication.process || {}; MWF.xApplication.process.FormDesigner = MWF.xApplication.process.FormDesigner || {}; MWF.xApplication.process.FormDesigner.widget = MWF.xApplication.process.FormDesigner.widget || {}; MWF.require("MWF.widget.ScriptArea", null, false); MWF.require("MWF.widget.Maplist", null, false); MWF.xApplication.process.FormDesigner.widget.ActionsEditor = new Class({ Implements: [Options, Events], Extends: MWF.widget.Common, options: { "style": "default", "maxObj": document.body, "isSystemTool" : false, "noCreate": false, "noDelete": false, "noCode": false, "noHide": false, "systemToolsAddress" : "../x_component_process_FormDesigner/Module/Actionbar/toolbars.json" }, initialize: function(node, designer, module, options){ this.setOptions(options); this.node = $(node); this.module = module; this.designer = designer; this.path = "../x_component_process_FormDesigner/widget/$ActionsEditor/"; this.cssPath = "../x_component_process_FormDesigner/widget/$ActionsEditor/"+this.options.style+"/css.wcss"; this._loadCss(); this.actions = []; this.currentEditItem = null; this.createActionsAreaNode(); }, createActionsAreaNode: function(){ this.actionsContainer = new Element("div", { "styles": this.css.actionsContainer }).inject(this.node); // var size = this.node.getUsefulSize(); // this.eventsContainer.setStyle("height", size.y); }, load: function(data){ this.loadActionsArea(); if (!this.options.noCreate) this.loadCreateActionButton(); this.data = data; if ( !this.data || typeOf(this.data)!=="array") this.data = []; this.loadRestoreActionButton(); this.data.each(function(actionData, idx){ if (actionData.type!=="MWFToolBarSeparator"){ var action = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor.ButtonAction(this); action.load(actionData); this.actions.push(action); } }.bind(this)); }, loadActionsArea: function(){ if (!this.options.noCreate){ this.actionTitleArea = new Element("div", { "styles": this.css.actionTitleArea }).inject(this.actionsContainer); } this.actionArea = new Element("div", { "styles": this.css.actionArea }).inject(this.actionsContainer); }, loadCreateActionButton: function(){ this.createActionButtonButton = new Element("div", { "styles": this.css.createActionButton, "title" : this.designer.lp.actionbar.addCustomTool, "text": "+" }).inject(this.actionTitleArea); this.createActionButtonButton.addEvent("click", function(){ this.addButtonAction(); }.bind(this)); }, loadRestoreActionButton : function(){ if( this.options.isSystemTool ){ if( !this.actionTitleArea ){ this.actionTitleArea = new Element("div", { "styles": this.css.actionTitleArea }).inject(this.actionArea,"before"); } this.restoreActionButtonButton = new Element("div", { "styles": this.css.restoreActionButton, "title" : this.designer.lp.actionbar.restoreDefaultTool }).inject(this.actionTitleArea); this.restoreActionButtonButton.addEvent("click", function(){ debugger; this.restoreButtonAction(); }.bind(this)); } }, listRemovedSystemTool : function(){ var list = []; if( !this.defaultTools ){ MWF.getJSON( this.options.systemToolsAddress, function(tools){ this.defaultTools = tools; if( this.options.target && this.options.target === "mobileForm" ){ this.defaultTools.push({ "type": "MWFToolBarButton", "img": "read.png", "title": this.designer.lp.actionbar.setReaded, "action": "readedWork", "text": this.designer.lp.actionbar.readed, "id": "action_readed", "control": "allowReadProcessing", "condition": "", "read": true }); } }.bind(this), false); } this.defaultTools.each( function( tool ){ var flag = true; for( var i=0; i<(this.data || []).length; i++ ){ if( this.data[i].id === tool.id ){ flag = false; break; } } if(flag)list.push(tool); }.bind(this)); return list; }, addButtonAction: function(){ var o = { "type": "MWFToolBarButton", "img": "4.png", "title": "", "action": "", "text": "Unnamed", "actionScript" : "", "condition": "", "editShow": true, "readShow": true }; var action = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor.ButtonAction(this); action.load(o); this.data.push(o); this.actions.push(action); this.fireEvent("change", [{ compareName: " [addAction]", force: true }]); }, restoreButtonAction : function(){ var list = this.listRemovedSystemTool(); if( !list.length )return; var selectableItems = []; list.each( function(d){ var title = ""; if( d.text && this.designer.lp.actionBar ){ title = this.designer.lp.actionBar[ d.text.split(".").getLast().replace("}}","") ] || ""; title = title ? (" (" + title + ")") : ""; } selectableItems.push( { name : d.text + title, id : d.id }) }.bind(this)); MWF.xDesktop.requireApp("Template", "Selector.Custom", null, false); var opt = { "count": 0, "title": this.designer.lp.actionbar.selectDefaultTool, "selectableItems" : selectableItems, "values": [], "onComplete": function( array ){ if( !array || array.length === 0 )return; var actionNameList = []; array.each( function(tool){ for( var i=0; i