X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/8a06f4f9392d1ac373442f82ee40428a3cb81395..a567eab022addf31c8b551a2bd6d47601d6623d8:/wp-admin/js/theme-preview.js diff --git a/wp-admin/js/theme-preview.js b/wp-admin/js/theme-preview.js index f4f85e8b..28d93cfc 100644 --- a/wp-admin/js/theme-preview.js +++ b/wp-admin/js/theme-preview.js @@ -1,44 +1,59 @@ +/* global tb_click */ +var thickDims, tbWidth, tbHeight; +jQuery(document).ready(function($) { -jQuery(function($) { - if ( 'undefined' == typeof $.fn.pngFix ) - $.fn.pngFix = function() { return this; } + thickDims = function() { + var tbWindow = $('#TB_window'), H = $(window).height(), W = $(window).width(), w, h; - var thickDims = function() { - var tbWindow = $('#TB_window'); - var H = $(window).height(); - var W = $(window).width(); + w = (tbWidth && tbWidth < W - 90) ? tbWidth : W - 90; + h = (tbHeight && tbHeight < H - 60) ? tbHeight : H - 60; if ( tbWindow.size() ) { - tbWindow.width( W - 90 ).height( H - 60 ); - $('#TB_iframeContent').width( W - 90 ).height( H - 90 ); - tbWindow.css({'margin-left': '-' + parseInt((( W - 90 ) / 2),10) + 'px'}); - if ( typeof document.body.style.maxWidth != 'undefined' ) + tbWindow.width(w).height(h); + $('#TB_iframeContent').width(w).height(h - 27); + tbWindow.css({'margin-left': '-' + parseInt((w / 2),10) + 'px'}); + if ( typeof document.body.style.maxWidth !== 'undefined' ) { tbWindow.css({'top':'30px','margin-top':'0'}); - }; - - return $('a.thickbox').each( function() { - var href = $(this).parents('.available-theme').find('.previewlink').attr('href'); - if ( ! href ) return; - href = href.replace(/&width=[0-9]+/g, ''); - href = href.replace(/&height=[0-9]+/g, ''); - $(this).attr( 'href', href + '&width=' + ( W - 110 ) + '&height=' + ( H - 100 ) ); - }); + } + } }; - thickDims() - .click( function() { - var alink = $(this).parents('.available-theme').find('.activatelink'); - var url = alink.attr('href'); - var text = alink.html(); + thickDims(); + $(window).resize( function() { thickDims(); } ); - $('#TB_title').css({'background-color':'#222','color':'#cfcfcf'}); + $('a.thickbox-preview').click( function() { + tb_click.call(this); + + var alink = $(this).parents('.available-theme').find('.activatelink'), link = '', href = $(this).attr('href'), url, text; + + if ( tbWidth = href.match(/&tbWidth=[0-9]+/) ) { + tbWidth = parseInt(tbWidth[0].replace(/[^0-9]+/g, ''), 10); + } else { + tbWidth = $(window).width() - 90; + } + + if ( tbHeight = href.match(/&tbHeight=[0-9]+/) ) { + tbHeight = parseInt(tbHeight[0].replace(/[^0-9]+/g, ''), 10); + } else { + tbHeight = $(window).height() - 60; + } + + if ( alink.length ) { + url = alink.attr('href') || ''; + text = alink.attr('title') || ''; + link = '  ' + text + ''; + } else { + text = $(this).attr('title') || ''; + link = '  ' + text + ''; + } + + $('#TB_title').css({'background-color':'#222','color':'#dfdfdf'}); $('#TB_closeAjaxWindow').css({'float':'left'}); - $('#TB_ajaxWindowTitle').css({'float':'right'}) - .append(' ' + text + ''); + $('#TB_ajaxWindowTitle').css({'float':'right'}).html(link); $('#TB_iframeContent').width('100%'); + thickDims(); + return false; } ); - - $(window).resize( function() { thickDims() } ); });