MCPcopy Create free account
hub / github.com/TruthHun/BookStack / initPanels

Function initPanels

static/editor.md/lib/codemirror/addon/display/panel.js:50–82  ·  view source on GitHub ↗
(cm)

Source from the content-addressed store, hash-verified

48 };
49
50 function initPanels(cm) {
51 var wrap = cm.getWrapperElement();
52 var style = window.getComputedStyle ? window.getComputedStyle(wrap) : wrap.currentStyle;
53 var height = parseInt(style.height);
54 var info = cm.state.panels = {
55 setHeight: wrap.style.height,
56 heightLeft: height,
57 panels: 0,
58 wrapper: document.createElement("div")
59 };
60 wrap.parentNode.insertBefore(info.wrapper, wrap);
61 var hasFocus = cm.hasFocus();
62 info.wrapper.appendChild(wrap);
63 if (hasFocus) cm.focus();
64
65 cm._setSize = cm.setSize;
66 if (height != null) cm.setSize = function(width, newHeight) {
67 if (newHeight == null) return this._setSize(width, newHeight);
68 info.setHeight = newHeight;
69 if (typeof newHeight != "number") {
70 var px = /^(\d+\.?\d*)px$/.exec(newHeight);
71 if (px) {
72 newHeight = Number(px[1]);
73 } else {
74 info.wrapper.style.height = newHeight;
75 newHeight = info.wrapper.offsetHeight;
76 info.wrapper.style.height = "";
77 }
78 }
79 cm._setSize(width, info.heightLeft += (newHeight - height));
80 height = newHeight;
81 };
82 }
83
84 function removePanels(cm) {
85 var info = cm.state.panels;

Callers 1

panel.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected