summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-01-12 21:20:41 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-01-12 21:20:41 +0100
commit8a40b530aebc974e4c5b140d30f12573705b6c27 (patch)
tree33f0142b22135aab00e2e1c9054e2233cff8b9c1
parentrender the settings menu (diff)
downloadpyload-8a40b530aebc974e4c5b140d30f12573705b6c27.tar.xz
added animation for packages
-rw-r--r--module/web/static/js/utils/animations.js9
-rw-r--r--module/web/static/js/views/packageView.js25
-rw-r--r--module/web/static/js/views/settingsView.js1
3 files changed, 20 insertions, 15 deletions
diff --git a/module/web/static/js/utils/animations.js b/module/web/static/js/utils/animations.js
index a1ec5d5e1..aa48c6f00 100644
--- a/module/web/static/js/utils/animations.js
+++ b/module/web/static/js/utils/animations.js
@@ -1,14 +1,5 @@
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);
- };
- });
// TODO: sloppy chaining
// in functions not possible without previous out
diff --git a/module/web/static/js/views/packageView.js b/module/web/static/js/views/packageView.js
index 844c6fa0a..365f3a69f 100644
--- a/module/web/static/js/views/packageView.js
+++ b/module/web/static/js/views/packageView.js
@@ -49,13 +49,27 @@ define(['jquery', 'views/abstract/itemView', 'underscore', 'views/fileView'],
var ul = $('<ul></ul>');
ul.addClass('file-items');
- if (!this.expanded)
- ul.hide();
-
this.model.get('files').each(function(file) {
ul.append(new fileView({model: file}).render().el);
});
+
this.$el.append(ul);
+
+ // TODO: additionally it could be placed out of viewport first
+ // The real height can only be retrieved when element is on DOM and display:true
+ ul.css('visibility', 'hidden');
+ var height = ul.height();
+ ul.css('visibility', '');
+
+ // Hide the element when not expanded
+ if (!this.expanded) {
+ ul.hide();
+ ul.height(0);
+ }
+
+ ul.data('height', height);
+ console.log(ul.data("height"));
+
this.ul = ul;
}
return this;
@@ -70,7 +84,6 @@ define(['jquery', 'views/abstract/itemView', 'underscore', 'views/fileView'],
// TODO destroy the fileViews ?
},
- // TODO: animation
// Toggle expanding of packages
expand: function(e) {
e.preventDefault();
@@ -80,12 +93,12 @@ define(['jquery', 'views/abstract/itemView', 'underscore', 'views/fileView'],
if (!this.expanded) {
this.model.fetch({silent: true, success: function() {
self.render(true);
- self.ul.show();
+ self.ul.animate({height: self.ul.data('height'), opacity: 'show'});
self.expanded = true;
}});
} else {
this.expanded = false;
- this.ul.hide();
+ this.ul.animate({height: 0, opacity: 'hide'});
}
},
diff --git a/module/web/static/js/views/settingsView.js b/module/web/static/js/views/settingsView.js
index 8372f77c1..aba16eb66 100644
--- a/module/web/static/js/views/settingsView.js
+++ b/module/web/static/js/views/settingsView.js
@@ -49,6 +49,7 @@ define(['jquery', 'underscore', 'backbone'],
this.menu.find("li.active").removeClass("active");
el.addClass("active");
+ e.preventDefault();
}
});