[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kupu-checkins
Subject:    [kupu-checkins] r5546 - in kupu/trunk/kupu: common
From:       duncan () codespeak ! net
Date:       2004-07-13 14:38:14
Message-ID: 20040713143814.E23115AA51 () thoth ! codespeak ! net
[Download RAW message or body]

Author: duncan
Date: Tue Jul 13 16:38:14 2004
New Revision: 5546

Modified:
   kupu/trunk/kupu/common/kupubasetools.js
   kupu/trunk/kupu/common/kupudrawers.js
   kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneeditor.js
   kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneinit.js
Log:
createLink no longer has any route where it can create an empty link.
Links target setting now easily overrideable.
IMG tag src attribute is now made relative at the same time as A tag href attribute.

Modified: kupu/trunk/kupu/common/kupubasetools.js
==============================================================================
--- kupu/trunk/kupu/common/kupubasetools.js	(original)
+++ kupu/trunk/kupu/common/kupubasetools.js	Tue Jul 13 16:38:14 2004
@@ -514,6 +514,7 @@
     // the order of the arguments is a bit odd here because of backward compatibility
     this.createLink = function(url, type, name, target, title) {
         var currnode = this.editor.getSelectedNode();
+        var doc = this.editor.getInnerDocument();
         var linkel = this.editor.getNearestParentOfType(currnode, 'A');
         if (!linkel) {
             this.editor.execCommand("CreateLink", url);
@@ -526,15 +527,16 @@
             if (!linkel) {
                 // Insert link with no text selected, insert the title
                 // or URI instead.
-                var doc = this.editor.getInnerDocument();
                 linkel = doc.createElement("a");
                 linkel.setAttribute('href', url);
-                linkel.appendChild(doc.createTextNode(title?title:url));
                 currnode.appendChild(linkel);
             };
         } else {
             linkel.setAttribute('href', url);
         }
+        if (linkel.innerHTML == "") {
+            linkel.appendChild(doc.createTextNode(title?title:url));
+        }
         if (type && type == 'anchor') {
             linkel.removeAttribute('href');
             linkel.setAttribute('name', name);

Modified: kupu/trunk/kupu/common/kupudrawers.js
==============================================================================
--- kupu/trunk/kupu/common/kupudrawers.js	(original)
+++ kupu/trunk/kupu/common/kupudrawers.js	Tue Jul 13 16:38:14 2004
@@ -130,7 +130,9 @@
         /* add or modify a link */
         var input = document.getElementById('kupu-linkdrawer-input');
         var url = input.value;
-        this.tool.createLink(url);
+        var target = '_self';
+        if (this.target) target = this.target;
+        this.tool.createLink(url, null, null, target);
 	input.value = '';
 
 	// XXX when reediting a link, the drawer does not close for

Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneeditor.js
==============================================================================
--- kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneeditor.js	(original)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneeditor.js	Tue Jul 13 16:38:14 2004
@@ -27,7 +27,7 @@
     var base = nodes[0];
     var href = base.href;
     var hrefparts = href.split('/');
-    return contents.replace(/(<[^>]* href=")([^"]*)"/g,
+    return contents.replace(/(<[^>]* (?:src|href)=")([^"]*)"/g,
         function(str, tag, url, offset, contents) {
             var urlparts = url.split('/');
             var common = 0;

Modified: kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneinit.js
==============================================================================
--- kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneinit.js	(original)
+++ kupu/trunk/kupu/plone/kupu_plone_layer/kupuploneinit.js	Tue Jul 13 16:38:14 2004
@@ -226,22 +226,7 @@
     return kupu;
 };
 
-// override LinkDrawer.save so all links have a _self target
-LinkDrawer.prototype.save = function() {
-    /* add or modify a link */
-    var input = document.getElementById('kupu-linkdrawer-input');
-    var url = input.value;
-    var currnode = this.editor.getSelectedNode();
-    var linkel = this.editor.getNearestParentOfType(currnode, 'a');
-    if (linkel) {
-        linkel.setAttribute('href', url);
-    } else {
-        this.tool.createLink(url, null, null, '_blank');
-    };
-    input.value = '';
+// modify LinkDrawer so all links have a target
+// defaults to _self, override here if reqd.
+//LinkDrawer.prototype.target = '_blank';
 
-    // XXX when reediting a link, the drawer does not close for
-    // some weird reason. BUG! Close the drawer manually until we
-    // find a fix:
-    this.drawertool.closeDrawer();
-};

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic