aboutsummaryrefslogtreecommitdiffstats
path: root/ui/source/effects.fade.js
diff options
context:
space:
mode:
authorPaul Bakaus <paul.bakaus@googlemail.com>2008-05-23 09:26:18 +0000
committerPaul Bakaus <paul.bakaus@googlemail.com>2008-05-23 09:26:18 +0000
commitab281b36d7cc10913a77f2f8da9ff7b7c011b3ee (patch)
treee75c648d2ee6a4fb467a2f1a2d092e1544a938a5 /ui/source/effects.fade.js
parent489160abd896aac7c140775207d18a3bf489c08f (diff)
downloadjquery-ui-ab281b36d7cc10913a77f2f8da9ff7b7c011b3ee.tar.gz
jquery-ui-ab281b36d7cc10913a77f2f8da9ff7b7c011b3ee.zip
Diffstat (limited to 'ui/source/effects.fade.js')
-rw-r--r--ui/source/effects.fade.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/ui/source/effects.fade.js b/ui/source/effects.fade.js
new file mode 100644
index 000000000..2d265bfc5
--- /dev/null
+++ b/ui/source/effects.fade.js
@@ -0,0 +1,35 @@
+;(function($) {
+
+ $.effects.fade = function(o) {
+
+ return this.queue(function() {
+
+ // Create element
+ var el = $(this), props = ['opacity'];
+
+ // Set options
+ var mode = $.effects.setMode(el, o.options.mode || 'effect'); // Set Mode
+ if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle
+ var opacity = o.options.opacity || 0; // Default fade opacity
+ var original_opacity = el.css('opacity');
+
+ // Adjust
+ $.effects.save(el, props); el.show(); // Save & Show
+ if(mode == 'show') el.css({opacity: 0}); // Shift
+
+ // Animation
+ var animation = {opacity: mode == 'show' ? original_opacity : opacity};
+
+ // Animate
+ el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() {
+ if(mode == 'hide') el.hide(); // Hide
+ if(mode == 'hide') $.effects.restore(el, props); // Restore
+ if(o.callback) o.callback.apply(this, arguments); // Callback
+ el.dequeue();
+ }});
+
+ });
+
+ };
+
+})(jQuery); \ No newline at end of file