AmberRack 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. data/.gitignore +74 -0
  2. data/.rvmrc +4 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +62 -0
  5. data/README.md +17 -0
  6. data/Rakefile +24 -0
  7. data/amber-rack.gemspec +33 -0
  8. data/app/amber_app.rb +35 -0
  9. data/app/javascripts/Benchfib.deploy.js +159 -0
  10. data/app/javascripts/Benchfib.js +159 -0
  11. data/app/javascripts/Canvas.deploy.js +1464 -0
  12. data/app/javascripts/Canvas.js +1464 -0
  13. data/app/javascripts/Compiler.deploy.js +1587 -0
  14. data/app/javascripts/Compiler.js +1587 -0
  15. data/app/javascripts/Examples.deploy.js +800 -0
  16. data/app/javascripts/Examples.js +800 -0
  17. data/app/javascripts/IDE.deploy.js +3457 -0
  18. data/app/javascripts/IDE.js +3457 -0
  19. data/app/javascripts/IDE.js.bak +3420 -0
  20. data/app/javascripts/JQuery.deploy.js +898 -0
  21. data/app/javascripts/JQuery.js +898 -0
  22. data/app/javascripts/Kernel.deploy.js +6761 -0
  23. data/app/javascripts/Kernel.js +6761 -0
  24. data/app/javascripts/Parser.deploy.js +1655 -0
  25. data/app/javascripts/Parser.js +1655 -0
  26. data/app/javascripts/Raphael-Core.js +0 -0
  27. data/app/javascripts/Raphael-Graph.js +0 -0
  28. data/app/javascripts/SUnit.deploy.js +1059 -0
  29. data/app/javascripts/SUnit.js +1059 -0
  30. data/app/javascripts/application.js +2 -0
  31. data/app/javascripts/boot.js +466 -0
  32. data/app/javascripts/init.js +2 -0
  33. data/app/javascripts/jquery-1.4.4.min.js +167 -0
  34. data/app/javascripts/jquery-ui-1.8.9.custom.min.js +781 -0
  35. data/app/javascripts/jquery.textarea.js +267 -0
  36. data/app/javascripts/jtalk.js +78 -0
  37. data/app/javascripts/lib/CodeMirror/LICENSE +19 -0
  38. data/app/javascripts/lib/CodeMirror/README.md +6 -0
  39. data/app/javascripts/lib/CodeMirror/compress.html +92 -0
  40. data/app/javascripts/lib/CodeMirror/css/baboon.png +0 -0
  41. data/app/javascripts/lib/CodeMirror/css/baboon_vector.svg +153 -0
  42. data/app/javascripts/lib/CodeMirror/css/docs.css +154 -0
  43. data/app/javascripts/lib/CodeMirror/demo/activeline.html +72 -0
  44. data/app/javascripts/lib/CodeMirror/demo/changemode.html +51 -0
  45. data/app/javascripts/lib/CodeMirror/demo/complete.html +79 -0
  46. data/app/javascripts/lib/CodeMirror/demo/complete.js +151 -0
  47. data/app/javascripts/lib/CodeMirror/demo/fullscreen.html +158 -0
  48. data/app/javascripts/lib/CodeMirror/demo/marker.html +53 -0
  49. data/app/javascripts/lib/CodeMirror/demo/mustache.html +57 -0
  50. data/app/javascripts/lib/CodeMirror/demo/preview.html +75 -0
  51. data/app/javascripts/lib/CodeMirror/demo/resize.html +44 -0
  52. data/app/javascripts/lib/CodeMirror/demo/runmode.html +50 -0
  53. data/app/javascripts/lib/CodeMirror/demo/search.html +106 -0
  54. data/app/javascripts/lib/CodeMirror/demo/theme.html +53 -0
  55. data/app/javascripts/lib/CodeMirror/index.html +239 -0
  56. data/app/javascripts/lib/CodeMirror/internals.html +389 -0
  57. data/app/javascripts/lib/CodeMirror/lib/codemirror.css +67 -0
  58. data/app/javascripts/lib/CodeMirror/lib/codemirror.js +2144 -0
  59. data/app/javascripts/lib/CodeMirror/lib/overlay.js +51 -0
  60. data/app/javascripts/lib/CodeMirror/lib/runmode.js +27 -0
  61. data/app/javascripts/lib/CodeMirror/manual.html +854 -0
  62. data/app/javascripts/lib/CodeMirror/mode/clike/clike.js +247 -0
  63. data/app/javascripts/lib/CodeMirror/mode/clike/index.html +102 -0
  64. data/app/javascripts/lib/CodeMirror/mode/css/css.js +124 -0
  65. data/app/javascripts/lib/CodeMirror/mode/css/index.html +56 -0
  66. data/app/javascripts/lib/CodeMirror/mode/diff/diff.css +3 -0
  67. data/app/javascripts/lib/CodeMirror/mode/diff/diff.js +13 -0
  68. data/app/javascripts/lib/CodeMirror/mode/diff/index.html +99 -0
  69. data/app/javascripts/lib/CodeMirror/mode/haskell/haskell.js +242 -0
  70. data/app/javascripts/lib/CodeMirror/mode/haskell/index.html +60 -0
  71. data/app/javascripts/lib/CodeMirror/mode/htmlmixed/htmlmixed.js +79 -0
  72. data/app/javascripts/lib/CodeMirror/mode/htmlmixed/index.html +52 -0
  73. data/app/javascripts/lib/CodeMirror/mode/javascript/index.html +78 -0
  74. data/app/javascripts/lib/CodeMirror/mode/javascript/javascript.js +348 -0
  75. data/app/javascripts/lib/CodeMirror/mode/lua/index.html +72 -0
  76. data/app/javascripts/lib/CodeMirror/mode/lua/lua.js +138 -0
  77. data/app/javascripts/lib/CodeMirror/mode/php/index.html +49 -0
  78. data/app/javascripts/lib/CodeMirror/mode/php/php.js +110 -0
  79. data/app/javascripts/lib/CodeMirror/mode/plsql/index.html +63 -0
  80. data/app/javascripts/lib/CodeMirror/mode/plsql/plsql.js +217 -0
  81. data/app/javascripts/lib/CodeMirror/mode/python/LICENSE.txt +21 -0
  82. data/app/javascripts/lib/CodeMirror/mode/python/index.html +123 -0
  83. data/app/javascripts/lib/CodeMirror/mode/python/python.js +321 -0
  84. data/app/javascripts/lib/CodeMirror/mode/rst/index.html +526 -0
  85. data/app/javascripts/lib/CodeMirror/mode/rst/rst.css +75 -0
  86. data/app/javascripts/lib/CodeMirror/mode/rst/rst.js +333 -0
  87. data/app/javascripts/lib/CodeMirror/mode/scheme/index.html +65 -0
  88. data/app/javascripts/lib/CodeMirror/mode/scheme/scheme.js +181 -0
  89. data/app/javascripts/lib/CodeMirror/mode/smalltalk/index.html +56 -0
  90. data/app/javascripts/lib/CodeMirror/mode/smalltalk/smalltalk.js +134 -0
  91. data/app/javascripts/lib/CodeMirror/mode/sparql/index.html +41 -0
  92. data/app/javascripts/lib/CodeMirror/mode/sparql/sparql.js +143 -0
  93. data/app/javascripts/lib/CodeMirror/mode/stex/index.html +96 -0
  94. data/app/javascripts/lib/CodeMirror/mode/stex/stex.js +167 -0
  95. data/app/javascripts/lib/CodeMirror/mode/xml/index.html +42 -0
  96. data/app/javascripts/lib/CodeMirror/mode/xml/xml.js +231 -0
  97. data/app/javascripts/lib/CodeMirror/mode/yaml/index.html +68 -0
  98. data/app/javascripts/lib/CodeMirror/mode/yaml/yaml.js +95 -0
  99. data/app/javascripts/lib/CodeMirror/oldrelease.html +178 -0
  100. data/app/javascripts/lib/CodeMirror/test/index.html +29 -0
  101. data/app/javascripts/lib/CodeMirror/test/test.js +249 -0
  102. data/app/javascripts/lib/CodeMirror/theme/default.css +18 -0
  103. data/app/javascripts/lib/CodeMirror/theme/elegant.css +9 -0
  104. data/app/javascripts/lib/CodeMirror/theme/jtalk.css +21 -0
  105. data/app/javascripts/lib/CodeMirror/theme/neat.css +8 -0
  106. data/app/javascripts/lib/CodeMirror/theme/night.css +20 -0
  107. data/app/javascripts/lib/jQuery/jquery-1.4.4.min.js +167 -0
  108. data/app/javascripts/lib/jQuery/jquery-ui-1.8.9.custom.min.js +781 -0
  109. data/app/javascripts/lib/jQuery/jquery.textarea.js +267 -0
  110. data/app/smalltalk/Canvas.st +481 -0
  111. data/app/smalltalk/IDE.st +1752 -0
  112. data/config.ru +2 -0
  113. data/lib/amber-rack.rb +4 -0
  114. data/lib/amber-rack/version.rb +3 -0
  115. data/public/CodeMirror/LICENSE +19 -0
  116. data/public/CodeMirror/README.md +6 -0
  117. data/public/CodeMirror/compress.html +92 -0
  118. data/public/CodeMirror/css/baboon.png +0 -0
  119. data/public/CodeMirror/css/baboon_vector.svg +153 -0
  120. data/public/CodeMirror/css/docs.css +154 -0
  121. data/public/CodeMirror/demo/activeline.html +72 -0
  122. data/public/CodeMirror/demo/changemode.html +51 -0
  123. data/public/CodeMirror/demo/complete.html +79 -0
  124. data/public/CodeMirror/demo/complete.js +151 -0
  125. data/public/CodeMirror/demo/fullscreen.html +158 -0
  126. data/public/CodeMirror/demo/marker.html +53 -0
  127. data/public/CodeMirror/demo/mustache.html +57 -0
  128. data/public/CodeMirror/demo/preview.html +75 -0
  129. data/public/CodeMirror/demo/resize.html +44 -0
  130. data/public/CodeMirror/demo/runmode.html +50 -0
  131. data/public/CodeMirror/demo/search.html +106 -0
  132. data/public/CodeMirror/demo/theme.html +53 -0
  133. data/public/CodeMirror/index.html +239 -0
  134. data/public/CodeMirror/internals.html +389 -0
  135. data/public/CodeMirror/lib/codemirror.css +67 -0
  136. data/public/CodeMirror/lib/codemirror.js +2144 -0
  137. data/public/CodeMirror/lib/overlay.js +51 -0
  138. data/public/CodeMirror/lib/runmode.js +27 -0
  139. data/public/CodeMirror/manual.html +854 -0
  140. data/public/CodeMirror/mode/clike/clike.js +247 -0
  141. data/public/CodeMirror/mode/clike/index.html +102 -0
  142. data/public/CodeMirror/mode/css/css.js +124 -0
  143. data/public/CodeMirror/mode/css/index.html +56 -0
  144. data/public/CodeMirror/mode/diff/diff.css +3 -0
  145. data/public/CodeMirror/mode/diff/diff.js +13 -0
  146. data/public/CodeMirror/mode/diff/index.html +99 -0
  147. data/public/CodeMirror/mode/haskell/haskell.js +242 -0
  148. data/public/CodeMirror/mode/haskell/index.html +60 -0
  149. data/public/CodeMirror/mode/htmlmixed/htmlmixed.js +79 -0
  150. data/public/CodeMirror/mode/htmlmixed/index.html +52 -0
  151. data/public/CodeMirror/mode/javascript/index.html +78 -0
  152. data/public/CodeMirror/mode/javascript/javascript.js +348 -0
  153. data/public/CodeMirror/mode/lua/index.html +72 -0
  154. data/public/CodeMirror/mode/lua/lua.js +138 -0
  155. data/public/CodeMirror/mode/php/index.html +49 -0
  156. data/public/CodeMirror/mode/php/php.js +110 -0
  157. data/public/CodeMirror/mode/plsql/index.html +63 -0
  158. data/public/CodeMirror/mode/plsql/plsql.js +217 -0
  159. data/public/CodeMirror/mode/python/LICENSE.txt +21 -0
  160. data/public/CodeMirror/mode/python/index.html +123 -0
  161. data/public/CodeMirror/mode/python/python.js +321 -0
  162. data/public/CodeMirror/mode/rst/index.html +526 -0
  163. data/public/CodeMirror/mode/rst/rst.css +75 -0
  164. data/public/CodeMirror/mode/rst/rst.js +333 -0
  165. data/public/CodeMirror/mode/scheme/index.html +65 -0
  166. data/public/CodeMirror/mode/scheme/scheme.js +181 -0
  167. data/public/CodeMirror/mode/smalltalk/index.html +56 -0
  168. data/public/CodeMirror/mode/smalltalk/smalltalk.js +134 -0
  169. data/public/CodeMirror/mode/sparql/index.html +41 -0
  170. data/public/CodeMirror/mode/sparql/sparql.js +143 -0
  171. data/public/CodeMirror/mode/stex/index.html +96 -0
  172. data/public/CodeMirror/mode/stex/stex.js +167 -0
  173. data/public/CodeMirror/mode/xml/index.html +42 -0
  174. data/public/CodeMirror/mode/xml/xml.js +231 -0
  175. data/public/CodeMirror/mode/yaml/index.html +68 -0
  176. data/public/CodeMirror/mode/yaml/yaml.js +95 -0
  177. data/public/CodeMirror/oldrelease.html +178 -0
  178. data/public/CodeMirror/test/index.html +29 -0
  179. data/public/CodeMirror/test/test.js +249 -0
  180. data/public/CodeMirror/theme/default.css +18 -0
  181. data/public/CodeMirror/theme/elegant.css +9 -0
  182. data/public/CodeMirror/theme/jtalk.css +21 -0
  183. data/public/CodeMirror/theme/neat.css +8 -0
  184. data/public/CodeMirror/theme/night.css +20 -0
  185. data/public/css/jtalk.css +362 -0
  186. data/public/css/style.css +456 -0
  187. data/public/css/sunit.css +66 -0
  188. data/public/ide/fork_me.png +0 -0
  189. data/public/ide/screen2.png +0 -0
  190. data/public/ide/style.css +456 -0
  191. data/public/ide/syntax.css +61 -0
  192. data/public/ide/text_header.png +0 -0
  193. data/public/ide/title_container1.png +0 -0
  194. data/public/images/background_box.png +0 -0
  195. data/public/images/background_header.png +0 -0
  196. data/public/images/balloon_header.png +0 -0
  197. data/views/index.haml +66 -0
  198. metadata +341 -0
@@ -0,0 +1,267 @@
1
+ /*
2
+ * Tabby jQuery plugin version 0.12
3
+ *
4
+ * Ted Devito - http://teddevito.com/demos/textarea.html
5
+ *
6
+ * Copyright (c) 2009 Ted Devito
7
+ *
8
+ * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following
9
+ * conditions are met:
10
+ *
11
+ * 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
12
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer
13
+ * in the documentation and/or other materials provided with the distribution.
14
+ * 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written
15
+ * permission.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
19
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
22
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ *
24
+ */
25
+
26
+ // create closure
27
+
28
+ (function($) {
29
+
30
+ // plugin definition
31
+
32
+ $.fn.tabby = function(options) {
33
+ //debug(this);
34
+ // build main options before element iteration
35
+ var opts = $.extend({}, $.fn.tabby.defaults, options);
36
+ var pressed = $.fn.tabby.pressed;
37
+
38
+ // iterate and reformat each matched element
39
+ return this.each(function() {
40
+ $this = $(this);
41
+
42
+ // build element specific options
43
+ var options = $.meta ? $.extend({}, opts, $this.data()) : opts;
44
+
45
+ $this.bind('keydown',function (e) {
46
+ var kc = $.fn.tabby.catch_kc(e);
47
+ if (16 == kc) pressed.shft = true;
48
+ /*
49
+ because both CTRL+TAB and ALT+TAB default to an event (changing tab/window) that
50
+ will prevent js from capturing the keyup event, we'll set a timer on releasing them.
51
+ */
52
+ if (17 == kc) {pressed.ctrl = true; setTimeout("$.fn.tabby.pressed.ctrl = false;",1000);}
53
+ if (18 == kc) {pressed.alt = true; setTimeout("$.fn.tabby.pressed.alt = false;",1000);}
54
+
55
+ if (9 == kc && !pressed.ctrl && !pressed.alt) {
56
+ e.preventDefault; // does not work in O9.63 ??
57
+ pressed.last = kc; setTimeout("$.fn.tabby.pressed.last = null;",0);
58
+ process_keypress ($(e.target).get(0), pressed.shft, options);
59
+ return false;
60
+ }
61
+
62
+ }).bind('keyup',function (e) {
63
+ if (16 == $.fn.tabby.catch_kc(e)) pressed.shft = false;
64
+ }).bind('blur',function (e) { // workaround for Opera -- http://www.webdeveloper.com/forum/showthread.php?p=806588
65
+ if (9 == pressed.last) $(e.target).one('focus',function (e) {pressed.last = null;}).get(0).focus();
66
+ });
67
+
68
+ });
69
+ };
70
+
71
+ // define and expose any extra methods
72
+ $.fn.tabby.catch_kc = function(e) { return e.keyCode ? e.keyCode : e.charCode ? e.charCode : e.which; };
73
+ $.fn.tabby.pressed = {shft : false, ctrl : false, alt : false, last: null};
74
+
75
+ // private function for debugging
76
+ function debug($obj) {
77
+ if (window.console && window.console.log)
78
+ window.console.log('textarea count: ' + $obj.size());
79
+ };
80
+
81
+ function process_keypress (o,shft,options) {
82
+ var scrollTo = o.scrollTop;
83
+ //var tabString = String.fromCharCode(9);
84
+
85
+ // gecko; o.setSelectionRange is only available when the text box has focus
86
+ if (o.setSelectionRange) gecko_tab (o, shft, options);
87
+
88
+ // ie; document.selection is always available
89
+ else if (document.selection) ie_tab (o, shft, options);
90
+
91
+ o.scrollTop = scrollTo;
92
+ }
93
+
94
+ // plugin defaults
95
+ $.fn.tabby.defaults = {tabString : String.fromCharCode(9)};
96
+
97
+ function gecko_tab (o, shft, options) {
98
+ var ss = o.selectionStart;
99
+ var es = o.selectionEnd;
100
+
101
+ // when there's no selection and we're just working with the caret, we'll add/remove the tabs at the caret, providing more control
102
+ if(ss == es) {
103
+ // SHIFT+TAB
104
+ if (shft) {
105
+ // check to the left of the caret first
106
+ if ("\t" == o.value.substring(ss-options.tabString.length, ss)) {
107
+ o.value = o.value.substring(0, ss-options.tabString.length) + o.value.substring(ss); // put it back together omitting one character to the left
108
+ o.focus();
109
+ o.setSelectionRange(ss - options.tabString.length, ss - options.tabString.length);
110
+ }
111
+ // then check to the right of the caret
112
+ else if ("\t" == o.value.substring(ss, ss + options.tabString.length)) {
113
+ o.value = o.value.substring(0, ss) + o.value.substring(ss + options.tabString.length); // put it back together omitting one character to the right
114
+ o.focus();
115
+ o.setSelectionRange(ss,ss);
116
+ }
117
+ }
118
+ // TAB
119
+ else {
120
+ o.value = o.value.substring(0, ss) + options.tabString + o.value.substring(ss);
121
+ o.focus();
122
+ o.setSelectionRange(ss + options.tabString.length, ss + options.tabString.length);
123
+ }
124
+ }
125
+ // selections will always add/remove tabs from the start of the line
126
+ else {
127
+ // split the textarea up into lines and figure out which lines are included in the selection
128
+ var lines = o.value.split("\n");
129
+ var indices = new Array();
130
+ var sl = 0; // start of the line
131
+ var el = 0; // end of the line
132
+ var sel = false;
133
+ for (var i in lines) {
134
+ el = sl + lines[i].length;
135
+ indices.push({start: sl, end: el, selected: (sl <= ss && el > ss) || (el >= es && sl < es) || (sl > ss && el < es)});
136
+ sl = el + 1;// for "\n"
137
+ }
138
+
139
+ // walk through the array of lines (indices) and add tabs where appropriate
140
+ var modifier = 0;
141
+ for (var i in indices) {
142
+ if (indices[i].selected) {
143
+ var pos = indices[i].start + modifier; // adjust for tabs already inserted/removed
144
+ // SHIFT+TAB
145
+ if (shft && options.tabString == o.value.substring(pos,pos+options.tabString.length)) { // only SHIFT+TAB if there's a tab at the start of the line
146
+ o.value = o.value.substring(0,pos) + o.value.substring(pos + options.tabString.length); // omit the tabstring to the right
147
+ modifier -= options.tabString.length;
148
+ }
149
+ // TAB
150
+ else if (!shft) {
151
+ o.value = o.value.substring(0,pos) + options.tabString + o.value.substring(pos); // insert the tabstring
152
+ modifier += options.tabString.length;
153
+ }
154
+ }
155
+ }
156
+ o.focus();
157
+ var ns = ss + ((modifier > 0) ? options.tabString.length : (modifier < 0) ? -options.tabString.length : 0);
158
+ var ne = es + modifier;
159
+ o.setSelectionRange(ns,ne);
160
+ }
161
+ }
162
+
163
+ function ie_tab (o, shft, options) {
164
+ var range = document.selection.createRange();
165
+
166
+ if (o == range.parentElement()) {
167
+ // when there's no selection and we're just working with the caret, we'll add/remove the tabs at the caret, providing more control
168
+ if ('' == range.text) {
169
+ // SHIFT+TAB
170
+ if (shft) {
171
+ var bookmark = range.getBookmark();
172
+ //first try to the left by moving opening up our empty range to the left
173
+ range.moveStart('character', -options.tabString.length);
174
+ if (options.tabString == range.text) {
175
+ range.text = '';
176
+ } else {
177
+ // if that didn't work then reset the range and try opening it to the right
178
+ range.moveToBookmark(bookmark);
179
+ range.moveEnd('character', options.tabString.length);
180
+ if (options.tabString == range.text)
181
+ range.text = '';
182
+ }
183
+ // move the pointer to the start of them empty range and select it
184
+ range.collapse(true);
185
+ range.select();
186
+ }
187
+
188
+ else {
189
+ // very simple here. just insert the tab into the range and put the pointer at the end
190
+ range.text = options.tabString;
191
+ range.collapse(false);
192
+ range.select();
193
+ }
194
+ }
195
+ // selections will always add/remove tabs from the start of the line
196
+ else {
197
+
198
+ var selection_text = range.text;
199
+ var selection_len = selection_text.length;
200
+ var selection_arr = selection_text.split("\r\n");
201
+
202
+ var before_range = document.body.createTextRange();
203
+ before_range.moveToElementText(o);
204
+ before_range.setEndPoint("EndToStart", range);
205
+ var before_text = before_range.text;
206
+ var before_arr = before_text.split("\r\n");
207
+ var before_len = before_text.length; // - before_arr.length + 1;
208
+
209
+ var after_range = document.body.createTextRange();
210
+ after_range.moveToElementText(o);
211
+ after_range.setEndPoint("StartToEnd", range);
212
+ var after_text = after_range.text; // we can accurately calculate distance to the end because we're not worried about MSIE trimming a \r\n
213
+
214
+ var end_range = document.body.createTextRange();
215
+ end_range.moveToElementText(o);
216
+ end_range.setEndPoint("StartToEnd", before_range);
217
+ var end_text = end_range.text; // we can accurately calculate distance to the end because we're not worried about MSIE trimming a \r\n
218
+
219
+ var check_html = $(o).html();
220
+ $("#r3").text(before_len + " + " + selection_len + " + " + after_text.length + " = " + check_html.length);
221
+ if((before_len + end_text.length) < check_html.length) {
222
+ before_arr.push("");
223
+ before_len += 2; // for the \r\n that was trimmed
224
+ if (shft && options.tabString == selection_arr[0].substring(0,options.tabString.length))
225
+ selection_arr[0] = selection_arr[0].substring(options.tabString.length);
226
+ else if (!shft) selection_arr[0] = options.tabString + selection_arr[0];
227
+ } else {
228
+ if (shft && options.tabString == before_arr[before_arr.length-1].substring(0,options.tabString.length))
229
+ before_arr[before_arr.length-1] = before_arr[before_arr.length-1].substring(options.tabString.length);
230
+ else if (!shft) before_arr[before_arr.length-1] = options.tabString + before_arr[before_arr.length-1];
231
+ }
232
+
233
+ for (var i = 1; i < selection_arr.length; i++) {
234
+ if (shft && options.tabString == selection_arr[i].substring(0,options.tabString.length))
235
+ selection_arr[i] = selection_arr[i].substring(options.tabString.length);
236
+ else if (!shft) selection_arr[i] = options.tabString + selection_arr[i];
237
+ }
238
+
239
+ if (1 == before_arr.length && 0 == before_len) {
240
+ if (shft && options.tabString == selection_arr[0].substring(0,options.tabString.length))
241
+ selection_arr[0] = selection_arr[0].substring(options.tabString.length);
242
+ else if (!shft) selection_arr[0] = options.tabString + selection_arr[0];
243
+ }
244
+
245
+ if ((before_len + selection_len + after_text.length) < check_html.length) {
246
+ selection_arr.push("");
247
+ selection_len += 2; // for the \r\n that was trimmed
248
+ }
249
+
250
+ before_range.text = before_arr.join("\r\n");
251
+ range.text = selection_arr.join("\r\n");
252
+
253
+ var new_range = document.body.createTextRange();
254
+ new_range.moveToElementText(o);
255
+
256
+ if (0 < before_len) new_range.setEndPoint("StartToEnd", before_range);
257
+ else new_range.setEndPoint("StartToStart", before_range);
258
+ new_range.setEndPoint("EndToEnd", range);
259
+
260
+ new_range.select();
261
+
262
+ }
263
+ }
264
+ }
265
+
266
+ // end of closure
267
+ })(jQuery);
@@ -0,0 +1,481 @@
1
+ Object subclass: #CanvasRenderingContext
2
+ instanceVariableNames: ''
3
+ category: 'Canvas'!
4
+
5
+ !CanvasRenderingContext methodsFor: 'drawing arcs'!
6
+
7
+ arcTo: aPoint radius: aNumber startAngle: aNumber2 endAngle: aNumber3 anticlockwise: aBoolean
8
+ <self.arc(aPoint._x(), aPoint._y(), aNumber, aNumber2, aNumber3, aBoolean)>
9
+ !
10
+
11
+ arcTo: aPoint radius: aNumber
12
+ self arcTo: aPoint radius: aNumber startAngle: 0 endAngle: Number pi * 2 anticlockwise: false
13
+ ! !
14
+
15
+ !CanvasRenderingContext methodsFor: 'drawing paths'!
16
+
17
+ fillStyle: aString
18
+ <self.fillStyle = String(aString)>
19
+ !
20
+
21
+ beginPath
22
+ <self.beginPath()>
23
+ !
24
+
25
+ closePath
26
+ <self.closePath()>
27
+ !
28
+
29
+ fill
30
+ <self.fill()>
31
+ !
32
+
33
+ stroke
34
+ <self.stroke()>
35
+ !
36
+
37
+ moveTo: aPoint
38
+ <self.moveTo(aPoint._x(), aPoint._y())>
39
+ !
40
+
41
+ lineTo: aPoint
42
+ <self.lineTo(aPoint._x(), aPoint._y())>
43
+ !
44
+
45
+ strokeStyle: aString
46
+ <self.strokeStyle = String(aString)>
47
+ !
48
+
49
+ lineWidth: aNumber
50
+ <self.lineWidth = aNumber>
51
+ ! !
52
+
53
+ !CanvasRenderingContext methodsFor: 'drawing rectangles'!
54
+
55
+ fillRectFrom: aPoint to: anotherPoint
56
+ <self.fillRect(aPoint._x(), aPoint._y(), anotherPoint._x(), anotherPoint._y())>
57
+ !
58
+
59
+ strokeRectFrom: aPoint to: anotherPoint
60
+ <self.strokeRect(aPoint._x(), aPoint._y(), anotherPoint._x(), anotherPoint._y())>
61
+ !
62
+
63
+ clearRectFrom: aPoint to: anotherPoint
64
+ <self.fillRect(aPoint._x(), aPoint._y(), anotherPoint._x(), anotherPoint._y())>
65
+ ! !
66
+
67
+ !CanvasRenderingContext class methodsFor: 'instance creation'!
68
+
69
+ tagBrush: aTagBrush
70
+ <return aTagBrush._element().getContext('2d')>
71
+ ! !
72
+
73
+ Object subclass: #HTMLCanvas
74
+ instanceVariableNames: 'root'
75
+ category: 'Canvas'!
76
+
77
+ !HTMLCanvas methodsFor: 'accessing'!
78
+
79
+ root: aTagBrush
80
+ root := aTagBrush
81
+ !
82
+
83
+ root
84
+ ^root
85
+ ! !
86
+
87
+ !HTMLCanvas methodsFor: 'adding'!
88
+
89
+ with: anObject
90
+ ^self root with: anObject
91
+ ! !
92
+
93
+ !HTMLCanvas methodsFor: 'initialization'!
94
+
95
+ initialize
96
+ super initialize.
97
+ root ifNil: [root := TagBrush fromString: 'div' canvas: self]
98
+ !
99
+
100
+ initializeFromJQuery: aJQuery
101
+ root := TagBrush fromJQuery: aJQuery canvas: self
102
+ ! !
103
+
104
+ !HTMLCanvas methodsFor: 'tags'!
105
+
106
+ newTag: aString
107
+ ^TagBrush fromString: aString canvas: self
108
+ !
109
+
110
+ tag: aString
111
+ ^root addBrush: (self newTag: aString)
112
+ !
113
+
114
+ h1
115
+ ^self tag: 'h1'
116
+ !
117
+
118
+ h2
119
+ ^self tag: 'h2'
120
+ !
121
+
122
+ h3
123
+ ^self tag: 'h3'
124
+ !
125
+
126
+ h4
127
+ ^self tag: 'h4'
128
+ !
129
+
130
+ h5
131
+ ^self tag: 'h5'
132
+ !
133
+
134
+ h6
135
+ ^self tag: 'h6'
136
+ !
137
+
138
+ p
139
+ ^self tag: 'p'
140
+ !
141
+
142
+ div
143
+ ^self tag: 'div'
144
+ !
145
+
146
+ span
147
+ ^self tag: 'span'
148
+ !
149
+
150
+ img
151
+ ^self tag: 'img'
152
+ !
153
+
154
+ ul
155
+ ^self tag: 'ul'
156
+ !
157
+
158
+ ol
159
+ ^self tag: 'ol'
160
+ !
161
+
162
+ li
163
+ ^self tag: 'li'
164
+ !
165
+
166
+ table
167
+ ^self tag: 'table'
168
+ !
169
+
170
+ tr
171
+ ^self tag: 'tr'
172
+ !
173
+
174
+ td
175
+ ^self tag: 'td'
176
+ !
177
+
178
+ th
179
+ ^self tag: 'th'
180
+ !
181
+
182
+ form
183
+ ^self tag: 'form'
184
+ !
185
+
186
+ input
187
+ ^self tag: 'input'
188
+ !
189
+
190
+ button
191
+
192
+ ^self tag: 'button'
193
+ !
194
+
195
+ select
196
+ ^self tag: 'select'
197
+ !
198
+
199
+ option
200
+ ^self tag: 'option'
201
+ !
202
+
203
+ textarea
204
+ ^self tag: 'textarea'
205
+ !
206
+
207
+ a
208
+ ^self tag: 'a'
209
+ !
210
+
211
+ canvas
212
+ ^self tag: 'canvas'
213
+ !
214
+
215
+ pre
216
+ ^self tag: 'pre'
217
+ !
218
+
219
+ code
220
+ ^self tag: 'code'
221
+ !
222
+
223
+ br
224
+ ^self tag: 'br'
225
+ ! !
226
+
227
+ !HTMLCanvas class methodsFor: 'instance creation'!
228
+
229
+ onJQuery: aJQuery
230
+ ^self basicNew
231
+ initializeFromJQuery: aJQuery;
232
+ initialize;
233
+ yourself
234
+ ! !
235
+
236
+ Object subclass: #TagBrush
237
+ instanceVariableNames: 'canvas element'
238
+ category: 'Canvas'!
239
+
240
+ !TagBrush methodsFor: 'accessing'!
241
+
242
+ element
243
+ ^element
244
+ ! !
245
+
246
+ !TagBrush methodsFor: 'adding'!
247
+
248
+ contents: anObject
249
+ self asJQuery empty.
250
+ self append: anObject
251
+ !
252
+
253
+ addBrush: aTagBrush
254
+
255
+ self appendChild: aTagBrush element.
256
+ ^aTagBrush
257
+ !
258
+
259
+ with: anObject
260
+ self append: anObject
261
+ !
262
+
263
+ append: anObject
264
+
265
+
266
+ anObject appendToBrush: self
267
+ !
268
+
269
+ appendToBrush: aTagBrush
270
+ aTagBrush addBrush: self
271
+ !
272
+
273
+ appendBlock: aBlock
274
+ | root |
275
+ root := canvas root.
276
+ canvas root: self.
277
+ aBlock value: canvas.
278
+ canvas root: root
279
+ !
280
+
281
+ appendChild: anElement
282
+ <self['@element'].appendChild(anElement)>
283
+ !
284
+
285
+ appendString: aString
286
+ self appendChild: (self createTextNodeFor: aString)
287
+ ! !
288
+
289
+ !TagBrush methodsFor: 'attributes'!
290
+
291
+ at: aString put: aValue
292
+ <self['@element'].setAttribute(aString, aValue)>
293
+ !
294
+
295
+ removeAt: aString
296
+ <self['@element'].removeAttribute(aString)>
297
+ !
298
+
299
+ class: aString
300
+ self at: 'class' put: aString
301
+ !
302
+
303
+ id: aString
304
+ self at: 'id' put: aString
305
+ !
306
+
307
+ src: aString
308
+ self at: 'src' put: aString
309
+ !
310
+
311
+ href: aString
312
+ self at: 'href' put: aString
313
+ !
314
+
315
+ title: aString
316
+ self at: 'title' put: aString
317
+ !
318
+
319
+ style: aString
320
+ self at: 'style' put: aString
321
+ ! !
322
+
323
+ !TagBrush methodsFor: 'converting'!
324
+
325
+ asJQuery
326
+ <return smalltalk.JQuery._from_(jQuery(self['@element']))>
327
+ !
328
+
329
+ asJQueryDo: aBlock
330
+ aBlock value: self asJQuery
331
+ ! !
332
+
333
+ !TagBrush methodsFor: 'events'!
334
+
335
+ onKeyDown: aBlock
336
+ self asJQuery on: 'keydown' do: aBlock
337
+ !
338
+
339
+ onKeyPress: aBlock
340
+ self asJQuery on: 'keypress' do: aBlock
341
+ !
342
+
343
+ onKeyUp: aBlock
344
+ self asJQuery on: 'keyup' do: aBlock
345
+ !
346
+
347
+ onFocus: aBlock
348
+ self asJQuery on: 'focus' do: aBlock
349
+ !
350
+
351
+ onBlur: aBlock
352
+ self asJQuery on: 'blur' do: aBlock
353
+ !
354
+
355
+ onChange: aBlock
356
+ self asJQuery on: 'change' do: aBlock
357
+ !
358
+
359
+ onClick: aBlock
360
+ self asJQuery on: 'click' do: aBlock
361
+ ! !
362
+
363
+ !TagBrush methodsFor: 'initialization'!
364
+
365
+ initializeFromString: aString canvas: aCanvas
366
+ element := self createElementFor: aString.
367
+ canvas := aCanvas
368
+ !
369
+
370
+ initializeFromJQuery: aJQuery canvas: aCanvas
371
+ element := aJQuery jquery get: 0.
372
+ canvas := aCanvas
373
+ ! !
374
+
375
+ !TagBrush methodsFor: 'private'!
376
+
377
+ createElementFor: aString
378
+ <return document.createElement(String(aString))>
379
+ !
380
+
381
+ createTextNodeFor: aString
382
+ <return document.createTextNode(String(aString))>
383
+ ! !
384
+
385
+ !TagBrush class methodsFor: 'instance creation'!
386
+
387
+ fromString: aString canvas: aCanvas
388
+ ^self new
389
+ initializeFromString: aString canvas: aCanvas;
390
+ yourself
391
+ !
392
+
393
+ fromJQuery: aJQuery canvas: aCanvas
394
+ ^self new
395
+ initializeFromJQuery: aJQuery canvas: aCanvas;
396
+ yourself
397
+ ! !
398
+
399
+ Object subclass: #Widget
400
+ instanceVariableNames: ''
401
+ category: 'Canvas'!
402
+
403
+ !Widget methodsFor: 'actions'!
404
+
405
+ alert: aString
406
+ <alert(aString)>
407
+ !
408
+
409
+ confirm: aString
410
+ <return window.confirm(aString)>
411
+ !
412
+
413
+ prompt: aString
414
+ ^self prompt: aString default: ''
415
+ !
416
+
417
+ prompt: aString default: anotherString
418
+ <return window.prompt(aString, anotherString)>
419
+ ! !
420
+
421
+ !Widget methodsFor: 'adding'!
422
+
423
+ appendToBrush: aTagBrush
424
+ self appendToJQuery: aTagBrush asJQuery
425
+ !
426
+
427
+ appendToJQuery: aJQuery
428
+ self renderOn: (HTMLCanvas onJQuery: aJQuery)
429
+ ! !
430
+
431
+ !Widget methodsFor: 'rendering'!
432
+
433
+ renderOn: html
434
+ self
435
+ ! !
436
+
437
+ TagBrush subclass: #CanvasBrush
438
+ instanceVariableNames: ''
439
+ category: 'Canvas'!
440
+
441
+ !CanvasBrush methodsFor: 'initialization'!
442
+
443
+ initializeWithCanvas: aCanvas
444
+
445
+
446
+
447
+ canvas := aCanvas
448
+ ! !
449
+
450
+ !CanvasBrush methodsFor: 'private'!
451
+
452
+ createElement
453
+ <return document.createElement('canvas')>
454
+ ! !
455
+
456
+ !CanvasBrush class methodsFor: 'instance creation'!
457
+
458
+ canvas: aCanvas
459
+ ^self new
460
+ initializeWithCanvas: aCanvas;
461
+ yourself
462
+ ! !
463
+
464
+ !Object methodsFor: '*Canvas'!
465
+
466
+ appendToBrush: aTagBrush
467
+ aTagBrush append: self asString
468
+ ! !
469
+
470
+ !BlockClosure methodsFor: '*Canvas'!
471
+
472
+ appendToBrush: aTagBrush
473
+ aTagBrush appendBlock: self
474
+ ! !
475
+
476
+ !String methodsFor: '*Canvas'!
477
+
478
+ appendToBrush: aTagBrush
479
+ aTagBrush appendString: self
480
+ ! !
481
+