diff --git a/o2web/source/o2_core/o2/widget/CssArea.js b/o2web/source/o2_core/o2/widget/CssArea.js index 42f37aaee08a0889aa8a5cb7d5f9761343cfd5e9..80b7baddb78fc99f873139eb83cec70b90d0cf66 100644 --- a/o2web/source/o2_core/o2/widget/CssArea.js +++ b/o2web/source/o2_core/o2/widget/CssArea.js @@ -1,6 +1,7 @@ o2.widget = o2.widget || {}; o2.require("o2.widget.ScriptArea", null, false); -o2.require("o2.widget.CssEditor", null, false); +//o2.require("o2.widget.CssEditor", null, false); + o2.widget.CssArea = new Class({ Implements: [Options, Events], Extends: o2.widget.ScriptArea, @@ -52,22 +53,31 @@ o2.widget.CssArea = new Class({ loadEditor: function(content){ var value=(content) ? content.code : ""; value = (value) ? value : ""; - this.jsEditor = new o2.widget.CssEditor(this.contentNode,{ + this.jsEditor = new o2.widget.JavascriptEditor(this.contentNode,{ "option": { + "mode": "css", "value": value, "lineNumbers": false }, "onPostLoad": function(){ this.editor = this.jsEditor.editor; this.editor.id = "2"; - this.editor.on("change", function() { + + this.jsEditor.addEditorEvent("change", function() { this.fireEvent("change"); }.bind(this)); - this.editor.on("blur", function() { + this.jsEditor.addEditorEvent("blur", function() { this.fireEvent("blur"); }.bind(this)); - this.editor.resize(); + // this.editor.on("change", function() { + // this.fireEvent("change"); + // }.bind(this)); + // this.editor.on("blur", function() { + // this.fireEvent("blur"); + // }.bind(this)); + + this.jsEditor.resize(); this.fireEvent("postLoad"); }.bind(this), "onSave": function(){ diff --git a/o2web/source/o2_core/o2/widget/HtmlEditorArea.js b/o2web/source/o2_core/o2/widget/HtmlEditorArea.js index c958cac6a904b030d012a5f4a68a690925cbfe9f..24b79c0acc866674f2dc815c6b1c09fded21a93b 100644 --- a/o2web/source/o2_core/o2/widget/HtmlEditorArea.js +++ b/o2web/source/o2_core/o2/widget/HtmlEditorArea.js @@ -1,5 +1,6 @@ o2.widget = o2.widget || {}; -o2.require("o2.widget.HtmlEditor", null, false); +//o2.require("o2.widget.HtmlEditor", null, false); +o2.require("o2.widget.ScriptArea", null, false); o2.widget.HtmlEditorArea = new Class({ Implements: [Options, Events], Extends: o2.widget.ScriptArea, @@ -7,16 +8,26 @@ o2.widget.HtmlEditorArea = new Class({ loadEditor: function(content){ var value=(content) ? content.code : ""; value = (value) ? value : ""; - this.jsEditor = new o2.widget.HtmlEditor(this.contentNode,{ + this.jsEditor = new o2.widget.JavascriptEditor(this.contentNode,{ "option": { + "mode": "html", "value": value, "lineNumbers": false }, "onPostLoad": function(){ this.editor = this.jsEditor.editor; - this.editor.on("change", function() { + + this.jsEditor.addEditorEvent("change", function() { this.fireEvent("change"); }.bind(this)); + this.jsEditor.addEditorEvent("blur", function() { + this.fireEvent("blur"); + }.bind(this)); + + // this.editor.on("change", function() { + // this.fireEvent("change"); + // }.bind(this)); + this.jsEditor.resize(); this.fireEvent("postLoad"); }.bind(this), "onSave": function(){ diff --git a/o2web/source/o2_core/o2/widget/JavascriptEditor.js b/o2web/source/o2_core/o2/widget/JavascriptEditor.js index 71f241d9d8d51041b8f894f3c1e1e39926e2d806..13faec022b7cc515ec3215fcc12619b9cbcc5172 100644 --- a/o2web/source/o2_core/o2/widget/JavascriptEditor.js +++ b/o2web/source/o2_core/o2/widget/JavascriptEditor.js @@ -89,28 +89,38 @@ o2.widget.JavascriptEditor = new Class({ this.editorClass.load(function(){ this.editor = monaco.editor.create(this.node, { value: this.options.option.value, - language: "javascript", + language: this.options.option.mode, theme: this.theme, fontSize: this.fontSize, lineNumbersMinChars: 3, + lineNumbers: (this.options.option.lineNumbers) ? "on" : "off", mouseWheelZoom: true, automaticLayout: true }); this.focus(); - o2.require("o2.xScript.Macro", function(){ + o2.require("o2.xScript.Macro", function() { var json = null; - o2.getJSON("/o2_core/o2/widget/$JavascriptEditor/environment.json", function(data){ json = data; }, false); + o2.getJSON("/o2_core/o2/widget/$JavascriptEditor/environment.json", function (data) { + json = data; + }, false); this.Macro = new o2.Macro.FormContext(json); //registerReferenceProvider //monaco.languages.registerReferenceProvider('javascript', { monaco.languages.registerCompletionItemProvider('javascript', { - provideCompletionItems: function(model, position, context, token) { + "triggerCharacters": ["."], + provideCompletionItems: function (model, position, context, token) { debugger; - var textUntilPosition = model.getValueInRange({startLineNumber: position.lineNumber, startColumn: 1, endLineNumber: position.lineNumber, endColumn: position.column}); + var textUntilPosition = model.getValueInRange({ + startLineNumber: position.lineNumber, + startColumn: 1, + endLineNumber: position.lineNumber, + endColumn: position.column + }); var textPrefix = textUntilPosition.substr(0, textUntilPosition.lastIndexOf(".")); code = "try {return "+textPrefix+";}catch(e){return null;}"; + //code = "try {return this;}catch(e){return null;}"; var o = this.Macro.exec(code); var word = model.getWordUntilPosition(position); @@ -121,43 +131,40 @@ o2.widget.JavascriptEditor = new Class({ endColumn: word.endColumn }; - if (o){ + if (o) { var arr = []; - Object.keys(o).each(function(key){ + Object.keys(o).each(function (key) { var type = typeOf(o[key]); - if (type==="function") { + if (type === "function") { var count = o[key].length; - var v = key+"("; - for (var i=1; i<=count; i++) v+= (i==count) ? "par"+i : "par"+i+", "; - v+=");"; + var v = key + "("; + for (var i = 1; i <= count; i++) v += (i == count) ? "par" + i : "par" + i + ", "; + v += ")"; arr.push({ label: key, kind: monaco.languages.CompletionItemKind.Function, //documentation: "Fast, unopinionated, minimalist web framework", insertText: v, - range: range + range: range, + detail: type }); - }else{ + } else { arr.push({ label: key, kind: monaco.languages.CompletionItemKind.Interface, //documentation: "Fast, unopinionated, minimalist web framework", insertText: key, - range: range + range: range, + detail: type }); } }); } - return {suggestions: arr} - - }.bind(this), - resolveCompletionItem: this.provideCompletionItems + }.bind(this) }); - - }.bind(this)); - + }); this.editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_S, function(e){ this.fireEvent("save"); @@ -238,14 +245,14 @@ o2.widget.JavascriptEditor = new Class({ caption: key, value: v, score: 3, - meta: "function O2" + meta: type }); }else{ arr2.push({ caption: key, value: x+"."+key, score: 3, - meta: (type!="null") ? typeOf(o[key])+" O2" : "O2" + meta: type }); } }); @@ -319,6 +326,8 @@ o2.widget.JavascriptEditor = new Class({ var ev = name; switch (ev) { case "change": ev = "onDidChangeModelContent"; break; + case "blue": ev = "onDidBlurEditorText"; break; + } if (this.editor[ev]) this.editor[ev](fun); break; diff --git a/o2web/source/o2_core/o2/widget/MWFRaphael.js b/o2web/source/o2_core/o2/widget/MWFRaphael.js index 6bde483c1383d5142fd6b5260d320ad78b252ccf..28fa766a990eaccf94c3cc4950259aec606cdb91 100644 --- a/o2web/source/o2_core/o2/widget/MWFRaphael.js +++ b/o2web/source/o2_core/o2/widget/MWFRaphael.js @@ -4,7 +4,7 @@ o2.widget.MWFRaphael = MWFRaphael = { if (window.Raphael){ if (callback) callback(); }else{ - COMMON.AjaxModule.loadDom("raphael", function(){ + COMMON.AjaxModule.load("raphael", function(){ this.expandRaphael(); if (callback) callback(); }.bind(this), true, true); diff --git a/o2web/source/o2_core/o2/widget/ScriptArea.js b/o2web/source/o2_core/o2/widget/ScriptArea.js index 2ca629b456b71aca508fce4d7357d1fb4fb4b912..c94225c5a4cd141eaa52d9cf5c93a85bab34cc5d 100644 --- a/o2web/source/o2_core/o2/widget/ScriptArea.js +++ b/o2web/source/o2_core/o2/widget/ScriptArea.js @@ -120,7 +120,7 @@ o2.widget.ScriptArea = new Class({ var th = this.titleNode.getStyle("height").toInt(); var height = (size.y || h)-(titleSize.y || th)-2-6; this.contentNode.setStyle("height", ""+height+"px"); - if (this.editor) this.editor.resize(); + if (this.jsEditor) this.jsEditor.resize(); }, toJson: function(){ return (this.editor) ? {"code": this.editor.getValue(), "html": this.editor.getValue()} : this.contentCode; @@ -190,10 +190,18 @@ o2.widget.ScriptArea = new Class({ }, "onPostLoad": function(){ this.editor = this.jsEditor.editor; - this.editor.id = "2"; - this.editor.on("change", function() { + //this.editor.id = "2"; + + this.jsEditor.addEditorEvent("change", function() { this.fireEvent("change"); }.bind(this)); + this.jsEditor.addEditorEvent("blur", function() { + this.fireEvent("blur"); + }.bind(this)); + + // this.editor.on("change", function() { + // this.fireEvent("change"); + // }.bind(this)); // this.editor.on("paste", function() { // o2.load("JSBeautifier", function(){ // this.editor.setValue(js_beautify(this.editor.getValue())); @@ -201,7 +209,7 @@ o2.widget.ScriptArea = new Class({ // this.fireEvent("paste"); // }.bind(this)); - this.editor.resize(); + this.jsEditor.resize(); this.fireEvent("postLoad"); }.bind(this), "onSave": function(){ diff --git a/o2web/source/x_component_cms_ScriptDesigner/Script.js b/o2web/source/x_component_cms_ScriptDesigner/Script.js index 961054bf739e7bee3e2b3f466ef1832298d04dbb..119f40002bf39ba439c1ffb7a5ee988b94d7c352 100644 --- a/o2web/source/x_component_cms_ScriptDesigner/Script.js +++ b/o2web/source/x_component_cms_ScriptDesigner/Script.js @@ -104,12 +104,20 @@ MWF.xApplication.cms.ScriptDesigner.Script = new Class({ if (this.data.text) { this.editor.editor.setValue(this.data.text); } - this.editor.editor.on("change", function (e) { - if (!this.isChanged) { + this.editor.addEditorEvent("change", function(){ + if (!this.isChanged){ this.isChanged = true; - this.page.textNode.set("text", " * " + this.page.textNode.get("text")); + this.page.textNode.set("text", " * "+this.page.textNode.get("text")); } }.bind(this)); + + // this.editor.editor.on("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)); diff --git a/o2web/source/x_component_portal_PageDesigner/Script.js b/o2web/source/x_component_portal_PageDesigner/Script.js index 40e66623d4dc782fe52733ad6cfde1bf94313abc..96d97d2c49664c9e778a96f5a0403a530fa1449f 100644 --- a/o2web/source/x_component_portal_PageDesigner/Script.js +++ b/o2web/source/x_component_portal_PageDesigner/Script.js @@ -545,10 +545,18 @@ MWF.xApplication.portal.PageDesigner.Script = new Class({ }, "onPostLoad": function(){ this.editor = this.jsEditor.editor; - this.editor.on("change", function() { + + this.jsEditor.addEditorEvent("change", function() { this.fireEvent("change"); }.bind(this)); - this.editor.resize(); + this.jsEditor.addEditorEvent("blur", function() { + this.fireEvent("blur"); + }.bind(this)); + + // this.editor.on("change", function() { + // this.fireEvent("change"); + // }.bind(this)); + this.jsEditor.resize(); if (callback) callback(); this.fireEvent("postLoad"); }.bind(this), @@ -842,12 +850,22 @@ MWF.xApplication.portal.PageDesigner.Script.Item = new Class({ "onPostLoad": function(){ this.editor = this.jsEditor.editor; this.editor.id = "1"; - this.editor.on("change", function() { + + this.jsEditor.addEditorEvent("change", function() { var text = this.scriptPage.textNode.get("text"); if (text.substr(0,1)!=="*") this.scriptPage.textNode.set("text","*"+ text); this.change(); }.bind(this)); - this.editor.resize(); + this.jsEditor.addEditorEvent("blur", function() { + this.fireEvent("blur"); + }.bind(this)); + + // this.editor.on("change", function() { + // var text = this.scriptPage.textNode.get("text"); + // if (text.substr(0,1)!=="*") this.scriptPage.textNode.set("text","*"+ text); + // this.change(); + // }.bind(this)); + this.jsEditor.resize(); }.bind(this), "onSave": function(){ this.save(); diff --git a/o2web/source/x_component_portal_ScriptDesigner/Script.js b/o2web/source/x_component_portal_ScriptDesigner/Script.js index 2fd4cfd6d65d6ae4c9b8c5d9dd59b7fc5b4d4ed5..382728838065cd9905e23d189a6b7a3b650de3a6 100644 --- a/o2web/source/x_component_portal_ScriptDesigner/Script.js +++ b/o2web/source/x_component_portal_ScriptDesigner/Script.js @@ -102,12 +102,18 @@ MWF.xApplication.portal.ScriptDesigner.Script = new Class({ if (this.data.text){ this.editor.editor.setValue(this.data.text); } - this.editor.editor.on("change", function(e){ + this.editor.addEditorEvent("change", function(){ if (!this.isChanged){ this.isChanged = true; this.page.textNode.set("text", " * "+this.page.textNode.get("text")); } }.bind(this)); + // this.editor.editor.on("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)); diff --git a/o2web/source/x_component_process_ProcessDesigner/widget/ScriptText.js b/o2web/source/x_component_process_ProcessDesigner/widget/ScriptText.js index ae99c6ae6fdfe7840738e1690a82cf7ffb2d9286..7caedb631e0799d68f6c4b18357c19bff7d7c65c 100644 --- a/o2web/source/x_component_process_ProcessDesigner/widget/ScriptText.js +++ b/o2web/source/x_component_process_ProcessDesigner/widget/ScriptText.js @@ -56,17 +56,23 @@ MWF.xApplication.process.ProcessDesigner.widget.ScriptText = new Class({ this.editor = new MWF.widget.JavascriptEditor(this.editorNode, { "option": {"value": this.code}, "onSave": function(){ - var value = this.editor.editor.getValue(); + var value = this.editor.getValue(); this.fireEvent("change", [value]); this.app.saveProcess(); }.bind(this) }); this.editor.load(function(){ - this.editor.editor.on("blur", function(){ - var value = this.editor.editor.getValue(); + + this.editor.addEditorEvent("blur", function(){ + var value = this.editor.getValue(); this.fireEvent("change", [value]); }.bind(this)); + // this.editor.editor.on("blur", function(){ + // var value = this.editor.editor.getValue(); + // this.fireEvent("change", [value]); + // }.bind(this)); + this.createScriptReferenceMenu(); this.editor.addEvent("reference", function(editor, e, e1){ diff --git a/o2web/source/x_component_query_StatementDesigner/Statement.js b/o2web/source/x_component_query_StatementDesigner/Statement.js index 75b1e5473aafc2d5a611db671427cf0d38e5a997..fbec6b8248f9085c00c9e06bdfa6ebdea5f5e854 100644 --- a/o2web/source/x_component_query_StatementDesigner/Statement.js +++ b/o2web/source/x_component_query_StatementDesigner/Statement.js @@ -208,10 +208,15 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({ } this.json.data = this.editor.editor.getValue(); - this.editor.editor.on("change", function(){ - this.data.data = this.editor.editor.getValue(); + this.editor.addEditorEvent("change", function(){ + this.data.data = this.editor.getValue(); this.checkJpqlType(); }.bind(this)); + + // this.editor.editor.on("change", function(){ + // this.data.data = this.editor.getValue(); + // this.checkJpqlType(); + // }.bind(this)); }.bind(this)); }.bind(this), false); } diff --git a/o2web/source/x_component_query_TableDesigner/Table.js b/o2web/source/x_component_query_TableDesigner/Table.js index 1084acf639e72c75c76b1a08cefa140208c75b61..8fe79447fc60dbf0ce4e06565275d373709b7507 100644 --- a/o2web/source/x_component_query_TableDesigner/Table.js +++ b/o2web/source/x_component_query_TableDesigner/Table.js @@ -1099,9 +1099,13 @@ MWF.xApplication.query.TableDesigner.Table.JPQLRunner = new Class({ o2.require("o2.widget.JavascriptEditor", function(){ this.editor = new o2.widget.JavascriptEditor(this.contentWhereArea, {"title": "JPQL", "option": {"mode": "sql"}}); this.editor.load(function(){ - this.editor.editor.on("change", function(){ + this.editor.addEditorEvent("change", function(){ this.checkJpqlType(); }.bind(this)); + + // this.editor.editor.on("change", function(){ + // this.checkJpqlType(); + // }.bind(this)); if (callback) callback(); }.bind(this)); }.bind(this), false); diff --git a/o2web/source/x_component_service_AgentDesigner/Agent.js b/o2web/source/x_component_service_AgentDesigner/Agent.js index 0bd438f2fb232de1e8aa442a8eb215bd0a411d60..434924071628ced36b2dc2d88f3595928666905e 100644 --- a/o2web/source/x_component_service_AgentDesigner/Agent.js +++ b/o2web/source/x_component_service_AgentDesigner/Agent.js @@ -117,12 +117,19 @@ MWF.xApplication.service.AgentDesigner.Agent = new Class({ defaultText += "********************/\n"; this.editor.editor.setValue(defaultText); } - this.editor.editor.on("change", function(e){ + this.editor.addEditorEvent("change", function(){ if (!this.isChanged){ this.isChanged = true; this.page.textNode.set("text", " * "+this.page.textNode.get("text")); } }.bind(this)); + + // this.editor.editor.on("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)); diff --git a/o2web/source/x_component_service_InvokeDesigner/Invoke.js b/o2web/source/x_component_service_InvokeDesigner/Invoke.js index 64e65703d2fd4cb899e591ea5321355d2fb7091e..caf8fa226a8eeab0d7c5a3d9b7f851e8e2ad4059 100644 --- a/o2web/source/x_component_service_InvokeDesigner/Invoke.js +++ b/o2web/source/x_component_service_InvokeDesigner/Invoke.js @@ -124,12 +124,19 @@ MWF.xApplication.service.InvokeDesigner.Invoke = new Class({ defaultText += "********************/\n"; this.editor.editor.setValue(defaultText); } - this.editor.editor.on("change", function(e){ + this.editor.addEditorEvent("change", function(){ if (!this.isChanged){ this.isChanged = true; this.page.textNode.set("text", " * "+this.page.textNode.get("text")); } }.bind(this)); + + // this.editor.editor.on("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));