luca 0.8.599 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/.gitignore +3 -0
  2. data/.rvmrc +1 -0
  3. data/CHANGELOG +51 -2
  4. data/README.md +10 -247
  5. data/ROADMAP +6 -2
  6. data/app.rb +16 -2
  7. data/assets/javascripts/dependencies/bootstrap.min.js +7 -1
  8. data/assets/javascripts/dependencies/codemirror-coffeescript.js +347 -0
  9. data/assets/javascripts/dependencies/codemirror-css.js +124 -0
  10. data/assets/javascripts/dependencies/codemirror-html.js +410 -0
  11. data/assets/javascripts/dependencies/codemirror-javascript.js +361 -0
  12. data/assets/javascripts/dependencies/codemirror-less.js +232 -0
  13. data/assets/javascripts/dependencies/codemirror-vim.js +500 -0
  14. data/assets/javascripts/dependencies/codemirror.js +3076 -0
  15. data/assets/javascripts/dependencies.coffee +0 -1
  16. data/assets/javascripts/luca-ui-base.coffee +10 -3
  17. data/assets/javascripts/luca-ui-bootstrap.js +1 -0
  18. data/assets/javascripts/luca-ui-development-tools.coffee +9 -0
  19. data/assets/javascripts/luca-ui.coffee +6 -1
  20. data/assets/javascripts/sandbox/application.coffee +51 -0
  21. data/assets/javascripts/sandbox/router.coffee +14 -0
  22. data/assets/javascripts/sandbox/templates/main.luca +33 -0
  23. data/assets/javascripts/sandbox/templates/sandbox/navigation.luca +1 -0
  24. data/assets/javascripts/sandbox/templates/sandbox.luca +1 -0
  25. data/assets/javascripts/sandbox/views/top_navigation.coffee +4 -0
  26. data/assets/javascripts/sandbox.coffee +2 -2
  27. data/assets/stylesheets/bootstrap.min.css +395 -297
  28. data/assets/stylesheets/codemirror-blackboard.css +25 -0
  29. data/assets/stylesheets/codemirror-monokai.css +33 -0
  30. data/assets/stylesheets/codemirror.css +126 -0
  31. data/assets/stylesheets/luca-ui-bootstrap.css +0 -1
  32. data/assets/stylesheets/luca-ui-development-tools.css +5 -0
  33. data/assets/stylesheets/sandbox/sandbox.scss +1 -3
  34. data/assets/stylesheets/themes/amelia-bootstrap.css +826 -0
  35. data/assets/stylesheets/themes/slate-bootstrap.css +797 -0
  36. data/assets/stylesheets/themes/superhero-bootstrap.css +830 -0
  37. data/lib/luca/code_browser.rb +55 -0
  38. data/lib/luca/rails/version.rb +1 -1
  39. data/lib/luca/rails.rb +1 -0
  40. data/spec/components/fields/checkbox_array_spec.coffee +46 -0
  41. data/spec/components/form_view_spec.coffee +10 -4
  42. data/spec/containers/card_view_spec.coffee +7 -0
  43. data/spec/core/collection_spec.coffee +58 -4
  44. data/spec/core/container_spec.coffee +6 -6
  45. data/spec/core/view_spec.coffee +93 -7
  46. data/spec/framework_spec.coffee +15 -12
  47. data/src/components/application.coffee +126 -18
  48. data/src/components/base_toolbar.coffee +2 -2
  49. data/src/components/collection_loader_view.coffee +1 -2
  50. data/src/components/collection_view.coffee +77 -0
  51. data/src/components/controller.coffee +1 -4
  52. data/src/components/fields/button_field.coffee +1 -1
  53. data/src/components/fields/checkbox_array.coffee +2 -2
  54. data/src/components/fields/checkbox_field.coffee +3 -1
  55. data/src/components/fields/file_upload_field.coffee +1 -1
  56. data/src/components/fields/hidden_field.coffee +1 -1
  57. data/src/components/fields/select_field.coffee +1 -1
  58. data/src/components/fields/text_area_field.coffee +1 -1
  59. data/src/components/fields/text_field.coffee +10 -6
  60. data/src/components/fields/type_ahead_field.coffee +18 -5
  61. data/src/components/form_button_toolbar.coffee +1 -2
  62. data/src/components/form_view.coffee +44 -62
  63. data/src/components/grid_view.coffee +27 -20
  64. data/src/components/load_mask.coffee +3 -0
  65. data/src/components/nav_bar.coffee +26 -0
  66. data/src/components/record_manager.coffee +1 -3
  67. data/src/components/router.coffee +1 -1
  68. data/src/components/template.coffee +3 -15
  69. data/src/components/toolbar_dialog.coffee +25 -0
  70. data/src/containers/card_view.coffee +22 -23
  71. data/src/containers/column_view.coffee +1 -6
  72. data/src/containers/modal_view.coffee +20 -71
  73. data/src/containers/panel_toolbar.coffee +156 -0
  74. data/src/containers/panel_view.coffee +1 -1
  75. data/src/containers/split_view.coffee +1 -3
  76. data/src/containers/tab_view.coffee +29 -29
  77. data/src/containers/viewport.coffee +38 -3
  78. data/src/core/collection.coffee +80 -48
  79. data/src/core/container.coffee +153 -72
  80. data/src/core/core.coffee +181 -0
  81. data/src/core/field.coffee +4 -2
  82. data/src/core/model.coffee +1 -1
  83. data/src/core/observer.coffee +3 -3
  84. data/src/core/panel.coffee +143 -0
  85. data/src/core/registry.coffee +104 -0
  86. data/src/core/util.coffee +82 -0
  87. data/src/core/view.coffee +158 -85
  88. data/src/framework.coffee +112 -178
  89. data/src/index.coffee +0 -255
  90. data/src/managers/collection_manager.coffee +1 -0
  91. data/src/samples/definition.coffee +49 -0
  92. data/src/stylesheets/base.scss +0 -78
  93. data/src/stylesheets/components/form_view.scss +8 -3
  94. data/src/stylesheets/components/grid_view.scss +3 -7
  95. data/src/stylesheets/components/load_mask.scss +14 -0
  96. data/src/stylesheets/components/toolbar.scss +0 -15
  97. data/src/stylesheets/containers/container.scss +14 -2
  98. data/src/stylesheets/containers/panels.scss +23 -0
  99. data/src/stylesheets/tools/class_browser.scss +32 -0
  100. data/src/stylesheets/tools/code_editor.scss +24 -0
  101. data/src/stylesheets/tools/component_tester.scss +8 -0
  102. data/src/stylesheets/tools/console.scss +26 -0
  103. data/src/templates/components/collection_loader_view.luca +1 -1
  104. data/src/templates/components/form_view.luca +2 -13
  105. data/src/templates/components/grid_view.luca +0 -2
  106. data/src/templates/components/load_mask.luca +3 -0
  107. data/src/templates/components/nav_bar.luca +2 -0
  108. data/src/templates/containers/tab_view.luca +1 -0
  109. data/src/templates/fields/text_field.luca +4 -1
  110. data/src/tools/class_browser.coffee +39 -0
  111. data/src/tools/code_editor.coffee +258 -0
  112. data/src/tools/code_mirror_field.coffee +57 -0
  113. data/src/tools/coffee_script_editor.coffee +60 -0
  114. data/src/tools/collection_inspector.coffee +4 -0
  115. data/src/tools/component_tester.coffee +472 -0
  116. data/src/tools/components/class_browser_detail.coffee +10 -0
  117. data/src/tools/components/class_browser_list.coffee +74 -0
  118. data/src/tools/console.coffee +147 -0
  119. data/src/tools/development_console.coffee +147 -0
  120. data/src/tools/models/components.coffee +63 -0
  121. data/src/tools/templates/component_tester/help.luca +14 -0
  122. data/vendor/assets/javascripts/luca-ui-base.js +1389 -611
  123. data/vendor/assets/javascripts/luca-ui-bootstrap.js +9 -0
  124. data/vendor/assets/javascripts/luca-ui-development-tools.js +18719 -0
  125. data/vendor/assets/javascripts/luca-ui-spec.js +2065 -878
  126. data/vendor/assets/javascripts/luca-ui.js +1759 -852
  127. data/vendor/assets/javascripts/luca-ui.min.js +3 -3
  128. data/vendor/assets/stylesheets/luca-ui-bootstrap.css +494 -440
  129. data/vendor/assets/stylesheets/luca-ui-development-tools.css +224 -0
  130. data/vendor/assets/stylesheets/luca-ui-spec.css +99 -140
  131. data/vendor/assets/stylesheets/luca-ui.css +99 -140
  132. data/views/index.erb +6 -3
  133. metadata +60 -18
  134. data/assets/javascripts/dependencies/jquery-console.js +0 -649
  135. data/assets/javascripts/development-console.coffee +0 -2
  136. data/assets/javascripts/sandbox/sandbox.coffee +0 -16
  137. data/assets/javascripts/sandbox/templates/features/collection_helpers.luca +0 -33
  138. data/assets/javascripts/sandbox/templates/features/form_demo_code.luca +0 -48
  139. data/assets/javascripts/sandbox/templates/features/grid_demo_code.luca +0 -24
  140. data/assets/javascripts/sandbox/templates/features/introduction.luca +0 -11
  141. data/assets/javascripts/sandbox/templates/features/view_helpers.luca +0 -43
  142. data/assets/javascripts/sandbox/templates/navigation.luca +0 -8
  143. data/assets/javascripts/sandbox/views/form_demo.coffee +0 -47
  144. data/assets/javascripts/sandbox/views/grid_demo.coffee +0 -23
  145. data/assets/javascripts/sandbox/views/pages/collection_events_sample.coffee +0 -1
  146. data/assets/javascripts/sandbox/views/pages/pages_controller.coffee +0 -38
  147. data/src/components/collection_inspector.coffee +0 -2
  148. data/src/components/development_console.coffee +0 -59
  149. data/src/stylesheets/components/development_console.scss +0 -47
@@ -0,0 +1,410 @@
1
+ CodeMirror.defineMode("xml", function(config, parserConfig) {
2
+ var indentUnit = config.indentUnit;
3
+ var Kludges = parserConfig.htmlMode ? {
4
+ autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
5
+ 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
6
+ 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
7
+ 'track': true, 'wbr': true},
8
+ implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
9
+ 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
10
+ 'th': true, 'tr': true},
11
+ contextGrabbers: {
12
+ 'dd': {'dd': true, 'dt': true},
13
+ 'dt': {'dd': true, 'dt': true},
14
+ 'li': {'li': true},
15
+ 'option': {'option': true, 'optgroup': true},
16
+ 'optgroup': {'optgroup': true},
17
+ 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
18
+ 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
19
+ 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
20
+ 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
21
+ 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
22
+ 'rp': {'rp': true, 'rt': true},
23
+ 'rt': {'rp': true, 'rt': true},
24
+ 'tbody': {'tbody': true, 'tfoot': true},
25
+ 'td': {'td': true, 'th': true},
26
+ 'tfoot': {'tbody': true},
27
+ 'th': {'td': true, 'th': true},
28
+ 'thead': {'tbody': true, 'tfoot': true},
29
+ 'tr': {'tr': true}
30
+ },
31
+ doNotIndent: {"pre": true},
32
+ allowUnquoted: true,
33
+ allowMissing: false
34
+ } : {
35
+ autoSelfClosers: {},
36
+ implicitlyClosed: {},
37
+ contextGrabbers: {},
38
+ doNotIndent: {},
39
+ allowUnquoted: false,
40
+ allowMissing: false
41
+ };
42
+ var alignCDATA = parserConfig.alignCDATA;
43
+
44
+ // Return variables for tokenizers
45
+ var tagName, type;
46
+
47
+ function inText(stream, state) {
48
+ function chain(parser) {
49
+ state.tokenize = parser;
50
+ return parser(stream, state);
51
+ }
52
+
53
+ var ch = stream.next();
54
+ if (ch == "<") {
55
+ if (stream.eat("!")) {
56
+ if (stream.eat("[")) {
57
+ if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
58
+ else return null;
59
+ }
60
+ else if (stream.match("--")) return chain(inBlock("comment", "-->"));
61
+ else if (stream.match("DOCTYPE", true, true)) {
62
+ stream.eatWhile(/[\w\._\-]/);
63
+ return chain(doctype(1));
64
+ }
65
+ else return null;
66
+ }
67
+ else if (stream.eat("?")) {
68
+ stream.eatWhile(/[\w\._\-]/);
69
+ state.tokenize = inBlock("meta", "?>");
70
+ return "meta";
71
+ }
72
+ else {
73
+ type = stream.eat("/") ? "closeTag" : "openTag";
74
+ stream.eatSpace();
75
+ tagName = "";
76
+ var c;
77
+ while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
78
+ state.tokenize = inTag;
79
+ return "tag";
80
+ }
81
+ }
82
+ else if (ch == "&") {
83
+ var ok;
84
+ if (stream.eat("#")) {
85
+ if (stream.eat("x")) {
86
+ ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
87
+ } else {
88
+ ok = stream.eatWhile(/[\d]/) && stream.eat(";");
89
+ }
90
+ } else {
91
+ ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
92
+ }
93
+ return ok ? "atom" : "error";
94
+ }
95
+ else {
96
+ stream.eatWhile(/[^&<]/);
97
+ return null;
98
+ }
99
+ }
100
+
101
+ function inTag(stream, state) {
102
+ var ch = stream.next();
103
+ if (ch == ">" || (ch == "/" && stream.eat(">"))) {
104
+ state.tokenize = inText;
105
+ type = ch == ">" ? "endTag" : "selfcloseTag";
106
+ return "tag";
107
+ }
108
+ else if (ch == "=") {
109
+ type = "equals";
110
+ return null;
111
+ }
112
+ else if (/[\'\"]/.test(ch)) {
113
+ state.tokenize = inAttribute(ch);
114
+ return state.tokenize(stream, state);
115
+ }
116
+ else {
117
+ stream.eatWhile(/[^\s\u00a0=<>\"\'\/?]/);
118
+ return "word";
119
+ }
120
+ }
121
+
122
+ function inAttribute(quote) {
123
+ return function(stream, state) {
124
+ while (!stream.eol()) {
125
+ if (stream.next() == quote) {
126
+ state.tokenize = inTag;
127
+ break;
128
+ }
129
+ }
130
+ return "string";
131
+ };
132
+ }
133
+
134
+ function inBlock(style, terminator) {
135
+ return function(stream, state) {
136
+ while (!stream.eol()) {
137
+ if (stream.match(terminator)) {
138
+ state.tokenize = inText;
139
+ break;
140
+ }
141
+ stream.next();
142
+ }
143
+ return style;
144
+ };
145
+ }
146
+ function doctype(depth) {
147
+ return function(stream, state) {
148
+ var ch;
149
+ while ((ch = stream.next()) != null) {
150
+ if (ch == "<") {
151
+ state.tokenize = doctype(depth + 1);
152
+ return state.tokenize(stream, state);
153
+ } else if (ch == ">") {
154
+ if (depth == 1) {
155
+ state.tokenize = inText;
156
+ break;
157
+ } else {
158
+ state.tokenize = doctype(depth - 1);
159
+ return state.tokenize(stream, state);
160
+ }
161
+ }
162
+ }
163
+ return "meta";
164
+ };
165
+ }
166
+
167
+ var curState, setStyle;
168
+ function pass() {
169
+ for (var i = arguments.length - 1; i >= 0; i--) curState.cc.push(arguments[i]);
170
+ }
171
+ function cont() {
172
+ pass.apply(null, arguments);
173
+ return true;
174
+ }
175
+
176
+ function pushContext(tagName, startOfLine) {
177
+ var noIndent = Kludges.doNotIndent.hasOwnProperty(tagName) || (curState.context && curState.context.noIndent);
178
+ curState.context = {
179
+ prev: curState.context,
180
+ tagName: tagName,
181
+ indent: curState.indented,
182
+ startOfLine: startOfLine,
183
+ noIndent: noIndent
184
+ };
185
+ }
186
+ function popContext() {
187
+ if (curState.context) curState.context = curState.context.prev;
188
+ }
189
+
190
+ function element(type) {
191
+ if (type == "openTag") {
192
+ curState.tagName = tagName;
193
+ return cont(attributes, endtag(curState.startOfLine));
194
+ } else if (type == "closeTag") {
195
+ var err = false;
196
+ if (curState.context) {
197
+ if (curState.context.tagName != tagName) {
198
+ if (Kludges.implicitlyClosed.hasOwnProperty(curState.context.tagName.toLowerCase())) {
199
+ popContext();
200
+ }
201
+ err = !curState.context || curState.context.tagName != tagName;
202
+ }
203
+ } else {
204
+ err = true;
205
+ }
206
+ if (err) setStyle = "error";
207
+ return cont(endclosetag(err));
208
+ }
209
+ return cont();
210
+ }
211
+ function endtag(startOfLine) {
212
+ return function(type) {
213
+ if (type == "selfcloseTag" ||
214
+ (type == "endTag" && Kludges.autoSelfClosers.hasOwnProperty(curState.tagName.toLowerCase()))) {
215
+ maybePopContext(curState.tagName.toLowerCase());
216
+ return cont();
217
+ }
218
+ if (type == "endTag") {
219
+ maybePopContext(curState.tagName.toLowerCase());
220
+ pushContext(curState.tagName, startOfLine);
221
+ return cont();
222
+ }
223
+ return cont();
224
+ };
225
+ }
226
+ function endclosetag(err) {
227
+ return function(type) {
228
+ if (err) setStyle = "error";
229
+ if (type == "endTag") { popContext(); return cont(); }
230
+ setStyle = "error";
231
+ return cont(arguments.callee);
232
+ }
233
+ }
234
+ function maybePopContext(nextTagName) {
235
+ var parentTagName;
236
+ while (true) {
237
+ if (!curState.context) {
238
+ return;
239
+ }
240
+ parentTagName = curState.context.tagName.toLowerCase();
241
+ if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
242
+ !Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
243
+ return;
244
+ }
245
+ popContext();
246
+ }
247
+ }
248
+
249
+ function attributes(type) {
250
+ if (type == "word") {setStyle = "attribute"; return cont(attribute, attributes);}
251
+ if (type == "endTag" || type == "selfcloseTag") return pass();
252
+ setStyle = "error";
253
+ return cont(attributes);
254
+ }
255
+ function attribute(type) {
256
+ if (type == "equals") return cont(attvalue, attributes);
257
+ if (!Kludges.allowMissing) setStyle = "error";
258
+ return (type == "endTag" || type == "selfcloseTag") ? pass() : cont();
259
+ }
260
+ function attvalue(type) {
261
+ if (type == "string") return cont(attvaluemaybe);
262
+ if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return cont();}
263
+ setStyle = "error";
264
+ return (type == "endTag" || type == "selfCloseTag") ? pass() : cont();
265
+ }
266
+ function attvaluemaybe(type) {
267
+ if (type == "string") return cont(attvaluemaybe);
268
+ else return pass();
269
+ }
270
+
271
+ return {
272
+ startState: function() {
273
+ return {tokenize: inText, cc: [], indented: 0, startOfLine: true, tagName: null, context: null};
274
+ },
275
+
276
+ token: function(stream, state) {
277
+ if (stream.sol()) {
278
+ state.startOfLine = true;
279
+ state.indented = stream.indentation();
280
+ }
281
+ if (stream.eatSpace()) return null;
282
+
283
+ setStyle = type = tagName = null;
284
+ var style = state.tokenize(stream, state);
285
+ state.type = type;
286
+ if ((style || type) && style != "comment") {
287
+ curState = state;
288
+ while (true) {
289
+ var comb = state.cc.pop() || element;
290
+ if (comb(type || style)) break;
291
+ }
292
+ }
293
+ state.startOfLine = false;
294
+ return setStyle || style;
295
+ },
296
+
297
+ indent: function(state, textAfter, fullLine) {
298
+ var context = state.context;
299
+ if ((state.tokenize != inTag && state.tokenize != inText) ||
300
+ context && context.noIndent)
301
+ return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
302
+ if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
303
+ if (context && /^<\//.test(textAfter))
304
+ context = context.prev;
305
+ while (context && !context.startOfLine)
306
+ context = context.prev;
307
+ if (context) return context.indent + indentUnit;
308
+ else return 0;
309
+ },
310
+
311
+ compareStates: function(a, b) {
312
+ if (a.indented != b.indented || a.tokenize != b.tokenize) return false;
313
+ for (var ca = a.context, cb = b.context; ; ca = ca.prev, cb = cb.prev) {
314
+ if (!ca || !cb) return ca == cb;
315
+ if (ca.tagName != cb.tagName) return false;
316
+ }
317
+ },
318
+
319
+ electricChars: "/"
320
+ };
321
+ });
322
+
323
+ CodeMirror.defineMIME("application/xml", "xml");
324
+ if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
325
+ CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
326
+ CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
327
+ var htmlMode = CodeMirror.getMode(config, {name: "xml", htmlMode: true});
328
+ var jsMode = CodeMirror.getMode(config, "javascript");
329
+ var cssMode = CodeMirror.getMode(config, "css");
330
+
331
+ function html(stream, state) {
332
+ var style = htmlMode.token(stream, state.htmlState);
333
+ if (style == "tag" && stream.current() == ">" && state.htmlState.context) {
334
+ if (/^script$/i.test(state.htmlState.context.tagName)) {
335
+ state.token = javascript;
336
+ state.localState = jsMode.startState(htmlMode.indent(state.htmlState, ""));
337
+ state.mode = "javascript";
338
+ }
339
+ else if (/^style$/i.test(state.htmlState.context.tagName)) {
340
+ state.token = css;
341
+ state.localState = cssMode.startState(htmlMode.indent(state.htmlState, ""));
342
+ state.mode = "css";
343
+ }
344
+ }
345
+ return style;
346
+ }
347
+ function maybeBackup(stream, pat, style) {
348
+ var cur = stream.current();
349
+ var close = cur.search(pat);
350
+ if (close > -1) stream.backUp(cur.length - close);
351
+ return style;
352
+ }
353
+ function javascript(stream, state) {
354
+ if (stream.match(/^<\/\s*script\s*>/i, false)) {
355
+ state.token = html;
356
+ state.localState = null;
357
+ state.mode = "html";
358
+ return html(stream, state);
359
+ }
360
+ return maybeBackup(stream, /<\/\s*script\s*>/,
361
+ jsMode.token(stream, state.localState));
362
+ }
363
+ function css(stream, state) {
364
+ if (stream.match(/^<\/\s*style\s*>/i, false)) {
365
+ state.token = html;
366
+ state.localState = null;
367
+ state.mode = "html";
368
+ return html(stream, state);
369
+ }
370
+ return maybeBackup(stream, /<\/\s*style\s*>/,
371
+ cssMode.token(stream, state.localState));
372
+ }
373
+
374
+ return {
375
+ startState: function() {
376
+ var state = htmlMode.startState();
377
+ return {token: html, localState: null, mode: "html", htmlState: state};
378
+ },
379
+
380
+ copyState: function(state) {
381
+ if (state.localState)
382
+ var local = CodeMirror.copyState(state.token == css ? cssMode : jsMode, state.localState);
383
+ return {token: state.token, localState: local, mode: state.mode,
384
+ htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
385
+ },
386
+
387
+ token: function(stream, state) {
388
+ return state.token(stream, state);
389
+ },
390
+
391
+ indent: function(state, textAfter) {
392
+ if (state.token == html || /^\s*<\//.test(textAfter))
393
+ return htmlMode.indent(state.htmlState, textAfter);
394
+ else if (state.token == javascript)
395
+ return jsMode.indent(state.localState, textAfter);
396
+ else
397
+ return cssMode.indent(state.localState, textAfter);
398
+ },
399
+
400
+ compareStates: function(a, b) {
401
+ if (a.mode != b.mode) return false;
402
+ if (a.localState) return CodeMirror.Pass;
403
+ return htmlMode.compareStates(a.htmlState, b.htmlState);
404
+ },
405
+
406
+ electricChars: "/{}:"
407
+ }
408
+ }, "xml", "javascript", "css");
409
+
410
+ CodeMirror.defineMIME("text/html", "htmlmixed");