Make WordPress Core

Changeset 18799


Ignore:
Timestamp:
09/28/2011 07:26:34 AM (13 years ago)
Author:
azaozz
Message:

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

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/media-upload.dev.js

    r18766 r18799  
    1313            return false;
    1414        }
    15     }
    16 
    17     if ( !ed && mce && wpActiveEditor )
    18         ed = tinymce.get(wpActiveEditor);
     15    } else {
     16        if ( mce && tinymce.activeEditor && (tinymce.activeEditor.id == 'mce_fullscreen' || tinymce.activeEditor.id == 'wp_mce_fullscreen') )
     17            ed = tinymce.activeEditor;
     18        else
     19            ed = tinymce.get(wpActiveEditor);
     20    }
    1921
    2022    if ( ed && !ed.isHidden() ) {
  • trunk/wp-admin/js/media-upload.js

    r18766 r18799  
    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);
     1var 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);
  • trunk/wp-includes/class-wp-editor.php

    r18766 r18799  
    2626    var $this_tinymce = false;
    2727    var $this_quicktags = false;
     28    var $has_tinymce = false;
     29    var $has_quicktags = false;
     30    var $has_medialib = false;
    2831
    2932    function __construct() {
     
    6871        if ( $this->this_quicktags && $this->this_tinymce ) {
    6972            $switch_class = 'html-active';
     73            $this->has_tinymce = $this->has_quicktags = true;
    7074
    7175            if ( 'html' == $this->default_editor ) {
     
    7882            $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";
    7983            $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";
     84        } else {
     85            if ( $this->this_tinymce )
     86                $this->has_tinymce = true;
     87
     88            if ( $this->this_quicktags )
     89                $this->has_quicktags = true;
    8090        }
    8191
     
    90100
    91101            if ( $set['media_buttons'] ) {
     102                $this->has_medialib = true;
     103
    92104                if ( !function_exists('media_buttons') )
    93105                    include(ABSPATH . 'wp-admin/includes/media.php');
     
    443455        wp_enqueue_style('editor-buttons');
    444456
    445         if ( $this->this_tinymce )
     457        if ( $this->has_tinymce )
    446458            wp_enqueue_script('editor');
    447459
    448         if ( $this->this_quicktags )
     460        if ( $this->has_quicktags )
    449461            wp_enqueue_script('quicktags');
    450462
     
    458470            wp_enqueue_script('wp-fullscreen');
    459471
    460         add_thickbox();
    461         wp_enqueue_script('media-upload');
     472        if ( $this->has_medialib ) {
     473            add_thickbox();
     474            wp_enqueue_script('media-upload');
     475        }
    462476    }
    463477
     
    801815}
    802816
    803 
  • trunk/wp-includes/script-loader.php

    r18798 r18799  
    277277    $scripts->add( 'word-count', "/wp-admin/js/word-count$suffix.js", array( 'jquery' ), '20110515', 1 );
    278278
    279     $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110922', 1 );
     279    $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20110927', 1 );
    280280
    281281    if ( is_admin() ) {
Note: See TracChangeset for help on using the changeset viewer.