diff options
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js')
23 files changed, 333 insertions, 90 deletions
diff --git a/StoneIsland/platforms/android/assets/www/js/index.js b/StoneIsland/platforms/android/assets/www/js/index.js index 9b54ad44..a8caa2e5 100755 --- a/StoneIsland/platforms/android/assets/www/js/index.js +++ b/StoneIsland/platforms/android/assets/www/js/index.js @@ -57,7 +57,8 @@ var app = (function(){ app.orders = new OrdersView () app.terms = new PageView ({ page: "terms" }) - app.privacy = new PageView ({ page: "privacy" }) + app.privacy = new PageView ({ page: "privacy" }) + app.account_terms = new PageView ({ page: "account_terms" }) app.returns = new PageView ({ page: "returns" }) app.care = new PageView ({ page: "care" }) @@ -96,17 +97,17 @@ var app = (function(){ app.view = null app.router = new SiteRouter () -// if (sdk.env == "test") { -// app.router.launch() -// } -// else { -// } + // if (sdk.env == "test") { + // app.router.launch() + // } + // else { + // } if (navigator.onLine) { app.account.connect(window.deepLinkRoute || '/intro') app.blog.fetch(function(){ console.log("navigating to deep link route after fetch") - app.router.initial_route = window.deepLinkRoute || "/intro" + app.router.initial_route = window.deepLinkRoute || null app.router.launch() }) } diff --git a/StoneIsland/platforms/android/assets/www/js/lib/_router.js b/StoneIsland/platforms/android/assets/www/js/lib/_router.js index 19bd3247..91f29b55 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/_router.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/_router.js @@ -4,53 +4,57 @@ var SiteRouter = Router.extend({ routeByHash: true, routes: { - '/': 'intro', - '/intro': 'intro', - '/hub': 'hub', - '/story': 'story', - '/archive': 'archive', + '/': 'intro', + '/intro': 'intro', + '/hub': 'hub', + '/story': 'story', + '/archive': 'archive', - '/store': 'collection', - '/store/closed': 'closed', - '/store/:code': 'product', + '/store': 'collection', + '/store/closed': 'closed', + '/store/:code': 'product', - '/account/login': 'login', - '/account/logout': 'logout', - '/account/signup': 'signup', - '/account/profile': 'profile', - '/account/payment': 'payment', - '/account/shipping': 'shipping', - '/account/orders': 'orders', - '/account/settings': 'settings', + '/account/login': 'login', + '/account/logout': 'logout', + '/account/signup': 'signup', + '/account/profile': 'profile', + '/account/payment': 'payment', + '/account/shipping': 'shipping', + '/account/orders': 'orders', + '/account/settings': 'settings', - '/page/terms': 'terms', - '/page/privacy': 'privacy', - '/page/returns': 'returns', - '/page/care': 'care', + '/page/terms': 'terms', + '/page/account_terms': 'account_terms', + '/page/privacy': 'privacy', + '/page/returns': 'returns', + '/page/care': 'care', - '/search': 'search', + '/search': 'search', - '/cart': 'cart.summary', - '/cart/summary': 'cart.summary', - '/cart/payment': 'cart.payment', - '/cart/shipping': 'cart.shipping', - '/cart/confirm': 'cart.confirm', - '/cart/thanks': 'cart.thanks', - '/cart/error': 'cart.error', + '/cart': 'cart.summary', + '/cart/summary': 'cart.summary', + '/cart/payment': 'cart.payment', + '/cart/shipping': 'cart.shipping', + '/cart/confirm': 'cart.confirm', + '/cart/thanks': 'cart.thanks', + '/cart/error': 'cart.error', }, - + + terms_routes: ['terms','account_terms','privacy','returns','care','logout'], + initialize: function(){ var fn - for (var route in this.routes) { - fn = this.routes[route] - if (! this[fn]) { - this[fn] = this.default_view(fn) - } - } + for (var route in this.routes) { + fn = this.routes[route] + if (! this[fn]) { + this[fn] = this.default_view(fn) + } + } }, initial_route: null, launch: function(){ + console.log("LAUNCH!") if (this.initial_route) { this.parseRoute( this.initial_route ) } @@ -73,6 +77,7 @@ var SiteRouter = Router.extend({ default_view: function(name){ var fn = function(){ console.log(name) + var n = [name] if (app.view != app.login && app.view != app.signin) { app.last_view = app.view } @@ -80,7 +85,7 @@ var SiteRouter = Router.extend({ app.view.hide() } if (name.match(/\./)) { - var n = name.split(".") + n = name.split(".") console.log(name, n) app.view = app[n[0]][n[1]] } @@ -89,9 +94,22 @@ var SiteRouter = Router.extend({ } // window.FirebasePlugin && window.FirebasePlugin.setScreenName(name) - + console.log("view >>", app.view) app.header.set_back( !! app.view.back ) app.view.show() + + // var isTermsRoute = this.terms_routes.indexOf(name) !== -1 + // var isCartRoute = n[0] === 'cart' + // if ( (isCartRoute || app.demand_consent && !isTermsRoute) && app.account.consent.check()) { + // console.log('showed consent modal') + // return + // } + + var isTermsRoute = this.terms_routes.indexOf(name) !== -1 + if (app.demand_consent && !isTermsRoute && app.account.consent.check()) { + console.log('showed consent modal') + return + } }.bind(this) return fn }, diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js index 4a6ff9e0..4605416c 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js @@ -1,6 +1,7 @@ var AccountView = View.extend({ initialize: function(){ + this.consent = new ConsentModal({ parent: this }) }, connect: function(initialLoginPath){ diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/ConsentModal.js b/StoneIsland/platforms/android/assets/www/js/lib/account/ConsentModal.js new file mode 100644 index 00000000..dfeb4fac --- /dev/null +++ b/StoneIsland/platforms/android/assets/www/js/lib/account/ConsentModal.js @@ -0,0 +1,85 @@ +var ConsentModal = View.extend({ + + el: "#consent_modal", + + events: { + "change [name=AccountTermsConsent]": "changeConsent", + "click #consent_proceed": "proceed", + "click #consent_logout": "logout", + "click a": "navigate", + }, + + initialize: function(){ + this.$form = this.$(".form") + this.$msg = this.$(".msg") + this.$checkbox = this.$("[name=AccountTermsConsent]") + this.$consentError = this.$("#consent_error") + }, + + check: function(){ + var status = localStorage.getItem('account_terms.consent') + if (status !== 'true') { + app.demand_consent = true + this.show() + return true + } else { + this.hide() + app.demand_consent = false + return false + } + }, + + show: function(){ + app.demand_consent = true + this.$el.show() + setTimeout(function(){ + this.$el.addClass('visible') + }.bind(this), 20) + app.curtain.show() + app.curtain.classList.add('opaque') + }, + + hide: function(){ + app.curtain.hide() + this.$el.removeClass('visible') + setTimeout(function(){ + this.$el.hide() + app.curtain.classList.remove('opaque') + }.bind(this), 300) + }, + + navigate: function(e){ + var href = $(e.currentTarget).attr('href').replace('#', '') + console.log(href) + this.hide() + app.router.go(href) + }, + + changeConsent: function(){ + var state = this.$checkbox.prop("checked") + if (state) { + this.$consentError.removeClass('visible') + } else { + this.$consentError.addClass('visible') + } + }, + + proceed: function(){ + var state = this.$checkbox.prop("checked") + if (!state) { + this.$consentError.addClass('visible') + return + } + app.demand_consent = false + this.hide() + localStorage.setItem('account_terms.consent', 'true') + }, + + logout: function(){ + app.demand_consent = false + this.hide() + localStorage.setItem('account_terms.consent', 'false') + app.router.go("account/logout") + }, + +})
\ No newline at end of file diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/OrdersView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/OrdersView.js index b3ff3e7a..ee0eb277 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/account/OrdersView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/account/OrdersView.js @@ -36,6 +36,7 @@ var OrdersView = ScrollableView.extend({ app.closed.setMessage("PLEASE GO ONLINE TO VIEW<br>YOUR ORDERS.", "") return } + app.account.consent.check() app.header.set_back(false) app.footer.hide() document.body.className = "orders" diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js index 796ea188..0fcf7e8f 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js @@ -39,6 +39,7 @@ var PaymentView = FormView.extend({ app.closed.setMessage("PLEASE GO ONLINE TO CHANGE<br>YOUR PAYMENT INFO.", "") return } + app.account.consent.check() app.footer.show("SAVE") document.body.className = "payment" this.deferScrollToTop() @@ -74,8 +75,9 @@ var PaymentView = FormView.extend({ app.curtain.show("loading") app.account.listAddresses({ success: function(){ + this.$msg.html('Your payment information has been saved.') app.curtain.hide("loading") - }, + }.bind(this), error: function(){ app.curtain.hide("loading") }, diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js index ee39374b..a4e06791 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js @@ -21,6 +21,8 @@ var ProfileView = FormView.extend({ app.closed.setMessage("PLEASE GO ONLINE TO<br>EDIT YOUR PROFILE.", "") return } + if (! auth.user) return + app.account.consent.check() app.footer.show("SAVE") document.body.className = "profile" if (auth.user.BirthDay.match(/T/)) { @@ -47,6 +49,7 @@ var ProfileView = FormView.extend({ "Name": "Please enter your first name.", "Surname": "Please enter your last name.", "Email": "Please enter a valid email address.", + "BirthDay": "Please your birthday.", }, validate_fields: function(data, errors){ @@ -54,7 +57,14 @@ 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.Birthday) data.BirthDay = '1900-01-01' + var now = new Date () + var year = now.getFullYear() + if (! data.BirthDay) data.BirthDay = year + '-01-01' + if (data.BirthDay.split('-')[0] || '2018') + var birthday = new Date (data.BirthDay) + if (isNaN(birthday) || (now - birthday) / (365*24*60*60*1000) < 18) { + errors.push(['BirthDay', 'You must be 18 or older to use the Stone Island app.']) + } // if (data.Gender === "NONE") { errors.push([ "Gender", "Please supply your gender." ]) } }, diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js index 90ace549..5586e0fd 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js @@ -22,6 +22,7 @@ var SettingsView = FormView.extend({ app.closed.setMessage("PLEASE GO ONLINE TO CHANGE<br>YOUR NOTIFICATION SETTINGS.", "") return } + app.account.consent.check() document.body.className = "settings" this.deferScrollToTop() diff --git a/StoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js b/StoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js index 67a1cfec..c1bac782 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js @@ -38,6 +38,7 @@ var ShippingView = FormView.extend({ return } // this.preload( this.data || this.test_data ) + app.account.consent.check() app.footer.show("SAVE") document.body.className = "shipping" this.deferScrollToTop() @@ -68,8 +69,9 @@ var ShippingView = FormView.extend({ app.curtain.show("loading") app.account.listAddresses({ success: function(){ + this.$msg.html('Your address has been saved.') app.curtain.hide("loading") - }, + }.bind(this), error: function(){ app.curtain.hide("loading") }, diff --git a/StoneIsland/platforms/android/assets/www/js/lib/auth/LogoutView.js b/StoneIsland/platforms/android/assets/www/js/lib/auth/LogoutView.js index 481dcb8d..89091473 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/auth/LogoutView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/auth/LogoutView.js @@ -10,6 +10,8 @@ var LogoutView = View.extend({ app.header.set_cart_count(0) app.footer.hide() auth.log_out() + app.demand_consent = false + app.account.consent.hide() app.account.logged_out() }, diff --git a/StoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js b/StoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js index ed702a03..078f7c07 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/auth/SignupView.js @@ -49,10 +49,11 @@ var SignupView = FormView.extend({ "Surname": "Please enter your last name.", "Email": "Please enter a valid email address.", "ConfirmEmail": "Please enter a valid email address.", - // "BirthDay": "Please enter your birthday.", + "BirthDay": "Please enter your birthday. You must be 18 or older to use the Stone Island app.", "Password": "Please enter your password.", "Password2": "Please enter your password again.", - "DataProfiling": "You must agree to data profiling.", + "DataProfiling": "You must consent to data profiling to use the Stone Island app.", + "AccountTerms": "You must agree to the Your My Account terms.", }, validate_fields: function(data, errors){ @@ -62,8 +63,18 @@ var SignupView = FormView.extend({ 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.DataProfiling !== "true") { errors.push([ "DataProfiling", "You must consent to use this service." ]) } - if (! data.BirthDay) data.BirthDay = '1900-01-01' + if (data.DataProfiling !== "true") { errors.push([ "DataProfiling", "You must consent to data profiling to use the Stone Island app." ]) } + if (data.AccountTerms !== "true") { errors.push([ "AccountTerms", "You must agree to the Your My Account terms to use the Stone Island app." ]) } + + var now = new Date () + var year = now.getFullYear() + if (! data.Birthday) data.BirthDay = year + '-01-01' + if (data.BirthDay.split('-')[0] || '2018') + var birthday = new Date (data.BirthDay) + if (isNaN(birthday) || (now - birthday) / (365*24*60*60*1000) < 18) { + errors.push(['BirthDay', 'You must be 18 or older to use the Stone Island app.']) + } + data.YooxLetter = this.$("[name=YooxLetter]").prop("checked") }, @@ -96,6 +107,7 @@ var SignupView = FormView.extend({ auth.user.Surname = this.last_data.Surname auth.user.Email = this.last_data.Email auth.user.BirthDay = this.last_data.BirthDay + localStorage.setItem('account_terms.consent', 'true') app.account.logged_in(function(){ app.router.go("store") }) }, diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js index 6eea977f..e58c975c 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/BlogView.js @@ -54,6 +54,7 @@ var BlogView = View.extend({ app.closed.storeClosedMessageTwo = app.store.StoreClosedMessageTwo break } + console.log(data) if (app.closed.storeIsClosed && sdk.env !== 'test') { app.closed.populate(app.store.ClosedStoreImages) @@ -87,7 +88,7 @@ var BlogView = View.extend({ }.bind(this)) data.page.forEach(function(page){ - app[page.tag].populate(page) + app[page.tag] && app[page.tag].populate(page) }) console.log(app.store.StoreStatus) diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js index 5e2ff67e..b072a887 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/HubView.js @@ -153,6 +153,7 @@ var HubLoader = (function(){ var HubLoader = {} var loader var needed = false + var loading = false HubLoader.init = function(v){ view = v } @@ -163,7 +164,8 @@ var HubLoader = (function(){ HubLoader.load = function(){ item = queue.shift() count++ - if (! item) return + if (! item || loading) return + loading = true if (item.image && item.image.length) { loader = new Loader (HubLoader.build) images = item.image.map(function(img){ @@ -179,11 +181,13 @@ var HubLoader = (function(){ } HubLoader.isNeeded = function(){ needed = true + if (!loading) HubLoader.load() } HubLoader.build = function(){ view.append(item) view.scroller.refresh() - if (count < 2 && ! needed) return + loading = false + if (count > 3 && ! needed) return // if (count === 10) return setTimeout(HubLoader.load, count < 10 ? 1000 : 5000) } diff --git a/StoneIsland/platforms/android/assets/www/js/lib/blogs/PageView.js b/StoneIsland/platforms/android/assets/www/js/lib/blogs/PageView.js index f5f8ab2e..ae18091a 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/blogs/PageView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/blogs/PageView.js @@ -22,10 +22,11 @@ var PageView = ScrollableView.extend({ this.$content.html(data.body.replace(/\n/g, "<br>")) this.$content.find("a").each(function(){ var href = $(this).attr("href") // .substr(1, "fuck".length-2) - if (href.indexOf("“")) { + if (href.indexOf("“") !== -1) { href = href.substr(1, href.length-2) $(this).attr("href", href) } + console.log(href) $(this).attr("target", "_system") }) }, @@ -35,7 +36,11 @@ var PageView = ScrollableView.extend({ e.preventDefault() var href = $(e.currentTarget).attr("href") console.log(href) - window.open(href, '_system') + if (href.indexOf('http') !== 0) { + app.router.go(href.replace('!/', '')) + } else { + window.open(href, '_system') + } }, })
\ No newline at end of file diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js index a82509af..031e3359 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartConfirm.js @@ -110,20 +110,31 @@ var CartConfirm = FormView.extend({ this.$tax.html( as_cash(tax) ) this.$total.html( as_cash(total) ) - var street = data.Receiver.StreetWithNumber.replace(/\n$/,"").replace("\n", ", ") - var address = data.Receiver.Name.toUpperCase() + " " + data.Receiver.Surname.toUpperCase() + "<br>" + street + ", " - address += data.Receiver.City + ", " + data.Receiver.Region + " " + data.Receiver.PostalCode + if (data.Receiver) { + var street = data.Receiver.StreetWithNumber.replace(/\n$/,"").replace("\n", ", ") + var address = data.Receiver.Name.toUpperCase() + " " + data.Receiver.Surname.toUpperCase() + "<br>" + street + ", " + address += data.Receiver.City + ", " + data.Receiver.Region + " " + data.Receiver.PostalCode - this.$shipping_address.html(address) - this.$shipping_method.html(data.DeliveryMethod.Selected.Type == 1 ? "* STANDARD SHIPPING" : "* EXPRESS SHIPPING") + this.$shipping_address.html(address) + this.$shipping_method.html(data.DeliveryMethod.Selected.Type == 1 ? "* STANDARD SHIPPING" : "* EXPRESS SHIPPING") + } else { + this.$shipping_address.html( "Please enter your shipping information." ) + this.$shipping_method.html( "" ) + } var cc = data.Payment.CreditCard - var cc_street = cc.HolderAddress.replace(/\n$/,"").replace("\n", ", ") - var cc_type = cc.Type == "AmericanExpress" ? "American Express" : cc.Type + if (cc) { + var cc_street = cc.HolderAddress.replace(/\n$/,"").replace("\n", ", ") + var cc_type = cc.Type == "AmericanExpress" ? "American Express" : cc.Type + var cc_name = cc.HolderName.toUpperCase() + " " + cc.HolderSurname.toUpperCase() + var cc_eNcrYpTed = cc_type.toUpperCase() + " XXXX-XXXX-XXXX-" + cc.Last4 + this.$payment_name.html( cc_name ) + this.$payment_method.html( cc_eNcrYpTed ) + } else { + this.$payment_name.html( "Please enter your credit card information." ) + this.$payment_method.html( "" ) + } - this.$payment_name.html( cc.HolderName.toUpperCase() + " " + cc.HolderSurname.toUpperCase() ) - this.$payment_method.html( cc_type.toUpperCase() + " XXXX-XXXX-XXXX-" + cc.Last4 ) - app.curtain.hide("loading") }, @@ -132,7 +143,9 @@ var CartConfirm = FormView.extend({ promise(sdk.cart.finalize, {}).then(function(){ app.curtain.hide("loading") app.router.go('cart/thanks') - }.bind(this)).error(function(data){ + }.bind(this)).error(function(res){ + const data = res.responseJSON + console.log(data) app.curtain.hide("loading") // {"Header":{"StatusCode":403,"Description":"403 Forbidden"},"Error":{"Description":"GenericApiError:CartAlreadyClosed"}} // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\\"Item has been removed from cart because it is no longer available.\\"\\n235"}}' @@ -140,7 +153,7 @@ var CartConfirm = FormView.extend({ // {"Header":{"StatusCode":409,"Description":"304 NotModified"},"Error":{"Description":"FinalizationError:\"The reciever validation fails."}} // {"Header":{"StatusCode":440,"Description":"304 NotModified"},"Error":{"Description":"GenericApiError:CartFinalizationNotYetCompleted"}} // {"Header":{"StatusCode":441,"Description":"304 NotModified"},"Error":{"Description":"GenericApiError:EmptyCreditCard"}} - switch (data.StatusCode) { + switch (data.StatusCode || data.Header.StatusCode) { case 403: // cart already closed auth.clear_cart(auth.create_cart) app.router.go('thanks') @@ -158,14 +171,17 @@ var CartConfirm = FormView.extend({ }, finalization_error: function(data){ - if (data['Error']['Description'].match(/receiver validation fails/)) { - app.router.go('cart/shipping') + if (data['Error']['Description'].match(/receiver validation fails/i)) { + console.log('cc error') + app.router.go('cart/billing') app.cart.payment.show_errors([["Number","There was a problem with your credit card."]]) } - else if (data['Error']['Description'].match(/cart cannot be empty/)) { + else if (data['Error']['Description'].match(/cart cannot be empty/i)) { + console.log('cart empty') app.router.go('cart/summary') } - else if (data['Error']['Description'].match(/Item has been removed/)) { + else if (data['Error']['Description'].match(/Item has been removed/i)) { + console.log('item does not exist') app.router.go('cart/error') app.cart.error.show_error("We're sorry, but one or more items was out of stock. Please check your cart and try again.") } diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js index 31c371a5..3a9e6412 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartPayment.js @@ -15,6 +15,7 @@ var CartPayment = FormView.extend({ "change [name=SameAsShipping]": "toggle_shipping", "click .address_dropdown": "toggle_address", "click .cc_dropdown": "toggle_cc", + "focus [name=Number]": "focus_on_cc", }, initialize: function(opt){ @@ -34,6 +35,11 @@ var CartPayment = FormView.extend({ this.address = new AddressView ({ parent: this, checkPhone: false }) this.cc = new CreditCardView ({ parent: this }) this.scroller = new IScroll('#cart_payment', app.iscroll_options) + this.scroller.on('scrollStart', function(){ + if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'SELECT') { + document.activeElement.blur() + } + }) this.address.disabled = true this.cc.disabled = true }, @@ -63,7 +69,7 @@ var CartPayment = FormView.extend({ } // this.$address_dropdown.toggle( !! app.account.ccs.length ) - this.address_list_mode = typeof state == "boolean" ? state : ! this.list_mode + this.address_list_mode = typeof state == "boolean" ? state : ! this.address_list_mode this.address.disabled = this.address_list_mode this.$address_form.toggle(! this.address_list_mode) this.$address_list.toggle(this.address_list_mode) @@ -82,6 +88,15 @@ var CartPayment = FormView.extend({ this.$cc_confirm.toggle(this.cc_list_mode) }, + focus_on_cc: function(e){ + this.scroller.scrollToElement(e.currentTarget) + if (e.currentTarget.textShadow === '') { + e.currentTarget.textShadow = 'rgba(0,0,0,0) 0 0 0'; + } else { + e.currentTarget.textShadow = ''; + } + }, + populate: function(){ this.$(".save_as_default").show() this.$address_list.empty() diff --git a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js index 536b5161..ef8f94b7 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/cart/CartShipping.js @@ -129,7 +129,22 @@ var CartShipping = FormView.extend({ success: function(){ app.router.go('cart/payment') }, - + + error: function(res){ + console.log('error', res.responseJSON) + var data = res.responseJSON || { 'Error': { 'Description': 'Unknown' } } + const errors = [] + switch(data['Error']['Description']) { + case 'InvalidFormatParameterException:AddressPostalCode': + errors.push(['ZipCode', 'Please enter a valid US/Canada Zip Code.']) + break + default: + errors.push(['', 'An unknown error occured.']) + break + } + this.show_errors(errors) + }, + cancel: function(){ app.router.go('cart/summary') }, diff --git a/StoneIsland/platforms/android/assets/www/js/lib/etc/backup_db.js b/StoneIsland/platforms/android/assets/www/js/lib/etc/backup_db.js index dce8835a..d4d4557b 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/etc/backup_db.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/etc/backup_db.js @@ -375,6 +375,20 @@ var BACKUP_DB = { "__index": "4", "dateCreated": "Tue, 17 Nov 2015 21:03:57 GMT", "tag": "care" + }, + { + "id": "account-terms", + "title": "Account Terms", + "image": { + "uri": "", + "caption": "", + "width": "", + "height": "" + }, + "body": "<h2>1. Services</h2>\r\n\r\nStone Island - SPORTSWEAR COMPANY S.p.A. (\"Stone Island\") offers you the possibility of using the following services \"My Account\" (the \"Services\")*:\r\n\r\n<ul>\r\n<li><b>My Orders:</b> Track the shipping of your orders, change or return items that are not for you and see the history of your orders.</li>\r\n<li><b>My Profile:</b> Manage your registration data.</li>\r\n<li><b>Address Book:</b> Save or change your addresses to have them always at hand and complete your purchases faster.</li>\r\n<li><b>My Card:</b> Save or change your card information and complete your orders faster and always safely.</li>\r\n</ul>\r\n\r\n<h2>2. Registration</h2>\r\n<h3>2.1</h3>\r\n\r\nIf you want to use the Services you must be an adult user, register on stoneisland.com creating your My Account account, and accept these terms and conditions for using the Services (\"Terms\"). Registration is free of charge. To create your My Account account, you will need to fill out the registration form by entering the required information, and guarantee to Stone Island that the information provided during the registration process is complete, accurate and truthful. We will send you an email to confirm your registration. We remind you that the credentials to access your My Account account must be used exclusively by you, and they cannot be transferred to third parties. Subject to legal limitations, Stone Island cannot in any way be held responsible in the event of access to your My Account account by unauthorized third parties. You are requested to keep your credentials confidential and to immediately inform Stone Island if you suspect that there has been an unauthorized access to your My Account account or if your password has been violated.\r\n\r\n\r\n<h3>2.2</h3>\r\n\r\nFor the provision of some Services, it may be necessary to use electronic communication channels (such as e-mail, SMS or telephone). If you want to use these specific services, you will be asked to give your consent to be contacted by Stone Island for the related communications by SMS, email or other communication channel.\r\n\r\n\r\n<h3>2.3</h3>\r\n\r\nWe also request you to consult, if you have not already done so, our <a href=\"#!/page/terms\">General Terms of Use</a> which form an integral part of these Terms. For any other legal information, consult the <a href=\"http://www.stoneisland.com/localize.asp?tskay=4036416C&page=legal/saleterms&\">General Terms of Sale</a>, <a href=\"http://www.stoneisland.com/localize.asp?tskay=4036416C&page=legal/returnpolicy\">Return Policy</a> and <a href=\"http://www.stoneisland.com/localize.asp?tskay=4036416C&page=legal/privacypolicy&\">Privacy Policy</a> of stoneisland.com.\r\n\r\n\r\n<h2>3. Duration and withdrawal</h2>\r\n\r\n<h3>3.1</h3>\r\n\r\nThe registration with the Services shall be effective from the moment you receive the confirmation email and for the entire period in which you use the Services.\r\n\r\n\r\n<h3>3.2</h3>\r\n\r\nAt any time and for any reason, you can cancel your subscription to the Services by sending a request to our Customer Service and selecting \"privacy\". In the event you exercised the right of withdrawal, we will send you an email to confirm the cancellation of the Services.\r\n\r\n\r\n<h3>3.3</h3>\r\n\r\nStone Island reserves the right to cancel your registration with the Services in the event of a violation of the provisions contained in these Terms, or in the event that the data provided was not complete, truthful or accurate, without prejudice to the right to compensation for the damage suffered. Stone Island also reserves the right to temporarily suspend, without any prior communication, the provision of the Services, for the time necessary and / or appropriate, to perform all the technical interventions required to improve the quality of the Services. Stone Island may, at any time, interrupt the provision of the Services for security reasons.\r\n\r\n\r\n<h2>4. Warning on the Services</h2>\r\n\r\nStone Island shall do its best to provide an accurate services. Without prejudice to the legal limits, the Services are provided free of charge \"AS IS\". Stone Island does not provide any guarantee, by way of example but not limited to, relating to the quality, the good functioning, the absence of interruptions or the suitability of the Services for an end or a particular result set by the user.\r\n\r\n\r\n<h2>5. Rectification and Update</h2>\r\n\r\nThe present Terms can be amended from time to time in consideration of possible regulatory changes. The new Terms shall be effective as of their date of publication in stoneisland.com You are requested to regularly access this section in order to check the publication of the most recent and updated Privacy Policy.\r\n\r\n\r\n*The availability of the Service may vary by country or region. Verify your My Account account to see which Services are available.\r\n\r\n", + "tag": "account_terms", + "__index": 5, + "dateCreated": "Tue, 24 Jul 2018 13:59:23 GMT" } ], "store": [ diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js index 1c9540bc..9e0c49b6 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/AddressView.js @@ -38,9 +38,31 @@ var AddressView = SerializableView.extend({ validate_fields: function(data, errors){ if (this.disabled) { return } - if (this.checkPhone && ! data.Phone) { errors.push([ "Phone", "Please enter your phone number." ]) } - if (this.checkPhone && data.Phone && data.Phone.replace(/[^0-9]/g, "").length < 10) { errors.push([ "Phone", "Phone numbers must be at least 10 digits." ]) } - if (! data.Province || data.Province == "NONE") { errors.push([ "Province", "Please choose your state." ]) } + if (this.checkPhone) { + var phone_number = data.Phone ? data.Phone.replace(/[^0-9]/g, "") : "" + var phone_length = phone_number.length + if (phone_length === 0 || ! data.Phone) { + errors.push([ "Phone", "Please enter your phone number." ]) + } + else if (phone_length < 10) { + errors.push([ "Phone", "Please enter a valid 10 digit US/Canada phone number." ]) + } + else if (phone_length > 10) { + errors.push([ "Phone", "International phone numbers are not accepted." ]) + } + else if (data.Phone[0] === '+') { + errors.push([ "Phone", "Please enter a valid 10 digit US/Canada phone number. International phone numbers are not accepted." ]) + } + else if (phone_number[0] === '1') { + errors.push([ "Phone", "Please enter a valid 10 digit US/Canada phone number. International phone numbers are not accepted." ]) + } + } + if (! data.Province || data.Province == "NONE") { + errors.push([ "Province", "Please choose your state." ]) + } + if (data.ZipCode && data.ZipCode.length < 5) { + errors.push([ "ZipCode", "Please enter a valid zip code." ]) + } data.Address = data.Address1 + "\n" + data.Address2 data.UserId = auth.user_id delete data.Address1 diff --git a/StoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js b/StoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js index cfb39ff6..86c8ecaf 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/nav/NavView.js @@ -27,6 +27,7 @@ var NavView = View.extend({ "click .faq_back": "back", "click .privacy": "privacy", + "click .account_terms": "account_terms", "click .returns": "returns", "click .terms": "terms", "click .care": "care", @@ -126,6 +127,10 @@ var NavView = View.extend({ this.hide() app.router.go("page/privacy") }, + account_terms: function(){ + this.hide() + app.router.go("page/account_terms") + }, returns: function(){ this.hide() app.router.go("page/returns") diff --git a/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js b/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js index 0ad58acc..3bcf5ee4 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/products/ProductView.js @@ -217,18 +217,19 @@ var ProductView = ScrollableView.extend({ else { this.$fitHeader.hide() } + this.$fit.show() + + if (app.store.SizingFooter === 'use_alt_text' && (app.store.SizingFooterText || "").length) { + var sizing_lines = app.store.SizingFooterText.replace(/</g, "<").replace(/>/g, "&rt;").split('\n').join("<br>") + this.$sizing.html(sizing_lines) + this.$sizing.show() + } else if (app.store.SizingFooter === 'true') { + this.$sizing.show() + } } else { this.$fitHeader.hide() this.$fit.hide() - } - - if (app.store.SizingFooter === 'use_alt_text' && (app.store.SizingFooterText || "").length) { - var sizing_lines = app.store.SizingFooterText.replace(/</g, "<").replace(/>/g, "&rt;").split('\n').join("<br>") - this.$sizing.html(sizing_lines) - this.$sizing.show() - } - else { this.$sizing.hide() } diff --git a/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js b/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js index de5fe951..4155f102 100755 --- a/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js +++ b/StoneIsland/platforms/android/assets/www/js/lib/view/Serializable.js @@ -70,8 +70,9 @@ var SerializableView = View.extend({ update_select: function(e){ var $target = $(e.currentTarget), value = $target.val() var label = $target.find("option").filter(function(){ return this.value === value }).html() - $target.parent().addClass("picked") - $target.parent().find("span").html(label) + var $parent = $target.parent() + $parent.addClass("picked").removeClass("error_hilite") + $parent.find("span").html(label) }, update_date: function(e){ @@ -103,9 +104,18 @@ var SerializableView = View.extend({ console.log("showing errors") console.log(errors) var msgs = [] + this.$('.error_hilite').removeClass('error_hilite') errors.forEach(function(e, i){ - if (i > 0) { return } - this.$("[name=" + e[0] + "]").addClass('error_hilite') + // if (i > 0) { return } + if (e[0]) { + var $el = this.$("[name=" + e[0] + "]") + var el = $el[0] + if (el && el.nodeName === 'SELECT') { + $el.parent().addClass('error_hilite') + } else { + $el.addClass('error_hilite') + } + } msgs.push(e[1]) }.bind(this)) this.$msg.html(msgs.join("<br>")) diff --git a/StoneIsland/platforms/android/assets/www/js/sdk/_sdk.js b/StoneIsland/platforms/android/assets/www/js/sdk/_sdk.js index ef29ff92..aba05ca3 100755 --- a/StoneIsland/platforms/android/assets/www/js/sdk/_sdk.js +++ b/StoneIsland/platforms/android/assets/www/js/sdk/_sdk.js @@ -9,7 +9,7 @@ var sdk = (function(){ sdk.init = function(opt){ switch (sdk.env = opt.env || "development") { case 'test': - endpoint = window.location.origin + "/" + endpoint = ('window' in this ? window.location.origin + "/" : "http://lvh.me:9090/") break default: case 'development': |
