From ec3cce9173429d1fe2f692f5b8540677831b4d2e Mon Sep 17 00:00:00 2001 From: Xaver Maierhofer Date: Sun, 19 Feb 2017 00:15:36 +0100 Subject: [PATCH] [BUGFIX] Hide statistic onclick header --- lib/proportions.js | 36 +++++++++++------------------------ scss/modules/_proportion.scss | 4 ++++ 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/lib/proportions.js b/lib/proportions.js index 32c37b0..d984f03 100644 --- a/lib/proportions.js +++ b/lib/proportions.js @@ -8,21 +8,11 @@ define(['chroma-js', 'virtual-dom', 'filters/genericnode', 'helper'], var statusTable = document.createElement('table'); statusTable.classList.add('proportion'); - - var fwTable = document.createElement('table'); - fwTable.classList.add('proportion'); - - var hwTable = document.createElement('table'); - hwTable.classList.add('proportion'); - - var geoTable = document.createElement('table'); - geoTable.classList.add('proportion'); - - var autoTable = document.createElement('table'); - autoTable.classList.add('proportion'); - - var siteTable = document.createElement('table'); - siteTable.classList.add('proportion'); + var fwTable = statusTable.cloneNode(false); + var hwTable = statusTable.cloneNode(false); + var geoTable = statusTable.cloneNode(false); + var autoTable = statusTable.cloneNode(false); + var siteTable = statusTable.cloneNode(false); function showStatGlobal(o) { return helper.showStat(o); @@ -53,7 +43,6 @@ define(['chroma-js', 'virtual-dom', 'filters/genericnode', 'helper'], function addFilter(filter) { return function () { filterManager.addFilter(filter); - return false; }; } @@ -63,12 +52,9 @@ define(['chroma-js', 'virtual-dom', 'filters/genericnode', 'helper'], table.last = V.h('table'); } - var max = 0; - data.forEach(function (d) { - if (d[1] > max) { - max = d[1]; - } - }); + var max = Math.max.apply(Math, data.map(function (o) { + return o[1]; + })); var items = data.map(function (d) { var v = d[1] / max; @@ -181,11 +167,11 @@ define(['chroma-js', 'virtual-dom', 'filters/genericnode', 'helper'], }; self.renderSingle = function renderSingle(el, heading, table) { - var h2; - h2 = document.createElement('h2'); + var h2 = document.createElement('h2'); + h2.classList.add('proportion-header'); h2.textContent = _.t(heading); h2.onclick = function onclick() { - table.classList.toggle('hidden'); + table.classList.toggle('hide'); }; el.appendChild(h2); el.appendChild(table); diff --git a/scss/modules/_proportion.scss b/scss/modules/_proportion.scss index 11fb59a..a057c49 100644 --- a/scss/modules/_proportion.scss +++ b/scss/modules/_proportion.scss @@ -1,3 +1,7 @@ +.proportion-header { + cursor: pointer; +} + .proportion { th { font-size: .95em;