Mercurial > kallithea
annotate rhodecode/public/js/mode/htmlmixed/index.html @ 4026:a60a0e9092c6
added codemirror edit mode with autodetection
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 20 Jun 2013 23:53:18 +0200 |
parents | |
children |
rev | line source |
---|---|
4026
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 <!doctype html> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
2 <html> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
3 <head> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 <meta charset="utf-8"> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
5 <title>CodeMirror: HTML mixed mode</title> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
6 <link rel="stylesheet" href="../../lib/codemirror.css"> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
7 <script src="../../lib/codemirror.js"></script> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
8 <script src="../xml/xml.js"></script> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 <script src="../javascript/javascript.js"></script> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 <script src="../css/css.js"></script> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 <script src="../vbscript/vbscript.js"></script> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 <script src="htmlmixed.js"></script> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 <link rel="stylesheet" href="../../doc/docs.css"> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 </head> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 <body> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 <h1>CodeMirror: HTML mixed mode</h1> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
18 <form><textarea id="code" name="code"> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
19 <html style="color: green"> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
20 <!-- this is a comment --> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
21 <head> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
22 <title>Mixed HTML Example</title> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
23 <style type="text/css"> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 h1 {font-family: comic sans; color: #f0f;} |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 div {background: yellow !important;} |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 body { |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 max-width: 50em; |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 margin: 1em 2em 1em 5em; |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 } |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 </style> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 </head> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 <body> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 <h1>Mixed HTML Example</h1> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 <script> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 function jsFunc(arg1, arg2) { |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 if (arg1 && arg2) document.body.innerHTML = "achoo"; |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 } |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 </script> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 </body> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 </html> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 </textarea></form> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 <script> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 // Define an extended mixed-mode that understands vbscript and |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
44 // leaves mustache/handlebars embedded templates in html mode |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 var mixedMode = { |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 name: "htmlmixed", |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
47 scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i, |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 mode: null}, |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 {matches: /(text|application)\/(x-)?vb(a|script)/i, |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
50 mode: "vbscript"}] |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
51 }; |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 var editor = CodeMirror.fromTextArea(document.getElementById("code"), {mode: mixedMode, tabMode: "indent"}); |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 </script> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 <p>The HTML mixed mode depends on the XML, JavaScript, and CSS modes.</p> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
57 <p>It takes an optional mode configuration |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 option, <code>scriptTypes</code>, which can be used to add custom |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 behavior for specific <code><script type="..."></code> tags. If |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 given, it should hold an array of <code>{matches, mode}</code> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 objects, where <code>matches</code> is a string or regexp that |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 matches the script type, and <code>mode</code> is |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 either <code>null</code>, for script types that should stay in |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 HTML mode, or a <a href="../../doc/manual.html#option_mode">mode |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 spec</a> corresponding to the mode that should be used for the |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 script.</p> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
68 <p><strong>MIME types defined:</strong> <code>text/html</code> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 (redefined, only takes effect if you load this parser after the |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
70 XML parser).</p> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 </body> |
a60a0e9092c6
added codemirror edit mode with autodetection
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 </html> |