Sha256: 3ff394be6d51b5860ade88ff4bfdf32a9d2457d5afa867a6772a378800cc7be2

Contents?: true

Size: 1.25 KB

Versions: 13

Compression:

Stored size: 1.25 KB

Contents

// Because sometimes you need to style the cursor's line.
//
// Adds an option 'styleActiveLine' which, when enabled, gives the
// active line's wrapping <div> the CSS class "CodeMirror-activeline",
// and gives its background <div> the class "CodeMirror-activeline-background".

(function() {
  "use strict";
  var WRAP_CLASS = "CodeMirror-activeline";
  var BACK_CLASS = "CodeMirror-activeline-background";

  CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
    var prev = old && old != CodeMirror.Init;
    if (val && !prev) {
      updateActiveLine(cm);
      cm.on("cursorActivity", updateActiveLine);
    } else if (!val && prev) {
      cm.off("cursorActivity", updateActiveLine);
      clearActiveLine(cm);
      delete cm._activeLine;
    }
  });

  function clearActiveLine(cm) {
    if ("_activeLine" in cm) {
      cm.removeLineClass(cm._activeLine, "wrap", WRAP_CLASS);
      cm.removeLineClass(cm._activeLine, "background", BACK_CLASS);
    }
  }

  function updateActiveLine(cm) {
    var line = cm.getLineHandle(cm.getCursor().line);
    if (cm._activeLine == line) return;
    clearActiveLine(cm);
    cm.addLineClass(line, "wrap", WRAP_CLASS);
    cm.addLineClass(line, "background", BACK_CLASS);
    cm._activeLine = line;
  }
})();

Version data entries

13 entries across 7 versions & 3 rubygems

Version Path
mdbe-0.1.0 public/amber/js/lib/CodeMirror/active-line.js
mdbe-0.1.0 public/libs/codemirror/addon/selection/active-line.js
maglev-database-explorer-0.0.5 public/amber/js/lib/CodeMirror/active-line.js
maglev-database-explorer-0.0.5 public/libs/codemirror/addon/selection/active-line.js
maglev-database-explorer-0.0.4 public/amber/js/lib/CodeMirror/active-line.js
maglev-database-explorer-0.0.4 public/libs/codemirror/addon/selection/active-line.js
maglev-database-explorer-0.0.3 public/amber/js/lib/CodeMirror/active-line.js
maglev-database-explorer-0.0.3 public/libs/codemirror/addon/selection/active-line.js
maglev-database-explorer-0.0.2 public/amber/js/lib/CodeMirror/active-line.js
maglev-database-explorer-0.0.2 public/libs/codemirror/addon/selection/active-line.js
maglev-database-explorer-0.0.1 public/amber/js/lib/CodeMirror/active-line.js
maglev-database-explorer-0.0.1 public/libs/codemirror/addon/selection/active-line.js
codemirror-rails-3.12 vendor/assets/javascripts/codemirror/addons/selection/active-line.js