]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/plugin-install.js
WordPress 3.8
[autoinstalls/wordpress.git] / wp-admin / js / plugin-install.js
1 /* global plugininstallL10n, tb_click, confirm */
2
3 /* Plugin Browser Thickbox related JS*/
4 var tb_position;
5 jQuery(document).ready(function($) {
6         tb_position = function() {
7                 var tbWindow = $('#TB_window'),
8                         width = $(window).width(),
9                         H = $(window).height(),
10                         W = ( 720 < width ) ? 720 : width,
11                         adminbar_height = 0;
12
13                 if ( $('body.admin-bar').length ) {
14                         adminbar_height = parseInt( jQuery('#wpadminbar').css('height'), 10 );
15                 }
16
17                 if ( tbWindow.size() ) {
18                         tbWindow.width( W - 50 ).height( H - 45 - adminbar_height );
19                         $('#TB_iframeContent').width( W - 50 ).height( H - 75 - adminbar_height );
20                         tbWindow.css({'margin-left': '-' + parseInt( ( ( W - 50 ) / 2 ), 10 ) + 'px'});
21                         if ( typeof document.body.style.maxWidth !== 'undefined' )
22                                 tbWindow.css({'top': 20 + adminbar_height + 'px', 'margin-top': '0'});
23                 }
24
25                 return $('a.thickbox').each( function() {
26                         var href = $(this).attr('href');
27                         if ( ! href )
28                                 return;
29                         href = href.replace(/&width=[0-9]+/g, '');
30                         href = href.replace(/&height=[0-9]+/g, '');
31                         $(this).attr( 'href', href + '&width=' + ( W - 80 ) + '&height=' + ( H - 85 - adminbar_height ) );
32                 });
33         };
34
35         $(window).resize(function(){ tb_position(); });
36
37         $('.plugins').on( 'click', 'a.thickbox', function() {
38                 tb_click.call(this);
39
40                 $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
41                 $('#TB_ajaxWindowTitle').html('<strong>' + plugininstallL10n.plugin_information + '</strong>&nbsp;' + $(this).attr('title') );
42                 return false;
43         });
44
45         /* Plugin install related JS*/
46         $('#plugin-information #sidemenu a').click( function() {
47                 var tab = $(this).attr('name');
48                 //Flip the tab
49                 $('#plugin-information-header a.current').removeClass('current');
50                 $(this).addClass('current');
51                 //Flip the content.
52                 $('#section-holder div.section').hide(); //Hide 'em all
53                 $('#section-' + tab).show();
54                 return false;
55         });
56
57         $('a.install-now').click( function() {
58                 return confirm( plugininstallL10n.ays );
59         });
60 });