From fd6b10b02a536bc8f8ced65ef7d209cee87b786e Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Tue, 18 Dec 2012 11:03:24 -0500 Subject: [PATCH] Hide empty visualizations. --- themes/blueprint/js/pubdate_vis.js | 7 ++++++- .../blueprint/templates/Recommend/PubDateVisAjax.phtml | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/themes/blueprint/js/pubdate_vis.js b/themes/blueprint/js/pubdate_vis.js index 7ec28d252b4..36a61348af3 100644 --- a/themes/blueprint/js/pubdate_vis.js +++ b/themes/blueprint/js/pubdate_vis.js @@ -23,7 +23,12 @@ function loadVis(facetFields, searchParams, baseURL, zooming) { $.getJSON(url, function (data) { if (data.status == 'OK') { $.each(data['data'], function(key, val) { - //console.log(val); + //check if there is data to display, if there isn't hide the box + if (val['data'].length == 0){ + $("#datevis" + key + "xWrapper").hide(); + return; + } + // plot graph var placeholder = $("#datevis" + key + "x"); diff --git a/themes/blueprint/templates/Recommend/PubDateVisAjax.phtml b/themes/blueprint/templates/Recommend/PubDateVisAjax.phtml index 1ded1375862..ea8ece59130 100644 --- a/themes/blueprint/templates/Recommend/PubDateVisAjax.phtml +++ b/themes/blueprint/templates/Recommend/PubDateVisAjax.phtml @@ -9,10 +9,12 @@ <? foreach ($visFacets as $facetField=>$facetRange): ?> <div class="authorbox"> - <strong><?=$this->translate($facetRange['label']) ?></strong> - <? /* space the flot visualisation */ ?> - <div id="datevis<?=$facetField ?>x" style="margin:0 10px;width:auto;height:80px;cursor:crosshair;"></div> - <div id="clearButtonText" style="display: none"><?=$this->translate('Clear') ?></div> + <div id="datevis<?=$this->escapeHtml($facetField)?>xWrapper"> + <strong><?=$this->translate($facetRange['label']) ?></strong> + <? /* space the flot visualisation */ ?> + <div id="datevis<?=$facetField ?>x" style="margin:0 10px;width:auto;height:80px;cursor:crosshair;"></div> + <div id="clearButtonText" style="display: none"><?=$this->translate('Clear') ?></div> + </div> </div> <? endforeach; ?> <? -- GitLab