1 define(function(require) {
5 var $ = require('libs/jquery'),
6 genericElement = require('modules/documentCanvas/canvas/genericElement'), // TODO: This should be accessible via plugin infrastructure
7 linkElement = require('./links/linkElement');
10 footnoteHandler: function(clickHandler) {
11 var mydom = $('<span>')
12 .addClass('canvas-widget canvas-widget-footnote-handle')
13 .css('display', 'inline')
16 mydom.click(function(e) {
23 commentAdnotation: function(node) {
25 DOM: $('<div>').addClass('canvas-widget canvas-widget-comment-adnotation'),
26 update: function(node) {
28 metadata = node.getMetadata(),
30 metadata.forEach(function(row) {
31 parts.push(row.getValue());
33 metadata.some(function(row) {
40 this.DOM.text(parts.join(', '));
46 hideButton: function(clickHandler) {
47 var mydom = $('<span>x</span>')
48 .addClass('canvas-widget canvas-widget-hide-button');
49 mydom.click(function(e) {
58 var comment = Object.create(genericElement);
61 genericElement.init.call(this);
62 this.commentAdnotation = widgets.commentAdnotation(this.wlxmlNode);
63 this.addWidget(this.commentAdnotation, 'show');
64 this.commentAdnotation.DOM.show();
67 onMetadataChanged: function(event) {
68 this.commentAdnotation.update(event.meta.node);
70 onMetadataAdded: function(event) {
71 return this.onMetadataChanged(event);
73 onMetadataRemoved: function(event) {
74 return this.onMetadataChanged(event);
78 var footnote = Object.create(genericElement);
81 genericElement.init.call(this);
82 var clickHandler = function() {
85 this.footnoteHandler = widgets.footnoteHandler(clickHandler);
86 this.addWidget(this.footnoteHandler);
88 var closeHandler = function() {
91 this.hideButton = widgets.hideButton(closeHandler);
92 this.addWidget(this.hideButton);
93 this.toggle(false, {silent: true});
95 toggle: function(toggle, options) {
96 options = options || {};
97 this.hideButton.toggle(toggle);
98 this.footnoteHandler.toggle(!toggle);
101 this.displayAsBlock();
103 this.displayInline();
105 this._container().toggle(toggle);
106 if(!options.silent) {
107 this.trigger('elementToggled', toggle, this);
114 {tag: 'aside', klass: 'comment', prototype: null},
115 {tag: 'aside', klass: 'footnote', prototype: footnote},
116 {tag: 'span', klass: 'link', prototype: linkElement}