summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/ios/www/js')
-rw-r--r--StoneIsland/platforms/ios/www/js/index.js5
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/_router.js11
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/OrdersView.js173
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/ProfileView.js7
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/orders/OrderList.js17
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/orders/SingleOrder.js18
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js3
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js2
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js13
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js11
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js2
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js6
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/cart/CartThanks.js2
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/etc/deeplink.js3
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/etc/geo.js33
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/etc/push.js1
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js16
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js11
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js5
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js8
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/products/ProductView.js22
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/view/Scrollable.js11
-rw-r--r--StoneIsland/platforms/ios/www/js/sdk/account.js32
-rw-r--r--StoneIsland/platforms/ios/www/js/sdk/cart.js16
24 files changed, 370 insertions, 58 deletions
diff --git a/StoneIsland/platforms/ios/www/js/index.js b/StoneIsland/platforms/ios/www/js/index.js
index 546bd637..e6bdf49f 100644
--- a/StoneIsland/platforms/ios/www/js/index.js
+++ b/StoneIsland/platforms/ios/www/js/index.js
@@ -63,12 +63,13 @@ var app = (function(){
app.ready = function(){
if (window.cordova) {
- // cordova.plugins.Keyboard.disableScroll(true)
+ cordova.plugins.Keyboard.disableScroll(true)
+ geo.fetch()
}
app.view = null
app.router = new SiteRouter ()
- app.account.connect( app.router.route.bind(app.router) )
+ app.account.connect( app.router.launch.bind(app.router) )
$("body").removeClass("loading")
}
diff --git a/StoneIsland/platforms/ios/www/js/lib/_router.js b/StoneIsland/platforms/ios/www/js/lib/_router.js
index b70d9be8..23daf4c7 100644
--- a/StoneIsland/platforms/ios/www/js/lib/_router.js
+++ b/StoneIsland/platforms/ios/www/js/lib/_router.js
@@ -47,6 +47,17 @@ var SiteRouter = Router.extend({
}
}
},
+
+ initial_route: null,
+ launch: function(){
+ if (this.initial_route) {
+ this.parseRoute( this.initial_route )
+ }
+ else {
+ this.route()
+ }
+ this.initial_route = null
+ },
go: function(url){
if (app.view && app.view.hide) {
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/OrdersView.js b/StoneIsland/platforms/ios/www/js/lib/account/OrdersView.js
index 7283b65c..49901daa 100644
--- a/StoneIsland/platforms/ios/www/js/lib/account/OrdersView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/account/OrdersView.js
@@ -1,29 +1,188 @@
-var OrdersView = View.extend({
+var OrdersView = ScrollableView.extend({
el: "#orders",
+
+ loaded: false,
+
+ list_template: $("#orders .list_template").html(),
+ item_template: $("#orders .item_template").html(),
events: {
"click .back": "back",
- "click .details": "load_single",
+ "click .item": "load_single",
},
initialize: function(){
- this.single = new SingleOrder ({ parent: this })
- this.list = new OrderList ({ parent: this })
+ this.$list = this.$(".list")
+ this.$empty = this.$(".empty")
+ this.$single_order = this.$("#single_order")
+
+ this.$rows = this.$(".rows")
+ this.$subtotal = this.$(".subtotal")
+ this.$shipping = this.$(".shipping")
+ this.$tax = this.$(".tax")
+ this.$total = this.$(".total")
+
+ this.$shipping_address = this.$(".shipping_address")
+ this.$shipping_method = this.$(".shipping_method")
+
+ this.scroller = new IScroll('#orders', app.iscroll_options)
},
show: function(){
if (! auth.logged_in()) { return app.router.go("intro") }
+ app.header.set_back(false)
app.footer.hide()
document.body.className = "orders"
- this.el.className = "list"
+ this.el.className = ""
+
+ if (this.loaded) {
+ this.populate()
+ }
+ else {
+ this.fetch()
+ }
+ },
+
+ orders: null,
+ orderLookup: {},
+
+ fetch: function(){
+ this.$list.empty()
+ this.$empty.hide()
+ this.loader = new Loader(this.ready.bind(this))
+ app.curtain.show("loading")
+ sdk.account.fetch_orders({
+ success: function(data){
+ this.loader.register("orders")
+ this.orders = data.OrderDetails
+ data.OrderDetails.forEach(function(row){
+ this.loader.register(row.OrderNumber)
+ sdk.account.fetch_single_order({
+ id: row.OrderNumber,
+ success: function(row_data){
+ this.orderLookup[ row.OrderNumber ] = row_data.OrderFullDetails
+ this.loader.ready(row.OrderNumber)
+ }.bind(this),
+ error: function(){
+ this.orderLookup[ row.OrderNumber ] = null
+ this.loader.ready(row.OrderNumber)
+ }.bind(this),
+ })
+ }.bind(this))
+ this.loader.ready("orders")
+ }.bind(this),
+ error: function(){
+ console.log("error fetching orders")
+ }.bind(this),
+ })
+ },
+
+ ready: function(){
+ this.populate()
+ app.curtain.hide("loading")
+ },
+
+ populate: function(){
+ this.$list.empty()
+
+ if (! this.orders.length) {
+ this.$empty.show()
+ return
+ }
+ else {
+ this.$empty.hide()
+ }
+ this.orders.forEach(function(row){
+ var order = this.orderLookup[ row.OrderNumber ]
+ if (! order) { return }
+ var t = this.list_template.replace(/{{date}}/g, moment(order['Date']).format("ddd MM/DD/YYYY").toUpperCase())
+ .replace(/{{id}}/g, row.OrderNumber)
+ .replace(/{{total}}/g, as_cash( order.TotalAmount ))
+ var $t = $(t), $images = $t.find(".images")
+ order.Items.forEach(function(item){
+ var img = new Image ()
+ img.src = sdk.image(item['Code10'], "11_f")
+ $images.append(img)
+ }.bind(this))
+ this.$list.append($t)
+ }.bind(this))
+
+ this.refreshScroller()
},
+
+ load_single: function(e){
+ var id = $(e.currentTarget).data("id")
+ var order = this.orderLookup[ id ]
+ if (! order) { return }
+
+ console.log(order)
+
+ this.$rows.empty()
+
+ order.Items.forEach(function(item){
+ var $el = $("<div class='item'><img src='img/spinner.gif'></div>")
+ this.$rows.append($el)
+ var code_ten = item.Code10
+
+ var code = code_ten.substr(0, 8)
+ app.product.find(code, function(data, details){
+ var descriptions = app.product.get_descriptions( details )
+
+ 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
- load_single: function(){
+ details.Item.ModelColors.some(function(color){
+ if (color['Code10'] == code_ten) {
+ color_name = color['ColorDescription']
+ return true
+ }
+ return false
+ })
+ size_name = item.DefaultSize + " " + item.DefaultSizeClassFamily
+
+ var t = this.item_template
+ .replace(/{{image}}/, sdk.image(item['Code10'], '11_f'))
+ .replace(/{{sku}}/, num)
+ .replace(/{{title}}/, title)
+ .replace(/{{type}}/, type)
+ .replace(/{{size}}/, size_name || "DEFAULT")
+ .replace(/{{color}}/, color_name || "DEFAULT")
+ .replace(/{{quantity}}/, 1)
+ .replace(/{{price}}/, as_cash(details.Item.Price.DiscountedPrice))
+ $el.data("price", details.Item.Price.DiscountedPrice)
+ $el.html(t)
+ this.refreshScroller()
+ }.bind(this))
+ }.bind(this))
+
+ var subtotal = order.ItemsTotalAmount
+ var shipping_cost = order.Delivery.Amount
+ var tax = order.SalesTaxAmount
+ var total = order.TotalToPay
+
+ this.$subtotal.html( as_cash(subtotal) )
+ this.$shipping.html( as_cash(shipping_cost) )
+ this.$tax.html( as_cash(tax) )
+ this.$total.html( as_cash(total) )
+
+ var street = order.Delivery.Address.replace(/\n$/,"").replace("\n","<br>")
+ var address = order.Delivery.Name + "<br>" + street + "<br>" + order.Delivery.City + " " + order.Delivery.ZipCode
+ this.$shipping_address.html(address)
+ this.$shipping_method.html(order.Delivery.Type + " - " + order.Delivery.Time)
+
+ app.header.set_back(true)
+ this.$el.addClass("single")
},
back: function(){
- this.list.show()
+ app.header.set_back(false)
+ this.el.className = ""
},
})
+
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/ProfileView.js b/StoneIsland/platforms/ios/www/js/lib/account/ProfileView.js
index 999e8d65..da25fefc 100644
--- a/StoneIsland/platforms/ios/www/js/lib/account/ProfileView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/account/ProfileView.js
@@ -5,6 +5,8 @@ var ProfileView = FormView.extend({
events: {
},
+ action: sdk.account.update,
+
initialize: function(){
this.$form = this.$("form")
this.$msg = this.$(".msg")
@@ -30,7 +32,7 @@ var ProfileView = FormView.extend({
if (! data.CurrentPassword && (data.NewPassword || data.Email !== auth.user.Email)) { errors.push([ "CurrentPassword", "Please enter your current password." ]) }
if (data.CurrentPassword && ! data.NewPassword) { errors.push([ "NewPassword", "Please enter your new password." ]) }
if (data.NewPassword && data.NewPassword.length < 7) { errors.push([ "CurrentPassword", "New password must be 7 characters or more." ]) }
- if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) }
+ // if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) }
},
finalize: function(data){
@@ -50,7 +52,8 @@ var ProfileView = FormView.extend({
})
}
- var submissible_data = _.pick(data, "Name Surname BirthDay Gender YooxLetter".split(" "))
+ var submissible_data = _.pick(data, "Name Surname BirthDay YooxLetter".split(" "))
+ submissible_data.Gender = "U"
// submissible_data.idUser = auth.user_id
// submissible_data.AccessToken = auth.access_token
// submissible_data.Premium = "false"
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/orders/OrderList.js b/StoneIsland/platforms/ios/www/js/lib/account/orders/OrderList.js
deleted file mode 100644
index 876f609e..00000000
--- a/StoneIsland/platforms/ios/www/js/lib/account/orders/OrderList.js
+++ /dev/null
@@ -1,17 +0,0 @@
-var OrderList = ScrollableView.extend({
-
- el: "#order_list",
-
- template: $("#order_list .template"),
-
- initialize: function(opt){
- this.parent = opt.parent
- this.scroller = new IScroll('#order_list', app.iscroll_options)
- },
-
- show: function(){
- document.body.className = "orders"
- app.orders.el.className = "list"
- },
-
-})
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/orders/SingleOrder.js b/StoneIsland/platforms/ios/www/js/lib/account/orders/SingleOrder.js
deleted file mode 100644
index 21416401..00000000
--- a/StoneIsland/platforms/ios/www/js/lib/account/orders/SingleOrder.js
+++ /dev/null
@@ -1,18 +0,0 @@
-var SingleOrder = ScrollableView.extend({
-
- el: "#single_order",
-
- template: $("#single_order .template"),
-
- initialize: function(opt){
- this.parent = opt.parent
- this.scroller = new IScroll('#single_order', app.iscroll_options)
- },
-
- show: function(id){
- document.body.className = "orders"
- app.orders.el.className = "single"
- this.deferScrollToTop()
- },
-
-})
diff --git a/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js b/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js
index 7e6fc04d..22b310de 100644
--- a/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js
@@ -57,7 +57,7 @@ var SignupView = FormView.extend({
if (data.Password !== data.Password2) { errors.push([ "Password2", "Passwords don't match." ]) }
if (! data.Email.match("@")) { errors.push([ "Email", "Email address is not valid." ]) }
if (data.Email.toLowerCase() !== data.ConfirmEmail.toLowerCase()) { errors.push([ "ConfirmEmail", "Email addresses don't match." ]) }
- if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) }
+ // if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) }
if (data.DataProfiling !== "true") { errors.push([ "DataProfiling", "You must consent to use this service." ]) }
if (data.DataProfiling2 !== "true") { errors.push([ "DataProfiling2", "You must consent to use this service." ]) }
if (! data.YooxLetter) { data.YooxLetter = false }
@@ -67,6 +67,7 @@ var SignupView = FormView.extend({
delete data.DataProfiling2
delete data.ConfirmEmail
+ data.Gender = "U"
data.BirthDay += "T00:00:00Z"
this.last_data = data
diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js
index 3db5c8da..f0a796bf 100644
--- a/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/blogs/ArchiveView.js
@@ -33,6 +33,8 @@ var ArchiveView = ScrollableView.extend({
},
populate: function(data){
+ if (this.loaded) { return }
+ this.loaded = true
this.data = data
this.$loader.hide()
this.$content.empty()
diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js
index 19666f8b..3ea35418 100644
--- a/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/blogs/BlogView.js
@@ -42,6 +42,19 @@ var BlogView = View.extend({
if (data.store[0].StoreIsOpen !== "true") {
app.closed.storeIsClosed = true
}
+ var fits_large = (data.store[0].FitsLarge === "true")
+
+ app.product.$fit.toggle( fits_large )
+ app.product.$sizing.toggle( fits_large )
+
+ if (data.store[0].BackgroundIsGray === "true") {
+ app.collection.$el.addClass("gray")
+ app.product.gallery.$el.addClass("gray")
+ }
+
+ app.gallery_id = data.store[0].CollectionId
+
+ app.collection.fetch()
},
}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js
index 3b2900ad..a6ae958e 100644
--- a/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/blogs/HubView.js
@@ -5,6 +5,8 @@ var HubView = ScrollableView.extend({
events: {
"click .store": "store_link",
+ "click .gallery-left": "gallery_left",
+ "click .gallery-right": "gallery_right",
},
initialize: function(){
@@ -73,6 +75,8 @@ var HubView = ScrollableView.extend({
play.className = "play"
$(".gallery-" + row.id).append(play)
}
+ $t.find("gallery-left").remove()
+ $t.find("gallery-right").remove()
}
}.bind(this))
@@ -83,5 +87,12 @@ var HubView = ScrollableView.extend({
store_link: function(){
app.router.go("store")
},
+
+ gallery_prev: function(e){
+ $(e.currentTarget).closest("hub_item").flickity('prev')
+ },
+ gallery_next: function(e){
+ $(e.currentTarget).closest("hub_item").flickity('next')
+ },
}) \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js
index 1a9653e1..9b8205c1 100644
--- a/StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js
+++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartShipping.js
@@ -101,7 +101,7 @@ var CartShipping = FormView.extend({
shipping_info.City = address_data.City
shipping_info.Province = address_data.Province
shipping_info.Region = address_data.Province
- shipping_info.CountryCode = "US"
+ shipping_info.CountryCode = CANADIAN_LOOKUP[ address_data.Province ] ? "CA" : "US"
return shipping_info
},
diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js
index 9a24afa5..72c44405 100644
--- a/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js
+++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartSummary.js
@@ -64,6 +64,7 @@ var CartSummary = ScrollableView.extend({
var size_id = item['Size']
var $el = $("<div>").addClass("cart_item_row")
+ $el.html("<img src='img/spinner.gif'>")
$el.data({
code: code_ten,
size: size_id,
@@ -95,6 +96,10 @@ var CartSummary = ScrollableView.extend({
// console.log(size)
size_name = size['Default']['Text']
size_name = SIZE_LOOKUP[ size_name ] || size_name
+ if (! size_name && ! size['Default']['Labeled']) {
+ size_name = size['Default']['Text'] + " " + size['Default']['ClassFamily']
+ }
+
return true
}
return false
@@ -109,7 +114,6 @@ var CartSummary = ScrollableView.extend({
.replace(/{{color}}/, color_name)
.replace(/{{quantity}}/, 1)
.replace(/{{price}}/, as_cash(details.Item.Price.DiscountedPrice))
- $el.data("price", details.Item.Price.DiscountedPrice)
$el.html(t)
this.refreshScroller()
}.bind(this))
diff --git a/StoneIsland/platforms/ios/www/js/lib/cart/CartThanks.js b/StoneIsland/platforms/ios/www/js/lib/cart/CartThanks.js
index 993fd9ac..eb95197b 100644
--- a/StoneIsland/platforms/ios/www/js/lib/cart/CartThanks.js
+++ b/StoneIsland/platforms/ios/www/js/lib/cart/CartThanks.js
@@ -14,6 +14,8 @@ var CartThanks = View.extend({
app.cart.el.className = "thanks"
app.footer.show("&lt; BACK TO COLLECTION")
app.footer.hide()
+
+ app.orders.loaded = false
},
ok: function(){
diff --git a/StoneIsland/platforms/ios/www/js/lib/etc/deeplink.js b/StoneIsland/platforms/ios/www/js/lib/etc/deeplink.js
new file mode 100644
index 00000000..648dd167
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/etc/deeplink.js
@@ -0,0 +1,3 @@
+function handleOpenURL (url) {
+ app.router.initial_route = url
+} \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/etc/geo.js b/StoneIsland/platforms/ios/www/js/lib/etc/geo.js
new file mode 100644
index 00000000..0270d681
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/etc/geo.js
@@ -0,0 +1,33 @@
+var geo = (function(){
+ var geo = {}
+
+ geo.fetch = function(){
+ navigator.geolocation.getCurrentPosition(geo.success, geo.error, {timeout: 15000})
+ }
+
+ geo.success = function(position){
+ var lat_str = as_degrees( position.coords.latitude )
+ var lng_str = as_degrees( position.coords.longitude )
+ }
+
+ geo.error = function(error){
+ $(".latlng").html( "+40&deg; 58' 90\" -74&deg; 04' 46\"" )
+ }
+
+ function as_degrees (n) {
+ var s = ""
+ if (n >= 0) s += "+"
+ s += Math.floor(n) + "&deg; "
+
+ n %= 1
+ n *= 60
+ s += Math.floor(n) + "'"
+
+ n %= 1
+ n *= 60
+
+ s += Math.floor(n) + '"'
+ }
+
+ return geo
+})() \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/etc/push.js b/StoneIsland/platforms/ios/www/js/lib/etc/push.js
new file mode 100644
index 00000000..ab0c0141
--- /dev/null
+++ b/StoneIsland/platforms/ios/www/js/lib/etc/push.js
@@ -0,0 +1 @@
+// \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js b/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
index 31e9d802..ad5745fb 100644
--- a/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
@@ -6,6 +6,7 @@ var AddressView = SerializableView.extend({
disabled: false,
events: {
+ "change [name=Province]": 'update_country',
},
initialize: function(opt){
@@ -22,6 +23,7 @@ var AddressView = SerializableView.extend({
data.Address2 = address[1]
this.$(".address input").val("")
this.load_data(data)
+ this.update_country()
},
validate_presence: {
@@ -43,8 +45,22 @@ var AddressView = SerializableView.extend({
delete data.Address2
},
+ update_country: function(){
+ var state = this.$("[name=Province]").val()
+ console.log(state)
+ if (CANADIAN_LOOKUP[state]) {
+ this.$(".country-label").html("CANADA")
+ }
+ else {
+ this.$(".country-label").html("UNITED STATES")
+ }
+ },
+
})
+var CANADIAN_PROVINCES = "AB BC MB NB NL NS NT NU ON PE SK QC YT".split(" ")
+var CANADIAN_LOOKUP = {}
+CANADIAN_PROVINCES.forEach(function(k){ CANADIAN_LOOKUP[k] = true })
var COUNTRIES = [
['Country Name', 'NONE'],
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js b/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js
index 1855b7a9..ba3ac54a 100644
--- a/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/nav/CreditCardView.js
@@ -4,7 +4,7 @@ var CreditCardView = SerializableView.extend({
template: $("#creditcard_template").html(),
cardOptions: {
- accept: ['visa', 'mastercard', 'amex'],
+ accept: ['visa', 'mastercard', 'amex', 'jcb'],
},
events: {
@@ -46,8 +46,15 @@ var CreditCardView = SerializableView.extend({
if (! data.ExpirationYear || data.ExpirationYear == "NONE") { errors.push([ "ExpirationYear", "Please select the expiration month." ]) }
data.UserId = auth.user_id
if (card.valid) {
- data.Type = card.card_type.name
+ data.Type = YOOX_CREDIT_CARD_NAME_LOOKUP[ card.card_type.name ]
}
},
})
+
+var YOOX_CREDIT_CARD_NAME_LOOKUP = {
+ "visa": "Visa",
+ "mastercard": "Mastercard",
+ "amex": "AmericanExpress",
+ "jcb": "JCB",
+}
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js b/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js
index e35b789d..056f2a52 100644
--- a/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/products/CollectionView.js
@@ -33,7 +33,7 @@ var CollectionView = ScrollableView.extend({
if (this.loaded) {
return this.populate(this.data)
}
- this.fetch()
+ // this.fetch()
},
save: function(){
@@ -44,7 +44,7 @@ var CollectionView = ScrollableView.extend({
if (this.loaded) return
this.$loader.show()
sdk.product.collection({
- gallery_id: 32780,
+ gallery_id: app.gallery_id,
success: this.populate.bind(this)
})
},
@@ -65,6 +65,7 @@ var CollectionView = ScrollableView.extend({
this.deferScrollToTop()
}
this.afterFetchCallback && this.afterFetchCallback()
+ app.collection.deferRefresh()
},
append: function(item){
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js b/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js
index ea4637eb..b36c5df2 100644
--- a/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/products/GalleryView.js
@@ -31,7 +31,7 @@ var GalleryView = View.extend({
valid_styles[style] = size
}
})
- Object.keys(valid_styles).forEach(function(style){
+ Object.keys(valid_styles).sort(sort_image_styles).forEach(function(style){
var id = valid_styles[style] + "_" + style
var t = this.template.replace(/{{image}}/, sdk.image(code, id))
this.$el.append(t)
@@ -62,4 +62,8 @@ var GalleryView = View.extend({
touchend: function(e){
},
-}) \ No newline at end of file
+})
+
+var YOOX_IMAGE_STYLE_ORDER = "ZZZ d f".split(" ")
+
+function sort_image_styles (b,a){ return (YOOX_IMAGE_STYLE_ORDER.indexOf(a)) - (YOOX_IMAGE_STYLE_ORDER.indexOf(b)) } \ No newline at end of file
diff --git a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js
index e151c208..92a0e0f7 100644
--- a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js
@@ -4,9 +4,12 @@ var ProductView = ScrollableView.extend({
el: "#product",
events: {
+ "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(){
@@ -20,6 +23,8 @@ var ProductView = ScrollableView.extend({
this.$size = this.$(".size")
this.$color = this.$(".color")
this.$body = this.$(".body")
+ this.$fit = this.$(".fit")
+ this.$sizing = this.$(".sizing")
},
show: function(){
@@ -41,8 +46,15 @@ var ProductView = ScrollableView.extend({
cache: {},
+ gallery_prev: function(){
+ this.gallery.gallery.flickity('prev')
+ },
+ gallery_right: function(){
+ this.gallery.gallery.flickity('next')
+ },
+
find: function(code, cb){
- data = app.collection.items[code]
+ data = app.collection.items[code] || {}
if (code in this.cache) {
return cb(data, this.cache[code])
}
@@ -165,9 +177,14 @@ var ProductView = ScrollableView.extend({
sizes: {},
}
})
+
details['Item']['ModelSizes'].forEach(function(size){
var label = SIZE_LOOKUP[ size['Default']['Text'] ]
+ if (! label && ! size['Default']['Labeled']) {
+ label = size['Default']['Text'] + " " + size['Default']['ClassFamily']
+ }
size_lookup[ label ] = size['SizeId']
+ console.log( label )
sizes[ size['SizeId'] ] = {
id: label,
label: label.toUpperCase(),
@@ -242,6 +259,9 @@ var ProductView = ScrollableView.extend({
app.router.go('store')
},
+ scroll_to_bottom: function(){
+ },
+
share: function(){
},
diff --git a/StoneIsland/platforms/ios/www/js/lib/view/Scrollable.js b/StoneIsland/platforms/ios/www/js/lib/view/Scrollable.js
index 7cd96f89..d06ed590 100644
--- a/StoneIsland/platforms/ios/www/js/lib/view/Scrollable.js
+++ b/StoneIsland/platforms/ios/www/js/lib/view/Scrollable.js
@@ -1,7 +1,7 @@
var ScrollableView = View.extend({
events: {
- "load img": "deferScrollToTop",
+ "load img": "deferRefresh",
},
deferScrollToTop: function(){
@@ -10,8 +10,15 @@ var ScrollableView = View.extend({
refreshScroller: function(){
this.scroller.refresh()
+ clearTimeout( this.scrollerRefreshTimeout )
},
-
+
+ scrollerRefreshTimeout: null,
+ deferRefresh: function(){
+ clearTimeout( this.scrollerRefreshTimeout )
+ this.scrollerRefreshTimeout = setTimeout(this.refreshScroller.bind(this))
+ },
+
scrollToTop: function(){
this.scroller.refresh()
app.collection.scroller.scrollTo(0, 0)
diff --git a/StoneIsland/platforms/ios/www/js/sdk/account.js b/StoneIsland/platforms/ios/www/js/sdk/account.js
index fe5f03cd..3eb3f3bd 100644
--- a/StoneIsland/platforms/ios/www/js/sdk/account.js
+++ b/StoneIsland/platforms/ios/www/js/sdk/account.js
@@ -96,6 +96,38 @@ sdk.account = (function(){
})
}
+ account.fetch_orders = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/orders.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
+ account.fetch_single_order = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Account.API/1.5", "users/" + auth.user_id + "/orders/" + opt.id + ".json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-account-token": auth.access_token,
+ },
+ data: JSON.stringify( opt.data ),
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
return account
})()
diff --git a/StoneIsland/platforms/ios/www/js/sdk/cart.js b/StoneIsland/platforms/ios/www/js/sdk/cart.js
index a5e85089..3ff2e1d2 100644
--- a/StoneIsland/platforms/ios/www/js/sdk/cart.js
+++ b/StoneIsland/platforms/ios/www/js/sdk/cart.js
@@ -140,6 +140,22 @@ sdk.cart = (function(){
})
}
+ cart.get_card_types = function(opt){
+ return $.ajax({
+ method: "GET",
+ url: sdk.path("Cart.API/1.6", "cardTypes.json"),
+ headers: {
+ "x-yoox-appname": auth.appname,
+ "x-yoox-cart-token": cart.token,
+ },
+ data: "",
+ success: function(data){
+ opt.success(data)
+ },
+ error: opt.error,
+ })
+ }
+
// use with full CC data if not storing it in wallet
cart.set_credit_card = function(opt){
return $.ajax({