##// END OF EJS Templates
fix(license-import): don't crash if license file is not present, and only run this code for EE
fix(license-import): don't crash if license file is not present, and only run this code for EE

File last commit:

r4105:10488616 default
r5538:aa408762 default
Show More
codemirror_placeholder.js
63 lines | 2.2 KiB | application/javascript | JavascriptLexer
/ rhodecode / public / js / src / codemirror / codemirror_placeholder.js
project: added all source files and assets
r1 // CodeMirror, copyright (c) by Marijn Haverbeke and others
codemirror: bumped to version 5.49.2
r4105 // Distributed under an MIT license: https://codemirror.net/LICENSE
project: added all source files and assets
r1
(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) {
CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
var prev = old && old != CodeMirror.Init;
if (val && !prev) {
cm.on("blur", onBlur);
cm.on("change", onChange);
codemirror: bumped to version 5.49.2
r4105 cm.on("swapDoc", onChange);
project: added all source files and assets
r1 onChange(cm);
} else if (!val && prev) {
cm.off("blur", onBlur);
cm.off("change", onChange);
codemirror: bumped to version 5.49.2
r4105 cm.off("swapDoc", onChange);
project: added all source files and assets
r1 clearPlaceholder(cm);
var wrapper = cm.getWrapperElement();
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
}
if (val && !cm.hasFocus()) onBlur(cm);
});
function clearPlaceholder(cm) {
if (cm.state.placeholder) {
cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
cm.state.placeholder = null;
}
}
function setPlaceholder(cm) {
clearPlaceholder(cm);
var elt = cm.state.placeholder = document.createElement("pre");
elt.style.cssText = "height: 0; overflow: visible";
codemirror: bumped to version 5.49.2
r4105 elt.style.direction = cm.getOption("direction");
elt.className = "CodeMirror-placeholder CodeMirror-line-like";
codemirror: update from 5.4.0 to 5.11.0, fixes #3154
r346 var placeHolder = cm.getOption("placeholder")
if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
elt.appendChild(placeHolder)
project: added all source files and assets
r1 cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
}
function onBlur(cm) {
if (isEmpty(cm)) setPlaceholder(cm);
}
function onChange(cm) {
var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
if (empty) setPlaceholder(cm);
else clearPlaceholder(cm);
}
function isEmpty(cm) {
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
}
});