diff options
author | Nivesh Rajbhandari | 2012-02-20 11:14:44 -0800 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-02-20 11:14:44 -0800 |
commit | abf78e2d7a97d295ce5a1c425fd359d47379137e (patch) | |
tree | d08c91bd2aef31e6325e0b499b2ffc390018bec6 /js/codemirror/mode/htmlmixed/htmlmixed.js | |
parent | e80a79bff57fecf3aa9b869d8ed2de5fd815287c (diff) | |
parent | e23708721a71ca4c71365f5f8e8ac7d6113926db (diff) | |
download | ninja-abf78e2d7a97d295ce5a1c425fd359d47379137e.tar.gz |
Merge branch 'refs/heads/ninja-internal' into ToolFixes
Diffstat (limited to 'js/codemirror/mode/htmlmixed/htmlmixed.js')
-rw-r--r-- | js/codemirror/mode/htmlmixed/htmlmixed.js | 79 |
1 files changed, 0 insertions, 79 deletions
diff --git a/js/codemirror/mode/htmlmixed/htmlmixed.js b/js/codemirror/mode/htmlmixed/htmlmixed.js deleted file mode 100644 index fa30a13f..00000000 --- a/js/codemirror/mode/htmlmixed/htmlmixed.js +++ /dev/null | |||
@@ -1,79 +0,0 @@ | |||
1 | CodeMirror.defineMode("htmlmixed", function(config, parserConfig) { | ||
2 | var htmlMode = CodeMirror.getMode(config, {name: "xml", htmlMode: true}); | ||
3 | var jsMode = CodeMirror.getMode(config, "javascript"); | ||
4 | var cssMode = CodeMirror.getMode(config, "css"); | ||
5 | |||
6 | function html(stream, state) { | ||
7 | var style = htmlMode.token(stream, state.htmlState); | ||
8 | if (style == "tag" && stream.current() == ">" && state.htmlState.context) { | ||
9 | if (/^script$/i.test(state.htmlState.context.tagName)) { | ||
10 | state.token = javascript; | ||
11 | state.localState = jsMode.startState(htmlMode.indent(state.htmlState, "")); | ||
12 | state.mode = "javascript"; | ||
13 | } | ||
14 | else if (/^style$/i.test(state.htmlState.context.tagName)) { | ||
15 | state.token = css; | ||
16 | state.localState = cssMode.startState(htmlMode.indent(state.htmlState, "")); | ||
17 | state.mode = "css"; | ||
18 | } | ||
19 | } | ||
20 | return style; | ||
21 | } | ||
22 | function maybeBackup(stream, pat, style) { | ||
23 | var cur = stream.current(); | ||
24 | var close = cur.search(pat); | ||
25 | if (close > -1) stream.backUp(cur.length - close); | ||
26 | return style; | ||
27 | } | ||
28 | function javascript(stream, state) { | ||
29 | if (stream.match(/^<\/\s*script\s*>/i, false)) { | ||
30 | state.token = html; | ||
31 | state.curState = null; | ||
32 | state.mode = "html"; | ||
33 | return html(stream, state); | ||
34 | } | ||
35 | return maybeBackup(stream, /<\/\s*script\s*>/, | ||
36 | jsMode.token(stream, state.localState)); | ||
37 | } | ||
38 | function css(stream, state) { | ||
39 | if (stream.match(/^<\/\s*style\s*>/i, false)) { | ||
40 | state.token = html; | ||
41 | state.localState = null; | ||
42 | state.mode = "html"; | ||
43 | return html(stream, state); | ||
44 | } | ||
45 | return maybeBackup(stream, /<\/\s*style\s*>/, | ||
46 | cssMode.token(stream, state.localState)); | ||
47 | } | ||
48 | |||
49 | return { | ||
50 | startState: function() { | ||
51 | var state = htmlMode.startState(); | ||
52 | return {token: html, localState: null, mode: "html", htmlState: state}; | ||
53 | }, | ||
54 | |||
55 | copyState: function(state) { | ||
56 | if (state.localState) | ||
57 | var local = CodeMirror.copyState(state.token == css ? cssMode : jsMode, state.localState); | ||
58 | return {token: state.token, localState: local, mode: state.mode, | ||
59 | htmlState: CodeMirror.copyState(htmlMode, state.htmlState)}; | ||
60 | }, | ||
61 | |||
62 | token: function(stream, state) { | ||
63 | return state.token(stream, state); | ||
64 | }, | ||
65 | |||
66 | indent: function(state, textAfter) { | ||
67 | if (state.token == html || /^\s*<\//.test(textAfter)) | ||
68 | return htmlMode.indent(state.htmlState, textAfter); | ||
69 | else if (state.token == javascript) | ||
70 | return jsMode.indent(state.localState, textAfter); | ||
71 | else | ||
72 | return cssMode.indent(state.localState, textAfter); | ||
73 | }, | ||
74 | |||
75 | electricChars: "/{}:" | ||
76 | } | ||
77 | }); | ||
78 | |||
79 | CodeMirror.defineMIME("text/html", "htmlmixed"); | ||