]> source.dussan.org Git - jquery-ui.git/commitdiff
effects.*: More Style Guidance
authorgnarf <gnarf@gnarf.net>
Sun, 6 Mar 2011 21:24:24 +0000 (15:24 -0600)
committergnarf <gnarf@gnarf.net>
Sun, 6 Mar 2011 21:24:24 +0000 (15:24 -0600)
ui/jquery.effects.blind.js
ui/jquery.effects.explode.js
ui/jquery.effects.fade.js

index 0bf5b0b719931c650cf8c7ef69fb44d9429349b2..814649a0406e92951a0fe847c28185561b61bae7 100644 (file)
@@ -16,11 +16,11 @@ $.effects.blind = function(o) {
 
        return this.queue(function() {
                // Create element
-               var el = $(this), 
+               var el = $( this ), 
                        props = ['position','top','bottom','left','right'],
                        mode = $.effects.setMode( el, o.mode || 'hide' ),
                        direction = o.direction || 'vertical',
-                       ref = (direction == 'vertical') ? 'height' : 'width',
+                       ref = ( direction == 'vertical' ) ? 'height' : 'width',
                        animation = {},
                        wrapper, distance;
 
index 7dffed5ed6b15ed9385052cd012c22a00e464ad7..763092457fb52c58037eb8fea4235f8f4c696580 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.explode = function(o) {
+$.effects.explode = function( o ) {
 
-       return this.queue(function() {
+       return this.queue( function() {
 
-       var rows = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3;
-       var cells = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3;
+               var rows = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3,
+                       cells = rows,
+                       el = $( this ).show().css( 'visibility', 'hidden' ),
+                       mode = $.effects.setMode( el, o.mode || 'hide' ),
+                       offset = el.offset(),
+                       width = el.outerWidth( true ),
+                       height = el.outerHeight( true );
 
-       o.mode = o.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.mode;
-       var el = $(this).show().css('visibility', 'hidden');
-       var offset = el.offset();
+               //Substract the margins - not fixing the problem yet.
+               offset.top -= parseInt( el.css( "marginTop" ), 10 ) || 0;
+               offset.left -= parseInt( el.css( "marginLeft" ), 10 ) || 0;
 
-       //Substract the margins - not fixing the problem yet.
-       offset.top -= parseInt(el.css("marginTop"),10) || 0;
-       offset.left -= parseInt(el.css("marginLeft"),10) || 0;
-
-       var width = el.outerWidth(true);
-       var height = el.outerHeight(true);
-
-       for(var i=0;i<rows;i++) { // =
-               for(var j=0;j<cells;j++) { // ||
-                       el
-                               .clone()
-                               .appendTo('body')
-                               .wrap('<div></div>')
-                               .css({
-                                       position: 'absolute',
-                                       visibility: 'visible',
-                                       left: -j*(width/cells),
-                                       top: -i*(height/rows)
-                               })
-                               .parent()
-                               .addClass('ui-effects-explode')
-                               .css({
-                                       position: 'absolute',
-                                       overflow: 'hidden',
-                                       width: width/cells,
-                                       height: height/rows,
-                                       left: offset.left + j*(width/cells) + (o.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
-                                       top: offset.top + i*(height/rows) + (o.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
-                                       opacity: o.mode == 'show' ? 0 : 1
-                               }).animate({
-                                       left: offset.left + j*(width/cells) + (o.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
-                                       top: offset.top + i*(height/rows) + (o.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
-                                       opacity: o.mode == 'show' ? 1 : 0
-                               }, o.duration || 500);
+               for( var i = 0; i < rows ; i++ ) { // =
+                       for( var j = 0; j < cells ; j++ ) { // ||
+                               el
+                                       .clone()
+                                       .appendTo('body')
+                                       .wrap('<div></div>')
+                                       .css({
+                                               position: 'absolute',
+                                               visibility: 'visible',
+                                               left: -j*(width/cells),
+                                               top: -i*(height/rows)
+                                       })
+                                       .parent()
+                                       .addClass('ui-effects-explode')
+                                       .css({
+                                               position: 'absolute',
+                                               overflow: 'hidden',
+                                               width: width/cells,
+                                               height: height/rows,
+                                               left: offset.left + j*(width/cells) + (o.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
+                                               top: offset.top + i*(height/rows) + (o.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
+                                               opacity: mode == 'show' ? 0 : 1
+                                       }).animate({
+                                               left: offset.left + j*(width/cells) + (o.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
+                                               top: offset.top + i*(height/rows) + (o.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
+                                               opacity: mode == 'show' ? 1 : 0
+                                       }, o.duration || 500);
+                       }
                }
-       }
-
-       // Set a timeout, to call the callback approx. when the other animations have finished
-       setTimeout(function() {
 
-               o.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
-                               if(o.complete) o.complete.apply(el[0]); // Callback
-                               el.dequeue();
+               // Set a timeout, to call the callback approx. when the other animations have finished
+               setTimeout(function() {
 
-                               $('div.ui-effects-explode').remove();
+                       el.css({ visibility: 'visible' });
+                       mode != 'show' && el.hide();
+                       $.isFunction( o.complete ) && o.complete.apply( el[ 0 ] );
+                       el.dequeue();
 
-       }, o.duration || 500);
+                       // Note: This is removing all exploding peices from the dom, rather than the ones for this animation only... Ticket# 6022
+                       $('div.ui-effects-explode').remove();
+               }, o.duration || 500);
 
 
        });
index 9fa8a79c41234abef41159cb527613633af51d17..c6cb85cc212d5bcb34c6245a4ce4cf1047642c3e 100644 (file)
  */
 (function( $, undefined ) {
 
-$.effects.fade = function(o) {
-       return this.queue(function() {
-               var elem = $(this),
-                       mode = $.effects.setMode(elem, o.options.mode || 'hide');
+$.effects.fade = function( o ) {
+       return this.queue( function() {
+               var el = $( this ),
+                       mode = $.effects.setMode( el, o.mode || 'hide' );
 
-               elem.animate({ opacity: mode }, {
+               el.animate({ 
+                       opacity: mode 
+               }, {
                        queue: false,
                        duration: o.duration,
-                       easing: o.options.easing,
+                       easing: o.easing,
                        complete: function() {
-                               (o.callback && o.callback.apply(this, arguments));
-                               elem.dequeue();
+                               jQuery.isFunction( o.complete ) && o.complete.apply( this, arguments );
+                               el.dequeue();
                        }
                });
        });