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