Skip to content

Commit

Permalink
Trying to get rid of insert link bug once and for all
Browse files Browse the repository at this point in the history
  • Loading branch information
julmis committed Jul 30, 2006
1 parent 0fc71cc commit 980b1e0
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions lib/editor/htmlarea/htmlarea.php
Expand Up @@ -1470,26 +1470,21 @@ function (str, l1, l2, l3) {
}
var a = link;
if (!a) {
editor._doc.execCommand("createlink", false, param.f_href);
a = editor.getParentElement();
// Since startContainer check does not work
// very well in Moz use just insertHTML.
var sel = editor._getSelection();
var range = editor._createRange(sel);
/// Removed by PJ and Martin, Moodle bug #1455
/// Removed uncommenting since it prevents this function
/// to read given attributes for <a> tag such as target, title etc...
if (!HTMLArea.is_ie) {
try {
a = range.startContainer;
if (!/^a$/i.test(a.tagName)) {
a = a.nextSibling;
if ( a == null ) {
a = range.startContainer.parentNode;
}
}
} catch (e) {
alert("Send this message to bug tracker: " + e);
}
var strLink = '<a href="'+ param.f_href.trim() +'"';
if ( param.f_title != "" ) {
strLink += ' title="'+ param.f_title.trim() +'"';
}
if ( param.f_target != "" ) {
strLink += ' target="'+ param.f_target.trim() +'"';
}
strLink += '>';
strLink += (!HTMLArea.is_ie) ? sel : range.text;
strLink += '</a>';
editor.insertHTML(strLink);
} else {
var href = param.f_href.trim();
editor.selectNodeContents(a);
Expand Down

0 comments on commit 980b1e0

Please sign in to comment.