wp/wp-admin/js/plugin-install.js
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
       
     1 /* global plugininstallL10n, tb_click */
       
     2 
     1 /* Plugin Browser Thickbox related JS*/
     3 /* Plugin Browser Thickbox related JS*/
     2 var tb_position;
     4 var tb_position;
     3 jQuery(document).ready(function($) {
     5 jQuery( document ).ready( function( $ ) {
     4 	tb_position = function() {
     6 	tb_position = function() {
     5 		var tbWindow = $('#TB_window'), width = $(window).width(), H = $(window).height(), W = ( 720 < width ) ? 720 : width, adminbar_height = 0;
     7 		var tbWindow = $( '#TB_window' ),
     6 
     8 			width = $( window ).width(),
     7 		if ( $('body.admin-bar').length )
     9 			H = $( window ).height() - ( ( 792 < width ) ? 60 : 20 ),
     8 			adminbar_height = 28;
    10 			W = ( 792 < width ) ? 772 : width - 20;
     9 
    11 
    10 		if ( tbWindow.size() ) {
    12 		if ( tbWindow.size() ) {
    11 			tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
    13 			tbWindow.width( W ).height( H );
    12 			$('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
    14 			$( '#TB_iframeContent' ).width( W ).height( H );
    13 			tbWindow.css({'margin-left': '-' + parseInt((( W - 50 ) / 2),10) + 'px'});
    15 			tbWindow.css({
    14 			if ( typeof document.body.style.maxWidth != 'undefined' )
    16 				'margin-left': '-' + parseInt( ( W / 2 ), 10 ) + 'px'
    15 				tbWindow.css({'top': 20 + adminbar_height + 'px','margin-top':'0'});
    17 			});
    16 		};
    18 			if ( typeof document.body.style.maxWidth !== 'undefined' ) {
       
    19 				tbWindow.css({
       
    20 					'top': '30px',
       
    21 					'margin-top': '0'
       
    22 				});
       
    23 			}
       
    24 		}
    17 
    25 
    18 		return $('a.thickbox').each( function() {
    26 		return $( 'a.thickbox' ).each( function() {
    19 			var href = $(this).attr('href');
    27 			var href = $( this ).attr( 'href' );
    20 			if ( ! href )
    28 			if ( ! href ) {
    21 				return;
    29 				return;
    22 			href = href.replace(/&width=[0-9]+/g, '');
    30 			}
    23 			href = href.replace(/&height=[0-9]+/g, '');
    31 			href = href.replace( /&width=[0-9]+/g, '' );
    24 			$(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
    32 			href = href.replace( /&height=[0-9]+/g, '' );
       
    33 			$(this).attr( 'href', href + '&width=' + W + '&height=' + ( H ) );
    25 		});
    34 		});
    26 	};
    35 	};
    27 
    36 
    28 	$(window).resize(function(){ tb_position(); });
    37 	$( window ).resize( function() {
       
    38 		tb_position();
       
    39 	});
    29 
    40 
    30 	$('#dashboard_plugins, .plugins').on( 'click', 'a.thickbox', function() {
    41 	$( '.plugin-card, .plugins .column-description' ).on( 'click', 'a.thickbox', function() {
    31 		tb_click.call(this);
    42 		tb_click.call(this);
    32 
    43 
    33 		$('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
    44 		$('#TB_title').css({'background-color':'#23282d','color':'#cfcfcf'});
    34 		$('#TB_ajaxWindowTitle').html('<strong>' + plugininstallL10n.plugin_information + '</strong>&nbsp;' + $(this).attr('title') );
    45 		$('#TB_ajaxWindowTitle').html( '<strong>' + plugininstallL10n.plugin_information + '</strong>&nbsp;' + $(this).data( 'title' ) );
       
    46 		$('#TB_iframeContent').attr( 'title', plugininstallL10n.plugin_information + ' ' + $(this).data( 'title' ) );
       
    47 		$('#TB_closeWindowButton').focus();
       
    48 
    35 		return false;
    49 		return false;
    36 	});
    50 	});
    37 
    51 
    38 	/* Plugin install related JS*/
    52 	/* Plugin install related JS */
    39 	$('#plugin-information #sidemenu a').click( function() {
    53 	$( '#plugin-information-tabs a' ).click( function( event ) {
    40 		var tab = $(this).attr('name');
    54 		var tab = $( this ).attr( 'name' );
    41 		//Flip the tab
    55 		event.preventDefault();
    42 		$('#plugin-information-header a.current').removeClass('current');
       
    43 		$(this).addClass('current');
       
    44 		//Flip the content.
       
    45 		$('#section-holder div.section').hide(); //Hide 'em all
       
    46 		$('#section-' + tab).show();
       
    47 		return false;
       
    48 	});
       
    49 
    56 
    50 	$('a.install-now').click( function() {
    57 		// Flip the tab
    51 		return confirm( plugininstallL10n.ays );
    58 		$( '#plugin-information-tabs a.current' ).removeClass( 'current' );
       
    59 		$( this ).addClass( 'current' );
       
    60 
       
    61 		// Only show the fyi box in the description section, on smaller screen, where it's otherwise always displayed at the top.
       
    62 		if ( 'description' !== tab && $( window ).width() < 772 ) {
       
    63 			$( '#plugin-information-content' ).find( '.fyi' ).hide();
       
    64 		} else {
       
    65 			$( '#plugin-information-content' ).find( '.fyi' ).show();
       
    66 		}
       
    67 
       
    68 		// Flip the content.
       
    69 		$( '#section-holder div.section' ).hide(); // Hide 'em all.
       
    70 		$( '#section-' + tab ).show();
    52 	});
    71 	});
    53 });
    72 });