PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 2.0.2
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v2.0.2
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 / comment / continuecomment.js

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

55 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function() {
2 var modes = ["clike", "css", "javascript"];
3 for (var i = 0; i < modes.length; ++i)
4 CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "});
5
6 function continueComment(cm) {
7 var pos = cm.getCursor(), token = cm.getTokenAt(pos);
8 if (token.type != "comment") return CodeMirror.Pass;
9 var mode = CodeMirror.innerMode(cm.getMode(), token.state).mode;
10
11 var insert;
12 if (mode.blockCommentStart && mode.blockCommentContinue) {
13 var end = token.string.indexOf(mode.blockCommentEnd);
14 var full = cm.getRange(CodeMirror.Pos(pos.line, 0), CodeMirror.Pos(pos.line, token.end)), found;
15 if (end != -1 && end == token.string.length - mode.blockCommentEnd.length) {
16 // Comment ended, don't continue it
17 } else if (token.string.indexOf(mode.blockCommentStart) == 0) {
18 insert = full.slice(0, token.start);
19 if (!/^\s*$/.test(insert)) {
20 insert = "";
21 for (var i = 0; i < token.start; ++i) insert += " ";
22 }
23 } else if ((found = full.indexOf(mode.blockCommentContinue)) != -1 &&
24 found + mode.blockCommentContinue.length > token.start &&
25 /^\s*$/.test(full.slice(0, found))) {
26 insert = full.slice(0, found);
27 }
28 if (insert != null) insert += mode.blockCommentContinue;
29 }
30 if (insert == null && mode.lineComment) {
31 var line = cm.getLine(pos.line), found = line.indexOf(mode.lineComment);
32 if (found > -1) {
33 insert = line.slice(0, found);
34 if (/\S/.test(insert)) insert = null;
35 else insert += mode.lineComment + line.slice(found + mode.lineComment.length).match(/^\s*/)[0];
36 }
37 }
38
39 if (insert != null)
40 cm.replaceSelection("\n" + insert, "end");
41 else
42 return CodeMirror.Pass;
43 }
44
45 CodeMirror.defineOption("continueComments", null, function(cm, val, prev) {
46 if (prev && prev != CodeMirror.Init)
47 cm.removeKeyMap("continueComment");
48 if (val) {
49 var map = {name: "continueComment"};
50 map[typeof val == "string" ? val : "Enter"] = continueComment;
51 cm.addKeyMap(map);
52 }
53 });
54 })();
55