aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJonathan Duran2012-06-27 12:10:00 -0700
committerJonathan Duran2012-06-27 12:10:00 -0700
commitae2067a09cd9cd0ee60eac7bd35395bf81045626 (patch)
treef233ad47ef7ff229c8595d0b2ce36c3be7e7aec7 /js
parent0b0ad28a216d839aab37b2563912bb82f79768d1 (diff)
parent8351c3685a6db703d1940817abc71f92ef4e1bd4 (diff)
downloadninja-ae2067a09cd9cd0ee60eac7bd35395bf81045626.tar.gz
Merge branch 'refs/heads/NINJAmaster' into TimelineUber
Diffstat (limited to 'js')
-rw-r--r--js/code-editor/code-editor-wrapper.js (renamed from js/controllers/code-editor-controller.js)34
-rw-r--r--js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js6
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html10
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js62
-rwxr-xr-xjs/document/views/code.js2
-rwxr-xr-xjs/ninja.reel/ninja.html9
-rwxr-xr-xjs/ninja.reel/ninja.js2
7 files changed, 82 insertions, 43 deletions
diff --git a/js/controllers/code-editor-controller.js b/js/code-editor/code-editor-wrapper.js
index f3c19b92..942bd5cd 100644
--- a/js/controllers/code-editor-controller.js
+++ b/js/code-editor/code-editor-wrapper.js
@@ -9,7 +9,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component; 10 Component = require("montage/ui/component").Component;
11 11
12exports.CodeEditorController = Montage.create(Component, { 12exports.CodeEditorWrapper = Montage.create(Component, {
13 hasTemplate: { 13 hasTemplate: {
14 value: false 14 value: false
15 }, 15 },
@@ -32,8 +32,9 @@ exports.CodeEditorController = Montage.create(Component, {
32 if(!value) { 32 if(!value) {
33 33
34 } else if(this._currentDocument.currentView === "code") { 34 } else if(this._currentDocument.currentView === "code") {
35 this.autocomplete = !this.codeCompletionSupport[this._currentDocument.model.file.extension]; 35 this.autocomplete = this.codeCompletionSupport[this._currentDocument.model.file.extension];
36 this._currentDocument.model.views.code.editor.focus(); 36 this._currentDocument.model.views.code.editor.focus();
37
37 this.applySettings(); 38 this.applySettings();
38 } 39 }
39 } 40 }
@@ -56,21 +57,6 @@ exports.CodeEditorController = Montage.create(Component, {
56 value: false 57 value: false
57 }, 58 },
58 59
59 _automaticCodeComplete: {
60 value:false
61 },
62
63 automaticCodeComplete:{
64 get: function(){
65 return this._automaticCodeComplete;
66 },
67 set: function(value) {
68 if(this._automaticCodeComplete !== value) {
69 this._automaticCodeComplete = value;
70 }
71 }
72 },
73
74 _editorTheme: { 60 _editorTheme: {
75 value:"default" 61 value:"default"
76 }, 62 },
@@ -93,7 +79,10 @@ exports.CodeEditorController = Montage.create(Component, {
93 return this._zoomFactor; 79 return this._zoomFactor;
94 }, 80 },
95 set: function(value) { 81 set: function(value) {
96 this.handleZoom(value); 82 if(value !== this._zoomFactor){
83 this._zoomFactor = value;
84 this.handleZoom(value);
85 }
97 } 86 }
98 }, 87 },
99 88
@@ -112,6 +101,10 @@ exports.CodeEditorController = Montage.create(Component, {
112 value:function(codeDocumentView, type, documentType, textDocument){ 101 value:function(codeDocumentView, type, documentType, textDocument){
113 var self = this, editorOptions = null; 102 var self = this, editorOptions = null;
114 103
104 if(!this.application.ninja.editorViewOptions.codeEditorWrapper){
105 this.application.ninja.editorViewOptions.codeEditorWrapper = this;
106 }
107
115 editorOptions = { 108 editorOptions = {
116 lineNumbers: true, 109 lineNumbers: true,
117 matchBrackets:true, 110 matchBrackets:true,
@@ -132,6 +125,9 @@ exports.CodeEditorController = Montage.create(Component, {
132 }; 125 };
133 126
134 //configure auto code completion if it is supported for that document type 127 //configure auto code completion if it is supported for that document type
128
129 this.autocomplete = this.codeCompletionSupport[documentType];
130
135 if(this.autocomplete) { 131 if(this.autocomplete) {
136 132
137 editorOptions.onKeyEvent = function(cm, keyEvent){ 133 editorOptions.onKeyEvent = function(cm, keyEvent){
@@ -163,7 +159,7 @@ exports.CodeEditorController = Montage.create(Component, {
163 } 159 }
164 160
165 //===manually triggered code completion 161 //===manually triggered code completion
166 if((this.automaticCodeComplete === false)){ 162 if((this.currentDocument.model.views.code.editor.automaticCodeHint === false)){
167 if(keyEvent.ctrlKey && keyEvent.keyCode === 32){//Ctrl+Space 163 if(keyEvent.ctrlKey && keyEvent.keyCode === 32){//Ctrl+Space
168 this.codeEditor.simpleHint(cm, this.codeEditor.javascriptHint); 164 this.codeEditor.simpleHint(cm, this.codeEditor.javascriptHint);
169 } 165 }
diff --git a/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js b/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js
index 4787b4f8..99fe2d21 100644
--- a/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js
+++ b/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js
@@ -13,7 +13,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
13 13
14 // Ninja override: don't show code hinting if the token is empty 14 // Ninja override: don't show code hinting if the token is empty
15 var tempToken = editor.getTokenAt(editor.getCursor()); 15 var tempToken = editor.getTokenAt(editor.getCursor());
16 if(tempToken && ((tempToken.string === "") || !(/[\S]/gi.test(tempToken.string)))) return;//check that token has only spaces 16 if(!(/[\S]/gi.test(tempToken.string))) return;
17 17
18 18
19 var result = getHints(editor); 19 var result = getHints(editor);
@@ -22,8 +22,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
22 function insert(str) { 22 function insert(str) {
23 editor.replaceRange(str, result.from, result.to); 23 editor.replaceRange(str, result.from, result.to);
24 } 24 }
25 // Ninja override: don't autocomplete to reduce user's typing errors 25
26// if (completions.length == 1) {insert(completions[0]); return true;} 26 //if (completions.length == 1) {insert(completions[0]); return true;}
27 27
28 // Build the select widget 28 // Build the select widget
29 var complete = document.createElement("div"); 29 var complete = document.createElement("div");
diff --git a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html
index 4448e1f1..9871525b 100644
--- a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html
+++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html
@@ -11,12 +11,13 @@
11 <script type="text/montage-serialization"> 11 <script type="text/montage-serialization">
12 { 12 {
13 "codeCompleteCheck":{ 13 "codeCompleteCheck":{
14 "prototype": "montage/ui/input-checkbox.reel", 14 "prototype": "montage/ui/native/input-checkbox.reel",
15 "properties": { 15 "properties": {
16 "element": {"#": "codeComplete"} 16 "element": {"#": "codeComplete"}
17 }, 17 },
18 "bindings": { 18 "bindings": {
19 "disabled": {"<-": "@owner.autocomplete"} 19 "disabled": {"<-": "@owner.autocomplete"},
20 "checked": {"<->": "@owner.automaticCodeHint"}
20 } 21 }
21 }, 22 },
22 23
@@ -29,6 +30,9 @@
29 "stepSize" :10, 30 "stepSize" :10,
30 "acceptableUnits" : ["%"], 31 "acceptableUnits" : ["%"],
31 "units" : "%" 32 "units" : "%"
33 },
34 "bindings": {
35 "value": {"<->": "@owner.zoomFactor"}
32 } 36 }
33 }, 37 },
34 38
@@ -54,7 +58,7 @@
54 <input class="zoomFont" data-montage-id="zoomFont"/> 58 <input class="zoomFont" data-montage-id="zoomFont"/>
55 <div class="autoCodeComplete" > 59 <div class="autoCodeComplete" >
56 <input type="checkbox" data-montage-id="codeComplete" /> 60 <input type="checkbox" data-montage-id="codeComplete" />
57 <label data-montage-id="autoCompleteLabel">Automatic Completion</label> 61 <label data-montage-id="autoCompleteLabel">Auto Code Hints</label>
58 </div> 62 </div>
59 <div class="floatButtons"> 63 <div class="floatButtons">
60 <!--<button disabled="disabled" id="format" value="format" class="nj-skinned format">Format</button>--> 64 <!--<button disabled="disabled" id="format" value="format" class="nj-skinned format">Format</button>-->
diff --git a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js
index 13c9a705..5a33909c 100644
--- a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js
+++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js
@@ -31,11 +31,27 @@ exports.CodeEditorViewOptions = Montage.create(Component, {
31 } else { 31 } else {
32 this.visible = true; 32 this.visible = true;
33 this.autocomplete = !this.codeCompletionSupport[this._currentDocument.model.file.extension]; 33 this.autocomplete = !this.codeCompletionSupport[this._currentDocument.model.file.extension];
34 this._currentDocument.model.views.code.editor.automaticCodeHint = this.codeCompleteCheck.checked;
34 } 35 }
35 36
36 } 37 }
37 }, 38 },
38 39
40 _codeEditorWrapper:{
41 value: null
42 },
43
44 codeEditorWrapper:{
45 get : function() {
46 return this._codeEditorWrapper;
<