Minor cleanup.
[mkdru-moved-to-drupal.org.git] / mkdru.theme.js
index 8051e40..229c482 100644 (file)
@@ -101,8 +101,11 @@ Drupal.theme.prototype.mkdruPager = function (pages, start, current, total, prev
 };
 
 Drupal.theme.prototype.mkdruCounts = function(first, last, available, total) {
-  return first + Drupal.t(' to ') + last + Drupal.t(' of ') + available
+  if (last > 0)
+    return first + Drupal.t(' to ') + last + Drupal.t(' of ') + available
          + Drupal.t(' available (') + total + Drupal.t(' found)');
+  else
+    return Drupal.t('No results');
 };
 
 Drupal.theme.prototype.mkdruStatus = function(activeClients, clients) {
@@ -110,27 +113,34 @@ Drupal.theme.prototype.mkdruStatus = function(activeClients, clients) {
          + clients + Drupal.t(' targets');
 };
 
-Drupal.theme.prototype.mkdruFacet = function (terms, facet, max) {
-  debugger;
+Drupal.theme.prototype.mkdruFacet = function (terms, facet, max, selections) {
   var html = "";
   for (var i = 0; i < terms.length && i < max; i++ ) {
-    html += '<a href="';
-    if (facet == 'source')
-      html += mkdru.addLimit(facet, terms[i].id);
-    else 
-      html += mkdru.addLimit(facet, terms[i].name);
-    html += '">' + terms[i].name + '</a><span> (' + terms[i].freq + ')</span><br/>';
+    var term = terms[i];
+    html += '<a href="'+term.toggleLink+'"';
+    if (term.selected) html += ' class="cross"><strong';
+    html += '>'+terms[i].name;
+    if (term.selected) html += "</strong>";
+    html += '</a><span> (' + terms[i].freq
+        + ')</span><br/>';
   }
-  return html;
-};
-
-Drupal.theme.prototype.mkdruFacetLimit = function (term, link) {
-  if (term) {
-    return '<p>' + Drupal.t('Only displaying ') + term.name + '</p>'
-      + '<p><a href="' + link + '">' + Drupal.t('Show all...') + '</a></p>';
+  if (terms.length == 0 && selections && selections.length) {
+    for (var i=0; i<selections.length; i++) {
+      if (selections[i]) {
+        // since we have no target name (only id) go for the basename
+        // FIXME get the proper target name
+        var name = facet == "source" ? selections[i].replace(/.*[\/\\]/, "")
+          .replace(/\?.*/, '')
+          : selections[i];
+        html += '<a class="cross" href="'
+          + mkdru.removeLimit(facet, selections[i])
+          + '"><strong>'+name+'</strong></a><span> (0)</span><br/>';
+      }
+    } 
   }
+  return html;
 };
 
-Drupal.theme.prototype.mkdruFacetContainer = function (facets, facetCfg) {
+Drupal.theme.prototype.mkdruFacetContainer = function (facetsCfg) {
   return "";
 };