boundries → boundaries
[fnpeditor.git] / src / editor / plugins / core / links / linkElement.js
index ceefee1..6db8755 100644 (file)
@@ -9,6 +9,7 @@ var $ = require('libs/jquery'),
     genericElement = require('modules/documentCanvas/canvas/genericElement'),
     Dialog = require('views/dialog/dialog'),
     boxTemplate = require('libs/text!./box.html'),
+    attachments = require('views/attachments/attachments'),
     linkElement = Object.create(genericElement);
 
 
@@ -26,8 +27,11 @@ _.extend(linkElement, {
         this.box.hide();
         this.addWidget(this.box);
     },
-    markAsCurrent: function(toggle) {
-        this.box.toggle(toggle);
+    onStateChange: function(changes) {
+        genericElement.onStateChange.call(this, changes);
+        if(_.isBoolean(changes.active)) {
+            this.box.toggle(changes.active);
+        }
     },
     onNodeAttrChange: function(event) {
         if(event.meta.attr === 'href') {
@@ -49,7 +53,8 @@ _.extend(linkElement, {
                 {label: gettext('Link'), name: 'href', type: 'input', initialValue: el.wlxmlNode.getAttr('href'),
                 prePasteHandler: function(text) {
                                     return this.wlxmlNode.document.getLinkForUrl(text);
-                                }.bind(this)
+                                }.bind(this),
+                                description: '<a href="#-" class="attachment-library">' + gettext('attachment library') + '</a>'
             }
             ]
         });
@@ -71,6 +76,10 @@ _.extend(linkElement, {
             });
         });
         dialog.show();
+        $(".attachment-library", dialog.$el).on('click', function() {
+            attachments.select(function(v) {$("input", dialog.$el).val(v);});
+        });
+
     },
 
     deleteLink: function() {