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 / selection / active-line.js

active-line.js in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 2.0.2, at assets/lib/codemirror/addon/selection/active-line.js

40 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // Because sometimes you need to style the cursor's line.
2 //
3 // Adds an option 'styleActiveLine' which, when enabled, gives the
4 // active line's wrapping <div> the CSS class "CodeMirror-activeline",
5 // and gives its background <div> the class "CodeMirror-activeline-background".
6
7 (function() {
8 "use strict";
9 var WRAP_CLASS = "CodeMirror-activeline";
10 var BACK_CLASS = "CodeMirror-activeline-background";
11
12 CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
13 var prev = old && old != CodeMirror.Init;
14 if (val && !prev) {
15 updateActiveLine(cm);
16 cm.on("cursorActivity", updateActiveLine);
17 } else if (!val && prev) {
18 cm.off("cursorActivity", updateActiveLine);
19 clearActiveLine(cm);
20 delete cm.state.activeLine;
21 }
22 });
23
24 function clearActiveLine(cm) {
25 if ("activeLine" in cm.state) {
26 cm.removeLineClass(cm.state.activeLine, "wrap", WRAP_CLASS);
27 cm.removeLineClass(cm.state.activeLine, "background", BACK_CLASS);
28 }
29 }
30
31 function updateActiveLine(cm) {
32 var line = cm.getLineHandleVisualStart(cm.getCursor().line);
33 if (cm.state.activeLine == line) return;
34 clearActiveLine(cm);
35 cm.addLineClass(line, "wrap", WRAP_CLASS);
36 cm.addLineClass(line, "background", BACK_CLASS);
37 cm.state.activeLine = line;
38 }
39 })();
40