From: julmis Date: Fri, 20 Aug 2004 10:28:16 +0000 (+0000) Subject: Added text selection test, before opening insert link dialog. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=24d32007d04a1c7b1374a08fd895c36906157686;p=moodle.git Added text selection test, before opening insert link dialog. --- diff --git a/lib/editor/htmlarea.php b/lib/editor/htmlarea.php index 0a02569cda..6199ca020b 100644 --- a/lib/editor/htmlarea.php +++ b/lib/editor/htmlarea.php @@ -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 = {