Jump to content

User:MindstormsKid/terabox.js

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by MindstormsKid (talk | contribs) at 01:11, 1 September 2009 (fix). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
addOnloadHook(function(){
$ = jQuery;
$.terabox = function(content){
	if (!$("#terabox:visible").length && $.terabox.s.overlay.on) {
		$("#terabox-overlay").css("opacity", 0).click($.terabox.hide).show().animate({ opacity: $.terabox.s.overlay.opacity }, $.terabox.s.speed * 0.8);
	}
	$("#terabox-content").html(content).css("max-height", $(window).height() - 200).parent().css("left", ($(window).width() / 2) - ($("#terabox").width() / 2)).show();
	$().bind("keydown.terabox", function(e){ if (e.keyCode == 27) { $.terabox.hide(); } });
};

$.fn.terabox = function(){
	$.terabox(this.html());
	return this;
};

$.terabox.s = { speed: 600, overlay: { opacity: 0.8, on: true } };

$.terabox.hide = function(){ $().trigger("hide.terabox"); };

$(function(){
	$("body").append(
		'<div id="terabox" style="position: fixed; top: 50px; display: none; z-index: 999; background-color: white; padding: 10px; border: 10px solid #525252;' +
			'-moz-border-radius: 6px; -webkit-border-radius: 6px; border-radius: 6px;">' + // epic, epic fail
			'<div id="terabox-content" style="width: 475px; overflow: auto;"></div><br>' +
			'<div id="terabox-footer" style="text-align: right; border-top: 1px solid #D6D7FF;">' +
				'<a href="#" style="font-size: 20px; font-family: Tahoma,Helvetica,Arial,sans-serif; font-weight: bold; color: #7A7A7A; text-decoration: none;' +
					'background: none;">CLOSE</a>' +
			'</div>' +
		'</div>' +
		'<div id="terabox-overlay" style="top: 0; left: 0; width: 100%; height: 100%; position: fixed; display: none; z-index: 998; background-color: black"></div>'
	);
	
	$().bind("hide.terabox", function(){
		$("#terabox").fadeOut($.terabox.s.speed, function(){ $("#terabox-overlay").fadeOut($.terabox.s.speed * 0.8); });
	});
	
	$("#terabox-footer a").click(function(){ $.terabox.hide(); return false; });
});
});