[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/vendor/codemirror/addon/scroll/ -> scrollpastend.js (source)

   1  // CodeMirror, copyright (c) by Marijn Haverbeke and others
   2  // Distributed under an MIT license: https://codemirror.net/5/LICENSE
   3  
   4  (function(mod) {
   5    if (typeof exports == "object" && typeof module == "object") // CommonJS
   6      mod(require("../../lib/codemirror"));
   7    else if (typeof define == "function" && define.amd) // AMD
   8      define(["../../lib/codemirror"], mod);
   9    else // Plain browser env
  10      mod(CodeMirror);
  11  })(function(CodeMirror) {
  12    "use strict";
  13  
  14    CodeMirror.defineOption("scrollPastEnd", false, function(cm, val, old) {
  15      if (old && old != CodeMirror.Init) {
  16        cm.off("change", onChange);
  17        cm.off("refresh", updateBottomMargin);
  18        cm.display.lineSpace.parentNode.style.paddingBottom = "";
  19        cm.state.scrollPastEndPadding = null;
  20      }
  21      if (val) {
  22        cm.on("change", onChange);
  23        cm.on("refresh", updateBottomMargin);
  24        updateBottomMargin(cm);
  25      }
  26    });
  27  
  28    function onChange(cm, change) {
  29      if (CodeMirror.changeEnd(change).line == cm.lastLine())
  30        updateBottomMargin(cm);
  31    }
  32  
  33    function updateBottomMargin(cm) {
  34      var padding = "";
  35      if (cm.lineCount() > 1) {
  36        var totalH = cm.display.scroller.clientHeight - 30,
  37            lastLineH = cm.getLineHandle(cm.lastLine()).height;
  38        padding = (totalH - lastLineH) + "px";
  39      }
  40      if (cm.state.scrollPastEndPadding != padding) {
  41        cm.state.scrollPastEndPadding = padding;
  42        cm.display.lineSpace.parentNode.style.paddingBottom = padding;
  43        cm.off("refresh", updateBottomMargin);
  44        cm.setSize();
  45        cm.on("refresh", updateBottomMargin);
  46      }
  47    }
  48  });


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer