Ignore vim swap files.
[mkws-moved-to-github.git] / src / mkws-widget-main.js
index 07243e7..5106839 100644 (file)
@@ -116,31 +116,29 @@ mkws.registerWidgetType('Records', function() {
   var team = this.team;
 
   this.team.queue("records").subscribe(function(data) {
-    var html = [];
     for (var i = 0; i < data.hits.length; i++) {
       var hit = data.hits[i];
       that.team.queue("record").publish(hit);
-      var divId = team.recordElementId(hit.recid[0]);
-      html.push('<div class="mkwsSummary mkwsTeam_' + team.name() + ' ' + divId + '">', renderSummary(hit), '</div>');
+      hit.detailLinkId = team.recordElementId(hit.recid[0]);
+      hit.detailClick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;"
+      hit.containerClass = "mkwsSummary mkwsTeam_" + team.name();
+      hit.containerClass += " " + hit.detailLinkId;
       // ### At some point, we may be able to move the
       // m_currentRecordId and m_currentRecordData members
       // from the team object into this widget.
       if (hit.recid == team.currentRecordId()) {
-        if (team.currentRecordData())
-          html.push(team.renderDetails(team.currentRecordData()));
+        if (team.currentRecordData()) {
+          hit.renderedDetails = team.renderDetails(team.currentRecordData());
+          console.log(hit.renderedDetails); 
+        } 
       }
     }
-    that.node.html(html.join(''));
-
-    function renderSummary(hit) {
-      var template = team.loadTemplate(that.config.template || "Summary");
-      hit._id = team.recordElementId(hit.recid[0]);
-      hit._onclick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;"
-      return template(hit);
-    }
+    var template = team.loadTemplate(that.config.template || "Records");
+    var targs = $.extend({}, {"hits": data.hits}, that.config.template_vars);
+    that.node.html(template(targs));
   });
 
-  widget.autosearch(that);
+  that.autosearch();
 });
 
 
@@ -216,7 +214,7 @@ mkws.registerWidgetType('Switch', function() {
 <a href="#" onclick="mkws.switchView(\'' + tname + '\', \'records\')">Records</a><span> \
 | \
 </span><a href="#" onclick="mkws.switchView(\'' + tname + '\', \'targets\')">Targets</a>');
-  widget.hideWhenNarrow(this);
+  this.hideWhenNarrow();
 });
 
 
@@ -265,7 +263,7 @@ mkws.registerWidgetType('Results', function() {
   </tr>\
 </table>');
 
-  widget.autosearch(this);
+  this.autosearch();
 });
 
 
@@ -372,7 +370,7 @@ mkws.registerWidgetType('Lang', function() {
   }
 
   this.node.html(data);
-  widget.hideWhenNarrow(this);
+  this.hideWhenNarrow();
 
 
   // set or re-set "lang" URL parameter