~canonical-sysadmins/wordpress/4.5.2

« back to all changes in this revision

Viewing changes to wp-admin/js/plugin-install.js

  • Committer: Jacek Nykis
  • Date: 2015-01-05 16:17:05 UTC
  • Revision ID: jacek.nykis@canonical.com-20150105161705-w544l1h5mcg7u4w9
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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() - ( ( 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 .column-description' ).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).data( 'title' ) );
 
46
                $('#TB_iframeContent').attr( 'title', plugininstallL10n.plugin_information + ' ' + $(this).data( 'title' ) );
 
47
                $('#TB_closeWindowButton').focus();
 
48
 
 
49
                return false;
 
50
        });
 
51
 
 
52
        /* Plugin install related JS */
 
53
        $( '#plugin-information-tabs a' ).click( function( event ) {
 
54
                var tab = $( this ).attr( 'name' );
 
55
                event.preventDefault();
 
56
 
 
57
                // Flip the tab
 
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();
 
71
        });
 
72
 
 
73
        $( 'a.install-now' ).click( function() {
 
74
                return confirm( plugininstallL10n.ays );
 
75
        });
 
76
});