aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.css13
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html12
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js20
-rw-r--r--js/controllers/code-editor-controller.js21
4 files changed, 63 insertions, 3 deletions
diff --git a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.css b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.css
index 5aa66af2..90cf88d3 100644
--- a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.css
+++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.css
@@ -1,3 +1,14 @@
1.viewOptions{ 1.viewOptions{
2 color:#F7F7F7; 2 color:#F7F7F7;
3} \ No newline at end of file 3 font-size:12px;
4}
5
6.viewOptions div{
7 display:inline;
8}
9
10.viewOptions .format{
11 float:right;
12 font-size:9px;
13}
14
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 c6d3da4e..6698baa9 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
@@ -36,7 +36,10 @@
36 "properties": { 36 "properties": {
37 "element": {"#": "viewOptions"}, 37 "element": {"#": "viewOptions"},
38 "codeCompleteCheck":{"@": "codeCompleteCheck"}, 38 "codeCompleteCheck":{"@": "codeCompleteCheck"},
39 "zoomHottext":{"@":"zoomHottext"} 39 "zoomHottext":{"@":"zoomHottext"},
40 "format":{"#": "format"},
41 "comment":{"#":"comment"},
42 "uncomment":{"#":"uncomment"}
40 } 43 }
41 } 44 }
42 } 45 }
@@ -47,8 +50,13 @@
47 <div> 50 <div>
48 <input class="zoomFont" id="zoomFont"/> 51 <input class="zoomFont" id="zoomFont"/>
49 <div class="autoCodeComplete" > 52 <div class="autoCodeComplete" >
50 <span>Automatic Code completion</span>
51 <input type="checkbox" id="codeComplete" /> 53 <input type="checkbox" id="codeComplete" />
54 <span>Automatic Completion</span>
55 </div>
56 <div class="floatButtons">
57 <!--<button id="format" value="format" class="nj-skinned format">Format</button>-->
58 <button id="comment" value="comment" class="nj-skinned format">comment</button>
59 <button id="uncomment" value="uncomment" class="nj-skinned format">uncomment</button>
52 </div> 60 </div>
53 </div> 61 </div>
54</div> 62</div>
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 a1ff8547..a381ae2a 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
@@ -42,7 +42,27 @@ var CodeEditorViewOptions = exports.CodeEditorViewOptions = Montage.create(Compo
42 didDraw: { 42 didDraw: {
43 enumerable: false, 43 enumerable: false,
44 value: function() { 44 value: function() {
45 this.format.addEventListener("click", this.handleFormat.bind(this), false);
46 this.comment.addEventListener("click", this.handleComment.bind(this), false);
47 this.uncomment.addEventListener("click", this.handleUncomment.bind(this), false);
48 }
49 },
50
51 handleFormat:{
52 value: function(){
53 this.application.ninja.codeEditorController.autoFormatSelection();
54 }
55 },
56 handleComment:{
57 value: function(){
58 this.application.ninja.codeEditorController.commentSelection(true);
59 }
60 },
45 61
62 handleUncomment:{
63 value: function(){
64 this.application.ninja.codeEditorController.commentSelection(false);
46 } 65 }
47 } 66 }
67
48}); \ No newline at end of file 68}); \ No newline at end of file
diff --git a/js/controllers/code-editor-controller.js b/js/controllers/code-editor-controller.js
index 534d4645..52eb47eb 100644
--- a/js/controllers/code-editor-controller.js
+++ b/js/controllers/code-editor-controller.js
@@ -162,5 +162,26 @@ var CodeEditorController = exports.CodeEditorController = Montage.create(Compone
162 autoCodeCompleteElem.style.visibility = "hidden"; 162 autoCodeCompleteElem.style.visibility = "hidden";
163 } 163 }
164 } 164 }
165 },
166
167 getSelectedRange:{
168 value:function(editor){
169 return { from: editor.getCursor(true), to: editor.getCursor(false) };
170 }
171 },
172
173 autoFormatSelection:{
174 value: function(){
175 var range = this.getSelectedRange(this.application.ninja.documentController.activeDocument.editor);
176 this.application.ninja.documentController.activeDocument.editor.autoFormatRange(range.from, range.to);
177 }
178 },
179
180 commentSelection:{
181 value: function(isComment){
182 var range = this.getSelectedRange(this.application.ninja.documentController.activeDocument.editor);
183 this.application.ninja.documentController.activeDocument.editor.commentRange(isComment, range.from, range.to);
184 }
165 } 185 }
186
166}); \ No newline at end of file 187}); \ No newline at end of file