fix dialog on htmleditor link
[roojs1] / Roo / form / HtmlEditor / ToolbarStandard.js
index 2289ab8..b58a4cf 100644 (file)
@@ -9,7 +9,6 @@
 /**
  * @class Roo.form.HtmlEditor.ToolbarStandard
  * Basic Toolbar
- * @children   Roo.Toolbar.Item Roo.Toolbar.Button Roo.Toolbar.SplitButton Roo.form.Field 
 
  * Usage:
  *
@@ -527,14 +526,42 @@ Roo.form.HtmlEditor.ToolbarStandard.prototype = {
     createLink : function(){
         //Roo.log("create link?");
         var ec = this.editorcore;
-        Roo.MessageBox.prompt("Add Link URL",this.createLinkText, function(btn, url) {
-            if (btn != 'ok') {
-                return;
+        var ar = ec.getAllAncestors();
+        var n = false;
+        for(var i = 0;i< ar.length;i++) {
+            if (ar[i] && ar[i].nodeName == 'A') {
+                n = ar[i];
+                break;
             }
-            if(url && url != 'http:/'+'/'){
-                ec.relayCmd('createlink', url);
-            }
-        });
+        }
+        
+        (function() {
+            
+            Roo.MessageBox.show({
+                title : "Add / Edit Link URL",
+                msg : "Enter the url for the link",
+                buttons: Roo.MessageBox.OKCANCEL,
+                fn: function(btn, url){
+                    if (btn != 'ok') {
+                        return;
+                    }
+                    if(url && url != 'http:/'+'/'){
+                        if (n) {
+                            n.setAttribute('href', url);
+                        } else {
+                            ec.relayCmd('createlink', url);
+                        }
+                    }
+                },
+                minWidth:250,
+                prompt:true,
+                //multiline: multiline,
+                modal : true,
+                value :  n  ? n.getAttribute('href') : '' 
+            });
+            
+             
+        }).defer(100, this); // we have to defer this , otherwise the mouse click gives focus to the main window.
         
     },