[kupu-checkins] r44687 - kupu/trunk/kupu/common

duncan at codespeak.net duncan at codespeak.net
Tue Jul 3 10:17:56 CEST 2007


Author: duncan
Date: Tue Jul  3 10:17:55 2007
New Revision: 44687

Modified:
   kupu/trunk/kupu/common/kupubasetools.js
   kupu/trunk/kupu/common/kupudrawers.js
Log:
Plone ticket #5622
Add a class (even if empty) to internal LinkDrawer
Now adds class="internal-link" to links created/edited by the internal link drawer,
and class="external-link" to links created/edited by the external link drawer.

Modified: kupu/trunk/kupu/common/kupubasetools.js
==============================================================================
--- kupu/trunk/kupu/common/kupubasetools.js	(original)
+++ kupu/trunk/kupu/common/kupubasetools.js	Tue Jul  3 10:17:55 2007
@@ -1039,7 +1039,7 @@
         linkWindow.focus();
     };
 
-    this.updateLink = function (linkel, url, type, name, target, title) {
+    this.updateLink = function (linkel, url, type, name, target, title, className) {
         if (type && type == 'anchor') {
             linkel.removeAttribute('href');
             linkel.setAttribute('name', name);
@@ -1060,17 +1060,22 @@
             else {
                 linkel.removeAttribute('target');
             };
+            if (className===undefined) {
+                linkel.removeAttribute('className');
+            } else {
+                linkel.className = className;
+            }
             linkel.style.color = this.linkcolor;
         };
     };
 
-    this.formatSelectedLink = function(url, type, name, target, title) {
+    this.formatSelectedLink = function(url, type, name, target, title, className) {
         var currnode = this.editor.getSelectedNode();
 
         // selection inside link
         var linkel = this.editor.getNearestParentOfType(currnode, 'A');
         if (linkel) {
-            this.updateLink(linkel, url, type, name, target, title);
+            this.updateLink(linkel, url, type, name, target, title, className);
             return true;
         }
 
@@ -1083,7 +1088,7 @@
         for (var i = 0; i < linkelements.length; i++) {
             linkel = linkelements[i];
             if (selection.containsNode(linkel)) {
-                this.updateLink(linkel, url, type, name, target, title);
+                this.updateLink(linkel, url, type, name, target, title, className);
                 containsLink = true;
             }
         };
@@ -1102,24 +1107,24 @@
     //
     // the order of the arguments is a bit odd here because of backward
     // compatibility
-    this.createLink = function(url, type, name, target, title) {
+    this.createLink = function(url, type, name, target, title, className) {
         url = url.strip();
         if (!url) {
             this.deleteLink();
             return;
         };
-        if (!this.formatSelectedLink(url, type, name, target, title)) {
+        if (!this.formatSelectedLink(url, type, name, target, title, className)) {
             // No links inside or outside.
             this.editor.execCommand("CreateLink", url);
-            if (!this.formatSelectedLink(url, type, name, target, title)) {
+            if (!this.formatSelectedLink(url, type, name, target, title, className)) {
                 // Insert link with no text selected, insert the title
                 // or URI instead.
                 var doc = this.editor.getInnerDocument();
                 var linkel = doc.createElement("a");
                 linkel.setAttribute('href', url);
-                linkel.setAttribute('class', 'generated');
+                linkel.setAttribute('class', className || 'generated');
                 this.editor.getSelection().replaceWithNode(linkel, true);
-                this.updateLink(linkel, url, type, name, target, title);
+                this.updateLink(linkel, url, type, name, target, title, className);
             };
         }
     };

Modified: kupu/trunk/kupu/common/kupudrawers.js
==============================================================================
--- kupu/trunk/kupu/common/kupudrawers.js	(original)
+++ kupu/trunk/kupu/common/kupudrawers.js	Tue Jul  3 10:17:55 2007
@@ -365,7 +365,7 @@
         this.editor.resumeEditing();
         if (this.getMode()) {
             var url = input.value;
-            this.tool.createLink(url, null, null, this.target);
+            this.tool.createLink(url, null, null, this.target, 'external-link');
             input.value = '';
         } else {
             // Import the html
@@ -1549,7 +1549,7 @@
         var node = getFromSelector('link_target');
         var target = node && node.value;
         
-        this.tool.createLink(uri, null, name, target, title);
+        this.tool.createLink(uri, null, name, target, title, 'internal-link');
         this.drawertool.closeDrawer();
     };
 };


More information about the kupu-checkins mailing list