Hardcode the Ding1 theme
[mkdru-moved-to-drupal.org.git] / mkdru.theme.js
index 6f77dda..4b0638f 100644 (file)
@@ -1,23 +1,43 @@
 Drupal.theme.prototype.mkdruResult = function(hit, num, detailLink) {
+  var link = choose_url(hit);
+  if (!link) link = choose_url(hit['location'][0]);
   var html = "";
-  html += '<li class="mkdru-result" id="rec_' + hit.recid + '" >'
-          + '<span>' + num + '. </span>'
-          + '<a href="' + detailLink + '" class="mkdru-result-title">'
-          + hit["md-title"] + '</a> ';
-  if (hit["md-title-remainder"] !== undefined) {
-    html += '<span class="mkdru-result-title-remainder">' 
-            + hit["md-title-remainder"] + ' </span>';
+  html += '<li class="search-result" id="rec_' + hit.recid + '" >'
+    + '<h3 class="title">';
+  if (link) html += '<a href="'+link+'" target="_blank" >';
+  html += hit["md-title"];
+  if (link) html += '</a>';
+  html += '</h3>';
+  html += '<div class="search-snippet-info">'
+     + '<p class="search-snippet"></p>'
+     + '<div class="ting-object clearfix">'
+      + '<div class="ting-overview clearfix">'
+        + '<div class="left-column left">'
+          + '<div class="picture"></div>'
+        + '</div>'
+        + '<div class="right-column left">';
+  if (hit["md-author"]) {
+    html += '<div class="creator"><span class="byline">By </span>'
+      + '<a class="author" href="/search/meta/'+hit['md-author']+'">'
+      + hit['md-author']+'</a>';
+    if (hit['md-date']) {
+      html += '<span class="date"> ('+hit['md-date']+')</span>';
+    }
+    html += '</div><p></p>';
   }
-  if (hit["md-title-responsibility"] !== undefined) {
-    html += '<span class="mkdru-result-author"><i>'
-            + hit["md-title-responsibility"]
-            + '</i></span>';
+  html += "</div>";
+  if (hit["md-description"]) {
+    // limit description to 400 characters
+    html += hit["md-description"][0].substr(0, 400);
   }
+  html += '</div>'
+  html += '</div>'
+  html += '</div>'
   html += '</li>';
   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 +68,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;
 };
 
@@ -100,10 +120,65 @@ Drupal.theme.prototype.mkdruPager = function (pages, start, current, total, prev
   return html;
 };
 
-Drupal.theme.prototype.mkdruTerm = function (term, freq, linkClass, id) {
-  var html = '<a href="#"';
-  if (id)
-    html += ' target_id="' + id + '"';
-  html += ' class="' + linkClass + '">' + term + '</a><span> (' + freq + ')</span><br/>';
+Drupal.theme.prototype.mkdruCounts = function(first, last, available, total) {
+  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) {
+  return Drupal.t('Waiting on ') + activeClients + Drupal.t(' out of ')
+         + clients + Drupal.t(' targets');
+};
+
+Drupal.theme.prototype.mkdruFacet = function (terms, facet, max, selections) {
+  var html = "";
+  for (var i = 0; i < terms.length && i < max; i++ ) {
+    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/>';
+  }
+  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;
-};
\ No newline at end of file
+};
+
+Drupal.theme.prototype.mkdruFacetContainer = function (facetsCfg) {
+    var fs = [];
+  for (var fname in facetsCfg) {
+    facetsCfg[fname].originalKey = fname;
+    fs.push(facetsCfg[fname]);
+  }
+  fs.sort(function (a,b) { return a.orderWeight - b.orderWeight });
+  var html = '<div class="content"><table class="mkdru-facets-table"><tr>';
+  for (var i=0; i<fs.length; i++) {
+    var f = fs[i];
+    html += '<td><fieldset class="form-wrapper">'
+    html += '<legend><span class="fieldset-legend">'+f.displayName
+      +'</span></legend>';
+    html += '<div class="fieldset-wrapper">';
+    html += '<div class="mkdru-facet-'+f.originalKey+'"/>';
+    html += '</div>';
+    html += '</fieldset></td>'
+  }
+  html += '</tr></table></div>';
+  return html;
+};