From: Aleksander Ɓukasz Date: Mon, 5 Aug 2013 07:20:43 +0000 (+0200) Subject: wip: adding footnodes, first approach X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/6319abb90c8c46ec4223817f53b5cb1f357ada05 wip: adding footnodes, first approach --- diff --git a/modules/documentCanvas/canvas/documentElement.js b/modules/documentCanvas/canvas/documentElement.js index 0cf2e2c..e1d3203 100644 --- a/modules/documentCanvas/canvas/documentElement.js +++ b/modules/documentCanvas/canvas/documentElement.js @@ -362,6 +362,13 @@ $.extend(DocumentNodeElement.prototype, { toggleHighlight: function(toogle) { this._container().toggleClass('highlighted-element'); + }, + + toggle: function(toggle) { + var mng = this.data('_wlxmlManager'); + if(mng) { + mng.toggle(toggle); + } } }); diff --git a/modules/documentCanvas/canvas/wlxmlManagers.js b/modules/documentCanvas/canvas/wlxmlManagers.js index 75d8c67..0a48fdc 100644 --- a/modules/documentCanvas/canvas/wlxmlManagers.js +++ b/modules/documentCanvas/canvas/wlxmlManagers.js @@ -53,7 +53,11 @@ $.extend(GenericManager.prototype, { this.el.clearWidgets(); this.el.addWidget(widgets.labelWidget(this.el.tag(), this.el.klass())); + }, + toggle: function(toggle) { + this.el.toggle(toggle); } + }) var managers = { @@ -78,21 +82,21 @@ $.extend(FootnoteManager.prototype, { this.el.clearWidgets(); var clickHandler = function() { - this._toggleFootnote(true); + this.toggle(true); }.bind(this); this.footnoteHandler = widgets.footnoteHandler(clickHandler); this.el.addWidget(this.footnoteHandler); var closeHandler = function() { - this._toggleFootnote(false); + this.toggle(false); }.bind(this); this.hideButton = widgets.hideButton(closeHandler); this.el.addWidget(this.hideButton); - this._toggleFootnote(false); + this.toggle(false); }, - _toggleFootnote: function(toggle) { + toggle: function(toggle) { this.hideButton.toggle(toggle); this.footnoteHandler.toggle(!toggle); diff --git a/modules/documentCanvas/commands.js b/modules/documentCanvas/commands.js index 0e48de1..b08348e 100644 --- a/modules/documentCanvas/commands.js +++ b/modules/documentCanvas/commands.js @@ -99,6 +99,16 @@ commands.register('newNodeRequested', function(canvas, params) { } }); +commands.register('footnote', function(canvas, params) { + var position = canvas.getCursor().getPosition(); + + var asideElement = position.element.divide({tag: 'aside', klass: 'footnote', offset: position.offset}); + + asideElement.append({text: ''}); + asideElement.toggle(true); + canvas.setCurrentElement(asideElement); +}); + return { run: function(name, params, canvas) { diff --git a/modules/documentToolbar/template.html b/modules/documentToolbar/template.html index 45e6351..e521f25 100644 --- a/modules/documentToolbar/template.html +++ b/modules/documentToolbar/template.html @@ -26,6 +26,9 @@ +
+ +