diff options
Diffstat (limited to 'StoneIsland/www/js')
| -rw-r--r-- | StoneIsland/www/js/lib/_router.js | 3 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/products/CollectionView.js | 31 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/products/Selector.js | 10 | ||||
| -rw-r--r-- | StoneIsland/www/js/sdk/sdk.js | 26 | ||||
| -rw-r--r-- | StoneIsland/www/js/vendor/view/router.js | 2 |
5 files changed, 68 insertions, 4 deletions
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 diff --git a/StoneIsland/www/js/sdk/sdk.js b/StoneIsland/www/js/sdk/sdk.js new file mode 100644 index 00000000..1a1a03e0 --- /dev/null +++ b/StoneIsland/www/js/sdk/sdk.js @@ -0,0 +1,26 @@ +var sdk = (function(){ + var sdk = {} + + var endpoint = "https://secure.api.yoox.biz/" + + sdk.path = function(api, path){ + return endpoint + api + "/STONEISLAND_US/" + path + } + + sdk.fetch_collection = function(opt){ + $.ajax({ + method: "GET", + url: sdk.path("Search.API/1.2", "search.json"), + data: { format: "full", gallery: opt.gallery_id }, + success: opt.success, +// dataType: "jsonp", + cache: true, + }) + } + + sdk.image = function(code){ + return "http://cdn.yoox.biz/" + code.substr(0,2) + "/" + code + "_11_f.jpg" + } + + return sdk +})() diff --git a/StoneIsland/www/js/vendor/view/router.js b/StoneIsland/www/js/vendor/view/router.js index bff039b7..d766880f 100644 --- a/StoneIsland/www/js/vendor/view/router.js +++ b/StoneIsland/www/js/vendor/view/router.js @@ -17,7 +17,7 @@ var Router = View.extend({ if (pathname[0] !== "/" && pathname[0] !== "#") { pathname = "/" + pathname } - var routes = is_mobile ? this.mobileRoutes : this.routes, + var routes = this.routes, path = pathname.split("/"); for (var i = 0; i < path.length; i++) { |
