PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 2.0.6
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v2.0.6
4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 340 releases
profile-builder / assets / lib / codemirror / addon / runmode / runmode.js

runmode.js in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 2.0.6, at assets/lib/codemirror/addon/runmode/runmode.js

57 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 CodeMirror.runMode = function(string, modespec, callback, options) {
2 var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
3 var ie = /MSIE \d/.test(navigator.userAgent);
4 var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
5
6 if (callback.nodeType == 1) {
7 var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
8 var node = callback, col = 0;
9 node.innerHTML = "";
10 callback = function(text, style) {
11 if (text == "\n") {
12 // Emitting LF or CRLF on IE8 or earlier results in an incorrect display.
13 // Emitting a carriage return makes everything ok.
14 node.appendChild(document.createTextNode(ie_lt9 ? '\r' : text));
15 col = 0;
16 return;
17 }
18 var content = "";
19 // replace tabs
20 for (var pos = 0;;) {
21 var idx = text.indexOf("\t", pos);
22 if (idx == -1) {
23 content += text.slice(pos);
24 col += text.length - pos;
25 break;
26 } else {
27 col += idx - pos;
28 content += text.slice(pos, idx);
29 var size = tabSize - col % tabSize;
30 col += size;
31 for (var i = 0; i < size; ++i) content += " ";
32 pos = idx + 1;
33 }
34 }
35
36 if (style) {
37 var sp = node.appendChild(document.createElement("span"));
38 sp.className = "cm-" + style.replace(/ +/g, " cm-");
39 sp.appendChild(document.createTextNode(content));
40 } else {
41 node.appendChild(document.createTextNode(content));
42 }
43 };
44 }
45
46 var lines = CodeMirror.splitLines(string), state = CodeMirror.startState(mode);
47 for (var i = 0, e = lines.length; i < e; ++i) {
48 if (i) callback("\n");
49 var stream = new CodeMirror.StringStream(lines[i]);
50 while (!stream.eol()) {
51 var style = mode.token(stream, state);
52 callback(stream.current(), style, i, stream.start, state);
53 stream.start = stream.pos;
54 }
55 }
56 };
57