X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/bf5c68485ef07868ad0a91168ecd0092af7661ae..8f374b7233bc2815ccc387e448d208c5434eb961:/wp-includes/js/wplink.dev.js diff --git a/wp-includes/js/wplink.dev.js b/wp-includes/js/wplink.dev.js index 24403d31..d0c4b9a0 100644 --- a/wp-includes/js/wplink.dev.js +++ b/wp-includes/js/wplink.dev.js @@ -160,7 +160,7 @@ var wpLink; }, htmlUpdate : function() { - var attrs, html, start, end, cursor, + var attrs, html, begin, end, cursor, textarea = wpLink.textarea; if ( ! textarea ) @@ -183,35 +183,34 @@ var wpLink; 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 + ''; + 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 + ''; - 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 -= ''.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 + ''; - wpLink.range.moveToBookmark( wpLink.range.getBookmark() ); - wpLink.range.select(); - - wpLink.range = null; } wpLink.close(); @@ -243,7 +242,7 @@ var wpLink; 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#') {