From 14699818d58beef4b9b20b3ddb3e03641c0b7f21 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 16 Sep 2015 15:06:56 -0400 Subject: populate collectionview --- StoneIsland/www/js/lib/_router.js | 3 ++- StoneIsland/www/js/lib/products/CollectionView.js | 31 +++++++++++++++++++++-- StoneIsland/www/js/lib/products/Selector.js | 10 ++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) (limited to 'StoneIsland/www/js/lib') diff --git a/StoneIsland/www/js/lib/_router.js b/StoneIsland/www/js/lib/_router.js index d45ffdc2..08b8b819 100644 --- a/StoneIsland/www/js/lib/_router.js +++ b/StoneIsland/www/js/lib/_router.js @@ -53,8 +53,9 @@ var SiteRouter = Router.extend({ app.archive.show() }, - cart: function(){ + app.view = app.cart + app.cart.show() }, }) diff --git a/StoneIsland/www/js/lib/products/CollectionView.js b/StoneIsland/www/js/lib/products/CollectionView.js index 7e178a8a..0ce740a8 100644 --- a/StoneIsland/www/js/lib/products/CollectionView.js +++ b/StoneIsland/www/js/lib/products/CollectionView.js @@ -2,19 +2,46 @@ var CollectionView = View.extend({ el: "#collection", template: $("#collection .template").html(), + loaded: false, + data: null, + items: {}, events: { }, initialize: function(){ this.$content = this.$(".content") + this.$loader = this.$(".loader") }, show: function(){ document.body.className = "collection" + if (this.loaded) { + return this.populate(this.data) + } + this.fetch() + }, + + fetch: function(){ + this.$loader.show() + sdk.fetch_collection({ + gallery_id: 31617, // STONE ISLAND / SUPREME + success: this.populate.bind(this) + }) }, - populate: function(){ + populate: function(data){ + 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'])) + .replace(/{{code8}}/, item['Code8']) + this.$content.append(t) + + }.bind(this)) }, -}) \ No newline at end of file +}) diff --git a/StoneIsland/www/js/lib/products/Selector.js b/StoneIsland/www/js/lib/products/Selector.js index 3d3d5ccc..c81aa121 100644 --- a/StoneIsland/www/js/lib/products/Selector.js +++ b/StoneIsland/www/js/lib/products/Selector.js @@ -3,6 +3,8 @@ var Selector = View.extend({ el: "#selector", events: { + "click .close": "hide", + "click span": "pick", }, initialize: function(){ @@ -10,5 +12,13 @@ var Selector = View.extend({ select: function(options, callback){ }, + + hide: function(){ + }, + + pick: function(e){ + var el = $(e.currentTarget) + + }, }) \ No newline at end of file -- cgit v1.2.3-70-g09d2