Rolling on the Credo JS.
[mkws-moved-to-github.git] / examples / htdocs / mkws-widget-credo.js
1 mkws.registerWidgetType('Credo', function() {
2   var that = this;
3   var s = []
4   s.push('<table>');
5
6   // Main panel: encylopaedia and images on the left, topics on the right
7   s.push('<tr class="front">');
8
9   s.push('<td class="main">');
10   s.push(section('encyclopaedia', 'Topic Page: ### title',
11                  this.subwidget('Reference')));
12   s.push(section('image', 'Images',
13                  this.subwidget('Images', { /* ### config */ })));
14   s.push('</td>');
15
16   s.push('<td class="side">');
17   s.push(section('mindmap', 'Create a Mind Map for ### title',
18                  '### Is there a way to make a mind-map?'));
19   s.push(section('topics', 'Related Topics',
20                  this.subwidget('Facet', { facet: 'subject' })));
21   s.push('</td>');
22
23   s.push('</tr>');
24
25   s.push(sectionRow('entries', 'Credo Entries',
26                     this.subwidget('Records', { /* ### config */ })));
27   s.push(sectionRow('articles', 'Articles',
28                     this.subwidget('Records', { /* ### config */ })));
29   s.push(sectionRow('books', 'Books',
30                     this.subwidget('Records', { /* ### config */ })));
31   s.push(sectionRow('news', 'News',
32                     this.subwidget('Records', { /* ### config */ })));
33   s.push(sectionRow('resources', 'Suggested Resources',
34                     this.subwidget('Records', { /* ### config */ })));
35
36   s.push('</table>');
37
38   this.node.html(s.join(''));
39
40
41   function section(xclass, title, content) {
42     var s = [];
43     s.push('<div class="' + xclass + ' section">');
44     s.push('<div class="title">' + title + '</div>');
45     s.push('<div class="content">' + content + '</div>');
46     s.push('</div>');
47     return s.join('');
48   }
49
50   function sectionRow(xclass, title, content) {
51     var s = [];
52     s.push('<tr>');
53     s.push('<td colspan="2">');
54     s.push(section(xclass, title, content));
55     s.push('</td>');
56     s.push('</tr>');
57     return s.join('');
58   }
59 });