X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget-main.js;h=6731b1dd9c5cef1e5aeec0ba03727ccf571e775d;hb=f7781746145de7c7d226a6abbbf8547906e3e7d7;hp=99307753516046a4bbadf8e24b0e5625f8e407d4;hpb=a5db5420d793ca8550f326036e6fa30c95189719;p=mkws-moved-to-github.git diff --git a/src/mkws-widget-main.js b/src/mkws-widget-main.js index 9930775..6731b1d 100644 --- a/src/mkws-widget-main.js +++ b/src/mkws-widget-main.js @@ -1,3 +1,5 @@ +(function($) { // jQuery wrapper + // Functions follow for promoting the regular widget object into // widgets of specific types. These could be moved into their own // source files. @@ -86,6 +88,25 @@ mkws.registerWidgetType('Pager', function() { }); }); +mkws.registerWidgetType('Details', function() { + var that = this; + var recid = that.node.attr("data-mkws-recid"); + if (this.team.gotRecords()) { + that.team.fetchDetails(recid); + } else { + this.team.queue("firstrecords").subscribe(function() { + that.team.fetchDetails(recid); + }); + } + this.team.queue("record").subscribe(function(data) { + console.log(data); + if ($.inArray(recid, data.recid) > -1) { + var template = that.team.loadTemplate(that.config.template || "Record"); + that.node.html(template(data)); + } + }); + that.autosearch(); +}); mkws.registerWidgetType('Records', function() { var that = this; @@ -96,7 +117,7 @@ mkws.registerWidgetType('Records', function() { var hit = data.hits[i]; that.team.queue("record").publish(hit); hit.detailLinkId = team.recordElementId(hit.recid[0]); - hit.detailClick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;" + 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 @@ -347,8 +368,8 @@ mkws.registerWidgetType('Progress', function() { var that = this; this.node.hide(); this.team.queue("stat").subscribe(function(data) { - var template = this.team.loadTemplate(this.config.template || "Progress"); - this.node.html(template({ + var template = that.team.loadTemplate(that.config.template || "Progress"); + that.node.html(template({ done: data.clients - data.activeclients, waiting: data.activeclients })); @@ -367,3 +388,4 @@ mkws.registerWidgetType('MOTDContainer', function() {}); mkws.registerWidgetType('Button', function() {}); +})(mkws.$); // jQuery wrapper