[facets] mark titles of active facets with red dot (closes #1624857)
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Thu, 14 Apr 2011 14:41:40 +0200
changeset 7281 daee8aec3b9b
parent 7278 1144a2d90314
child 7282 f2dbac46031e
[facets] mark titles of active facets with red dot (closes #1624857)
web/data/cubicweb.facets.css
web/data/cubicweb.facets.js
--- a/web/data/cubicweb.facets.css	Fri Apr 29 09:08:30 2011 +0200
+++ b/web/data/cubicweb.facets.css	Thu Apr 14 14:41:40 2011 +0200
@@ -117,3 +117,7 @@
   font-weight:    bold;
   text-align:     center;
 }
+
+div.facetTitleSelected {
+  background: url("required.png") no-repeat right top;
+}
--- a/web/data/cubicweb.facets.js	Fri Apr 29 09:08:30 2011 +0200
+++ b/web/data/cubicweb.facets.js	Thu Apr 14 14:41:40 2011 +0200
@@ -238,6 +238,18 @@
     });
 }
 
+// change css class of facets that have a value selected
+function updateFacetTitles() {
+    $('.facet').each(function() {
+        var $divTitle = $(this).find('.facetTitle');
+       var facetSelected = $(this).find('.facetValueSelected');
+       if (facetSelected.length) {
+           $divTitle.addClass('facetTitleSelected');
+       } else {
+           $divTitle.removeClass('facetTitleSelected');
+       }
+    });
+}
 
 // we need to differenciate cases where initFacetBoxEvents is called with one
 // argument or without any argument. If we use `initFacetBoxEvents` as the
@@ -245,4 +257,5 @@
 // his, so we use this small anonymous function instead.
 jQuery(document).ready(function() {
     initFacetBoxEvents();
+    jQuery(cw).bind('facets-content-loading', updateFacetTitles);
 });