Emit a divider <tr>
[mkws-moved-to-github.git] / examples / htdocs / mkws-widget-credo.js
1 // ### This works inefficiently by having multiple teams all run the
2 // same search against different sets of targets. A much better
3 // approach would be run a single search, with all these panels
4 // members of the same team, but picking out only the results relevant
5 // to them. That will be more work.
6
7 mkws.registerWidgetType('Credo', function() {
8   var that = this;
9
10   this.team.registerTemplate('CredoImage', '\
11       <div>\
12        <a href="{{md-electronic-url}}" target="_blank">\
13         {{#mkws-first md-thumburl}}\
14           <img src="{{this}}" alt="{{../md-title}}"/>\
15         {{/mkws-first}}\
16         <br/>\
17        </a>\
18        <p>{{md-title}}</p>\
19       </div>\
20 ');
21
22   var s = []
23   s.push('<table>');
24
25   // Main panel: encylopaedia and images on the left, topics on the right
26   s.push('<tr class="front">');
27
28   s.push('<td class="main">');
29   s.push(section('encyclopaedia', 'Topic Page: ### title',
30                  this.subwidget('Reference', { _team: 'ref' })));
31   // The Images widget needs to be in our team so we can set its template
32   s.push(section('image', 'Images',
33                  this.subwidget('GoogleImage', { maxrecs: 4, template: 'CredoImage' })));
34   s.push('</td>');
35
36   s.push('<td class="side">');
37   s.push(section('mindmap', 'Create a Mind Map for ### title',
38                  this.subwidget('Mindmap', { _team: 'main', facet: 'subject' })));
39   s.push(section('topics', 'Related Topics',
40                  this.subwidget('Facet', { _team: 'main', facet: 'subject' })));
41   s.push('</td>');
42
43   s.push('</tr>');
44
45   s.push('<tr><td colspan="2"><hr class="divider"/></td></tr>');
46
47   s.push(sectionRow('entries', 'Credo Entries',
48                     this.subwidget('Records', { _team: 'main' })));
49   s.push(sectionRow('articles', 'Articles',
50                     1 || this.subwidget('Records', { /* ### config */ })));
51   s.push(sectionRow('books', 'Books',
52                     1 || this.subwidget('Records', { /* ### config */ })));
53   s.push(sectionRow('news', 'News',
54                     1 || this.subwidget('Records', { /* ### config */ })));
55   s.push(sectionRow('resources', 'Suggested Resources',
56                     1 || this.subwidget('Records', { /* ### config */ })));
57
58   s.push('</table>');
59
60   this.node.html(s.join(''));
61
62
63   function section(xclass, title, content) {
64     var s = [];
65     s.push('<div class="' + xclass + ' section">');
66     s.push('<div class="title">' + title + '</div>');
67     s.push('<div class="content">' + content + '</div>');
68     s.push('</div>');
69     return s.join('');
70   }
71
72   function sectionRow(xclass, title, content) {
73     var s = [];
74     s.push('<tr>');
75     s.push('<td colspan="2">');
76     s.push(section(xclass, title, content));
77     s.push('</td>');
78     s.push('</tr>');
79     return s.join('');
80   }
81 });
82
83
84 mkws.registerWidgetType('Mindmap', function() {
85   this.node.html("### We do not yet have a Mindmap widget");
86 });