diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-05 01:02:20 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-05 01:02:20 -0500 |
| commit | 4a04a1129fffd1e128e53ba7886777c8d7b36b55 (patch) | |
| tree | 79d394f2e14909e234ce8ffb9e1dfe5244678d23 /StoneIsland/www/js/lib/products | |
| parent | 83517eb8d489cfceda8e6b7ab1b104a8f0b1f3a8 (diff) | |
populate product view
Diffstat (limited to 'StoneIsland/www/js/lib/products')
| -rw-r--r-- | StoneIsland/www/js/lib/products/CollectionView.js | 21 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/products/ProductView.js | 15 |
2 files changed, 27 insertions, 9 deletions
diff --git a/StoneIsland/www/js/lib/products/CollectionView.js b/StoneIsland/www/js/lib/products/CollectionView.js index d638171b..a1a506a3 100644 --- a/StoneIsland/www/js/lib/products/CollectionView.js +++ b/StoneIsland/www/js/lib/products/CollectionView.js @@ -1,4 +1,5 @@ -var CollectionView = View.extend({ + +var CollectionView = ScrollableView.extend({ el: "#collection", template: $("#collection .template").html(), @@ -25,18 +26,25 @@ var CollectionView = View.extend({ }, fetch: function(){ + if (this.loaded) return this.$loader.show() sdk.product.collection({ - gallery_id: 31617, + gallery_id: 32780, success: this.populate.bind(this) }) }, populate: function(data){ + if (this.loaded && ! data) { + data = this.data + } + else { + this.data = data + } + this.loaded = true this.$loader.hide() this.$content.empty() // DefaultCode10 - console.log(data) data.SearchResponseFull.Results.Items.forEach(function(item){ this.items[ item['Code8'] ] = item var t = this.template.replace(/{{image}}/, sdk.image(item['DefaultCode10'], '11_f')) @@ -44,10 +52,9 @@ var CollectionView = View.extend({ this.$content.append(t) }.bind(this)) - setTimeout(function(){ - this.scroller.refresh() - app.collection.scroller.scrollTo(0, 0) - }.bind(this), 0) + this.deferScrollToTop() + + this.afterFetchCallback && this.afterFetchCallback() }, pick: function(e){ diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js index c0a1ee79..0e4063df 100644 --- a/StoneIsland/www/js/lib/products/ProductView.js +++ b/StoneIsland/www/js/lib/products/ProductView.js @@ -8,7 +8,7 @@ var SIZE_LOOKUP = { "XXXL": "XXX-LARGE", }; -var ProductView = View.extend({ +var ProductView = ScrollableView.extend({ el: "#product", @@ -44,7 +44,16 @@ var ProductView = View.extend({ cache: {}, load: function(code, data){ - window.location.href = "#/product/" + code + this.show() + if (! app.collection.loaded) { + app.collection.afterFetchCallback = this.load.bind(this, code, data) + app.collection.fetch() + return + } + else { + app.collection.afterFetchCallback = null + } + window.location.href = "#/store/" + code data = data || app.collection.items[code] if (code in this.cache) { return this.populate(data, this.cache[code]) @@ -59,6 +68,8 @@ var ProductView = View.extend({ }, populate: function(data, details){ + this.show() +console.log(data, details) var name_partz = data['ModelNames'].split(' ') var num = name_partz.shift() var title = name_partz.join(' ') |
