]> source.dussan.org Git - jquery-ui.git/commitdiff
Just a quick touch to update to new internal effects object API
authorgnarf <gnarf@gnarf.net>
Thu, 3 Mar 2011 02:00:57 +0000 (20:00 -0600)
committergnarf <gnarf@gnarf.net>
Thu, 3 Mar 2011 02:00:57 +0000 (20:00 -0600)
ui/jquery.effects.clip.js
ui/jquery.effects.drop.js
ui/jquery.effects.explode.js
ui/jquery.effects.fold.js
ui/jquery.effects.highlight.js
ui/jquery.effects.pulsate.js
ui/jquery.effects.shake.js
ui/jquery.effects.slide.js
ui/jquery.effects.transfer.js

index c0fe450c98ff468c5bba8ecd0b08c752d8b9966c..9c29d252df5e527e82a17bf2470039eb85e0dad9 100644 (file)
@@ -17,11 +17,10 @@ $.effects.clip = function(o) {
        return this.queue(function() {
 
                // Create element
-               var el = $(this), props = ['position','top','bottom','left','right','height','width'];
-
-               // Set options
-               var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
-               var direction = o.options.direction || 'vertical'; // Default direction
+               var el = $( this ), 
+                       props = ['position','top','bottom','left','right','height','width'], 
+                       mode = $.effects.setMode( el, o.mode || 'hide' ),
+                       direction = o.direction || 'vertical'; // Default direction
 
                // Adjust
                $.effects.save(el, props); el.show(); // Save & Show
@@ -40,10 +39,10 @@ $.effects.clip = function(o) {
                animation[ref.position] = mode == 'show' ? 0 : distance / 2;
 
                // Animate
-               animate.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
+               animate.animate(animation, { queue: false, duration: o.duration, easing: o.easing, complete: function() {
                        if(mode == 'hide') el.hide(); // Hide
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
-                       if(o.callback) o.callback.apply(el[0], arguments); // Callback
+                       if(o.complete) o.complete.apply(el[0], arguments); // Callback
                        el.dequeue();
                }});
 
index f13dda856c98dca636d87ceaee7c4bb0201a263f..152da6b54ef04b810c9ee7d9c5a87a9c2d07a6a5 100644 (file)
@@ -17,18 +17,17 @@ $.effects.drop = function(o) {
        return this.queue(function() {
 
                // Create element
-               var el = $(this), props = ['position','top','bottom','left','right','opacity'];
-
-               // Set options
-               var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
-               var direction = o.options.direction || 'left'; // Default Direction
+               var el = $( this ), 
+                       props = ['position','top','bottom','left','right','opacity'],
+                       mode = $.effects.setMode(el, o.mode || 'hide'),
+                       direction = o.direction || 'left'; // Default Direction
 
                // Adjust
                $.effects.save(el, props); el.show(); // Save & Show
                $.effects.createWrapper(el); // Create Wrapper
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
-               var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2);
+               var distance = o.distance || (ref == 'top' ? el.outerHeight({margin:true}) / 2 : el.outerWidth({margin:true}) / 2);
                if (mode == 'show') el.css('opacity', 0).css(ref, motion == 'pos' ? -distance : distance); // Shift
 
                // Animation
@@ -36,10 +35,10 @@ $.effects.drop = function(o) {
                animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
 
                // Animate
-               el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
+               el.animate(animation, { queue: false, duration: o.duration, easing: o.easing, complete: function() {
                        if(mode == 'hide') el.hide(); // Hide
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
-                       if(o.callback) o.callback.apply(this, arguments); // Callback
+                       if(o.complete) o.complete.apply(this, arguments); // Callback
                        el.dequeue();
                }});
 
index 80e12770fb293dfd9496771cfeaf3eda45c1c71b..7dffed5ed6b15ed9385052cd012c22a00e464ad7 100644 (file)
@@ -16,10 +16,10 @@ $.effects.explode = function(o) {
 
        return this.queue(function() {
 
-       var rows = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
-       var cells = o.options.pieces ? Math.round(Math.sqrt(o.options.pieces)) : 3;
+       var rows = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3;
+       var cells = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3;
 
-       o.options.mode = o.options.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.options.mode;
+       o.mode = o.mode == 'toggle' ? ($(this).is(':visible') ? 'hide' : 'show') : o.mode;
        var el = $(this).show().css('visibility', 'hidden');
        var offset = el.offset();
 
@@ -49,13 +49,13 @@ $.effects.explode = function(o) {
                                        overflow: 'hidden',
                                        width: width/cells,
                                        height: height/rows,
-                                       left: offset.left + j*(width/cells) + (o.options.mode == 'show' ? (j-Math.floor(cells/2))*(width/cells) : 0),
-                                       top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? (i-Math.floor(rows/2))*(height/rows) : 0),
-                                       opacity: o.options.mode == 'show' ? 0 : 1
+                                       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.options.mode == 'show' ? 0 : (j-Math.floor(cells/2))*(width/cells)),
-                                       top: offset.top + i*(height/rows) + (o.options.mode == 'show' ? 0 : (i-Math.floor(rows/2))*(height/rows)),
-                                       opacity: o.options.mode == 'show' ? 1 : 0
+                                       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);
                }
        }
@@ -63,8 +63,8 @@ $.effects.explode = function(o) {
        // Set a timeout, to call the callback approx. when the other animations have finished
        setTimeout(function() {
 
-               o.options.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
-                               if(o.callback) o.callback.apply(el[0]); // Callback
+               o.mode == 'show' ? el.css({ visibility: 'visible' }) : el.css({ visibility: 'visible' }).hide();
+                               if(o.complete) o.complete.apply(el[0]); // Callback
                                el.dequeue();
 
                                $('div.ui-effects-explode').remove();
index fa98ee2dd45e1ab22ba6f2ab3b38e223aeeeab18..9357868b75ad8752c8c6338d89b6de0d40d91fe8 100644 (file)
@@ -20,9 +20,9 @@ $.effects.fold = function(o) {
                var el = $(this), props = ['position','top','bottom','left','right'];
 
                // Set options
-               var mode = $.effects.setMode(el, o.options.mode || 'hide'); // Set Mode
-               var size = o.options.size || 15; // Default fold size
-               var horizFirst = !(!o.options.horizFirst); // Ensure a boolean value
+               var mode = $.effects.setMode(el, o.mode || 'hide'); // Set Mode
+               var size = o.size || 15; // Default fold size
+               var horizFirst = !(!o.horizFirst); // Ensure a boolean value
                var duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2;
 
                // Adjust
@@ -41,11 +41,11 @@ $.effects.fold = function(o) {
                animation2[ref[1]] = mode == 'show' ? distance[1] : 0;
 
                // Animate
-               wrapper.animate(animation1, duration, o.options.easing)
-               .animate(animation2, duration, o.options.easing, function() {
+               wrapper.animate(animation1, duration, o.easing)
+               .animate(animation2, duration, o.easing, function() {
                        if(mode == 'hide') el.hide(); // Hide
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
-                       if(o.callback) o.callback.apply(el[0], arguments); // Callback
+                       if(o.complete) o.complete.apply(el[0], arguments); // Callback
                        el.dequeue();
                });
 
index 9a3edc5bcfea0d2c3363af172027064af5cb224d..6ca0d53c25a60e5554491e17648521ac7e0f21b8 100644 (file)
@@ -16,7 +16,7 @@ $.effects.highlight = function(o) {
        return this.queue(function() {
                var elem = $(this),
                        props = ['backgroundImage', 'backgroundColor', 'opacity'],
-                       mode = $.effects.setMode(elem, o.options.mode || 'show'),
+                       mode = $.effects.setMode(elem, o.mode || 'show'),
                        animation = {
                                backgroundColor: elem.css('backgroundColor')
                        };
@@ -30,17 +30,17 @@ $.effects.highlight = function(o) {
                        .show()
                        .css({
                                backgroundImage: 'none',
-                               backgroundColor: o.options.color || '#ffff99'
+                               backgroundColor: o.color || '#ffff99'
                        })
                        .animate(animation, {
                                queue: false,
                                duration: o.duration,
-                               easing: o.options.easing,
+                               easing: o.easing,
                                complete: function() {
                                        (mode == 'hide' && elem.hide());
                                        $.effects.restore(elem, props);
                                        (mode == 'show' && !$.support.opacity && this.style.removeAttribute('filter'));
-                                       (o.callback && o.callback.apply(this, arguments));
+                                       (o.complete && o.complete.apply(this, arguments));
                                        elem.dequeue();
                                }
                        });
index 1b3cb00f8913ccd3e12582239f076216919125f6..e7d53d02d831b5829ee0dc72d88a81cfd689e2ce 100644 (file)
@@ -15,8 +15,8 @@
 $.effects.pulsate = function(o) {
        return this.queue(function() {
                var elem = $(this),
-                       mode = $.effects.setMode(elem, o.options.mode || 'show'),
-                       times = ((o.options.times || 5) * 2) - 1,
+                       mode = $.effects.setMode(elem, o.mode || 'show'),
+                       times = ((o.times || 5) * 2) - 1,
                        duration = o.duration ? o.duration / 2 : $.fx.speeds._default / 2,
                        isVisible = elem.is(':visible'),
                        animateTo = 0;
@@ -31,15 +31,15 @@ $.effects.pulsate = function(o) {
                }
 
                for (var i = 0; i < times; i++) {
-                       elem.animate({ opacity: animateTo }, duration, o.options.easing);
+                       elem.animate({ opacity: animateTo }, duration, o.easing);
                        animateTo = (animateTo + 1) % 2;
                }
 
-               elem.animate({ opacity: animateTo }, duration, o.options.easing, function() {
+               elem.animate({ opacity: animateTo }, duration, o.easing, function() {
                        if (animateTo == 0) {
                                elem.hide();
                        }
-                       (o.callback && o.callback.apply(this, arguments));
+                       (o.complete && o.complete.apply(this, arguments));
                });
 
                elem
index 14c94180936971cc96859a435aa56369f1853106..011bd6b54f9da3816af2dadd141200c71a09d753 100644 (file)
@@ -20,11 +20,11 @@ $.effects.shake = function(o) {
                var el = $(this), props = ['position','top','bottom','left','right'];
 
                // Set options
-               var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
-               var direction = o.options.direction || 'left'; // Default direction
-               var distance = o.options.distance || 20; // Default distance
-               var times = o.options.times || 3; // Default # of times
-               var speed = o.duration || o.options.duration || 140; // Default speed per shake
+               var mode = $.effects.setMode(el, o.mode || 'effect'); // Set Mode
+               var direction = o.direction || 'left'; // Default direction
+               var distance = o.distance || 20; // Default distance
+               var times = o.times || 3; // Default # of times
+               var speed = o.duration || o.duration || 140; // Default speed per shake
 
                // Adjust
                $.effects.save(el, props); el.show(); // Save & Show
@@ -39,14 +39,14 @@ $.effects.shake = function(o) {
                animation2[ref] = (motion == 'pos' ? '-=' : '+=')  + distance * 2;
 
                // Animate
-               el.animate(animation, speed, o.options.easing);
+               el.animate(animation, speed, o.easing);
                for (var i = 1; i < times; i++) { // Shakes
-                       el.animate(animation1, speed, o.options.easing).animate(animation2, speed, o.options.easing);
+                       el.animate(animation1, speed, o.easing).animate(animation2, speed, o.easing);
                };
-               el.animate(animation1, speed, o.options.easing).
-               animate(animation, speed / 2, o.options.easing, function(){ // Last shake
+               el.animate(animation1, speed, o.easing).
+               animate(animation, speed / 2, o.easing, function(){ // Last shake
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
-                       if(o.callback) o.callback.apply(this, arguments); // Callback
+                       if(o.complete) o.complete.apply(this, arguments); // Callback
                });
                el.queue('fx', function() { el.dequeue(); });
                el.dequeue();
index 35a584fd98ed2ce7a0a44c54f5a7b878e67a9067..57b60290e9684b7e19e5899486dc8ff1ce546252 100644 (file)
@@ -20,15 +20,15 @@ $.effects.slide = function(o) {
                var el = $(this), props = ['position','top','bottom','left','right'];
 
                // Set options
-               var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode
-               var direction = o.options.direction || 'left'; // Default Direction
+               var mode = $.effects.setMode(el, o.mode || 'show'); // Set Mode
+               var direction = o.direction || 'left'; // Default Direction
 
                // Adjust
                $.effects.save(el, props); el.show(); // Save & Show
                $.effects.createWrapper(el).css({overflow:'hidden'}); // Create Wrapper
                var ref = (direction == 'up' || direction == 'down') ? 'top' : 'left';
                var motion = (direction == 'up' || direction == 'left') ? 'pos' : 'neg';
-               var distance = o.options.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true}));
+               var distance = o.distance || (ref == 'top' ? el.outerHeight({margin:true}) : el.outerWidth({margin:true}));
                if (mode == 'show') el.css(ref, motion == 'pos' ? (isNaN(distance) ? "-" + distance : -distance) : distance); // Shift
 
                // Animation
@@ -36,10 +36,10 @@ $.effects.slide = function(o) {
                animation[ref] = (mode == 'show' ? (motion == 'pos' ? '+=' : '-=') : (motion == 'pos' ? '-=' : '+=')) + distance;
 
                // Animate
-               el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
+               el.animate(animation, { queue: false, duration: o.duration, easing: o.easing, complete: function() {
                        if(mode == 'hide') el.hide(); // Hide
                        $.effects.restore(el, props); $.effects.removeWrapper(el); // Restore
-                       if(o.callback) o.callback.apply(this, arguments); // Callback
+                       if(o.complete) o.complete.apply(this, arguments); // Callback
                        el.dequeue();
                }});
 
index 4b4c4105076c9f81ce761a74916a4e59a43ae02d..9765d49442c99bf61105988df5024f365a1da050 100644 (file)
@@ -15,7 +15,7 @@
 $.effects.transfer = function(o) {
        return this.queue(function() {
                var elem = $(this),
-                       target = $(o.options.to),
+                       target = $(o.to),
                        endPosition = target.offset(),
                        animation = {
                                top: endPosition.top,
@@ -26,7 +26,7 @@ $.effects.transfer = function(o) {
                        startPosition = elem.offset(),
                        transfer = $('<div class="ui-effects-transfer"></div>')
                                .appendTo(document.body)
-                               .addClass(o.options.className)
+                               .addClass(o.className)
                                .css({
                                        top: startPosition.top,
                                        left: startPosition.left,
@@ -34,9 +34,9 @@ $.effects.transfer = function(o) {
                                        width: elem.innerWidth(),
                                        position: 'absolute'
                                })
-                               .animate(animation, o.duration, o.options.easing, function() {
+                               .animate(animation, o.duration, o.easing, function() {
                                        transfer.remove();
-                                       (o.callback && o.callback.apply(elem[0], arguments));
+                                       (o.complete && o.complete.apply(elem[0], arguments));
                                        elem.dequeue();
                                });
        });