diff options
Diffstat (limited to 'StoneIsland/www/js/lib/products/ProductView.js')
| -rwxr-xr-x | StoneIsland/www/js/lib/products/ProductView.js | 84 |
1 files changed, 57 insertions, 27 deletions
diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js index 9d518b11..285e551d 100755 --- a/StoneIsland/www/js/lib/products/ProductView.js +++ b/StoneIsland/www/js/lib/products/ProductView.js @@ -4,12 +4,12 @@ var ProductView = ScrollableView.extend({ el: "#product", events: { - "touchstart .fit": "scroll_to_bottom", - "touchstart .size": "select_size", - "touchstart .color": "select_color", - "touchstart .share": "share", - "touchstart .gallery-left": "gallery_left", - "touchstart .gallery-right": "gallery_right", + "click .fit": "scroll_to_bottom", + "click .size": "select_size", + "click .color": "select_color", + "click .share": "share", + "click .gallery-left": "gallery_left", + "click .gallery-right": "gallery_right", }, initialize: function(){ @@ -29,12 +29,21 @@ var ProductView = ScrollableView.extend({ }, show: function(){ - app.footer.show("ADD TO CART", "BUY NOW") + this.showFooter() document.body.className = "product" }, hide: function(){ }, + showFooter: function(){ + if (this.not_available) { + app.footer.show("SOLD OUT") + } + else { + app.footer.show("ADD TO CART", "BUY NOW") + } + }, + item: null, details: null, size: null, @@ -87,7 +96,6 @@ var ProductView = ScrollableView.extend({ } window.location.href = "#/store/" + code - console.log(data) if (data) { app.collection.items[code] = data } @@ -113,38 +121,46 @@ var ProductView = ScrollableView.extend({ var body = descriptions['EditorialDescription'].replace(/<br>/g, "<br><br>") var default_color_id = this.populate_selectors(data, details) - - var color = this.colors[default_color_id] - var color_label = color.label - var sizes = this.find_sizes_for_color(default_color_id) - var size = sizes[0] - var size_label = this.sizes[size].label - this.is_onesize = !! this.sizes[1] + if (this.not_available) { + this.$color.html("NOT AVAILABLE") + this.$size.hide() + } + else { + var color = this.colors[default_color_id] + var color_label = color.label + var sizes = this.find_sizes_for_color(default_color_id) + var size = sizes[0] + var size_label = this.sizes[size].label + + this.color = color + this.size = size + + this.is_onesize = !! this.sizes[1] + this.$size.show().html(size_label) + if (color_label) { + this.$color.html(color_label) + } + else { + this.$color.hide() + } + } + // console.log(color, color_label, size, size_label) this.item = data this.details = details['Item'] this.code = data['DefaultCode10'] - this.color = color - this.size = size - this.$num.html(num) this.$title.html(title) this.$type.html(type) this.$price.html(price) this.$body.html(body) - - this.$size.html(size_label) - if (color_label) { - this.$color.show().html(color_label) - } - else { - this.$color.hide() - } + this.showFooter() + this.deferScrollToTop() }, @@ -167,6 +183,15 @@ var ProductView = ScrollableView.extend({ populate_selectors: function(data, details){ var sizes = {}, colors = {}, size_lookup = {}, default_color + console.log(details['Item']['ModelColors'].length) + if (! details['Item']['ModelColors'].length) { + this.not_available = true + return + } + else { + this.not_available = false + } + details['Item']['ModelColors'].forEach(function(color, index){ if (! default_color || color['Code10'] == data['DefaultCode10']) { default_color = color['ColorId'] @@ -203,7 +228,7 @@ var ProductView = ScrollableView.extend({ }, select_size: function(){ - + if (this.not_available) { return } if (this.is_onesize) { return this.select_color() } if (this.item['Sizes'].length == 0) { return } var sizes = Object.keys(this.sizes).map(function(key){ @@ -217,6 +242,7 @@ var ProductView = ScrollableView.extend({ }, select_color: function(){ + if (this.not_available) { return } if (this.item['Colors'].length == 0) { return } var colors = Object.keys(this.colors).map(function(key){ return this.colors[key] @@ -224,15 +250,19 @@ var ProductView = ScrollableView.extend({ app.selector.select("style", colors, function(color){ this.code = color.code this.$color.html(color.label) + + // UPDATE GALLERY }.bind(this)) }, // ADD TO CART save: function(){ + if (this.not_available) { return } this.add_to_cart({ route: false }) }, // BUY NOW cancel: function(){ + if (this.not_available) { return } this.add_to_cart({ route: true }) }, |
