aboutsummaryrefslogtreecommitdiff
path: root/js/code-editor
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-04 15:31:40 -0700
committerValerio Virgillito2012-05-04 15:31:40 -0700
commit3ebed34665fa73b0ce613b400f3029ebf4476439 (patch)
tree09a3c592035030bda7bb62d1f908ce263377d74c /js/code-editor
parent8dcbac5d4c30e9dfbc543a5f997939111e9c9f89 (diff)
parent526e423e4a2734c2b139af23911e912452a4443f (diff)
downloadninja-3ebed34665fa73b0ce613b400f3029ebf4476439.tar.gz
Merge branch 'refs/heads/master' into dom-architecture
Diffstat (limited to 'js/code-editor')
-rw-r--r--js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js86
-rw-r--r--js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css54
-rw-r--r--js/code-editor/codemirror-ninja/theme/rubyblue-ninja.css30
-rw-r--r--js/code-editor/codemirror-ninja/theme/xq-dark-ninja.css54
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.css112
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.html87
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js79
7 files changed, 502 insertions, 0 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..4787b4f8
--- /dev/null
+++ b/js/code-editor/codemirror-ninja/lib/ninja-simple-hint.js
@@ -0,0 +1,86 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7/* adopted from CodeMirror 2.23 (http://codemirror.net/) */
8
9(function() {
10 CodeMirror.simpleHint = function(editor, getHints) {
11 // We want a single cursor position.
12 if (editor.somethingSelected()) return;
13
14 // Ninja override: don't show code hinting if the token is empty
15 var tempToken = editor.getTokenAt(editor.getCursor());
16 if(tempToken && ((tempToken.string === "") || !(/[\S]/gi.test(tempToken.string)))) return;//check that token has only spaces
17
18
19 var result = getHints(editor);
20 if (!result || !result.list.length) return;
21 var completions = result.list;
22 function insert(str) {
23 editor.replaceRange(str, result.from, result.to);
24 }
25 // Ninja override: don't autocomplete to reduce user's typing errors
26// if (completions.length == 1) {insert(completions[0]); return true;}
27
28 // Build the select widget
29 var complete = document.createElement("div");
30 complete.className = "CodeMirror-completions";
31 var sel = complete.appendChild(document.createElement("select"));
32 // Opera doesn't move the selection when pressing up/down in a
33 // multi-select, but it does properly support the size property on
34 // single-selects, so no multi-select is necessary.
35 if (!window.opera) sel.multiple = true;
36 for (var i = 0; i < completions.length; ++i) {
37 var opt = sel.appendChild(document.createElement("option"));
38 opt.appendChild(document.createTextNode(completions[i]));
39 }
40 sel.firstChild.selected = true;
41 sel.size = Math.min(10, completions.length);
42 var pos = editor.cursorCoords();
43 complete.style.left = pos.x + "px";
44 complete.style.top = pos.yBot + "px";
45 document.body.appendChild(complete);
46 // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
47 var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
48 if(winW - pos.x < sel.clientWidth)
49 complete.style.left = (pos.x - sel.clientWidth) + "px";
50 // Hack to hide the scrollbar.
51 if (completions.length <= 10)
52 complete.style.width = (sel.clientWidth - 1) + "px";
53
54 var done = false;
55 function close() {
56 if (done) return;
57 done = true;
58 complete.parentNode.removeChild(complete);
59 }
60 function pick() {
61 insert(completions[sel.selectedIndex]);
62 close();
63 setTimeout(function(){editor.focus();}, 50);
64 }
65 CodeMirror.connect(sel, "blur", close);
66 CodeMirror.connect(sel, "keydown", function(event) {
67 var code = event.keyCode;
68 // Enter
69 if (code == 13) {CodeMirror.e_stop(event); pick();}
70 // Escape
71 else if (code == 27) {CodeMirror.e_stop(event); close(); editor.focus();}
72 else if (code != 38 && code != 40) {
73 close(); editor.focus();
74 // Pass the event to the CodeMirror instance so that it can handle things like backspace properly.
75 editor.triggerOnKeyDown(event);
76 setTimeout(function(){CodeMirror.simpleHint(editor, getHints);}, 50);
77 }
78 });
79 CodeMirror.connect(sel, "dblclick", pick);
80
81 sel.focus();
82 // Opera sometimes ignores focusing a freshly created node
83 if (window.opera) setTimeout(function(){if (!done) sel.focus();}, 100);
84 return true;
85 };
86})();
diff --git a/js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css b/js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css
new file mode 100644
index 00000000..fe0e353b
--- /dev/null
+++ b/js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css
@@ -0,0 +1,54 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
7/* adopted from CodeMirror 2.23 (http://codemirror.net/) */
8
9/*
10http://lesscss.org/ dark theme
11Ported to CodeMirror by Peter Kroon
12*/
13
14.CodeMirror{
15 line-height: 15px;
16}
17.cm-s-lesser-dark {
18 font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', 'Monaco', Courier, monospace !important;
19 /*font-size:12px;*/
20}
21
22.cm-s-lesser-dark { background: #262626; color: #EBEFE7; text-shadow: 0 -1px 1px #262626; }
23.cm-s-lesser-dark div.CodeMirror-selected {background: #45443B !important;} /* 33322B*/
24.cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
25.cm-s-lesser-dark .CodeMirror-lines { margin-left:3px; margin-right:3px; }/*editable code holder*/
26
27div.CodeMirror span.CodeMirror-matchingbracket { color: #7EFC7E; }/*65FC65*/
28
29.cm-s-lesser-dark .CodeMirror-gutter { background: #262626; border-right:1px solid #aaa; padding-right:3px; min-width:2.5em; }
30.cm-s-lesser-dark .CodeMirror-gutter-text { color: #777; }
31
32.cm-s-lesser-dark span.cm-keyword { color: #599eff; }
33.cm-s-lesser-dark span.cm-atom { color: #C2B470; }
34.cm-s-lesser-dark span.cm-number { color: #B35E4D; }
35.cm-s-lesser-dark span.cm-def {color: color: white;}
36.cm-s-lesser-dark span.cm-variable { color:#D9BF8C; }
37.cm-s-lesser-dark span.cm-variable-2 { color: #669199; }
38.cm-s-lesser-dark span.cm-variable-3 { color: white; }
39.cm-s-lesser-dark span.cm-property {color: #92A75C;}
40.cm-s-lesser-dark span.cm-operator {color: #92A75C;}
41.cm-s-lesser-dark span.cm-comment { color: #666; }
42.cm-s-lesser-dark span.cm-string { color: #BCD279; }
43.cm-s-lesser-dark span.cm-string-2 {color: #f50;}
44.cm-s-lesser-dark span.cm-meta { color: #738C73; }
45.cm-s-lesser-dark span.cm-error { color: #9d1e15; }
46.cm-s-lesser-dark span.cm-qualifier {color: #555;}
47.cm-s-lesser-dark span.cm-builtin { color: #ff9e59; }
48.cm-s-lesser-dark span.cm-bracket { color: #EBEFE7; }
49.cm-s-lesser-dark span.cm-tag { color: #669199; }
50.cm-s-lesser-dark span.cm-attribute {color: #00c;}
51.cm-s-lesser-dark span.cm-header {color: #a0a;}
52.cm-s-lesser-dark span.cm-quote {color: #090;}
53.cm-s-lesser-dark span.cm-hr {color: #999;}
54.cm-s-lesser-dark span.cm-link {color: #00c;}
diff --git a/js/code-editor/codemirror-ninja/theme/rubyblue-ninja.css b/js/code-editor/codemirror-ninja/theme/rubyblue-ninja.css
new file mode 100644
index 00000000..656a88cf
--- /dev/null
+++ b/js/code-editor/codemirror-ninja/theme/rubyblue-ninja.css
@@ -0,0 +1,30 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
7/* adopted from CodeMirror 2.23 (http://codemirror.net/) */
8
9.cm-s-rubyblue {
10 font:Trebuchet, Verdana, sans-serif; } /* - customized editor font - */
11
12.cm-s-rubyblue { background: #112435; color: white; }
13.cm-s-rubyblue div.CodeMirror-selected { background: #38566F !important; }
14.cm-s-rubyblue .CodeMirror-gutter { background: #1F4661; border-right: 7px solid #3E7087; min-width:2.5em; }
15.cm-s-rubyblue .CodeMirror-gutter-text { color: white; }
16.cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white !important; }
17
18.cm-s-rubyblue span.cm-comment { color: #999; font-style:italic; line-height: 1em; }
19.cm-s-rubyblue span.cm-atom { color: #F4C20B; }
20.cm-s-rubyblue span.cm-number, .cm-s-rubyblue span.cm-attribute { color: #82C6E0; }
21.cm-s-rubyblue span.cm-keyword { color: #F0F; }
22.cm-s-rubyblue span.cm-string { color: #F08047; }
23.cm-s-rubyblue span.cm-meta { color: #F0F; }
24.cm-s-rubyblue span.cm-variable-2, .cm-s-rubyblue span.cm-tag { color: #7BD827; }
25.cm-s-rubyblue span.cm-variable-3, .cm-s-rubyblue span.cm-def { color: white; }
26.cm-s-rubyblue span.cm-error { color: #AF2018; }
27.cm-s-rubyblue span.cm-bracket { color: #F0F; }
28.cm-s-rubyblue span.cm-link { color: #F4C20B; }
29.cm-s-rubyblue span.CodeMirror-matchingbracket { color:#F0F !important; }
30.cm-s-rubyblue span.cm-builtin, .cm-s-rubyblue span.cm-special { color: #FF9D00; }
diff --git a/js/code-editor/codemirror-ninja/theme/xq-dark-ninja.css b/js/code-editor/codemirror-ninja/theme/xq-dark-ninja.css
new file mode 100644
index 00000000..4ccf2052
--- /dev/null
+++ b/js/code-editor/codemirror-ninja/theme/xq-dark-ninja.css
@@ -0,0 +1,54 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
7/* adopted from CodeMirror 2.23 (http://codemirror.net/) */
8
9/*
10Copyright (C) 2011 by MarkLogic Corporation
11Author: Mike Brevoort <mike@brevoort.com>
12
13Permission is hereby granted, free of charge, to any person obtaining a copy
14of this software and associated documentation files (the "Software"), to deal
15in the Software without restriction, including without limitation the rights
16to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17copies of the Software, and to permit persons to whom the Software is
18furnished to do so, subject to the following conditions: