summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--StoneIsland/www/js/lib/cart/CartSummary.js55
-rw-r--r--StoneIsland/www/js/lib/products/ProductView.js49
-rw-r--r--StoneIsland/www/js/vendor/view/scrollable.js8
3 files changed, 91 insertions, 21 deletions
diff --git a/StoneIsland/www/js/lib/cart/CartSummary.js b/StoneIsland/www/js/lib/cart/CartSummary.js
index d4729182..8e81c050 100644
--- a/StoneIsland/www/js/lib/cart/CartSummary.js
+++ b/StoneIsland/www/js/lib/cart/CartSummary.js
@@ -48,13 +48,62 @@ var CartSummary = ScrollableView.extend({
this.$loader.hide()
app.footer.show("SHIPPING >", "CANCEL")
- console.log(data)
-
app.header.set_cart_count(data.Cart.Items.length)
this.parent.$itemcount.html(pluralize(data.Cart.Items.length, "ITEM", "S"))
- this.$rows = this.$(".rows")
+ this.$rows.empty()
+
+ data.Cart.Items.forEach(function(item){
+ var $el = $("<div>")
+ this.$rows.append($el)
+ var code_ten = item['Code10']
+ var code = code_ten.substr(0, 8)
+ var size_id = item['Size']
+ app.product.find(code, function(data, details){
+ console.log(data, details)
+
+ var descriptions = app.product.get_descriptions( details )
+ console.log(descriptions)
+
+ var name_partz = descriptions['ModelNames'].split(' ')
+ var num = name_partz.shift()
+ var title = name_partz.join(' ')
+ var type = title_case( descriptions['MicroCategory'] )
+
+ var color_name, size_name
+ console.log(code)
+ details.Item.ModelColors.some(function(color){
+ console.log(color)
+ if (color['Code10'] == code_ten) {
+ color_name = color['ColorDescription']
+ console.log(color)
+ return true
+ }
+ return false
+ })
+ details.Item.ModelSizes.some(function(size){
+ if (size['SizeId'] == size_id) {
+ console.log(size)
+ size_name = size['Default']['Text']
+ size_name = SIZE_LOOKUP[ size_name ] || size_name
+ return true
+ }
+ return false
+ })
+
+ var t = this.template
+ .replace(/{{image}}/, sdk.image(item['Code10'], '11_f'))
+ .replace(/{{sku}}/, num)
+ .replace(/{{title}}/, title)
+ .replace(/{{type}}/, type)
+ .replace(/{{size}}/, size_name)
+ .replace(/{{color}}/, color_name)
+ .replace(/{{quantity}}/, 1)
+ .replace(/{{price}}/, as_cash(details.Item.Price.DiscountedPrice))
+ $el.html(t)
+ }.bind(this))
+ }.bind(this))
var subtotal = data.Cart.Totals.TotalToPay
var shipping_cost = data.Cart.DeliveryMethod.Selected.Amount.Total
diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js
index 69c6e407..0a00f365 100644
--- a/StoneIsland/www/js/lib/products/ProductView.js
+++ b/StoneIsland/www/js/lib/products/ProductView.js
@@ -40,6 +40,19 @@ var ProductView = ScrollableView.extend({
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()
@@ -59,30 +72,23 @@ var ProductView = ScrollableView.extend({
app.collection.afterFetchCallback = null
}
window.location.href = "#/store/" + code
- data = data || app.collection.items[code]
- if (code in this.cache) {
- return this.populate(data, this.cache[code])
- }
- else {
- this.el.className = "loading"
+
+ console.log(data)
+ if (data) {
+ app.collection.items[code] = data
}
- sdk.product.item({
- code: code
- }).done(function(details){
- this.cache[code] = details
- this.populate(data, details)
- }.bind(this))
+
+ this.el.className = "loading"
+ this.find(code, this.populate.bind(this))
},
-
+
populate: function(data, details){
this.el.className = ""
console.log(data, details)
- var descriptions = {}
- details['Item']['Descriptions'].forEach(function(pair){
- descriptions[pair.Key] = pair.Value
- })
+ var descriptions = this.get_descriptions(details)
+
this.gallery.populate( data['Code8'], details['Item']['ImageTypes'] )
var name_partz = data['ModelNames'].split(' ')
@@ -125,7 +131,14 @@ var ProductView = ScrollableView.extend({
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 ]
diff --git a/StoneIsland/www/js/vendor/view/scrollable.js b/StoneIsland/www/js/vendor/view/scrollable.js
index d3540723..2de6a108 100644
--- a/StoneIsland/www/js/vendor/view/scrollable.js
+++ b/StoneIsland/www/js/vendor/view/scrollable.js
@@ -1,9 +1,17 @@
var ScrollableView = View.extend({
+
+ events: {
+ "load img": "refreshScroller",
+ },
deferScrollToTop: function(){
setTimeout(this.scrollToTop.bind(this), 0)
},
+ refreshScroller: function(){
+ this.scroller.refresh()
+ },
+
scrollToTop: function(){
this.scroller.refresh()
app.collection.scroller.scrollTo(0, 0)