summaryrefslogtreecommitdiff
path: root/program/js/tiny_mce/themes/advanced/js/link.js
diff options
context:
space:
mode:
authoralecpl <alec@alec.pl>2008-07-18 14:59:01 +0000
committeralecpl <alec@alec.pl>2008-07-18 14:59:01 +0000
commit18240a9201d193a5a2420f8644fa05b7bfbceeec (patch)
tree79f1f65e1eede1f8f5e8bf87960594c286b600e8 /program/js/tiny_mce/themes/advanced/js/link.js
parentbc0fe54235ae4f5cd4a74be91beb1f9953eb7b03 (diff)
- Updated TinyMCE to version 3.1.0.1
Diffstat (limited to 'program/js/tiny_mce/themes/advanced/js/link.js')
-rw-r--r--program/js/tiny_mce/themes/advanced/js/link.js43
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 ab434da3d..2974878e1 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 LinkDialog = {
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 @@ var LinkDialog = {
}
}
- 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();
},