var ProductView = ScrollableView.extend({
el: "#product",
events: {
"click .fit": "scroll_to_bottom",
"click .size": "select_size",
"click .color": "select_color",
"click .share": "share",
},
initialize: function(){
this.gallery = new GalleryView ()
this.scroller = new IScroll('#product', app.iscroll_options)
this.$num = this.$(".num")
this.$title = this.$(".title")
this.$type = this.$(".type")
this.$price = this.$(".price")
this.$size = this.$(".size")
this.$color = this.$(".color")
this.$body = this.$(".body")
this.$fit = this.$(".fit")
this.$sizing = this.$(".sizing")
},
show: function(){
app.footer.show("ADD TO CART", "BUY NOW")
document.body.className = "product"
},
hide: function(){
},
item: null,
details: null,
size: null,
color: null,
code: null,
is_onesize: false,
sizes: null,
colors: null,
cache: {},
find: function(code, cb){
data = app.collection.items[code] || {}
if (code in this.cache) {
return cb(data, this.cache[code])
}
sdk.product.item({
code: code
}).done(function(details){
this.cache[code] = details
cb(data, details)
}.bind(this))
},
load: function(code, data){
this.gallery.reset()
this.show()
if (app.view && app.view.hide) {
app.view.hide()
}
app.view = this
app.header.set_back(true)
if (! app.collection.loaded) {
this.el.className = "loading"
app.collection.afterFetchCallback = this.load.bind(this, code, data)
app.collection.fetch()
return
}
else {
app.collection.afterFetchCallback = null
}
window.location.href = "#/store/" + code
console.log(data)
if (data) {
app.collection.items[code] = data
}
this.el.className = "loading"
this.find(code, this.populate.bind(this))
},
populate: function(data, details){
this.el.className = ""
console.log(data, details)
var descriptions = this.get_descriptions(details)
this.gallery.populate( data['Code8'], details['Item']['ImageTypes'] )
var name_partz = data['ModelNames'].split(' ')
var num = name_partz.shift()
var title = name_partz.join(' ')
var type = title_case( data['MicroCategory'] )
var price = "$" + data['DiscountedPrice'] + ".00"
var body = descriptions['EditorialDescription'].replace(/
/g, "
")
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]
// 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.deferScrollToTop()
},
get_descriptions: function (details){
var descriptions = {}
details['Item']['Descriptions'].forEach(function(pair){
descriptions[pair.Key] = pair.Value
})
return descriptions
},
find_sizes_for_color: function(color_id){
return Object.keys( this.colors[color_id].sizes ).sort(function(a,b){
var ao = SIZE_ORDER[ a.label ], bo = SIZE_ORDER[ b.label ]
return aoShort sleeve T-Shirt in cotton jersey. Garment dyed.
Stone Island Compass logo print on the front, made up of a series of numbers."
ItemDescription: "Logo detail
Jersey
Round collar
Solid color
"
KeywordDescription: "Logo detail Jersey Round collar Solid color Jersey Woven not made of fur "
Kind of fabric: "Woven"
MFC: "631520081CC-6315-81V0060"
MacroCategory: "POLO SHIRTS & T-SHIRTS"
MadeIn: "Made In Turkmenistan"
MadeInIsoCode: "TN"
MainMaterial: "Cotton"
Material Description: "Jersey"
MicroCategory: "Short sleeve t-shirt"
MicroCategoryPlural: "Short sleeve t-shirts"
ModelFabric: "631520081CC-6315-81"
ModelNames: "20081 DATA DRIP PIN"
Neckline: "Claudine or round collar"
*/