RU widget: use own template; be independent of records widget
[mkws-moved-to-github.git] / examples / htdocs / mkws-widget-ru.js
1 var mkws_config = {service_proxy_auth: "http://mkws.indexdata.com/service-proxy/?command=auth&action=login&username=paratext&password=paratext_mkc"};
2
3 mkws.registerWidgetType('ReferenceUniverse', function() {
4   if (!this.config.perpage) this.config.perpage = 5;
5   if (!this.config.sort) this.config.sort = "position";
6   this.team.registerTemplate('ReferenceUniverse', '\
7 <h2>Results from Reference Universe</h2>\
8 <ul>\
9 {{#each hits}}\
10   <li>\
11     {{#mkws-first md-electronic-url}}\
12     <a href="{{this}}">\
13     {{/mkws-first}}\
14       {{md-title}}\
15     </a>\
16   {{#if md-title-remainder}}\
17     <span>{{md-title-remainder}}</span>\
18   {{/if}}\
19   {{#if md-title-responsibility}}\
20     <span><i>{{md-title-responsibility}}</i></span>\
21   {{/if}}\
22   </li>\
23 {{/each}}\
24 </ul>\
25 ');
26
27   var that = this;
28   var template = that.team.loadTemplate(that.config.template || "ReferenceUniverse");
29   this.team.queue("records").subscribe(function(data) {
30     that.node.html(template(data));
31   }); 
32   widget.autosearch(that);
33 });