wip: adding footnodes, first approach
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 5 Aug 2013 07:20:43 +0000 (09:20 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 5 Aug 2013 10:20:07 +0000 (12:20 +0200)
modules/documentCanvas/canvas/documentElement.js
modules/documentCanvas/canvas/wlxmlManagers.js
modules/documentCanvas/commands.js
modules/documentToolbar/template.html

index 0cf2e2c..e1d3203 100644 (file)
@@ -362,6 +362,13 @@ $.extend(DocumentNodeElement.prototype, {
 
     toggleHighlight: function(toogle) {
         this._container().toggleClass('highlighted-element');
 
     toggleHighlight: function(toogle) {
         this._container().toggleClass('highlighted-element');
+    },
+
+    toggle: function(toggle) {
+        var mng = this.data('_wlxmlManager');
+        if(mng) {
+            mng.toggle(toggle);
+        }
     }
 });
 
     }
 });
 
index 75d8c67..0a48fdc 100644 (file)
@@ -53,7 +53,11 @@ $.extend(GenericManager.prototype, {
         this.el.clearWidgets();
         this.el.addWidget(widgets.labelWidget(this.el.tag(), this.el.klass()));
 
         this.el.clearWidgets();
         this.el.addWidget(widgets.labelWidget(this.el.tag(), this.el.klass()));
 
+    },
+    toggle: function(toggle) {
+        this.el.toggle(toggle);
     }
     }
+
 })
 
 var managers = {
 })
 
 var managers = {
@@ -78,21 +82,21 @@ $.extend(FootnoteManager.prototype, {
         this.el.clearWidgets();
 
         var clickHandler = function() {
         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() {
         }.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);
 
 
         }.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);
         
         this.hideButton.toggle(toggle);
         this.footnoteHandler.toggle(!toggle);
         
index 0e48de1..b08348e 100644 (file)
@@ -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) {
 
 return {
     run: function(name, params, canvas) {
index 45e6351..e521f25 100644 (file)
@@ -26,6 +26,9 @@
         <button data-name="list" data-btn-type="toggle" data-meta="bullets" class="btn btn-mini"><i class="icon-list"></i></button>
         <button data-name="createList" data-btn-type="cmd" data-meta="enum" class="btn btn-mini"><i class="icon-th-list"></i></button>
     </div>
         <button data-name="list" data-btn-type="toggle" data-meta="bullets" class="btn btn-mini"><i class="icon-list"></i></button>
         <button data-name="createList" data-btn-type="cmd" data-meta="enum" class="btn btn-mini"><i class="icon-th-list"></i></button>
     </div>
+    <div class="rng-module-documentToolbar-toolbarGroup">
+        <button data-name="footnote" data-btn-type="cmd" class="btn btn-mini"><i class="icon-comment"></i></button>
+    </div>
     <div class="rng-module-documentToolbar-toolbarGroup">
         <button data-name="grid" data-btn-type="toggle" class="btn btn-mini"><i class="icon-th-large"></i></button>
     </div>
     <div class="rng-module-documentToolbar-toolbarGroup">
         <button data-name="grid" data-btn-type="toggle" class="btn btn-mini"><i class="icon-th-large"></i></button>
     </div>