editor: Setting descriptions for transactions performed in actions
[fnpeditor.git] / src / editor / modules / documentCanvas / canvas / widgets.js
1 define([
2 'libs/jquery',
3 'utils/wlxml'
4 ], function($, wlxmlUtils) {
5     
6 'use strict';
7
8 return {
9     labelWidget: function(tag, klass) {
10         return $('<span>')
11             .addClass('canvas-widget canvas-widget-label')
12             .text(wlxmlUtils.getTagLabel(tag) + (klass ? ' / ' + wlxmlUtils.getClassLabel(klass) : ''));
13     },
14
15     footnoteHandler: function(clickHandler) {
16         var mydom = $('<span>')
17             .addClass('canvas-widget canvas-widget-footnote-handle')
18             .css('display', 'inline')
19             .show();
20
21         mydom.click(function(e) {
22             e.stopPropagation();
23             clickHandler();
24         });
25
26         return mydom;
27     },
28
29     hideButton: function(clickHandler) {
30         var mydom = $('<span>x</span>')
31             .addClass('canvas-widget canvas-widget-hide-button');
32         mydom.click(function(e) {
33             e.stopPropagation();
34             clickHandler();
35         });
36         return mydom;
37     },
38
39     commentAdnotation: function(node) {
40         var widget = {
41             DOM: $('<div>').addClass('canvas-widget canvas-widget-comment-adnotation'),
42             update: function(node) {
43                 var parts = [],
44                     metadata = node.getMetadata(),
45                     dt;
46                 metadata.forEach(function(row) {
47                     parts.push(row.getValue());
48                 }, 'creator');
49                 metadata.some(function(row) {
50                     dt = row.getValue();
51                     return true; // break
52                 }, 'date');
53                 if(dt) {
54                     parts.push(dt);
55                 }
56                 this.DOM.text(parts.join(', '));
57             }
58         };
59         widget.update(node);
60         return widget;
61     }
62
63 };
64
65 });