]> git.mjollnir.org Git - moodle.git/commitdiff
Added text selection test, before opening insert link dialog.
authorjulmis <julmis>
Fri, 20 Aug 2004 10:28:16 +0000 (10:28 +0000)
committerjulmis <julmis>
Fri, 20 Aug 2004 10:28:16 +0000 (10:28 +0000)
lib/editor/htmlarea.php

index 0a02569cda2cef73c077b1de738f278088881f5e..6199ca020b109f53821a2f73ed6c411f9c9fe5ce 100644 (file)
@@ -1314,8 +1314,16 @@ HTMLArea.prototype._createLink = function(link) {
     var outparam = null;
     if (typeof link == "undefined") {
         link = this.getParentElement();
-        if (link && !/^a$/i.test(link.tagName))
+        if (link && !/^a$/i.test(link.tagName)) {
             link = null;
+            var sel = this._getSelection();
+            var rng = this._createRange(sel);
+            var len = HTMLArea.is_ie ? rng.text.toString().length : sel.toString().length;
+            if(len < 1) {
+                alert("You must select text first!");
+                return false;
+            }
+        }
     }
     if (link) {
         outparam = {