Another attempt to fix the http blog redirects.
[WebKit-https.git] / Websites / webkit.org / blog / wp-admin / js / theme-preview.dev.js
1
2 var thickDims, tbWidth, tbHeight;
3 jQuery(document).ready(function($) {
4
5         thickDims = function() {
6                 var tbWindow = $('#TB_window'), H = $(window).height(), W = $(window).width(), w, h;
7
8                 w = (tbWidth && tbWidth < W - 90) ? tbWidth : W - 90;
9                 h = (tbHeight && tbHeight < H - 60) ? tbHeight : H - 60;
10
11                 if ( tbWindow.size() ) {
12                         tbWindow.width(w).height(h);
13                         $('#TB_iframeContent').width(w).height(h - 27);
14                         tbWindow.css({'margin-left': '-' + parseInt((w / 2),10) + 'px'});
15                         if ( typeof document.body.style.maxWidth != 'undefined' )
16                                 tbWindow.css({'top':'30px','margin-top':'0'});
17                 }
18         };
19
20         thickDims();
21         $(window).resize( function() { thickDims() } );
22
23         $('a.thickbox-preview').click( function() {
24                 tb_click.call(this);
25
26                 var alink = $(this).parents('.available-theme').find('.activatelink'), link = '', href = $(this).attr('href'), url, text;
27
28                 if ( tbWidth = href.match(/&tbWidth=[0-9]+/) )
29                         tbWidth = parseInt(tbWidth[0].replace(/[^0-9]+/g, ''), 10);
30                 else
31                         tbWidth = $(window).width() - 90;
32
33                 if ( tbHeight = href.match(/&tbHeight=[0-9]+/) )
34                         tbHeight = parseInt(tbHeight[0].replace(/[^0-9]+/g, ''), 10);
35                 else
36                         tbHeight = $(window).height() - 60;
37
38                 if ( alink.length ) {
39                         url = alink.attr('href') || '';
40                         text = alink.attr('title') || '';
41                         link = '&nbsp; <a href="' + url + '" target="_top" class="tb-theme-preview-link">' + text + '</a>';
42                 } else {
43                         text = $(this).attr('title') || '';
44                         link = '&nbsp; <span class="tb-theme-preview-link">' + text + '</span>';
45                 }
46
47                 $('#TB_title').css({'background-color':'#222','color':'#dfdfdf'});
48                 $('#TB_closeAjaxWindow').css({'float':'left'});
49                 $('#TB_ajaxWindowTitle').css({'float':'right'}).html(link);
50
51                 $('#TB_iframeContent').width('100%');
52                 thickDims();
53
54                 return false;
55         } );
56
57         // Theme details
58         $('.theme-detail').click(function () {
59                 $(this).siblings('.themedetaildiv').toggle();
60                 return false;
61         });
62
63 });
64