aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/code-editor/codemirror-ninja-lib/ninja-simple-hint.js72
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.css53
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html78
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js76
-rwxr-xr-xjs/components/layout/document-bar.reel/document-bar.js2
-rw-r--r--js/controllers/code-editor-controller.js245
-rwxr-xr-xjs/controllers/document-controller.js3
-rw-r--r--js/io/templates/descriptor.json9
-rw-r--r--js/io/templates/files/xml.txt1
-rwxr-xr-xjs/ninja.reel/ninja.html23
-rwxr-xr-xjs/panels/Splitter.js35
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.css35
-rwxr-xr-xjs/stage/stage-view.reel/stage-view.js192
13 files changed, 701 insertions, 123 deletions
diff --git a/js/code-editor/codemirror-ninja-lib/ninja-simple-hint.js b/js/code-editor/codemirror-ninja-lib/ninja-simple-hint.js
new file mode 100644
index 00000000..e2334a45
--- /dev/null
+++ b/js/code-editor/codemirror-ninja-lib/ninja-simple-hint.js
@@ -0,0 +1,72 @@
1(function() {
2 CodeMirror.simpleHint = function(editor, getHints) {
3 // We want a single cursor position.
4 if (editor.somethingSelected()) return;
5 var result = getHints(editor);
6 if (!result || !result.list.length) return;
7 var completions = result.list;
8 function insert(str) {
9 editor.replaceRange(str, result.from, result.to);
10 }
11 // Ninja override: don't autocomplete to reduce user's typing errors
12// if (completions.length == 1) {insert(completions[0]); return true;}
13
14 // Build the select widget
15 var complete = document.createElement("div");
16 complete.className = "CodeMirror-completions";
17 var sel = complete.appendChild(document.createElement("select"));
18 // Opera doesn't move the selection when pressing up/down in a
19 // multi-select, but it does properly support the size property on
20 // single-selects, so no multi-select is necessary.
21 if (!window.opera) sel.multiple = true;
22 for (var i = 0; i < completions.length; ++i) {
23 var opt = sel.appendChild(document.createElement("option"));
24 opt.appendChild(document.createTextNode(completions[i]));
25 }
26 sel.firstChild.selected = true;
27 sel.size = Math.min(10, completions.length);
28 var pos = editor.cursorCoords();
29 complete.style.left = pos.x + "px";
30 complete.style.top = pos.yBot + "px";
31 document.body.appendChild(complete);
32 // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
33 var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
34 if(winW - pos.x < sel.clientWidth)
35 complete.style.left = (pos.x - sel.clientWidth) + "px";
36 // Hack to hide the scrollbar.
37 if (completions.length <= 10)
38 complete.style.width = (sel.clientWidth - 1) + "px";
39
40 var done = false;
41 function close() {
42 if (done) return;
43 done = true;
44 complete.parentNode.removeChild(complete);
45 }
46 function pick() {
47 insert(completions[sel.selectedIndex]);
48 close();
49 setTimeout(function(){editor.focus();}, 50);
50 }
51 CodeMirror.connect(sel, "blur", close);
52 CodeMirror.connect(sel, "keydown", function(event) {
53 var code = event.keyCode;
54 // Enter
55 if (code == 13) {CodeMirror.e_stop(event); pick();}
56 // Escape
57 else if (code == 27) {CodeMirror.e_stop(event); close(); editor.focus();}
58 else if (code != 38 && code != 40) {
59 close(); editor.focus();
60 // Pass the event to the CodeMirror instance so that it can handle things like backspace properly.
61 editor.triggerOnKeyDown(event);
62 setTimeout(function(){CodeMirror.simpleHint(editor, getHints);}, 50);
63 }
64 });
65 CodeMirror.connect(sel, "dblclick", pick);
66
67 sel.focus();
68 // Opera sometimes ignores focusing a freshly created node
69 if (window.opera) setTimeout(function(){if (!done) sel.focus();}, 100);
70 return true;
71 };
72})();
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
new file mode 100644
index 00000000..442a5183
--- /dev/null
+++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.css
@@ -0,0 +1,53 @@
1.viewOptions{
2 color:#F7F7F7;
3 font-size:12px;
4}
5
6.viewOptions div{
7 display:inline;
8}
9
10.viewOptions .autoCodeComplete{
11 float:left;
12 height: 20px;
13}
14
15.viewOptions .autoCodeComplete span{
16 vertical-align: middle;
17}
18
19.viewOptions .autoCodeComplete .disabled{
20 color:#515151;
21}
22
23.viewOptions .floatButtons{
24 float:left;
25 font-size:9px;
26 padding-left: 20px;
27}
28
29.viewOptions .format{
30 float:left;
31 margin-left:5px;
32 height: 20px;
33}
34
35.viewOptions .themeOptions{
36 float: right;
37 margin-right:5px;
38}
39
40.viewOptions .themeOptions select{
41 background-color: #616161;
42 color: white;
43 font-size:9px;
44 margin-top:2px;
45 border-color: #616161;
46}
47
48.viewOptions .themeOptions select option{
49 background-color: #616161;
50 color: white;
51 border-color: #616161;
52}
53
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
new file mode 100644
index 00000000..fadc4683
--- /dev/null
+++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html
@@ -0,0 +1,78 @@
1<!DOCTYPE HTML>
2<!-- <copyright>
3 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
4 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
5 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
6 </copyright> -->
7<html>
8<head>
9 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
10 <link rel="stylesheet" type="text/css" href="code-editor-view-options.css">
11 <script type="text/montage-serialization">
12 {
13 "codeCompleteCheck":{
14 "prototype": "montage/ui/checkbox.reel",
15 "properties": {
16 "element": {"#": "codeComplete"}
17 }
18 },
19
20 "zoomHottext": {
21 "prototype": "js/components/hottextunit.reel[HotTextUnit]",
22 "properties": {
23 "element": {"#": "zoomFont"},
24 "minValue":100,
25 "maxValue" :200,
26 "stepSize" :10,
27 "acceptableUnits" : ["%"],
28 "units" : "%"
29 }
30 },
31
32 "owner":{
33 "prototype": "js/code-editor/ui/code-editor-view-options.reel[CodeEditorViewOptions]",
34 "properties": {
35 "element": {"#": "viewOptions"},
36 "codeCompleteCheck":{"@": "codeCompleteCheck"},
37 "zoomHottext":{"@":"zoomHottext"},
38 "format":{"#": "format"},
39 "comment":{"#":"comment"},
40 "uncomment":{"#":"uncomment"},
41 "themeSelect":{"#":"themeSelect"}
42 }
43 }
44 }
45 </script>
46</head>
47<body>
48<div id="viewOptions" class="viewOptions">
49 <div>
50 <input class="zoomFont" id="zoomFont"/>
51 <div class="autoCodeComplete" >
52 <input type="checkbox" id="codeComplete" />
53 <span>Automatic Completion</span>
54 </div>
55 <div class="floatButtons">
56 <button id="format" value="format" class="nj-skinned format">Format</button>
57 <button id="comment" value="comment" class="nj-skinned format">comment</button>
58 <button id="uncomment" value="uncomment" class="nj-skinned format">uncomment</button>
59 </div>