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()));
57 toggle: function(toggle) {
58 this.el.toggle(toggle);
65 set: function(tag, klass, manager) {
68 this._m[tag][klass] = manager;
70 get: function(tag,klass) {
71 if(this._m[tag] && this._m[tag][klass])
72 return this._m[tag][klass];
73 return GenericManager;
77 var FootnoteManager = function(wlxmlElement) {
78 this.el = wlxmlElement;
80 $.extend(FootnoteManager.prototype, {
82 this.el.clearWidgets();
84 var clickHandler = function() {
87 this.footnoteHandler = widgets.footnoteHandler(clickHandler);
88 this.el.addWidget(this.footnoteHandler);
90 var closeHandler = function() {
94 this.hideButton = widgets.hideButton(closeHandler);
95 this.el.addWidget(this.hideButton);
99 toggle: function(toggle) {
100 this.hideButton.toggle(toggle);
101 this.footnoteHandler.toggle(!toggle);
103 this.el.setDisplayStyle(toggle ? 'block' : 'inline');
104 this.el.toggle(toggle);
107 managers.set('aside', 'footnote', FootnoteManager);
111 getFor: function(documentElement) {
112 var wlxmlElement = new DocumentElementWrapper(documentElement);
113 return new (managers.get(wlxmlElement.tag(), wlxmlElement.klass()))(wlxmlElement);