2 'libs/jquery-1.9.1.min',
3 'modules/documentCanvas/canvas/widgets'
4 ], function($, widgets) {
9 var DocumentElementWrapper = function(documentElement) {
11 this.addWidget = function(widget) {
12 documentElement.dom().find('.canvas-widgets').append(widget);
15 this.clearWidgets = function() {
16 documentElement.dom().find('.canvas-widgets').empty();
19 this.setDisplayStyle = function(displayStyle) {
20 documentElement.dom().css('display', displayStyle);
21 documentElement._container().css('display', displayStyle);
24 this.tag = function() {
25 return documentElement.getWlxmlTag();
28 this.klass = function() {
29 return documentElement.getWlxmlClass();
32 this.toggle = function(toggle) {
33 documentElement._container().toggle(toggle);
37 var getDisplayStyle = function(tag, klass) {
38 if(tag === 'metadata')
45 var GenericManager = function(wlxmlElement) {
46 this.el = wlxmlElement;
49 $.extend(GenericManager.prototype, {
51 this.el.setDisplayStyle(getDisplayStyle(this.el.tag(), this.el.klass()));
53 this.el.clearWidgets();
54 this.el.addWidget(widgets.labelWidget(this.el.tag(), this.el.klass()));
61 set: function(tag, klass, manager) {
64 this._m[tag][klass] = manager;
66 get: function(tag,klass) {
67 if(this._m[tag] && this._m[tag][klass])
68 return this._m[tag][klass];
69 return GenericManager;
73 var FootnoteManager = function(wlxmlElement) {
74 this.el = wlxmlElement;
76 $.extend(FootnoteManager.prototype, {
78 this.el.clearWidgets();
80 var clickHandler = function() {
81 this._toggleFootnote(true);
83 this.footnoteHandler = widgets.footnoteHandler(clickHandler);
84 this.el.addWidget(this.footnoteHandler);
86 var closeHandler = function() {
87 this._toggleFootnote(false);
90 this.hideButton = widgets.hideButton(closeHandler);
91 this.el.addWidget(this.hideButton);
93 this._toggleFootnote(false);
95 _toggleFootnote: function(toggle) {
96 this.hideButton.toggle(toggle);
97 this.footnoteHandler.toggle(!toggle);
99 this.el.setDisplayStyle(toggle ? 'block' : 'inline');
100 this.el.toggle(toggle);
103 managers.set('aside', 'footnote', FootnoteManager);
107 getFor: function(documentElement) {
108 var wlxmlElement = new DocumentElementWrapper(documentElement);
109 return new (managers.get(wlxmlElement.tag(), wlxmlElement.klass()))(wlxmlElement);