New file, mkws-widget-reference.js
authorMike Taylor <mike@indexdata.com>
Fri, 25 Apr 2014 16:23:55 +0000 (17:23 +0100)
committerMike Taylor <mike@indexdata.com>
Fri, 25 Apr 2014 16:23:55 +0000 (17:23 +0100)
First widget to be defined by application code!

examples/htdocs/mkws-widget-reference.js [new file with mode: 0644]

diff --git a/examples/htdocs/mkws-widget-reference.js b/examples/htdocs/mkws-widget-reference.js
new file mode 100644 (file)
index 0000000..71f91ea
--- /dev/null
@@ -0,0 +1,26 @@
+mkws.registerWidgetType('Reference', function() {
+    mkws.promotionFunction('Record').call(this);
+    if (!this.config.target) this.config.target = 'wikimedia_wikipedia_single_result';
+    if (!this.config.template) this.config.template = 'Reference';
+
+    this.team.registerTemplate('Reference', '\
+<a href="{{md-electronic-url}}">\
+  <h1>{{md-title}}</h1>\
+</a>\
+{{#if md-title-remainder}}\
+  <b>{{md-title-remainder}}</b>\
+{{/if}}\
+{{#if md-title-responsibility}}\
+  <i>{{md-title-responsibility}}</i>\
+{{/if}}\
+  <p>\
+    <img style="float:right; margin: 0 0 1em 3em" src="{{md-thumburl}}" alt="{{md-title}}">\
+    {{md-description}}\
+  </p>\
+');
+
+    var that = this;
+    this.team.queue("record").subscribe(function(data) {
+        that.log("got data " + $.toJSON(data));
+    });
+});