59 lines
2.1 KiB
JavaScript
59 lines
2.1 KiB
JavaScript
/*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This product is licensed for one customer to use on one installation (test stores and multishop included).
|
|
* Site developer has the right to modify this module to suit their needs, but can not redistribute the module in
|
|
* whole or in part. Any other use of this module constitutes a violation of the user agreement.
|
|
*
|
|
* DISCLAIMER
|
|
*
|
|
* NO WARRANTIES OF DATA SAFETY OR MODULE SECURITY
|
|
* ARE EXPRESSED OR IMPLIED. USE THIS MODULE IN ACCORDANCE
|
|
* WITH YOUR MERCHANT AGREEMENT, KNOWING THAT VIOLATIONS OF
|
|
* PCI COMPLIANCY OR A DATA BREACH CAN COST THOUSANDS OF DOLLARS
|
|
* IN FINES AND DAMAGE A STORES REPUTATION. USE AT YOUR OWN RISK.
|
|
*
|
|
* @author idnovate.com <info@idnovate.com>
|
|
* @copyright 2022 idnovate.com
|
|
* @license See above
|
|
*/
|
|
|
|
(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("fullScreen", false, function(cm, val, old) {
|
|
if (old == CodeMirror.Init) old = false;
|
|
if (!old == !val) return;
|
|
if (val) setFullscreen(cm);
|
|
else setNormal(cm);
|
|
});
|
|
|
|
function setFullscreen(cm) {
|
|
var wrap = cm.getWrapperElement();
|
|
cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
|
|
width: wrap.style.width, height: wrap.style.height};
|
|
wrap.style.width = "";
|
|
wrap.style.height = "auto";
|
|
wrap.className += " CodeMirror-fullscreen";
|
|
document.documentElement.style.overflow = "hidden";
|
|
cm.refresh();
|
|
}
|
|
|
|
function setNormal(cm) {
|
|
var wrap = cm.getWrapperElement();
|
|
wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, "");
|
|
document.documentElement.style.overflow = "";
|
|
var info = cm.state.fullScreenRestore;
|
|
wrap.style.width = info.width; wrap.style.height = info.height;
|
|
window.scrollTo(info.scrollLeft, info.scrollTop);
|
|
cm.refresh();
|
|
}
|
|
});
|