From 6319abb90c8c46ec4223817f53b5cb1f357ada05 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Mon, 5 Aug 2013 09:20:43 +0200 Subject: [PATCH] wip: adding footnodes, first approach --- modules/documentCanvas/canvas/documentElement.js | 7 +++++++ modules/documentCanvas/canvas/wlxmlManagers.js | 12 ++++++++---- modules/documentCanvas/commands.js | 10 ++++++++++ modules/documentToolbar/template.html | 3 +++ 4 files changed, 28 insertions(+), 4 deletions(-) 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 @@ +
+ +
-- 2.20.1