summaryrefslogtreecommitdiffstats
path: root/module/web/static/js/utils/animations.js
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-09-18 17:59:50 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-09-18 17:59:50 +0200
commit6130a2377ca6754fee88773097ce220abef1aa47 (patch)
tree76bea0d76393100fcf393c164c96d34f286aba7a /module/web/static/js/utils/animations.js
parentAdded DuckcryptInfo decrypter, smaller fixes (diff)
parentdropdowns in navbar (diff)
downloadpyload-6130a2377ca6754fee88773097ce220abef1aa47.tar.xz
merged stable into default
Diffstat (limited to 'module/web/static/js/utils/animations.js')
-rw-r--r--module/web/static/js/utils/animations.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/module/web/static/js/utils/animations.js b/module/web/static/js/utils/animations.js
new file mode 100644
index 000000000..9b1448f61
--- /dev/null
+++ b/module/web/static/js/utils/animations.js
@@ -0,0 +1,36 @@
+define(['jquery', 'underscore', 'transit'], function(jQuery, _) {
+
+ // Overwrite common animations with transitions
+ jQuery.each({
+ fadeIn: { opacity: "show" },
+ fadeOut: { opacity: "hide" }
+ }, function(name, props) {
+ jQuery.fn[ name ] = function(speed, easing, callback) {
+ return this.transition(props, speed, easing, callback);
+ };
+ });
+
+ jQuery.fn._transit = jQuery.fn.transit;
+
+ // Over riding transit plugin to support hide and show
+ // Props retains it properties across multiple calls, therefore props.show value is introduced
+ jQuery.fn.transit = jQuery.fn.transition = function(props, duration, easing, callback) {
+ var self = this;
+ var cb = callback;
+ if (props && (props.opacity === 'hide' || (props.opacity === 0 && props.show === true))) {
+ props.opacity = 0;
+ props.show = true;
+
+ callback = function() {
+ self.css({display: 'none'});
+ if (typeof cb === 'function') { cb.apply(self); }
+ };
+ } else if (props && (props.opacity === 'show' || (props.opacity === 1 && props.show === true))) {
+ props.opacity = 1;
+ props.show = true;
+ this.css({display: 'block'});
+ }
+
+ return this._transit(props, duration, easing, callback);
+ };
+}); \ No newline at end of file