web/wp-admin/js/theme-preview.js
changeset 204 09a1c134465b
parent 194 32102edaa81b
--- a/web/wp-admin/js/theme-preview.js	Wed Dec 19 12:35:13 2012 -0800
+++ b/web/wp-admin/js/theme-preview.js	Wed Dec 19 17:46:52 2012 -0800
@@ -1,1 +1,56 @@
-var thickDims,tbWidth,tbHeight;jQuery(document).ready(function(a){thickDims=function(){var f=a("#TB_window"),d=a(window).height(),b=a(window).width(),c,e;c=(tbWidth&&tbWidth<b-90)?tbWidth:b-90;e=(tbHeight&&tbHeight<d-60)?tbHeight:d-60;if(f.size()){f.width(c).height(e);a("#TB_iframeContent").width(c).height(e-27);f.css({"margin-left":"-"+parseInt((c/2),10)+"px"});if(typeof document.body.style.maxWidth!="undefined"){f.css({top:"30px","margin-top":"0"})}}};thickDims();a(window).resize(function(){thickDims()});a("a.thickbox-preview").click(function(){tb_click.call(this);var d=a(this).parents(".available-theme").find(".activatelink"),e="",b=a(this).attr("href"),c,f;if(tbWidth=b.match(/&tbWidth=[0-9]+/)){tbWidth=parseInt(tbWidth[0].replace(/[^0-9]+/g,""),10)}else{tbWidth=a(window).width()-90}if(tbHeight=b.match(/&tbHeight=[0-9]+/)){tbHeight=parseInt(tbHeight[0].replace(/[^0-9]+/g,""),10)}else{tbHeight=a(window).height()-60}if(d.length){c=d.attr("href")||"";f=d.attr("title")||"";e='&nbsp; <a href="'+c+'" target="_top" class="tb-theme-preview-link">'+f+"</a>"}else{f=a(this).attr("title")||"";e='&nbsp; <span class="tb-theme-preview-link">'+f+"</span>"}a("#TB_title").css({"background-color":"#222",color:"#dfdfdf"});a("#TB_closeAjaxWindow").css({"float":"left"});a("#TB_ajaxWindowTitle").css({"float":"right"}).html(e);a("#TB_iframeContent").width("100%");thickDims();return false})});
\ No newline at end of file
+
+var thickDims, tbWidth, tbHeight;
+jQuery(document).ready(function($) {
+
+	thickDims = function() {
+		var tbWindow = $('#TB_window'), H = $(window).height(), W = $(window).width(), w, h;
+
+		w = (tbWidth && tbWidth < W - 90) ? tbWidth : W - 90;
+		h = (tbHeight && tbHeight < H - 60) ? tbHeight : H - 60;
+
+		if ( tbWindow.size() ) {
+			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'});
+		}
+	};
+
+	thickDims();
+	$(window).resize( function() { thickDims() } );
+
+	$('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 = '&nbsp; <a href="' + url + '" target="_top" class="tb-theme-preview-link">' + text + '</a>';
+		} else {
+			text = $(this).attr('title') || '';
+			link = '&nbsp; <span class="tb-theme-preview-link">' + text + '</span>';
+		}
+
+		$('#TB_title').css({'background-color':'#222','color':'#dfdfdf'});
+		$('#TB_closeAjaxWindow').css({'float':'left'});
+		$('#TB_ajaxWindowTitle').css({'float':'right'}).html(link);
+
+		$('#TB_iframeContent').width('100%');
+		thickDims();
+
+		return false;
+	} );
+});