]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/plugin-install.js
WordPress 4.4.1-scripts
[autoinstalls/wordpress.git] / wp-admin / js / plugin-install.js
1 /* global plugininstallL10n, tb_click */
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() - ( ( 792 < width ) ? 60 : 20 ),
10                         W = ( 792 < width ) ? 772 : 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': '30px',
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         $( '.plugin-card, .plugins .plugin-version-author-uri' ).on( 'click', 'a.thickbox', function( e ) {
42                 e.preventDefault();
43                 e.stopPropagation();
44
45                 tb_click.call(this);
46
47                 $('#TB_title').css({'background-color':'#23282d','color':'#cfcfcf'});
48                 $('#TB_ajaxWindowTitle').html( '<strong>' + plugininstallL10n.plugin_information + '</strong>&nbsp;' + $(this).data( 'title' ) );
49                 $('#TB_iframeContent').attr( 'title', plugininstallL10n.plugin_information + ' ' + $(this).data( 'title' ) );
50                 $('#TB_closeWindowButton').focus();
51         });
52
53         /* Plugin install related JS */
54         $( '#plugin-information-tabs a' ).click( function( event ) {
55                 var tab = $( this ).attr( 'name' );
56                 event.preventDefault();
57
58                 // Flip the tab
59                 $( '#plugin-information-tabs a.current' ).removeClass( 'current' );
60                 $( this ).addClass( 'current' );
61
62                 // Only show the fyi box in the description section, on smaller screen, where it's otherwise always displayed at the top.
63                 if ( 'description' !== tab && $( window ).width() < 772 ) {
64                         $( '#plugin-information-content' ).find( '.fyi' ).hide();
65                 } else {
66                         $( '#plugin-information-content' ).find( '.fyi' ).show();
67                 }
68
69                 // Flip the content.
70                 $( '#section-holder div.section' ).hide(); // Hide 'em all.
71                 $( '#section-' + tab ).show();
72         });
73 });