From 18240a9201d193a5a2420f8644fa05b7bfbceeec Mon Sep 17 00:00:00 2001 From: alecpl <alec@alec.pl> Date: Fri, 18 Jul 2008 10:59:01 -0400 Subject: [PATCH] - Updated TinyMCE to version 3.1.0.1 --- program/js/tiny_mce/themes/advanced/js/link.js | 43 ++++++++++++++++++++++++++++++++++++------- 1 files changed, 36 insertions(+), 7 deletions(-) diff --git a/program/js/tiny_mce/themes/advanced/js/link.js b/program/js/tiny_mce/themes/advanced/js/link.js index ab434da..2974878 100644 --- a/program/js/tiny_mce/themes/advanced/js/link.js +++ b/program/js/tiny_mce/themes/advanced/js/link.js @@ -34,10 +34,10 @@ var f = document.forms[0], ed = tinyMCEPopup.editor, e, b; tinyMCEPopup.restoreSelection(); + e = ed.dom.getParent(ed.selection.getNode(), 'A'); // Remove element if there is no href if (!f.href.value) { - e = ed.dom.getParent(ed.selection.getNode(), 'A'); if (e) { tinyMCEPopup.execCommand("mceBeginUndoLevel"); b = ed.selection.getBookmark(); @@ -49,13 +49,42 @@ } } - ed.execCommand('mceInsertLink', false, { - href : f.href.value, - title : f.linktitle.value, - target : f.target_list ? f.target_list.options[f.target_list.selectedIndex].value : null, - 'class' : f.class_list ? f.class_list.options[f.class_list.selectedIndex].value : null - }); + tinyMCEPopup.execCommand("mceBeginUndoLevel"); + // Create new anchor elements + if (e == null) { + tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1}); + + tinymce.each(ed.dom.select("a"), function(n) { + if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') { + e = n; + + ed.dom.setAttribs(e, { + href : f.href.value, + title : f.linktitle.value, + target : f.target_list ? f.target_list.options[f.target_list.selectedIndex].value : null, + 'class' : f.class_list ? f.class_list.options[f.class_list.selectedIndex].value : null + }); + } + }); + } else { + ed.dom.setAttribs(e, { + href : f.href.value, + title : f.linktitle.value, + target : f.target_list ? f.target_list.options[f.target_list.selectedIndex].value : null, + 'class' : f.class_list ? f.class_list.options[f.class_list.selectedIndex].value : null + }); + } + + // Don't move caret if selection was image + if (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') { + ed.focus(); + ed.selection.select(e); + ed.selection.collapse(0); + tinyMCEPopup.storeSelection(); + } + + tinyMCEPopup.execCommand("mceEndUndoLevel"); tinyMCEPopup.close(); }, -- Gitblit v1.9.1