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'),
9 videoElement = require('./video/videoElement')
13 footnoteHandler: function(clickHandler) {
14 var mydom = $('<span>')
15 .addClass('canvas-widget canvas-widget-footnote-handle')
16 .css('display', 'inline')
19 mydom.click(function(e) {
26 commentAdnotation: function(node) {
28 DOM: $('<div>').addClass('canvas-widget canvas-widget-comment-adnotation'),
29 update: function(node) {
31 metadata = node.getMetadata(),
33 metadata.forEach(function(row) {
34 parts.push(row.getValue());
36 metadata.some(function(row) {
43 this.DOM.text(parts.join(', '));
49 hideButton: function(clickHandler) {
50 var mydom = $('<span>x</span>')
51 .addClass('canvas-widget canvas-widget-hide-button');
52 mydom.click(function(e) {
61 var comment = Object.create(genericElement);
64 genericElement.init.call(this);
65 this.commentAdnotation = widgets.commentAdnotation(this.wlxmlNode);
66 this.addWidget(this.commentAdnotation, 'show');
67 this.commentAdnotation.DOM.show();
70 onMetadataChanged: function(event) {
71 this.commentAdnotation.update(event.meta.node);
73 onMetadataAdded: function(event) {
74 return this.onMetadataChanged(event);
76 onMetadataRemoved: function(event) {
77 return this.onMetadataChanged(event);
81 var footnote = Object.create(genericElement);
84 genericElement.init.call(this);
85 var clickHandler = function() {
88 this.footnoteHandler = widgets.footnoteHandler(clickHandler);
89 this.addWidget(this.footnoteHandler);
91 var closeHandler = function() {
94 this.hideButton = widgets.hideButton(closeHandler);
95 this.addWidget(this.hideButton);
96 this.toggle(false, {silent: true});
98 toggle: function(toggle, options) {
99 options = options || {};
100 this.hideButton.toggle(toggle);
101 this.footnoteHandler.toggle(!toggle);
104 this.displayAsBlock();
106 this.displayInline();
108 this._container().toggle(toggle);
109 if(!options.silent) {
110 this.trigger('elementToggled', toggle, this);
117 {tag: 'aside', klass: 'comment', prototype: null},
118 {tag: 'aside', klass: 'footnote', prototype: footnote},
119 {tag: 'span', klass: 'link', prototype: linkElement},
120 {tag: 'div', klass: 'img', prototype: imgElement},
121 {tag: 'div', klass: 'video', prototype: videoElement}