1 define(function(require) {
4 var $ = require('libs/jquery');
8 footnoteHandler: function(clickHandler) {
9 var mydom = $('<span>')
10 .addClass('canvas-widget canvas-widget-footnote-handle')
11 .css('display', 'inline')
14 mydom.click(function(e) {
21 commentAdnotation: function(node) {
23 DOM: $('<div>').addClass('canvas-widget canvas-widget-comment-adnotation'),
24 update: function(node) {
26 metadata = node.getMetadata(),
28 metadata.forEach(function(row) {
29 parts.push(row.getValue());
31 metadata.some(function(row) {
38 this.DOM.text(parts.join(', '));
44 hideButton: function(clickHandler) {
45 var mydom = $('<span>x</span>')
46 .addClass('canvas-widget canvas-widget-hide-button');
47 mydom.click(function(e) {
58 this.super.init.call(this);
59 this.commentAdnotation = widgets.commentAdnotation(this.wlxmlNode);
60 this.addWidget(this.commentAdnotation, 'show');
61 this.commentAdnotation.DOM.show();
64 onMetadataChanged: function(event) {
65 this.commentAdnotation.update(event.meta.node);
67 onMetadataAdded: function(event) {
68 return this.onMetadataChanged(event);
70 onMetadataRemoved: function(event) {
71 return this.onMetadataChanged(event);
77 this.super.init.call(this);
78 var clickHandler = function() {
81 this.footnoteHandler = widgets.footnoteHandler(clickHandler);
82 this.addWidget(this.footnoteHandler);
84 var closeHandler = function() {
87 this.hideButton = widgets.hideButton(closeHandler);
88 this.addWidget(this.hideButton);
89 this.toggle(false, {silent: true});
91 toggle: function(toggle, options) {
92 options = options || {};
93 this.hideButton.toggle(toggle);
94 this.footnoteHandler.toggle(!toggle);
97 this.displayAsBlock();
101 this._container().toggle(toggle);
102 if(!options.silent) {
103 this.trigger('elementToggled', toggle, this);
110 {tag: 'aside', klass: 'comment', prototype: comment, extending: {tag: 'div'}},
111 {tag: 'aside', klass: 'footnote', prototype: footnote, extending: {tag: 'aside'}}