From cc657e52cc793cb193df9c8f8ef9efadd6d7e819 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 5 Nov 2015 19:18:49 -0500 Subject: loader on product view --- StoneIsland/www/js/lib/products/GalleryView.js | 5 +++++ StoneIsland/www/js/lib/products/ProductView.js | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'StoneIsland/www/js') diff --git a/StoneIsland/www/js/lib/products/GalleryView.js b/StoneIsland/www/js/lib/products/GalleryView.js index a139c454..ea4637eb 100644 --- a/StoneIsland/www/js/lib/products/GalleryView.js +++ b/StoneIsland/www/js/lib/products/GalleryView.js @@ -15,6 +15,11 @@ var GalleryView = View.extend({ this.$(".template").remove() }, + reset: function(){ + this.gallery && this.gallery.destroy() + this.$el.empty() + }, + populate: function(code, image_ids){ var valid_styles = {} image_ids.forEach(function(id){ diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js index a179d227..c5a7ff29 100644 --- a/StoneIsland/www/js/lib/products/ProductView.js +++ b/StoneIsland/www/js/lib/products/ProductView.js @@ -44,8 +44,10 @@ var ProductView = ScrollableView.extend({ cache: {}, load: function(code, data){ + this.gallery.reset() this.show() if (! app.collection.loaded) { + this.el.className = "loading" app.collection.afterFetchCallback = this.load.bind(this, code, data) app.collection.fetch() return @@ -58,6 +60,9 @@ var ProductView = ScrollableView.extend({ if (code in this.cache) { return this.populate(data, this.cache[code]) } + else { + this.el.className = "loading" + } sdk.product.item({ code: code, success: function(details){ @@ -68,7 +73,7 @@ var ProductView = ScrollableView.extend({ }, populate: function(data, details){ - this.show() + this.el.className = "" console.log(data, details) var descriptions = {} @@ -86,7 +91,7 @@ var ProductView = ScrollableView.extend({ var size_label = SIZE_LOOKUP[size] var color = data['Colors'].length && data['Colors'][0] var color_label = color && color['Text'] - var body = descriptions['EditorialDescription'] + var body = descriptions['EditorialDescription'].replace(/
/g, "

") this.item = data this.color = color -- cgit v1.2.3-70-g09d2