From f30313f589ae285ec9141e44a111a6cda6bb07ae Mon Sep 17 00:00:00 2001 From: Vesa Karvonen Date: Tue, 2 Jan 2018 12:06:20 +0200 Subject: [PATCH] Quick fix to Klipse integration --- docs/fw/klipse-settings.js | 34 +++++++++++++--------------------- docs/fw/styles.css | 8 ++++---- 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/docs/fw/klipse-settings.js b/docs/fw/klipse-settings.js index 95d43a7a..d8516075 100644 --- a/docs/fw/klipse-settings.js +++ b/docs/fw/klipse-settings.js @@ -44,44 +44,36 @@ window.klipse_settings = { } function accelerate_klipse() { - const all = Array.prototype.slice.call(document.querySelectorAll('.klipse-container'), 0, -1).map(function (e) { - const pre = e.parentNode - const cm1 = pre.children[0] - const cm2 = pre.children[1] - return [pre, cm1, cm2] - }) + const all = Array.prototype.slice.call(document.querySelectorAll('.CodeMirror'), 0, -1) function hide(i) { - const pcc = all[i] - pcc[0].style.cssText = 'min-height: ' + pcc[0].getBoundingClientRect().height + 'px;' - pcc[1].style.cssText = '' - pcc[2].style.cssText = '' + const e = all[i] + e.parentNode.style.cssText = 'min-height: ' + e.getBoundingClientRect().height + 'px;' + e.style.cssText = '' } function show(i) { - const pcc = all[i] - pcc[0].style.cssText = '' - pcc[1].style.cssText = 'display: block;' - pcc[2].style.cssText = 'display: block;' - pcc[1].CodeMirror.refresh() - pcc[2].CodeMirror.refresh() + const e = all[i] + e.parentNode.style.cssText = '' + e.style.cssText = 'display: block;' + e.CodeMirror.refresh() } function hasBeenShown(i) { - const pcc = all[i] - return pcc[0].style.length || pcc[1].style.length + const e = all[i] + return e.style.length } let oldVisStart = 0 let oldVisStop = 0 function visibility(i, height) { - const pcc = all[i] - const r = pcc[0].getBoundingClientRect() + const e = all[i] + const r = e.parentNode.getBoundingClientRect() return height <= r.top ? 1 : r.bottom < 0 ? -1 : 0 } function findFirst(i, height) { while (0 < i && 0 === visibility(i-1, height)) - --i; + --i return i } diff --git a/docs/fw/styles.css b/docs/fw/styles.css index 0fcdfb9f..b0c4916b 100644 --- a/docs/fw/styles.css +++ b/docs/fw/styles.css @@ -48,7 +48,7 @@ display: block; } -.CodeMirror:first-of-type { +.klipse-snippet .CodeMirror { border: 1px #f7f7f7 solid; border-radius: 5px; } @@ -58,15 +58,15 @@ padding: 5px; } -.CodeMirror:first-of-type:hover { +.klipse-snippet .CodeMirror:hover { border: 1px #ddd solid; } -.CodeMirror:last-of-type { +.klipse-result .CodeMirror { background: #f7f7f7; } -.CodeMirror:last-of-type { +.klipse-result .CodeMirror { background: transparent; filter: brightness(50%); opacity: 0.85;