},
htmlUpdate : function() {
- var attrs, html, start, end, cursor,
+ var attrs, html, begin, end, cursor,
textarea = wpLink.textarea;
if ( ! textarea )
html += '>';
// Insert HTML
- // W3C
- if ( typeof textarea.selectionStart !== 'undefined' ) {
- start = textarea.selectionStart;
+ if ( document.selection && wpLink.range ) {
+ // IE
+ // Note: If no text is selected, IE will not place the cursor
+ // inside the closing tag.
+ textarea.focus();
+ wpLink.range.text = html + wpLink.range.text + '</a>';
+ wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
+ wpLink.range.select();
+
+ wpLink.range = null;
+ } else if ( typeof textarea.selectionStart !== 'undefined' ) {
+ // W3C
+ begin = textarea.selectionStart;
end = textarea.selectionEnd;
- selection = textarea.value.substring( start, end );
+ selection = textarea.value.substring( begin, end );
html = html + selection + '</a>';
- cursor = start + html.length;
+ cursor = begin + html.length;
// If no next is selected, place the cursor inside the closing tag.
- if ( start == end )
+ if ( begin == end )
cursor -= '</a>'.length;
- textarea.value = textarea.value.substring( 0, start )
+ textarea.value = textarea.value.substring( 0, begin )
+ html
+ textarea.value.substring( end, textarea.value.length );
// Update cursor position
textarea.selectionStart = textarea.selectionEnd = cursor;
-
- // IE
- // Note: If no text is selected, IE will not place the cursor
- // inside the closing tag.
- } else if ( document.selection && wpLink.range ) {
- textarea.focus();
- wpLink.range.text = html + wpLink.range.text + '</a>';
- wpLink.range.moveToBookmark( wpLink.range.getBookmark() );
- wpLink.range.select();
-
- wpLink.range = null;
}
wpLink.close();
if (e == null) {
ed.getDoc().execCommand("unlink", false, null);
- tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
+ tinyMCEPopup.execCommand("mceInsertLink", false, "#mce_temp_url#", {skip_undo : 1});
tinymce.each(ed.dom.select("a"), function(n) {
if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {