diff options
| author | Jules Laplace <jules@okfoc.us> | 2015-11-04 20:33:14 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2015-11-04 20:33:14 -0500 |
| commit | 83517eb8d489cfceda8e6b7ab1b104a8f0b1f3a8 (patch) | |
| tree | be6fce89034de08d745cfd0940ea7ea747a1b2a7 /StoneIsland/www/js/lib | |
| parent | 8d7a5da72199e25db9056b9ee585094ac3274f49 (diff) | |
iscroll workin, api fetching, hud populating
Diffstat (limited to 'StoneIsland/www/js/lib')
| -rw-r--r-- | StoneIsland/www/js/lib/_router.js | 9 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/blogs/ArchiveView.js | 2 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/blogs/HubView.js | 2 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/blogs/StoryView.js | 2 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/products/CollectionView.js | 12 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/products/ProductView.js | 31 |
6 files changed, 45 insertions, 13 deletions
diff --git a/StoneIsland/www/js/lib/_router.js b/StoneIsland/www/js/lib/_router.js index 08b8b819..567d1aad 100644 --- a/StoneIsland/www/js/lib/_router.js +++ b/StoneIsland/www/js/lib/_router.js @@ -6,11 +6,13 @@ var SiteRouter = Router.extend({ routes: { '/': 'intro', '/intro': 'intro', - '/store': 'store', '/hub': 'hub', '/story': 'story', '/archive': 'archive', + '/store': 'store', + '/store/:code': 'product', + '/faq': 'faq', '/search': 'search', @@ -38,6 +40,11 @@ var SiteRouter = Router.extend({ app.collection.show() }, + product: function(code){ + app.view = app.product + app.product.load(code) + }, + hub: function(){ app.view = app.hub app.hub.show() diff --git a/StoneIsland/www/js/lib/blogs/ArchiveView.js b/StoneIsland/www/js/lib/blogs/ArchiveView.js index 34e8b109..13bacb22 100644 --- a/StoneIsland/www/js/lib/blogs/ArchiveView.js +++ b/StoneIsland/www/js/lib/blogs/ArchiveView.js @@ -9,7 +9,7 @@ var ArchiveView = View.extend({ initialize: function(){ this.$content = this.$(".content") this.$loader = this.$(".loader") - this.scroller = new IScroll('#archive .scroll') + this.scroller = new IScroll('#archive', app.iscroll_options) }, show: function(){ diff --git a/StoneIsland/www/js/lib/blogs/HubView.js b/StoneIsland/www/js/lib/blogs/HubView.js index ea9b3048..95cdef3f 100644 --- a/StoneIsland/www/js/lib/blogs/HubView.js +++ b/StoneIsland/www/js/lib/blogs/HubView.js @@ -9,7 +9,7 @@ var HubView = View.extend({ initialize: function(){ this.$content = this.$(".content") this.$loader = this.$(".loader") - this.scroller = new IScroll('#hub .scroll') + this.scroller = new IScroll('#hub', app.iscroll_options) }, show: function(){ diff --git a/StoneIsland/www/js/lib/blogs/StoryView.js b/StoneIsland/www/js/lib/blogs/StoryView.js index 7f9b30a1..b47b0488 100644 --- a/StoneIsland/www/js/lib/blogs/StoryView.js +++ b/StoneIsland/www/js/lib/blogs/StoryView.js @@ -9,7 +9,7 @@ var StoryView = View.extend({ initialize: function(){ this.$content = this.$(".content") this.$loader = this.$(".loader") - this.scroller = new IScroll('#story .scroll') + this.scroller = new IScroll('#story', app.iscroll_options) }, show: function(){ diff --git a/StoneIsland/www/js/lib/products/CollectionView.js b/StoneIsland/www/js/lib/products/CollectionView.js index 987804fc..d638171b 100644 --- a/StoneIsland/www/js/lib/products/CollectionView.js +++ b/StoneIsland/www/js/lib/products/CollectionView.js @@ -13,7 +13,7 @@ var CollectionView = View.extend({ initialize: function(){ this.$content = this.$(".content") this.$loader = this.$(".loader") - this.scroller = new IScroll('#collection .scroll') + this.scroller = new IScroll('#collection', app.iscroll_options) }, show: function(){ @@ -39,17 +39,21 @@ var CollectionView = View.extend({ 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'])) + var t = this.template.replace(/{{image}}/, sdk.image(item['DefaultCode10'], '11_f')) .replace(/{{code8}}/, item['Code8']) this.$content.append(t) - }.bind(this)) + + setTimeout(function(){ + this.scroller.refresh() + app.collection.scroller.scrollTo(0, 0) + }.bind(this), 0) }, pick: function(e){ var code = $(e.currentTarget).data("code") var data = this.items[code] - app.product.load(data) + app.product.load(code, data) }, }) diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js index 76527c8b..c0a1ee79 100644 --- a/StoneIsland/www/js/lib/products/ProductView.js +++ b/StoneIsland/www/js/lib/products/ProductView.js @@ -41,7 +41,24 @@ var ProductView = View.extend({ color: null, code: null, - load: function(data){ + cache: {}, + + load: function(code, data){ + window.location.href = "#/product/" + code + data = data || app.collection.items[code] + if (code in this.cache) { + return this.populate(data, this.cache[code]) + } + sdk.product.item({ + code: code, + success: function(details){ + this.cache[code] = details + this.populate(data, details) + }.bind(this), + }) + }, + + populate: function(data, details){ var name_partz = data['ModelNames'].split(' ') var num = name_partz.shift() var title = name_partz.join(' ') @@ -50,7 +67,8 @@ var ProductView = View.extend({ var size = data['Sizes'][0] var size_label = SIZE_LOOKUP[size] var color = data['Colors'][0] - var color_label = color['Text'] + console.log(color) + var color_label = color && color['Text'] var body = "" this.item = data @@ -63,10 +81,13 @@ var ProductView = View.extend({ this.$type.html(type) this.$price.html(price) this.$size.html(size_label) - this.$color.html(color) + if (color_label) { + this.$color.show().html(color_label) + } + else { + this.$color.hide() + } this.$body.html(body) - - // TODO: fetch product from item API, get other Code10s so you can populate the gallery }, select_size: function(){ |
