return $('<span>')
.addClass('canvas-widget canvas-widget-label')
.text(tag + (klass ? ' / ' + klass : ''));
+ },
+
+ footnoteHandler: function(clickHandler) {
+ var mydom = $('<span>')
+ .addClass('canvas-widget canvas-widget-footnote-handle')
+ .css('display', 'inline')
+ .show();
+
+ mydom.click(function() {
+ clickHandler();
+ });
+
+ return mydom;
+ },
+
+ hideButton: function(clickHandler) {
+ var mydom = $('<span>x</span>')
+ .addClass('canvas-widget canvas-widget-hide-button');
+ mydom.click(clickHandler);
+ return mydom;
}
+
};
});
\ No newline at end of file
[document-node-element] {
.canvas-widgets {
display: inline;
+ text-indent: 0;
}
.canvas-widget {
z-index:9999;
white-space: nowrap;
}
+
+
+
+ .canvas-widget-footnote-handle {
+ display: inline;
+ outline: 0px solid transparent;
+ cursor: pointer;
+ counter-increment: footnote;
+ vertical-align: super;
+ color: blue;
+ font-size: .8em;
+
+ &::before, {
+ content: "[" counter(footnote) "]";
+ }
+ }
+
+ .canvas-widget-hide-button {
+ @line_height: 12px;
+ @padding: 2px;
+
+ position: absolute;
+ top: -(@line_height + 2 * @padding);
+ right: 0;
+ line-height: @line_height;
+ padding: @padding;
+ font-weight: bold;
+ color: white;
+ background-image: linear-gradient(to bottom,#ee5f5b,#bd362f);
+ border-radius: 1px;
+ cursor: pointer;
+ }
}
\ No newline at end of file
'use strict';
-var DocumentElementAPI = function(documentElement) {
+var DocumentElementWrapper = function(documentElement) {
this.addWidget = function(widget) {
documentElement.dom().find('.canvas-widgets').append(widget);
this.klass = function() {
return documentElement.getWlxmlClass();
};
+
+ this.toggle = function(toggle) {
+ documentElement._container().toggle(toggle);
+ }
}
var getDisplayStyle = function(tag, klass) {
}
})
+var managers = {
+ _m: {},
+ set: function(tag, klass, manager) {
+ if(!this._m[tag])
+ this._m[tag] = {};
+ this._m[tag][klass] = manager;
+ },
+ get: function(tag,klass) {
+ if(this._m[tag] && this._m[tag][klass])
+ return this._m[tag][klass];
+ return GenericManager;
+ }
+}
+
+var FootnoteManager = function(wlxmlElement) {
+ this.el = wlxmlElement;
+};
+$.extend(FootnoteManager.prototype, {
+ setup: function() {
+ this.el.clearWidgets();
+
+ var clickHandler = function() {
+ this._toggleFootnote(true);
+ }.bind(this);
+ this.footnoteHandler = widgets.footnoteHandler(clickHandler);
+ this.el.addWidget(this.footnoteHandler);
+
+ var closeHandler = function() {
+ this._toggleFootnote(false);
+
+ }.bind(this);
+ this.hideButton = widgets.hideButton(closeHandler);
+ this.el.addWidget(this.hideButton);
+
+ this._toggleFootnote(false);
+ },
+ _toggleFootnote: function(toggle) {
+ this.hideButton.toggle(toggle);
+ this.footnoteHandler.toggle(!toggle);
+
+ this.el.setDisplayStyle(toggle ? 'block' : 'inline');
+ this.el.toggle(toggle);
+ }
+})
+managers.set('aside', 'footnote', FootnoteManager);
+
+
return {
getFor: function(documentElement) {
- var wlxmlElement = new DocumentElementAPI(documentElement);
- return new GenericManager(wlxmlElement);
+ var wlxmlElement = new DocumentElementWrapper(documentElement);
+ return new (managers.get(wlxmlElement.tag(), wlxmlElement.klass()))(wlxmlElement);
+
}
};