Plugin install and thickbox for the network admin. props ocean90, fixes #15510, fixes #15750.

git-svn-id: http://svn.automattic.com/wordpress/trunk@16963 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-12-15 18:48:40 +00:00
parent 98ae904159
commit 6c025aa06f
6 changed files with 40 additions and 10 deletions

View File

@ -719,6 +719,7 @@ function revoke_super_admin( $user_id ) {
}
return false;
}
/**
* Whether or not we can edit this network from this page
*
@ -737,4 +738,22 @@ function can_edit_network( $site_id ) {
return apply_filters( 'can_edit_network', $result, $site_id );
}
/**
* Thickbox image paths for Network Admin.
*
* @since 3.1.0
* @access private
*/
function _thickbox_path_admin_subfolder() {
?>
<script type="text/javascript">
//<![CDATA[
var tb_pathToImage = "../../wp-includes/js/thickbox/loadingAnimation.gif";
var tb_closeImage = "../../wp-includes/js/thickbox/tb-close.png";
//]]>
</script>
<?
}
?>

View File

@ -1,14 +1,18 @@
/* Plugin Browser Thickbox related JS*/
var tb_position;
jQuery(document).ready(function($) {
var thickDims = function() {
var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width;
tb_position = function() {
var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width, adminbar_height = 0;
if ( $('body.admin-bar').length )
adminbar_height = 28;
if ( tbWindow.size() ) {
tbWindow.width( W - 50 ).height( H - 45 );
$('#TB_iframeContent').width( W - 50 ).height( H - 75 );
tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
$('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
if ( ! ( $.browser.msie && $.browser.version.substr(0,1) < 7 ) )
tbWindow.css({'top':'20px','margin-top':'0'});
if ( typeof document.body.style.maxWidth != 'undefined' )
tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'});
};
return $('#dashboard_plugins a.thickbox, .plugins a.thickbox').each( function() {
@ -17,11 +21,13 @@ jQuery(document).ready(function($) {
return;
href = href.replace(/&width=[0-9]+/g, '');
href = href.replace(/&height=[0-9]+/g, '');
$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 ) );
$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
});
};
thickDims().click( function() {
$(window).resize(function(){ tb_position(); });
$('#dashboard_plugins a.thickbox, .plugins a.thickbox').click( function() {
tb_click.call(this);
$('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});

View File

@ -1 +1 @@
jQuery(document).ready(function(b){var a=function(){var f=b("#TB_window"),e=b(window).width(),d=b(window).height(),c=(720<e)?720:e;if(f.size()){f.width(c-50).height(d-45);b("#TB_iframeContent").width(c-50).height(d-75);f.css({"margin-left":"-"+parseInt(((c-50)/2),10)+"px"});if(!(b.browser.msie&&b.browser.version.substr(0,1)<7)){f.css({top:"20px","margin-top":"0"})}}return b("#dashboard_plugins a.thickbox, .plugins a.thickbox").each(function(){var g=b(this).attr("href");if(!g){return}g=g.replace(/&width=[0-9]+/g,"");g=g.replace(/&height=[0-9]+/g,"");b(this).attr("href",g+"&width="+(c-80)+"&height="+(d-85))})};a().click(function(){tb_click.call(this);b("#TB_title").css({"background-color":"#222",color:"#cfcfcf"});b("#TB_ajaxWindowTitle").html("<strong>"+plugininstallL10n.plugin_information+"</strong>&nbsp;"+b(this).attr("title"));return false});b("#plugin-information #sidemenu a").click(function(){var c=b(this).attr("name");b("#plugin-information-header a.current").removeClass("current");b(this).addClass("current");b("#section-holder div.section").hide();b("#section-"+c).show();return false});b("#install-plugins .action-links .install-now").click(function(){return confirm(plugininstallL10n.ays)})});
var tb_position;jQuery(document).ready(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("#dashboard_plugins a.thickbox, .plugins 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("#dashboard_plugins a.thickbox, .plugins a.thickbox").click(function(){tb_click.call(this);a("#TB_title").css({"background-color":"#222",color:"#cfcfcf"});a("#TB_ajaxWindowTitle").html("<strong>"+plugininstallL10n.plugin_information+"</strong>&nbsp;"+a(this).attr("title"));return false});a("#plugin-information #sidemenu a").click(function(){var b=a(this).attr("name");a("#plugin-information-header a.current").removeClass("current");a(this).addClass("current");a("#section-holder div.section").hide();a("#section-"+b).show();return false});a("#install-plugins .action-links .install-now").click(function(){return confirm(plugininstallL10n.ays)})});

View File

@ -35,7 +35,9 @@ add_contextual_help($current_screen,
wp_dashboard_setup();
wp_enqueue_script( 'dashboard' );
wp_enqueue_script( 'plugin-install' );
wp_admin_css( 'dashboard' );
wp_admin_css( 'plugin-install' );
add_thickbox();
add_screen_option('layout_columns', array('max' => 4, 'default' => 2) );

View File

@ -2154,6 +2154,9 @@ function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
function add_thickbox() {
wp_enqueue_script( 'thickbox' );
wp_enqueue_style( 'thickbox' );
if ( is_network_admin() )
add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
}
/**

View File

@ -404,7 +404,7 @@ function wp_default_scripts( &$scripts ) {
'l10n_print_after' => 'try{convertEntities(inlineEditL10n);}catch(e){};'
) );
$scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'thickbox' ), '20100407' );
$scripts->add( 'plugin-install', "/wp-admin/js/plugin-install$suffix.js", array( 'jquery', 'thickbox' ), '20101215' );
$scripts->add_data( 'plugin-install', 'group', 1 );
$scripts->localize( 'plugin-install', 'plugininstallL10n', array(
'plugin_information' => __('Plugin Information:'),