From: Jakub Skoczen Date: Thu, 3 Mar 2011 01:22:33 +0000 (+0100) Subject: Draw selected facets also when no results X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=f1795ec17ae3999b5e652bdabb4016345533b35b;p=mkdru-moved-to-drupal.org.git Draw selected facets also when no results this alows to return from "no hits" situation --- diff --git a/mkdru.client.js b/mkdru.client.js index f931c3e..ce5637e 100644 --- a/mkdru.client.js +++ b/mkdru.client.js @@ -146,7 +146,7 @@ mkdru.pz2Term = function (data) { // map all facets against selected, for simple rendering var hash = $.deparam.fragment(); for (var key in hash) { - if (key.indexOf('limit') == 0 && hash[key].indexOf(';')) + if (key.indexOf('limit') == 0) //always wrap in array hash[key.substr(6)] = hash[key].split(';'); delete hash[key]; } @@ -164,7 +164,7 @@ mkdru.pz2Term = function (data) { } } $('.mkdru-facet-' + facet).html( - Drupal.theme('mkdruFacet', terms, facet, mkdru.facets[facet].max)); + Drupal.theme('mkdruFacet', terms, facet, mkdru.facets[facet].max, hash)); } }; diff --git a/mkdru.theme.js b/mkdru.theme.js index bcf9de9..09226c1 100644 --- a/mkdru.theme.js +++ b/mkdru.theme.js @@ -120,7 +120,16 @@ Drupal.theme.prototype.mkdruFacet = function (terms, facet, max) { if (term.selected) html += ""; html += ' (' + terms[i].freq + ')
'; - + } + //TODO, meed to look up target name from ID + var sel = selections[facet]; + if (terms.length == 0 && sel && sel.length) { + for (var i=0; i'+sel[i]+' (0)
'; + } + } } return html; };