1 define(function(require) {
4 var $ = require('libs/jquery'),
5 genericElement = require('modules/documentCanvas/canvas/genericElement'); // TODO: This should be accessible via plugin infrastructure
9 footnoteHandler: function(clickHandler) {
10 var mydom = $('<span>')
11 .addClass('canvas-widget canvas-widget-footnote-handle')
12 .css('display', 'inline')
15 mydom.click(function(e) {
22 commentAdnotation: function(node) {
24 DOM: $('<div>').addClass('canvas-widget canvas-widget-comment-adnotation'),
25 update: function(node) {
27 metadata = node.getMetadata(),
29 metadata.forEach(function(row) {
30 parts.push(row.getValue());
32 metadata.some(function(row) {
39 this.DOM.text(parts.join(', '));
45 hideButton: function(clickHandler) {
46 var mydom = $('<span>x</span>')
47 .addClass('canvas-widget canvas-widget-hide-button');
48 mydom.click(function(e) {
57 var comment = Object.create(genericElement);
60 genericElement.init.call(this);
61 this.commentAdnotation = widgets.commentAdnotation(this.wlxmlNode);
62 this.addWidget(this.commentAdnotation, 'show');
63 this.commentAdnotation.DOM.show();
66 onMetadataChanged: function(event) {
67 this.commentAdnotation.update(event.meta.node);
69 onMetadataAdded: function(event) {
70 return this.onMetadataChanged(event);
72 onMetadataRemoved: function(event) {
73 return this.onMetadataChanged(event);
77 var footnote = Object.create(genericElement);
80 genericElement.init.call(this);
81 var clickHandler = function() {
84 this.footnoteHandler = widgets.footnoteHandler(clickHandler);
85 this.addWidget(this.footnoteHandler);
87 var closeHandler = function() {
90 this.hideButton = widgets.hideButton(closeHandler);
91 this.addWidget(this.hideButton);
92 this.toggle(false, {silent: true});
94 toggle: function(toggle, options) {
95 options = options || {};
96 this.hideButton.toggle(toggle);
97 this.footnoteHandler.toggle(!toggle);
100 this.displayAsBlock();
102 this.displayInline();
104 this._container().toggle(toggle);
105 if(!options.silent) {
106 this.trigger('elementToggled', toggle, this);
113 {tag: 'aside', klass: 'comment', prototype: comment},
114 {tag: 'aside', klass: 'footnote', prototype: footnote}