From 0541a50bae77fca45c9b6d633b39595b4d933103 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 26 Jan 2013 23:33:55 +0100 Subject: little fixes, added pyload logo as svg --- module/web/static/js/utils/animations.js | 24 ++++++++++++++++++++++++ module/web/static/js/views/packageView.js | 16 +--------------- 2 files changed, 25 insertions(+), 15 deletions(-) (limited to 'module/web/static/js') diff --git a/module/web/static/js/utils/animations.js b/module/web/static/js/utils/animations.js index aa48c6f00..657bd2bec 100644 --- a/module/web/static/js/utils/animations.js +++ b/module/web/static/js/utils/animations.js @@ -1,7 +1,31 @@ define(['jquery', 'underscore', 'transit'], function(jQuery, _) { + // Adds an element and computes its height, which is saved as data attribute + // Important function to have slide animations + jQuery.fn.appendWithHeight = function(element, hide) { + var o = jQuery(this[0]); + + // 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 + element.css('visibility', 'hidden'); + o.append(element); + + var height = element.height(); + + // Hide the element + if (hide === true) { + element.hide(); + element.height(0); + } + + element.css('visibility', ''); + element.data('height', height); + + return this; + }; // TODO: sloppy chaining + // // in functions not possible without previous out jQuery.fn.zapIn = function(speed, easing, callback) { diff --git a/module/web/static/js/views/packageView.js b/module/web/static/js/views/packageView.js index 5d8aa7738..2c1541c7f 100644 --- a/module/web/static/js/views/packageView.js +++ b/module/web/static/js/views/packageView.js @@ -53,22 +53,8 @@ define(['jquery', 'views/abstract/itemView', 'underscore', 'views/fileView'], ul.append(new fileView({model: file}).render().el); }); - // 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'); - this.$el.append(ul); - - var height = ul.height(); - // Hide the element when not expanded - if (!this.expanded) { - ul.hide(); - ul.height(0); - } - - ul.css('visibility', ''); - ul.data('height', height); - console.log(ul.data("height")); + this.$el.appendWithHeight(ul, !this.expanded); this.ul = ul; } -- cgit v1.2.3