diff options
| -rw-r--r-- | StoneIsland/platforms/ios/StoneIsland.xcodeproj/project.xcworkspace/xcuserdata/jules.xcuserdatad/UserInterfaceState.xcuserstate | bin | 13428 -> 13429 bytes | |||
| -rw-r--r-- | StoneIsland/www/css/index.css | 2 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/_router.js | 2 | ||||
| -rw-r--r-- | StoneIsland/www/js/lib/products/ProductView.js | 77 | ||||
| -rw-r--r-- | StoneIsland/www/js/sdk/auth.js | 2 | ||||
| -rw-r--r-- | StoneIsland/www/js/sdk/cart.js | 4 | ||||
| -rw-r--r-- | StoneIsland/www/js/sdk/payment.js | 4 | ||||
| -rw-r--r-- | StoneIsland/www/js/sdk/shipping.js | 4 | ||||
| -rw-r--r-- | proxy/index.js | 6 | ||||
| -rw-r--r-- | test/test/04-cart.js | 25 |
10 files changed, 91 insertions, 35 deletions
diff --git a/StoneIsland/platforms/ios/StoneIsland.xcodeproj/project.xcworkspace/xcuserdata/jules.xcuserdatad/UserInterfaceState.xcuserstate b/StoneIsland/platforms/ios/StoneIsland.xcodeproj/project.xcworkspace/xcuserdata/jules.xcuserdatad/UserInterfaceState.xcuserstate Binary files differindex 3b7233e1..bcf4bbca 100644 --- a/StoneIsland/platforms/ios/StoneIsland.xcodeproj/project.xcworkspace/xcuserdata/jules.xcuserdatad/UserInterfaceState.xcuserstate +++ b/StoneIsland/platforms/ios/StoneIsland.xcodeproj/project.xcworkspace/xcuserdata/jules.xcuserdatad/UserInterfaceState.xcuserstate diff --git a/StoneIsland/www/css/index.css b/StoneIsland/www/css/index.css index 79364e54..0988d8a4 100644 --- a/StoneIsland/www/css/index.css +++ b/StoneIsland/www/css/index.css @@ -22,7 +22,7 @@ body { width: 80px; height: 80px; position: absolute; - top: 50vw; + top: 50vh; left: 50%; margin-top: -60px; margin-left: -40px; diff --git a/StoneIsland/www/js/lib/_router.js b/StoneIsland/www/js/lib/_router.js index bf4af40b..47f0ec26 100644 --- a/StoneIsland/www/js/lib/_router.js +++ b/StoneIsland/www/js/lib/_router.js @@ -53,7 +53,7 @@ var SiteRouter = Router.extend({ default_view: function(name){ var fn = function(){ console.log(name) - if (name.match(".")) { + if (name.match(/\./)) { var n = name.split(".") console.log(name, n) app.view = app[n[0]][n[1]] diff --git a/StoneIsland/www/js/lib/products/ProductView.js b/StoneIsland/www/js/lib/products/ProductView.js index fd81f199..9b7912aa 100644 --- a/StoneIsland/www/js/lib/products/ProductView.js +++ b/StoneIsland/www/js/lib/products/ProductView.js @@ -21,7 +21,7 @@ var ProductView = ScrollableView.extend({ this.$color = this.$(".color") this.$body = this.$(".body") - app.footer.show("< BACK TO SHOPPING", "ADD TO CART") + app.footer.show("ADD TO CART", "< BACK TO SHOPPING") }, show: function(){ @@ -31,9 +31,13 @@ var ProductView = ScrollableView.extend({ }, item: null, + details: null, size: null, color: null, code: null, + + sizes: null, + colors: null, cache: {}, @@ -74,27 +78,34 @@ var ProductView = ScrollableView.extend({ descriptions[pair.Key] = pair.Value }) 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 = data['MicroCategory'].toUpperCase() var price = "$" + data['DiscountedPrice'] + ".00" + 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 size = data['Sizes'][0] var size_label = SIZE_LOOKUP[size] - var color = data['Colors'].length && data['Colors'][0] - var color_label = color && color['Text'] - var body = descriptions['EditorialDescription'].replace(/<br>/g, "<br><br>") - + this.item = data + this.details = details['Item'] + this.code = data['DefaultCode10'] + this.color = color this.size = size - this.code = data['DefaultCode10'] 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) @@ -102,7 +113,46 @@ var ProductView = ScrollableView.extend({ else { this.$color.hide() } - this.$body.html(body) + }, + + 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 ao<bo?-1:ao==bo?0:1 + }) + }, + find_colors_for_size: function(size_id){ + return Object.keys( this.sizes[size_id].colors ) + }, + + populate_selectors: function(data, details){ + var sizes = {}, colors = {}, size_lookup = {}, default_color + details['Item']['ModelColors'].forEach(function(color, index){ + if (! default_color || color['Code10'] == data['DefaultCode10']) { + default_color = color['ColorId'] + } + colors[ color['ColorId'] ] = { + code: color['Code10'], + label: color['ColorDescription'], + sizes: {}, + } + }) + details['Item']['ModelSizes'].forEach(function(size){ + var label = SIZE_LOOKUP[ size['Default']['Text'] ] + size_lookup[ label ] = size['SizeId'] + sizes[ size['SizeId'] ] = { + label: label, + colors: {}, + } + }) + details['Item']['ModelColorSize'].forEach(function(cs){ + colors[ cs['IdColor'] ].sizes[ cs['IdSize'] ] = true + sizes[ cs['IdSize'] ].colors[ cs['IdColor'] ] = true + }) + + this.sizes = sizes + this.colors = colors + return default_color }, select_size: function(){ @@ -135,11 +185,14 @@ var ProductView = ScrollableView.extend({ }.bind(this)) }, - ok: function(){ + save: function(){ + // add to cart }, + cancel: function(){ app.router.go('store') }, + share: function(){ }, @@ -152,12 +205,12 @@ var SIZE_LOOKUP = { "L": "LARGE", "XL": "X-LARGE", "XXL": "XX-LARGE", - "XXXL": "XXX-LARGE", -}; + "3XL": "3X-LARGE", +} +var SIZE_ORDER = "XS S M L XL XXL 3XL".split(" ") /* - { "Code8": "41504876", "BrandName": "STONE ISLAND", diff --git a/StoneIsland/www/js/sdk/auth.js b/StoneIsland/www/js/sdk/auth.js index 3b905ffb..134107c2 100644 --- a/StoneIsland/www/js/sdk/auth.js +++ b/StoneIsland/www/js/sdk/auth.js @@ -37,4 +37,4 @@ var auth = sdk.auth = (function(){ } return auth -})() +})()
\ No newline at end of file diff --git a/StoneIsland/www/js/sdk/cart.js b/StoneIsland/www/js/sdk/cart.js index b10503d8..6de10d18 100644 --- a/StoneIsland/www/js/sdk/cart.js +++ b/StoneIsland/www/js/sdk/cart.js @@ -126,7 +126,7 @@ sdk.cart = (function(){ }, data: opt.data, success: function(data){ - console.log(data) + // console.log(data) opt.success(data) }, error: opt.error, @@ -144,7 +144,7 @@ sdk.cart = (function(){ }, data: opt.data, success: function(data){ - console.log(data) + // console.log(data) opt.success(data) }, error: opt.error, diff --git a/StoneIsland/www/js/sdk/payment.js b/StoneIsland/www/js/sdk/payment.js index 0076fbf8..e73bb5ff 100644 --- a/StoneIsland/www/js/sdk/payment.js +++ b/StoneIsland/www/js/sdk/payment.js @@ -11,7 +11,7 @@ sdk.payment = (function(){ }, data: opt.data, success: function(data){ - console.log(data) + // console.log(data) opt.success(data) }, error: opt.error, @@ -61,7 +61,7 @@ sdk.payment = (function(){ }, data: opt.data, success: function(data){ - console.log(data) + // console.log(data) opt.success(data) }, error: opt.error, diff --git a/StoneIsland/www/js/sdk/shipping.js b/StoneIsland/www/js/sdk/shipping.js index 9dd18454..1a148b23 100644 --- a/StoneIsland/www/js/sdk/shipping.js +++ b/StoneIsland/www/js/sdk/shipping.js @@ -34,7 +34,7 @@ sdk.shipping = (function() { "Type": opt.type, }, success: function(data){ - //console.log(data) + // console.log(data) opt.success(data) }, error: opt.error, @@ -83,4 +83,4 @@ sdk.shipping = (function() { } return shipping -})()
\ No newline at end of file +})() diff --git a/proxy/index.js b/proxy/index.js index d30b135b..27d3156e 100644 --- a/proxy/index.js +++ b/proxy/index.js @@ -67,12 +67,6 @@ server.on('request', function (req, res){ server_res.resume() }) - connector.on('response', function(e){ - console.log(">> RESPONSE") - }) - connector.on('connect', function(e){ - console.log(">> CONNECT") - }) connector.on('error', function(e){ console.error(e) }) diff --git a/test/test/04-cart.js b/test/test/04-cart.js index e378165d..5f6c04d7 100644 --- a/test/test/04-cart.js +++ b/test/test/04-cart.js @@ -156,6 +156,12 @@ describe('shipping', function(){ describe('payment', function(){ + + if (! sdk.auth.access_token) { + sdk.auth.access_token = "45871479f5001afc06e628c7bb8e95ffb1f71df8" + sdk.auth.user_id = 374663521 + } + describe('#set_payment_type()', function(){ it('sets payment type', function(done){ // this id probably needs to be hard coded. 1 = credit card. @@ -201,7 +207,7 @@ describe('payment', function(){ promise(sdk.payment.list_credit_cards, { data: {} }).then(function(data){ assert(data.Header.StatusCode == 200) // show any credit card on file - console.log(data) + // console.log(data) done() }) }) @@ -209,21 +215,24 @@ describe('payment', function(){ describe('#add_credit_card()', function(){ it('add credit card', function(done){ var new_card = { + "Name":"Name", + "Surname":"Surname", "Address":"address", "City":"Ferrara", - "ExpirationMonth":"02", - "ExpirationYear":"2017", - "Name":"Name", - "Number":"0000567890124285", "Province":"FE", - "Surname":"Surname", - "Type":"Visa", "ZipCode":"40200", + + "Type":"Visa", + "Number":"0000567890124285", + "ExpirationMonth":"02", + "ExpirationYear":"2017", "HolderIsoCountry":"IT", } promise(sdk.payment.add_credit_card, { data: new_card }).then(function(data){ assert(data.Header.StatusCode == 201) done() + }).error(function(data){ + console.log(data) }) }) }) @@ -263,4 +272,4 @@ describe('payment', function(){ describe('checkout', function(){ describe('#finalize()', function(){ }) -})
\ No newline at end of file +}) |
