From 57134c64b70f80eab787093bd777c287bc2e54ed Mon Sep 17 00:00:00 2001 From: azaozz Date: Mon, 25 Apr 2011 22:49:22 +0000 Subject: [PATCH] Fix image insertion in IE, fixes #17237 git-svn-id: http://svn.automattic.com/wordpress/trunk@17701 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/js/media-upload.dev.js | 16 +++++++++++++++- wp-admin/js/media-upload.js | 2 +- wp-includes/script-loader.php | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/wp-admin/js/media-upload.dev.js b/wp-admin/js/media-upload.dev.js index 672d81de93..75478725ac 100644 --- a/wp-admin/js/media-upload.dev.js +++ b/wp-admin/js/media-upload.dev.js @@ -3,7 +3,9 @@ function send_to_editor(h) { var ed; if ( typeof tinyMCE != 'undefined' && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) { - ed.focus(); + // restore caret position on IE + if ( tinymce.isIE && ed.windowManager.insertimagebookmark ) + ed.selection.moveToBookmark(ed.windowManager.insertimagebookmark); if ( h.indexOf('[caption') === 0 ) { if ( ed.plugins.wpeditimage ) @@ -55,4 +57,16 @@ var tb_position; $(window).resize(function(){ tb_position(); }); + // store caret position in IE + $(document).ready(function($){ + $('a.thickbox').click(function(){ + var ed; + + if ( typeof tinyMCE != 'undefined' && tinymce.isIE && ( ed = tinyMCE.activeEditor ) && !ed.isHidden() ) { + ed.focus(); + ed.windowManager.insertimagebookmark = ed.selection.getBookmark(); + } + }); + }); + })(jQuery); diff --git a/wp-admin/js/media-upload.js b/wp-admin/js/media-upload.js index 8ed45caa55..201f6abc2c 100644 --- a/wp-admin/js/media-upload.js +++ b/wp-admin/js/media-upload.js @@ -1 +1 @@ -function send_to_editor(b){var a;if(typeof tinyMCE!="undefined"&&(a=tinyMCE.activeEditor)&&!a.isHidden()){a.focus();if(b.indexOf("[caption")===0){if(a.plugins.wpeditimage){b=a.plugins.wpeditimage._do_shcode(b)}}else{if(b.indexOf("[gallery")===0){if(a.plugins.wpgallery){b=a.plugins.wpgallery._do_gallery(b)}}else{if(b.indexOf("[embed")===0){if(a.plugins.wordpress){b=a.plugins.wordpress._setEmbed(b)}}}}a.execCommand("mceInsertContent",false,b)}else{if(typeof edInsertContent=="function"){edInsertContent(edCanvas,b)}else{jQuery(edCanvas).val(jQuery(edCanvas).val()+b)}}tb_remove()}var tb_position;(function(a){tb_position=function(){var f=a("#TB_window"),e=a(window).width(),d=a(window).height(),c=(720add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20110414' ); - $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110414' ); + $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110425' ); $scripts->add_data( 'media-upload', 'group', 1 ); $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), '20101007' );