From b8bbcd01db0f40342c42e6ff6bf326c40ce29b03 Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 20 Jan 2016 21:02:10 +0300 Subject: [PATCH] Autohide lint report in narrow mode; show # of issues --- edit.html | 14 +++++++++++++- edit.js | 9 +++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/edit.html b/edit.html index f905f882..33fc617e 100644 --- a/edit.html +++ b/edit.html @@ -447,6 +447,18 @@ position: relative; top: 0.2rem; } + #lint h2 { + display: block; + cursor: default; + margin-bottom: 0; + } + #lint > div { + max-height: 0; + } + #lint:hover > div { + margin-top: 1em; + max-height: 30vh; + } #sections { padding-left: 0; } @@ -594,7 +606,7 @@ -

+

:

diff --git a/edit.js b/edit.js index d884fd44..2ee74e42 100644 --- a/edit.js +++ b/edit.js @@ -914,12 +914,14 @@ function renderLintReport(someBlockChanged) { var content = container.children[1]; var label = t("sectionCode"); var newContent = content.cloneNode(false); + var issueCount = 0; editors.forEach(function(cm, index) { if (cm.state.lint.html) { var newBlock = newContent.appendChild(document.createElement("table")); var html = "" + label + " " + (index+1) + "" + cm.state.lint.html; newBlock.innerHTML = html; newBlock.cm = cm; + issueCount += newBlock.rows.length; var block = content.children[newContent.children.length - 1]; var blockChanged = !block || cm != block.cm || html != block.innerHTML; @@ -928,6 +930,7 @@ function renderLintReport(someBlockChanged) { } }); if (someBlockChanged || newContent.children.length != content.children.length) { + document.getElementById('issue-count').textContent = issueCount; container.replaceChild(newContent, content); container.style.display = newContent.children.length ? "block" : "none"; resizeLintReport(null, newContent); @@ -937,10 +940,8 @@ function renderLintReport(someBlockChanged) { function resizeLintReport(event, content) { content = content || document.getElementById("lint").children[1]; if (content.children.length) { - var header = document.getElementById("header"); - var headerHeight = parseFloat(getComputedStyle(header).height); - var contentTop = content.getBoundingClientRect().top - header.getBoundingClientRect().top; - var newMaxHeight = Math.max(100, headerHeight - contentTop) + "px"; + var bounds = content.getBoundingClientRect(); + var newMaxHeight = bounds.bottom <= innerHeight ? '' : (innerHeight - bounds.top) + "px"; if (newMaxHeight != content.style.maxHeight) { content.style.maxHeight = newMaxHeight; }