X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widget-record.js;h=1d77e4018d9a8162cda521d6fce00f85ed3f4142;hb=9760c20d77e528ca91397ac4754db7e4f3be7443;hp=106c8a311f2afc3e8ee6957ee7664e56e45cdef5;hpb=e6cb922902b29c80209e6dce577fb6c09af862c8;p=mkws-moved-to-github.git diff --git a/src/mkws-widget-record.js b/src/mkws-widget-record.js index 106c8a3..1d77e40 100644 --- a/src/mkws-widget-record.js +++ b/src/mkws-widget-record.js @@ -1,24 +1,32 @@ -mkws.registerWidgetType('Record', function() { - mkws.promotionFunction('Records').call(this); +// A widget for one record +mkws.registerWidgetType('record', function() { if (!this.config.maxrecs) this.config.maxrecs = 1; + var that = this; + var team = this.team; + team.queue("records").subscribe(function(data) { + var template = team.loadTemplate(that.config.template || "Record"); + var targs = mkws.$.extend({}, data.hits[0], that.config.template_vars); + that.node.html(template(targs)); + }); + that.autosearch(); }); -mkws.registerWidgetType('Image', function() { - mkws.promotionFunction('Record').call(this); +mkws.registerWidgetType('image', function() { + mkws.promotionFunction('records').call(this); if (!this.config.template) this.config.template = 'Image'; }); -mkws.registerWidgetType('GoogleImage', function() { - mkws.promotionFunction('Image').call(this); +mkws.registerWidgetType('google-image', function() { + mkws.promotionFunction('image').call(this); if (!this.config.target) this.config.target = 'Google_Images'; }); -mkws.registerWidgetType('Lolcat', function() { - mkws.promotionFunction('GoogleImage').call(this); +mkws.registerWidgetType('lolcat', function() { + mkws.promotionFunction('google-image').call(this); if (!this.config.autosearch) this.config.autosearch = 'kitteh'; }); -mkws.registerWidgetType('Coverart', function() { - mkws.promotionFunction('Image').call(this); +mkws.registerWidgetType('cover-art', function() { + mkws.promotionFunction('image').call(this); if (!this.config.target) this.config.target = 'AmazonBooks'; });