mkdru.removeLimits() no longer leaves dangling limit_subject
[mkdru-moved-to-drupal.org.git] / mkdru.theme.js
index 7d92e61..1871750 100644 (file)
@@ -17,7 +17,7 @@ Drupal.theme.prototype.mkdruResult = function(hit, num, detailLink) {
   return html;
 };
 
-Drupal.theme.prototype.mkdruDetail = function(data) {
+Drupal.theme.prototype.mkdruDetail = function(data, linkBack) {
   var html = '<table id="det_' + data.recid +'">';
   if (data["md-title"] != undefined) {
     html += '<tr><th>' + Drupal.t("Title") + '</th><td><strong>:</strong> '
@@ -48,7 +48,7 @@ Drupal.theme.prototype.mkdruDetail = function(data) {
             + data["location"][0]["@name"] + " (" + data["location"][0]["@id"] + ")"
             + '</td></tr>';
   html += '</table></div>';
-  html += '<a class="mkdru-detail-back">Return to result list...</a>';
+  html += '<a href="' + linkBack + '">Return to result list...</a>';
   return html;
 };
 
@@ -110,32 +110,30 @@ Drupal.theme.prototype.mkdruStatus = function(activeClients, clients) {
          + clients + Drupal.t(' targets');
 };
 
-Drupal.theme.prototype.mkdruFacet = function (terms, facet, max) {
+Drupal.theme.prototype.mkdruFacet = function (terms, facet, max, selections) {
   var html = "";
   for (var i = 0; i < terms.length && i < max; i++ ) {
-    html += Drupal.theme('mkdruFacetTerm', terms[i], facet);
+    var term = terms[i];
+    html += '<a href="'+term.hashQuery+'"';
+    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.mkdruFacetTerm = function (term, facet) {
-  var html = '<a href="';
-  switch (facet) {
-    case 'source':
-      html += mkdru.hashAddDelOne('limit_' + facet, term.id, 'page');
-      break;
-    case 'subject':
-    case 'author':
-      html += mkdru.hashAddDelOne('limit_' + facet, term.name, 'page');
-      break;
+  //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.length; i++) {
+      if (sel[i]) {
+        html += '<a class="cross" href="'+mkdru.removeLimit(facet, sel[i])
+          + '"><strong>'+sel[i]+'</strong></a><span> (0)</span><br/>';
+      }
+    } 
   }
-  html += '">' + term.name + '</a><span> (' + term.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>';
-  }
-};
\ No newline at end of file
+Drupal.theme.prototype.mkdruFacetContainer = function (facets, facetCfg) {
+  return "";
+};