2 * jQuery UI Effects Explode 1.8.10
4 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5 * Dual licensed under the MIT or GPL Version 2 licenses.
6 * http://jquery.org/license
8 * http://docs.jquery.com/UI/Effects/Explode
11 * jquery.effects.core.js
13 (function( $, undefined ) {
15 $.effects.explode = function(o) {
17 return this.queue(function() {
19 var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
20 var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
22 o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;
23 var el = $(this).show().css('visibility', 'hidden');
24 var offset = el.offset();
26 //Substract the margins - not fixing the problem yet.
27 offset.top -= parseInt(el.css("marginTop"),10) || 0;
28 offset.left -= parseInt(el.css("marginLeft"),10) || 0;
30 var width = el.outerWidth(true);
31 var height = el.outerHeight(true);
33 for(var i=0;i<rows;i++) { // =
34 for(var j=0;j<cells;j++) { // ||
41 visibility: 'visible',
42 left: -j*(width/cells),
46 .addClass('ui-effects-explode')
52 left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
53 top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
54 opacity: o.options.mode == 'show' ? 0 : 1
56 left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
57 top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
58 opacity: o.options.mode == 'show' ? 1 : 0
59 }, o.duration || 500);
63 // Set a timeout, to call the callback approx. when the other animations have finished
64 setTimeout(function() {
66 o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
67 if(o.callback) o.callback.apply(el[0]); // Callback
70 $('div.ui-effects-explode').remove();
72 }, o.duration || 500);