web/wp-admin/js/theme-preview.dev.js
author ymh <ymh.work@gmail.com>
Mon, 22 Mar 2010 16:36:28 +0100
changeset 5 ac511f1ccc8e
parent 1 0d28b7c10758
permissions -rw-r--r--
add hgignore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
0d28b7c10758 First commit
ymh
parents:
diff changeset
     1
0d28b7c10758 First commit
ymh
parents:
diff changeset
     2
var thickDims, tbWidth, tbHeight;
0d28b7c10758 First commit
ymh
parents:
diff changeset
     3
jQuery(document).ready(function($) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
     4
0d28b7c10758 First commit
ymh
parents:
diff changeset
     5
	thickDims = function() {
0d28b7c10758 First commit
ymh
parents:
diff changeset
     6
		var tbWindow = $('#TB_window'), H = $(window).height(), W = $(window).width(), w, h;
0d28b7c10758 First commit
ymh
parents:
diff changeset
     7
0d28b7c10758 First commit
ymh
parents:
diff changeset
     8
		w = (tbWidth && tbWidth < W - 90) ? tbWidth : W - 90;
0d28b7c10758 First commit
ymh
parents:
diff changeset
     9
		h = (tbHeight && tbHeight < H - 60) ? tbHeight : H - 60;
0d28b7c10758 First commit
ymh
parents:
diff changeset
    10
0d28b7c10758 First commit
ymh
parents:
diff changeset
    11
		if ( tbWindow.size() ) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    12
			tbWindow.width(w).height(h);
0d28b7c10758 First commit
ymh
parents:
diff changeset
    13
			$('#TB_iframeContent').width(w).height(h - 27);
0d28b7c10758 First commit
ymh
parents:
diff changeset
    14
			tbWindow.css({'margin-left': '-' + parseInt((w / 2),10) + 'px'});
0d28b7c10758 First commit
ymh
parents:
diff changeset
    15
			if ( typeof document.body.style.maxWidth != 'undefined' )
0d28b7c10758 First commit
ymh
parents:
diff changeset
    16
				tbWindow.css({'top':'30px','margin-top':'0'});
0d28b7c10758 First commit
ymh
parents:
diff changeset
    17
		}
0d28b7c10758 First commit
ymh
parents:
diff changeset
    18
	};
0d28b7c10758 First commit
ymh
parents:
diff changeset
    19
0d28b7c10758 First commit
ymh
parents:
diff changeset
    20
	thickDims();
0d28b7c10758 First commit
ymh
parents:
diff changeset
    21
	$(window).resize( function() { thickDims() } );
0d28b7c10758 First commit
ymh
parents:
diff changeset
    22
0d28b7c10758 First commit
ymh
parents:
diff changeset
    23
	$('a.thickbox-preview').click( function() {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    24
		var alink = $(this).parents('.available-theme').find('.activatelink'), link = '', href = $(this).attr('href'), url, text;
0d28b7c10758 First commit
ymh
parents:
diff changeset
    25
0d28b7c10758 First commit
ymh
parents:
diff changeset
    26
		if ( tbWidth = href.match(/&tbWidth=[0-9]+/) )
0d28b7c10758 First commit
ymh
parents:
diff changeset
    27
			tbWidth = parseInt(tbWidth[0].replace(/[^0-9]+/g, ''), 10);
0d28b7c10758 First commit
ymh
parents:
diff changeset
    28
		else
0d28b7c10758 First commit
ymh
parents:
diff changeset
    29
			tbWidth = $(window).width() - 90;
0d28b7c10758 First commit
ymh
parents:
diff changeset
    30
0d28b7c10758 First commit
ymh
parents:
diff changeset
    31
		if ( tbHeight = href.match(/&tbHeight=[0-9]+/) )
0d28b7c10758 First commit
ymh
parents:
diff changeset
    32
			tbHeight = parseInt(tbHeight[0].replace(/[^0-9]+/g, ''), 10);
0d28b7c10758 First commit
ymh
parents:
diff changeset
    33
		else
0d28b7c10758 First commit
ymh
parents:
diff changeset
    34
			tbHeight = $(window).height() - 60;
0d28b7c10758 First commit
ymh
parents:
diff changeset
    35
0d28b7c10758 First commit
ymh
parents:
diff changeset
    36
		if ( alink.length ) {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    37
			url = alink.attr('href') || '';
0d28b7c10758 First commit
ymh
parents:
diff changeset
    38
			text = alink.attr('title') || '';
0d28b7c10758 First commit
ymh
parents:
diff changeset
    39
			link = '&nbsp; <a href="' + url + '" target="_top" class="tb-theme-preview-link">' + text + '</a>';
0d28b7c10758 First commit
ymh
parents:
diff changeset
    40
		} else {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    41
			text = $(this).attr('title') || '';
0d28b7c10758 First commit
ymh
parents:
diff changeset
    42
			link = '&nbsp; <span class="tb-theme-preview-link">' + text + '</span>';
0d28b7c10758 First commit
ymh
parents:
diff changeset
    43
		}
0d28b7c10758 First commit
ymh
parents:
diff changeset
    44
0d28b7c10758 First commit
ymh
parents:
diff changeset
    45
		$('#TB_title').css({'background-color':'#222','color':'#dfdfdf'});
0d28b7c10758 First commit
ymh
parents:
diff changeset
    46
		$('#TB_closeAjaxWindow').css({'float':'left'});
0d28b7c10758 First commit
ymh
parents:
diff changeset
    47
		$('#TB_ajaxWindowTitle').css({'float':'right'}).html(link);
0d28b7c10758 First commit
ymh
parents:
diff changeset
    48
0d28b7c10758 First commit
ymh
parents:
diff changeset
    49
		$('#TB_iframeContent').width('100%');
0d28b7c10758 First commit
ymh
parents:
diff changeset
    50
		thickDims();
0d28b7c10758 First commit
ymh
parents:
diff changeset
    51
		return false;
0d28b7c10758 First commit
ymh
parents:
diff changeset
    52
	} );
0d28b7c10758 First commit
ymh
parents:
diff changeset
    53
0d28b7c10758 First commit
ymh
parents:
diff changeset
    54
	// Theme details
0d28b7c10758 First commit
ymh
parents:
diff changeset
    55
	$('.theme-detail').click(function () {
0d28b7c10758 First commit
ymh
parents:
diff changeset
    56
		$(this).siblings('.themedetaildiv').toggle();
0d28b7c10758 First commit
ymh
parents:
diff changeset
    57
		return false;
0d28b7c10758 First commit
ymh
parents:
diff changeset
    58
	});
0d28b7c10758 First commit
ymh
parents:
diff changeset
    59
0d28b7c10758 First commit
ymh
parents:
diff changeset
    60
});
0d28b7c10758 First commit
ymh
parents:
diff changeset
    61