Sha256: 012b2f857ef9a877edeaebbcb4e73f7e88f8dc4c763e8c72e6719375632ad2f3

Contents?: true

Size: 1.87 KB

Versions: 24

Compression:

Stored size: 1.87 KB

Contents

// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE

(function(mod) {
  if (typeof exports == "object" && typeof module == "object") // CommonJS
    mod(require("../../lib/codemirror"));
  else if (typeof define == "function" && define.amd) // AMD
    define(["../../lib/codemirror"], mod);
  else // Plain browser env
    mod(CodeMirror);
})(function(CodeMirror) {
  "use strict";

  CodeMirror.defineOption("rulers", false, function(cm, val) {
    if (cm.state.rulerDiv) {
      cm.state.rulerDiv.parentElement.removeChild(cm.state.rulerDiv)
      cm.state.rulerDiv = null
      cm.off("refresh", drawRulers)
    }
    if (val && val.length) {
      cm.state.rulerDiv = cm.display.lineSpace.parentElement.insertBefore(document.createElement("div"), cm.display.lineSpace)
      cm.state.rulerDiv.className = "CodeMirror-rulers"
      drawRulers(cm)
      cm.on("refresh", drawRulers)
    }
  });

  function drawRulers(cm) {
    cm.state.rulerDiv.textContent = ""
    var val = cm.getOption("rulers");
    var cw = cm.defaultCharWidth();
    var left = cm.charCoords(CodeMirror.Pos(cm.firstLine(), 0), "div").left;
    cm.state.rulerDiv.style.minHeight = (cm.display.scroller.offsetHeight + 30) + "px";
    for (var i = 0; i < val.length; i++) {
      var elt = document.createElement("div");
      elt.className = "CodeMirror-ruler";
      var col, conf = val[i];
      if (typeof conf == "number") {
        col = conf;
      } else {
        col = conf.column;
        if (conf.className) elt.className += " " + conf.className;
        if (conf.color) elt.style.borderColor = conf.color;
        if (conf.lineStyle) elt.style.borderLeftStyle = conf.lineStyle;
        if (conf.width) elt.style.borderLeftWidth = conf.width;
      }
      elt.style.left = (left + col * cw) + "px";
      cm.state.rulerDiv.appendChild(elt)
    }
  }
});

Version data entries

24 entries across 24 versions & 3 rubygems

Version Path
rails_db-2.4.4 app/assets/javascripts/codemirror/codemirror/addons/display/rulers.js
rails_db-2.4.3 app/assets/javascripts/codemirror/codemirror/addons/display/rulers.js
wallaby-7.0.0.beta2 vendor/assets/javascripts/codemirror/5.49.2/addon/display/rulers.js
wallaby-7.0.0.beta1 vendor/assets/javascripts/codemirror/5.49.2/addon/display/rulers.js
wallaby-6.1.6 vendor/assets/javascripts/codemirror/5.49.2/addon/display/rulers.js
rails_db-2.4.2 app/assets/javascripts/codemirror/codemirror/addons/display/rulers.js
wallaby-6.1.5 vendor/assets/javascripts/codemirror/5.49.2/addon/display/rulers.js
wallaby-6.1.4 vendor/assets/javascripts/codemirror/5.49.2/addon/display/rulers.js
rails_db-2.4.1 app/assets/javascripts/codemirror/codemirror/addons/display/rulers.js
rails_db-2.4.0 app/assets/javascripts/codemirror/codemirror/addons/display/rulers.js
wallaby-6.1.3 vendor/assets/javascripts/codemirror/5.49.2/addon/display/rulers.js
wallaby-6.1.2 vendor/assets/javascripts/codemirror/5.49.2/addon/display/rulers.js
wallaby-6.1.1 vendor/assets/javascripts/codemirror/5.49.2/addon/display/rulers.js
wallaby-6.1.0 vendor/assets/javascripts/codemirror/5.49.2/addon/display/rulers.js
rails_db-2.3.1 app/assets/javascripts/codemirror/codemirror/addons/display/rulers.js
rails_db-2.3.0 app/assets/javascripts/codemirror/codemirror/addons/display/rulers.js
wallaby-6.0.2 vendor/assets/javascripts/codemirror/5.49.2/addon/display/rulers.js
wallaby-6.0.1 vendor/assets/javascripts/codemirror/5.49.2/addon/display/rulers.js
rails_db-2.2.1 app/assets/javascripts/codemirror/codemirror/addons/display/rulers.js
rails_db-2.2.0 app/assets/javascripts/codemirror/codemirror/addons/display/rulers.js