From a370d1ffc8b0783a3a9ed1951e144902baddb264 Mon Sep 17 00:00:00 2001 From: gnarf Date: Wed, 2 Mar 2011 20:00:57 -0600 Subject: [PATCH] Just a quick touch to update to new internal effects object API --- ui/jquery.effects.clip.js | 13 ++++++------- ui/jquery.effects.drop.js | 15 +++++++-------- ui/jquery.effects.explode.js | 22 +++++++++++----------- ui/jquery.effects.fold.js | 12 ++++++------ ui/jquery.effects.highlight.js | 8 ++++---- ui/jquery.effects.pulsate.js | 10 +++++----- ui/jquery.effects.shake.js | 20 ++++++++++---------- ui/jquery.effects.slide.js | 10 +++++----- ui/jquery.effects.transfer.js | 8 ++++---- 9 files changed, 58 insertions(+), 60 deletions(-) diff --git a/ui/jquery.effects.clip.js b/ui/jquery.effects.clip.js index c0fe450c9..9c29d252d 100644 --- a/ui/jquery.effects.clip.js +++ b/ui/jquery.effects.clip.js @@ -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(); }}); diff --git a/ui/jquery.effects.drop.js b/ui/jquery.effects.drop.js index f13dda856..152da6b54 100644 --- a/ui/jquery.effects.drop.js +++ b/ui/jquery.effects.drop.js @@ -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(); }}); diff --git a/ui/jquery.effects.explode.js b/ui/jquery.effects.explode.js index 80e12770f..7dffed5ed 100644 --- a/ui/jquery.effects.explode.js +++ b/ui/jquery.effects.explode.js @@ -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(); diff --git a/ui/jquery.effects.fold.js b/ui/jquery.effects.fold.js index fa98ee2dd..9357868b7 100644 --- a/ui/jquery.effects.fold.js +++ b/ui/jquery.effects.fold.js @@ -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(); }); diff --git a/ui/jquery.effects.highlight.js b/ui/jquery.effects.highlight.js index 9a3edc5bc..6ca0d53c2 100644 --- a/ui/jquery.effects.highlight.js +++ b/ui/jquery.effects.highlight.js @@ -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(); } }); diff --git a/ui/jquery.effects.pulsate.js b/ui/jquery.effects.pulsate.js index 1b3cb00f8..e7d53d02d 100644 --- a/ui/jquery.effects.pulsate.js +++ b/ui/jquery.effects.pulsate.js @@ -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 diff --git a/ui/jquery.effects.shake.js b/ui/jquery.effects.shake.js index 14c941809..011bd6b54 100644 --- a/ui/jquery.effects.shake.js +++ b/ui/jquery.effects.shake.js @@ -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(); diff --git a/ui/jquery.effects.slide.js b/ui/jquery.effects.slide.js index 35a584fd9..57b60290e 100644 --- a/ui/jquery.effects.slide.js +++ b/ui/jquery.effects.slide.js @@ -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(); }}); diff --git a/ui/jquery.effects.transfer.js b/ui/jquery.effects.transfer.js index 4b4c41050..9765d4944 100644 --- a/ui/jquery.effects.transfer.js +++ b/ui/jquery.effects.transfer.js @@ -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 = $('
') .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(); }); }); -- 2.39.5