commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / bower_components / jquery-ui / ui / effect-explode.js
1 /*!
2 * jQuery UI Effects Explode 1.11.4
3 * http://jqueryui.com
4 *
5 * Copyright jQuery Foundation and other contributors
6 * Released under the MIT license.
7 * http://jquery.org/license
8 *
9 * http://api.jqueryui.com/explode-effect/
10 */
11 (function( factory ) {
12 if ( typeof define === "function" && define.amd ) {
13
14 // AMD. Register as an anonymous module.
15 define([
16 "jquery",
17 "./effect"
18 ], factory );
19 } else {
20
21 // Browser globals
22 factory( jQuery );
23 }
24 }(function( $ ) {
25
26 return $.effects.effect.explode = function( o, done ) {
27
28 var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
29 cells = rows,
30 el = $( this ),
31 mode = $.effects.setMode( el, o.mode || "hide" ),
32 show = mode === "show",
33
34 // show and then visibility:hidden the element before calculating offset
35 offset = el.show().css( "visibility", "hidden" ).offset(),
36
37 // width and height of a piece
38 width = Math.ceil( el.outerWidth() / cells ),
39 height = Math.ceil( el.outerHeight() / rows ),
40 pieces = [],
41
42 // loop
43 i, j, left, top, mx, my;
44
45 // children animate complete:
46 function childComplete() {
47 pieces.push( this );
48 if ( pieces.length === rows * cells ) {
49 animComplete();
50 }
51 }
52
53 // clone the element for each row and cell.
54 for ( i = 0; i < rows ; i++ ) { // ===>
55 top = offset.top + i * height;
56 my = i - ( rows - 1 ) / 2 ;
57
58 for ( j = 0; j < cells ; j++ ) { // |||
59 left = offset.left + j * width;
60 mx = j - ( cells - 1 ) / 2 ;
61
62 // Create a clone of the now hidden main element that will be absolute positioned
63 // within a wrapper div off the -left and -top equal to size of our pieces
64 el
65 .clone()
66 .appendTo( "body" )
67 .wrap( "<div></div>" )
68 .css({
69 position: "absolute",
70 visibility: "visible",
71 left: -j * width,
72 top: -i * height
73 })
74
75 // select the wrapper - make it overflow: hidden and absolute positioned based on
76 // where the original was located +left and +top equal to the size of pieces
77 .parent()
78 .addClass( "ui-effects-explode" )
79 .css({
80 position: "absolute",
81 overflow: "hidden",
82 width: width,
83 height: height,
84 left: left + ( show ? mx * width : 0 ),
85 top: top + ( show ? my * height : 0 ),
86 opacity: show ? 0 : 1
87 }).animate({
88 left: left + ( show ? 0 : mx * width ),
89 top: top + ( show ? 0 : my * height ),
90 opacity: show ? 1 : 0
91 }, o.duration || 500, o.easing, childComplete );
92 }
93 }
94
95 function animComplete() {
96 el.css({
97 visibility: "visible"
98 });
99 $( pieces ).remove();
100 if ( !show ) {
101 el.hide();
102 }
103 done();
104 }
105 };
106
107 }));