diff options
Diffstat (limited to 'StoneIsland/platforms/ios/www/js')
5 files changed, 93 insertions, 10 deletions
diff --git a/StoneIsland/platforms/ios/www/js/index.js b/StoneIsland/platforms/ios/www/js/index.js index eb3b32b9..511849ad 100755 --- a/StoneIsland/platforms/ios/www/js/index.js +++ b/StoneIsland/platforms/ios/www/js/index.js @@ -79,10 +79,16 @@ var app = (function(){ cordova.plugins.Keyboard.disableScroll(true) cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false) geo.fetch() + sim.fetch(app.api_ready) var image = new Image image.src = "./img/compass-logo.png" } - + else { + app.api_ready() + } + } + + app.api_ready = function(){ if (is_iphone_x) { StatusBar.hide() } diff --git a/StoneIsland/platforms/ios/www/js/lib/etc/sim.js b/StoneIsland/platforms/ios/www/js/lib/etc/sim.js new file mode 100644 index 00000000..ca01ddc7 --- /dev/null +++ b/StoneIsland/platforms/ios/www/js/lib/etc/sim.js @@ -0,0 +1,44 @@ +var sim = (function(){ + var sim = {} + + sim.loaded = false + sim.data = { + carrierName: 'unknown', + countryCode: 'us', + mcc: '0', + mnc: '0', + } + + sim.fetch = function(cb){ + sim.afterFetch = cb + window.plugins.sim.getSimInfo(sim.success, sim.error) + } + + sim.afterFetch = function(){} + + sim.success = function(data){ + console.log(data) + if (sim.data.countryCode) { + sim.data = data + sim.data.countryCode = sim.data.countryCode.toLowerCase() + // app is only available in US or Canada, so call the US API regardless + if (sim.data.countryCode !== 'ca') { + sim.data.countryCode = 'us' + } + } + sim.loaded = true + sim.afterFetch() + } + + sim.error = function(){ + console.log("no SIM card detected") + $.ajax({ + url: "http://ip-api.com/json/", + jsonp: "callback", + dataType: "jsonp", + success: sim.success, + }) + } + + return sim +})()
\ 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 4a05c4b6..fd7df218 100755 --- a/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js +++ b/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js @@ -2,6 +2,8 @@ var AddressView = SerializableView.extend({ template: $("#address_template").html(), + us_states: $("#us_states").html(), + ca_states: $("#ca_states").html(), disabled: false, @@ -18,6 +20,11 @@ var AddressView = SerializableView.extend({ }, populate: function(data){ + this.$("[name=Province]").empty() + this.$("[name=Province]").append(this.us_states) + if (! app.store.notAvailableInCanada) { + this.$("[name=Province]").append(this.ca_states) + } this.data = data var address = data.Address.split("\n") data.Address1 = address[0] diff --git a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js index c1847496..7434888c 100755 --- a/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js +++ b/StoneIsland/platforms/ios/www/js/lib/products/ProductView.js @@ -5,6 +5,7 @@ var ProductView = ScrollableView.extend({ events: { "click .fit": "scroll_to_bottom", + "click .notAvailableInCanada": "scroll_to_bottom", "click .size": "select_size", "click .color": "select_color", "click .share": "share", @@ -25,6 +26,7 @@ var ProductView = ScrollableView.extend({ this.$color = this.$(".color") this.$body = this.$(".body") this.$fit = this.$(".fit") + this.$notAvailableInCanada = this.$(".notAvailableInCanada") this.$sizing = this.$(".sizing") this.$style = this.$(".style") }, @@ -39,9 +41,12 @@ var ProductView = ScrollableView.extend({ }, showFooter: function(){ - if (this.not_available) { + if (this.sold_out) { app.footer.show("SOLD OUT") } + else if (this.isNotAvailable) { + app.footer.show("NOT AVAILABLE") + } else { app.footer.show("ADD TO CART", "BUY NOW") } @@ -125,7 +130,20 @@ var ProductView = ScrollableView.extend({ var default_color_id = this.populate_selectors(data, details) - if (this.not_available) { + var notAvailableInCanada = !! app.store.notAvailableInCanada + app.product.$notAvailableInCanada.toggle( notAvailableInCanada ) + if (notAvailableInCanada && sim.data.countryCode === 'ca') { + this.isNotAvailable = true + } + else { + this.isNotAvailable = false + } + + if (! ('Price' in details['Item'])) { + this.isNotAvailable = true + } + + if (this.sold_out || this.isNotAvailable) { this.$style.css("opacity", 0) this.$color.html("NOT AVAILABLE") this.$size.hide() @@ -206,11 +224,11 @@ var ProductView = ScrollableView.extend({ console.log('colors:', modelColors.length || "none") if (! modelColors.length) { - this.not_available = true + this.sold_out = true return } else { - this.not_available = false + this.sold_out = false } modelColors.forEach(function(color, index){ @@ -261,7 +279,8 @@ var ProductView = ScrollableView.extend({ }, select_size: function(){ - if (this.not_available) { return } + if (this.sold_out) { return } + if (this.notAvailable) { 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){ @@ -276,7 +295,8 @@ var ProductView = ScrollableView.extend({ }, select_color: function(){ - if (this.not_available) { return } + if (this.sold_out) { return } + if (this.notAvailable) { return } if (this.item['Colors'].length == 0) { return } var colors = Object.keys(this.colors).map(function(key){ return this.colors[key] @@ -291,12 +311,14 @@ var ProductView = ScrollableView.extend({ // ADD TO CART save: function(){ - if (this.not_available) { return } + if (this.sold_out) { return } + if (this.notAvailable) { return } this.add_to_cart({ route: false }) }, // BUY NOW cancel: function(){ - if (this.not_available) { return } + if (this.sold_out) { return } + if (this.notAvailable) { return } this.add_to_cart({ route: true }) }, diff --git a/StoneIsland/platforms/ios/www/js/sdk/_sdk.js b/StoneIsland/platforms/ios/www/js/sdk/_sdk.js index 7b4966a5..fc871727 100755 --- a/StoneIsland/platforms/ios/www/js/sdk/_sdk.js +++ b/StoneIsland/platforms/ios/www/js/sdk/_sdk.js @@ -22,13 +22,17 @@ var sdk = (function(){ } sdk.path = function(api, path){ - return endpoint + api + "/STONEISLAND_US/" + path + return endpoint + api + "/STONEISLAND_" + sdk.cc() + "/" + path } sdk.image = function(code, size){ return "https://cdn.yoox.biz/" + code.substr(0,2) + "/" + code + "_" + size + ".jpg" } + sdk.cc = function(){ + return sim.data.countryCode.toUpperCase() + } + sdk.cms = function(){ return "https://stone.giraffe.life" // return "https://staging.stone.giraffe.life" |
