client/player/res/js/ui/jquery.effects.explode.js
author ymh <ymh.work@gmail.com>
Fri, 06 Aug 2010 16:29:21 +0200
changeset 30 2f27e07f9974
parent 29 client/player/res.new/js/ui/jquery.effects.explode.js@d969ba10156c
permissions -rw-r--r--
lowercase folder names
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
28
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
     1
/*
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
     2
 * jQuery UI Effects Explode 1.8.1
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
     3
 *
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
     4
 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
     5
 * Dual licensed under the MIT (MIT-LICENSE.txt)
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
     6
 * and GPL (GPL-LICENSE.txt) licenses.
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
     7
 *
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
     8
 * http://docs.jquery.com/UI/Effects/Explode
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
     9
 *
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    10
 * Depends:
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    11
 *	jquery.effects.core.js
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    12
 */
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    13
(function($) {
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    14
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    15
$.effects.explode = function(o) {
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    16
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    17
	return this.queue(function() {
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    18
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    19
	var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    20
	var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    21
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    22
	o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    23
	var el = $(this).show().css('visibility', 'hidden');
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    24
	var offset = el.offset();
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    25
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    26
	//Substract the margins - not fixing the problem yet.
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    27
	offset.top -= parseInt(el.css("marginTop"),10) || 0;
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    28
	offset.left -= parseInt(el.css("marginLeft"),10) || 0;
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    29
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    30
	var width = el.outerWidth(true);
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    31
	var height = el.outerHeight(true);
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    32
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    33
	for(var i=0;i<rows;i++) { // =
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    34
		for(var j=0;j<cells;j++) { // ||
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    35
			el
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    36
				.clone()
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    37
				.appendTo('body')
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    38
				.wrap('<div></div>')
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    39
				.css({
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    40
					position: 'absolute',
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    41
					visibility: 'visible',
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    42
					left: -j*(width/cells),
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    43
					top: -i*(height/rows)
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    44
				})
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    45
				.parent()
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    46
				.addClass('ui-effects-explode')
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    47
				.css({
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    48
					position: 'absolute',
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    49
					overflow: 'hidden',
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    50
					width: width/cells,
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    51
					height: height/rows,
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    52
					left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    53
					top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    54
					opacity: o.options.mode == 'show' ? 0 : 1
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    55
				}).animate({
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    56
					left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    57
					top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    58
					opacity: o.options.mode == 'show' ? 1 : 0
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    59
				}, o.duration || 500);
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    60
		}
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    61
	}
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    62
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    63
	// Set a timeout, to call the callback approx. when the other animations have finished
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    64
	setTimeout(function() {
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    65
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    66
		o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    67
				if(o.callback) o.callback.apply(el[0]); // Callback
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    68
				el.dequeue();
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    69
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    70
				$('div.ui-effects-explode').remove();
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    71
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    72
	}, o.duration || 500);
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    73
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    74
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    75
	});
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    76
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    77
};
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    78
44c6b827825d Commit new player (version radio) with new path organisation
hurons
parents:
diff changeset
    79
})(jQuery);