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'),
8 imgElement = require('./img/imgElement')
12 footnoteHandler: function(clickHandler) {
13 var mydom = $('<span>')
14 .addClass('canvas-widget canvas-widget-footnote-handle')
15 .css('display', 'inline')
18 mydom.click(function(e) {
25 commentAdnotation: function(node) {
27 DOM: $('<div>').addClass('canvas-widget canvas-widget-comment-adnotation'),
28 update: function(node) {
30 metadata = node.getMetadata(),
32 metadata.forEach(function(row) {
33 parts.push(row.getValue());
35 metadata.some(function(row) {
42 this.DOM.text(parts.join(', '));
48 hideButton: function(clickHandler) {
49 var mydom = $('<span>x</span>')
50 .addClass('canvas-widget canvas-widget-hide-button');
51 mydom.click(function(e) {
60 var comment = Object.create(genericElement);
63 genericElement.init.call(this);
64 this.commentAdnotation = widgets.commentAdnotation(this.wlxmlNode);
65 this.addWidget(this.commentAdnotation, 'show');
66 this.commentAdnotation.DOM.show();
69 onMetadataChanged: function(event) {
70 this.commentAdnotation.update(event.meta.node);
72 onMetadataAdded: function(event) {
73 return this.onMetadataChanged(event);
75 onMetadataRemoved: function(event) {
76 return this.onMetadataChanged(event);
80 var footnote = Object.create(genericElement);
83 genericElement.init.call(this);
84 var clickHandler = function() {
87 this.footnoteHandler = widgets.footnoteHandler(clickHandler);
88 this.addWidget(this.footnoteHandler);
90 var closeHandler = function() {
93 this.hideButton = widgets.hideButton(closeHandler);
94 this.addWidget(this.hideButton);
95 this.toggle(false, {silent: true});
97 toggle: function(toggle, options) {
98 options = options || {};
99 this.hideButton.toggle(toggle);
100 this.footnoteHandler.toggle(!toggle);
103 this.displayAsBlock();
105 this.displayInline();
107 this._container().toggle(toggle);
108 if(!options.silent) {
109 this.trigger('elementToggled', toggle, this);
116 {tag: 'aside', klass: 'comment', prototype: null},
117 {tag: 'aside', klass: 'footnote', prototype: footnote},
118 {tag: 'span', klass: 'link', prototype: linkElement},
119 {tag: 'div', klass: 'img', prototype: imgElement}