5
|
1 |
/* global plugininstallL10n, tb_click */ |
|
2 |
|
0
|
3 |
/* Plugin Browser Thickbox related JS*/ |
|
4 |
var tb_position; |
5
|
5 |
jQuery( document ).ready( function( $ ) { |
0
|
6 |
tb_position = function() { |
5
|
7 |
var tbWindow = $( '#TB_window' ), |
|
8 |
width = $( window ).width(), |
|
9 |
H = $( window ).height() - ( ( 792 < width ) ? 60 : 20 ), |
|
10 |
W = ( 792 < width ) ? 772 : width - 20; |
0
|
11 |
|
|
12 |
if ( tbWindow.size() ) { |
5
|
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 |
} |
0
|
25 |
|
5
|
26 |
return $( 'a.thickbox' ).each( function() { |
|
27 |
var href = $( this ).attr( 'href' ); |
|
28 |
if ( ! href ) { |
0
|
29 |
return; |
5
|
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 ) ); |
0
|
34 |
}); |
|
35 |
}; |
|
36 |
|
5
|
37 |
$( window ).resize( function() { |
|
38 |
tb_position(); |
|
39 |
}); |
0
|
40 |
|
5
|
41 |
$( '.plugin-card, .plugins .column-description' ).on( 'click', 'a.thickbox', function() { |
0
|
42 |
tb_click.call(this); |
|
43 |
|
5
|
44 |
$('#TB_title').css({'background-color':'#23282d','color':'#cfcfcf'}); |
|
45 |
$('#TB_ajaxWindowTitle').html( '<strong>' + plugininstallL10n.plugin_information + '</strong> ' + $(this).data( 'title' ) ); |
|
46 |
$('#TB_iframeContent').attr( 'title', plugininstallL10n.plugin_information + ' ' + $(this).data( 'title' ) ); |
|
47 |
$('#TB_closeWindowButton').focus(); |
|
48 |
|
0
|
49 |
return false; |
|
50 |
}); |
|
51 |
|
5
|
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' ); |
0
|
60 |
|
5
|
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(); |
0
|
71 |
}); |
|
72 |
}); |