includes/clientside/tinymce/themes/advanced/js/link.js
changeset 395 fa4c5ecb7c9a
parent 335 67bd3121a12e
child 543 dffcbfbc4e59
--- a/includes/clientside/tinymce/themes/advanced/js/link.js	Thu Jan 31 22:29:07 2008 -0500
+++ b/includes/clientside/tinymce/themes/advanced/js/link.js	Sat Feb 02 11:54:16 2008 -0500
@@ -31,7 +31,21 @@
 	},
 
 	update : function() {
-		var f = document.forms[0], ed = tinyMCEPopup.editor, e;
+		var f = document.forms[0], ed = tinyMCEPopup.editor, e, b;
+
+		// 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();
+				ed.dom.remove(e, 1);
+				ed.selection.moveToBookmark(b);
+				tinyMCEPopup.execCommand("mceEndUndoLevel");
+				tinyMCEPopup.close();
+				return;
+			}
+		}
 
 		ed.execCommand('mceInsertLink', false, {
 			href : f.href.value,
@@ -44,7 +58,7 @@
 	},
 
 	checkPrefix : function(n) {
-		if (Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_email')))
+		if (n.value && Validator.isEmail(n) && !/^\s*mailto:/i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_email')))
 			n.value = 'mailto:' + n.value;
 
 		if (/^\s*www./i.test(n.value) && confirm(tinyMCEPopup.getLang('advanced_dlg.link_is_external')))