MWF.xApplication = MWF.xApplication || {}; MWF.xApplication.cms = MWF.xApplication.cms || {}; MWF.xApplication.cms.ScriptDesigner = MWF.xApplication.cms.ScriptDesigner || {}; MWF.CMSSD = MWF.xApplication.cms.ScriptDesigner; MWF.require("MWF.widget.Common", null, false); MWF.xDesktop.requireApp("cms.ScriptDesigner", "lp."+MWF.language, null, false); MWF.require("MWF.widget.JavascriptEditor", null, false); MWF.xApplication.cms.ScriptDesigner.Script = new Class({ Extends: MWF.widget.Common, Implements: [Options, Events], options: { "style": "default", "showTab": true }, initialize: function(designer, data, options){ this.setOptions(options); this.path = "../x_component_cms_ScriptDesigner/$Script/"; this.cssPath = "../x_component_cms_ScriptDesigner/$Script/"+this.options.style+"/css.wcss"; this._loadCss(); this.isChanged = false; this.designer = designer; this.data = data; if (!this.data.text) this.data.text = ""; this.node = this.designer.designNode; this.tab = this.designer.scriptTab; this.areaNode = new Element("div", {"styles": {"overflow": "hidden", "height": "700px"}}); this.propertyIncludeNode = this.designer.propertyDomArea; this.propertyNode = this.designer.propertyContentArea; if(this.designer.application) this.data.applicationName = this.designer.application.name; if(this.designer.application) this.data.application = this.designer.application.id; this.isNewScript = (this.data.id) ? false : true; // this.createProperty(); this.autoSave(); this.designer.addEvent("queryClose", function(){ if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID); }.bind(this)); }, autoSave: function(){ this.autoSaveTimerID = window.setInterval(function(){ if (!this.autoSaveCheckNode) this.autoSaveCheckNode = this.designer.contentToolbarNode.getElement("#MWFScriptAutoSaveCheck"); if (this.autoSaveCheckNode){ if (this.autoSaveCheckNode.get("checked")){ if (this.isChanged) this.saveSilence(); } } }.bind(this), 60000); }, //createProperty: function(){ // this.scriptPropertyNode = new Element("div", {"styles": this.css.scriptPropertyNode}).inject(this.propertyNode); //}, load : function(){ this.setAreaNodeSize(); this.designer.addEvent("resize", this.setAreaNodeSize.bind(this)); this.page = this.tab.addTab(this.areaNode, this.data.name || this.designer.lp.newScript, (!this.data.isNewScript && this.data.id!=this.designer.options.id)); this.page.script = this; this.page.addEvent("show", function(){ this.designer.scriptListAreaNode.getChildren().each(function(node){ var scrtip = node.retrieve("script"); if (scrtip.id==this.data.id){ if (this.designer.currentListScriptItem){ this.designer.currentListScriptItem.setStyles(this.designer.css.listScriptItem); } node.setStyles(this.designer.css.listScriptItem_current); this.designer.currentListScriptItem = node; this.lisNode = node; } }.bind(this)); this.designer.currentScript = this; this.setPropertyContent(); this.setIncludeNode(); if (this.editor){ this.editor.focus(); }else{ this.loadEditor(); } this.setAreaNodeSize(); //if (this.editor.editor){ // this.editor.editor.focus(); //} }.bind(this)); var _self = this; this.page.addEvent("queryClose", function(){ if (_self.autoSaveTimerID) window.clearInterval(_self.autoSaveTimerID); this.showIm(); //this.saveSilence(); if (_self.lisNode) _self.lisNode.setStyles(_self.designer.css.listScriptItem); }); this.page.tabNode.addEvent("dblclick", this.designer.maxOrReturnEditor.bind(this.designer)); if (this.options.showTab) this.page.showTabIm(); }, loadEditor: function(){ this.editor = new MWF.widget.JavascriptEditor(this.areaNode, {"option": {"value": this.data.text}}); this.editor.load(function() { if (this.data.text)this.editor.setValue(this.data.text); this.editor.addEditorEvent("change", function(e){ if (!this.isChanged){ this.isChanged = true; this.page.textNode.set("text", " * "+this.page.textNode.get("text")); } }.bind(this)); this.editor.addEvent("save", function () { this.save(); }.bind(this)); //this.editor.addEvent("reference", function (editor, e, e1) { // if (!this.scriptReferenceMenu) { // MWF.require("MWF.widget.ScriptHelp", function () { // this.scriptReferenceMenu = new MWF.widget.ScriptHelp(null, this.editor.editor, { // "onPostLoad": function () { // this.showReferenceMenu(); // }.bind(this) // }); // this.scriptReferenceMenu.getEditor = function () { // return this.editor.editor; // }.bind(this) // }.bind(this)); // } else { // this.showReferenceMenu(); // } //}.bind(this)); if (this.designer.styleSelectNode) { var options = this.designer.styleSelectNode.options; for (var i = 0; i < options.length; i++) { var option = options[i]; if (option.value == this.editor.theme) { option.set("selected", true); break; } } } if(this.designer.fontsizeSelectNode){ var options = this.designer.fontsizeSelectNode.options; for (var i=0; i