Fix enqueueing of the right scripts when more than one instance of the editor, fix inserting images in full screen mode, see #17144

git-svn-id: http://svn.automattic.com/wordpress/trunk@18799 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2011-09-28 07:26:34 +00:00
parent 8315e48d3a
commit e076a246fd
4 changed files with 26 additions and 11 deletions

View File

@ -12,10 +12,12 @@ function send_to_editor(h) {
} else if ( !qt ) {
return false;
}
}
if ( !ed && mce && wpActiveEditor )
ed = tinymce.get(wpActiveEditor);
} else {
if ( mce && tinymce.activeEditor && (tinymce.activeEditor.id == 'mce_fullscreen' || tinymce.activeEditor.id == 'wp_mce_fullscreen') )
ed = tinymce.activeEditor;
else
ed = tinymce.get(wpActiveEditor);
}
if ( ed && !ed.isHidden() ) {
// restore caret position on IE

View File

@ -1 +1 @@
var wpActiveEditor;function send_to_editor(c){var b,a=typeof(tinymce)!="undefined",f=typeof(QTags)!="undefined";if(!wpActiveEditor){if(a&&tinymce.activeEditor){b=tinymce.activeEditor;wpActiveEditor=b.id}else{if(!f){return false}}}if(!b&&a&&wpActiveEditor){b=tinymce.get(wpActiveEditor)}if(b&&!b.isHidden()){if(tinymce.isIE&&b.windowManager.insertimagebookmark){b.selection.moveToBookmark(b.windowManager.insertimagebookmark)}if(c.indexOf("[caption")===0){if(b.plugins.wpeditimage){c=b.plugins.wpeditimage._do_shcode(c)}}else{if(c.indexOf("[gallery")===0){if(b.plugins.wpgallery){c=b.plugins.wpgallery._do_gallery(c)}}else{if(c.indexOf("[embed")===0){if(b.plugins.wordpress){c=b.plugins.wordpress._setEmbed(c)}}}}b.execCommand("mceInsertContent",false,c)}else{if(f){QTags.insertContent(c)}else{document.getElementById(wpActiveEditor).value+=c}}try{tb_remove()}catch(d){}}var tb_position;(function(a){tb_position=function(){var f=a("#TB_window"),e=a(window).width(),d=a(window).height(),c=(720<e)?720:e,b=0;if(a("body.admin-bar").length){b=28}if(f.size()){f.width(c-50).height(d-45-b);a("#TB_iframeContent").width(c-50).height(d-75-b);f.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){f.css({top:20+b+"px","margin-top":"0"})}}return a("a.thickbox").each(function(){var g=a(this).attr("href");if(!g){return}g=g.replace(/&width=[0-9]+/g,"");g=g.replace(/&height=[0-9]+/g,"");a(this).attr("href",g+"&width="+(c-80)+"&height="+(d-85-b))})};a(window).resize(function(){tb_position()});a(document).ready(function(b){b("a.thickbox").click(function(){var c;if(typeof(tinymce)!="undefined"&&tinymce.isIE&&(c=tinymce.get(wpActiveEditor))&&!c.isHidden()){c.focus();c.windowManager.insertimagebookmark=c.selection.getBookmark()}})})})(jQuery);
var wpActiveEditor;function send_to_editor(c){var b,a=typeof(tinymce)!="undefined",f=typeof(QTags)!="undefined";if(!wpActiveEditor){if(a&&tinymce.activeEditor){b=tinymce.activeEditor;wpActiveEditor=b.id}else{if(!f){return false}}}else{if(a&&tinymce.activeEditor&&(tinymce.activeEditor.id=="mce_fullscreen"||tinymce.activeEditor.id=="wp_mce_fullscreen")){b=tinymce.activeEditor}else{b=tinymce.get(wpActiveEditor)}}if(b&&!b.isHidden()){if(tinymce.isIE&&b.windowManager.insertimagebookmark){b.selection.moveToBookmark(b.windowManager.insertimagebookmark)}if(c.indexOf("[caption")===0){if(b.plugins.wpeditimage){c=b.plugins.wpeditimage._do_shcode(c)}}else{if(c.indexOf("[gallery")===0){if(b.plugins.wpgallery){c=b.plugins.wpgallery._do_gallery(c)}}else{if(c.indexOf("[embed")===0){if(b.plugins.wordpress){c=b.plugins.wordpress._setEmbed(c)}}}}b.execCommand("mceInsertContent",false,c)}else{if(f){QTags.insertContent(c)}else{document.getElementById(wpActiveEditor).value+=c}}try{tb_remove()}catch(d){}}var tb_position;(function(a){tb_position=function(){var f=a("#TB_window"),e=a(window).width(),d=a(window).height(),c=(720<e)?720:e,b=0;if(a("body.admin-bar").length){b=28}if(f.size()){f.width(c-50).height(d-45-b);a("#TB_iframeContent").width(c-50).height(d-75-b);f.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){f.css({top:20+b+"px","margin-top":"0"})}}return a("a.thickbox").each(function(){var g=a(this).attr("href");if(!g){return}g=g.replace(/&width=[0-9]+/g,"");g=g.replace(/&height=[0-9]+/g,"");a(this).attr("href",g+"&width="+(c-80)+"&height="+(d-85-b))})};a(window).resize(function(){tb_position()});a(document).ready(function(b){b("a.thickbox").click(function(){var c;if(typeof(tinymce)!="undefined"&&tinymce.isIE&&(c=tinymce.get(wpActiveEditor))&&!c.isHidden()){c.focus();c.windowManager.insertimagebookmark=c.selection.getBookmark()}})})})(jQuery);

View File

@ -25,6 +25,9 @@ class WP_Editor {
var $first_init;
var $this_tinymce = false;
var $this_quicktags = false;
var $has_tinymce = false;
var $has_quicktags = false;
var $has_medialib = false;
function __construct() {
$this->can_richedit = user_can_richedit();
@ -67,6 +70,7 @@ class WP_Editor {
if ( $this->this_quicktags && $this->this_tinymce ) {
$switch_class = 'html-active';
$this->has_tinymce = $this->has_quicktags = true;
if ( 'html' == $this->default_editor ) {
add_filter('the_editor_content', 'wp_htmledit_pre');
@ -77,6 +81,12 @@ class WP_Editor {
$buttons .= '<a id="' . $editor_id . '-html" class="hide-if-no-js wp-switch-editor switch-html" onclick="switchEditors.go(this);return false;">' . __('HTML') . "</a>\n";
$buttons .= '<a id="' . $editor_id . '-tmce" class="hide-if-no-js wp-switch-editor switch-tmce" onclick="switchEditors.go(this);return false;">' . __('Visual') . "</a>\n";
} else {
if ( $this->this_tinymce )
$this->has_tinymce = true;
if ( $this->this_quicktags )
$this->has_quicktags = true;
}
echo '<div id="wp-' . $editor_id . '-wrap" class="wp-editor-wrap ' . $switch_class . '">';
@ -89,6 +99,8 @@ class WP_Editor {
echo $buttons;
if ( $set['media_buttons'] ) {
$this->has_medialib = true;
if ( !function_exists('media_buttons') )
include(ABSPATH . 'wp-admin/includes/media.php');
@ -442,10 +454,10 @@ class WP_Editor {
wp_enqueue_script('word-count');
wp_enqueue_style('editor-buttons');
if ( $this->this_tinymce )
if ( $this->has_tinymce )
wp_enqueue_script('editor');
if ( $this->this_quicktags )
if ( $this->has_quicktags )
wp_enqueue_script('quicktags');
if ( in_array('wplink', $this->plugins, true) || in_array('link', $this->qt_buttons, true) ) {
@ -457,8 +469,10 @@ class WP_Editor {
if ( in_array('wpfullscreen', $this->plugins, true) || in_array('fullscreen', $this->qt_buttons, true) )
wp_enqueue_script('wp-fullscreen');
add_thickbox();
wp_enqueue_script('media-upload');
if ( $this->has_medialib ) {
add_thickbox();
wp_enqueue_script('media-upload');
}
}
function editor_js() {
@ -800,4 +814,3 @@ class WP_Editor {
}
}

View File

@ -276,7 +276,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20110515', 1 );
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110922', 1 );
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110927', 1 );
if ( is_admin() ) {
$scripts->add( 'ajaxcat', "/wp-admin/js/cat$suffix.js", array( 'wp-lists' ), '20090102' );