]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/theme-preview.js
Wordpress 2.6.2
[autoinstalls/wordpress.git] / wp-admin / js / theme-preview.js
1
2 jQuery(function($) {
3         if ( 'undefined' == typeof $.fn.pngFix )
4                 $.fn.pngFix = function() { return this; }
5
6         var thickDims = function() {
7                 var tbWindow = $('#TB_window');
8                 var H = $(window).height();
9                 var W = $(window).width();
10
11                 if ( tbWindow.size() ) {
12                         tbWindow.width( W - 90 ).height( H - 60 );
13                         $('#TB_iframeContent').width( W - 90 ).height( H - 90 );
14                         tbWindow.css({'margin-left': '-' + parseInt((( W - 90 ) / 2),10) + 'px'});
15                         if ( typeof document.body.style.maxWidth != 'undefined' )
16                                 tbWindow.css({'top':'30px','margin-top':'0'});
17                 };
18
19                 return $('a.thickbox').each( function() {
20                         var href = $(this).parents('.available-theme').find('.previewlink').attr('href');
21                         if ( ! href ) return;
22                         href = href.replace(/&width=[0-9]+/g, '');
23                         href = href.replace(/&height=[0-9]+/g, '');
24                         $(this).attr( 'href', href + '&width=' + ( W - 110 ) + '&height=' + ( H - 100 ) );
25                 });
26         };
27
28         thickDims()
29         .click( function() {
30                 var alink = $(this).parents('.available-theme').find('.activatelink');
31                 var url = alink.attr('href');
32                 var text = alink.html();
33
34                 $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'});
35                 $('#TB_closeAjaxWindow').css({'float':'left'});
36                 $('#TB_ajaxWindowTitle').css({'float':'right'})
37                         .append('&nbsp;<a href="' + url + '" target="_top" class="tb-theme-preview-link">' + text + '</a>');
38
39                 $('#TB_iframeContent').width('100%');
40                 return false;
41         } );
42
43         $(window).resize( function() { thickDims() } );
44 });