]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/js/theme-preview.js
WordPress 3.8.1-scripts
[autoinstalls/wordpress.git] / wp-admin / js / theme-preview.js
1 /* global tb_click */
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
21         thickDims();
22         $(window).resize( function() { thickDims(); } );
23
24         $('a.thickbox-preview').click( function() {
25                 tb_click.call(this);
26
27                 var alink = $(this).parents('.available-theme').find('.activatelink'), link = '', href = $(this).attr('href'), url, text;
28
29                 if ( tbWidth = href.match(/&tbWidth=[0-9]+/) ) {
30                         tbWidth = parseInt(tbWidth[0].replace(/[^0-9]+/g, ''), 10);
31                 } else {
32                         tbWidth = $(window).width() - 90;
33                 }
34
35                 if ( tbHeight = href.match(/&tbHeight=[0-9]+/) ) {
36                         tbHeight = parseInt(tbHeight[0].replace(/[^0-9]+/g, ''), 10);
37                 } else {
38                         tbHeight = $(window).height() - 60;
39                 }
40
41                 if ( alink.length ) {
42                         url = alink.attr('href') || '';
43                         text = alink.attr('title') || '';
44                         link = '&nbsp; <a href="' + url + '" target="_top" class="tb-theme-preview-link">' + text + '</a>';
45                 } else {
46                         text = $(this).attr('title') || '';
47                         link = '&nbsp; <span class="tb-theme-preview-link">' + text + '</span>';
48                 }
49
50                 $('#TB_title').css({'background-color':'#222','color':'#dfdfdf'});
51                 $('#TB_closeAjaxWindow').css({'float':'left'});
52                 $('#TB_ajaxWindowTitle').css({'float':'right'}).html(link);
53
54                 $('#TB_iframeContent').width('100%');
55                 thickDims();
56
57                 return false;
58         } );
59 });