summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/ios/www/js')
-rwxr-xr-xStoneIsland/platforms/ios/www/js/lib/_router.js16
-rwxr-xr-xStoneIsland/platforms/ios/www/js/lib/account/AccountView.js4
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/account/ConsentModal.js11
-rwxr-xr-xStoneIsland/platforms/ios/www/js/lib/auth/LoginView.js4
-rwxr-xr-xStoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js1
-rwxr-xr-xStoneIsland/platforms/ios/www/js/lib/auth/SignupView.js10
6 files changed, 32 insertions, 14 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/_router.js b/StoneIsland/platforms/ios/www/js/lib/_router.js
index 91f29b55..75f598e9 100755
--- a/StoneIsland/platforms/ios/www/js/lib/_router.js
+++ b/StoneIsland/platforms/ios/www/js/lib/_router.js
@@ -40,7 +40,14 @@ var SiteRouter = Router.extend({
'/cart/error': 'cart.error',
},
- terms_routes: ['terms','account_terms','privacy','returns','care','logout'],
+ terms_routes: [
+ 'terms',
+ 'account_terms',
+ 'privacy',
+ 'returns',
+ 'care',
+ 'logout',
+ ],
initialize: function(){
var fn
@@ -105,8 +112,11 @@ var SiteRouter = Router.extend({
// return
// }
- var isTermsRoute = this.terms_routes.indexOf(name) !== -1
- if (app.demand_consent && !isTermsRoute && app.account.consent.check()) {
+ var isNotTermsRoute = this.terms_routes.indexOf(name) === -1
+ var isCartRoute = n[0] === 'cart'
+ var userMightActuallyViewCart = isCartRoute && auth.logged_in()
+ var demandingConsent = app.demand_consent && isNotTermsRoute
+ if ((userMightActuallyViewCart || demandingConsent) && app.account.consent.check()) {
console.log('showed consent modal')
return
}
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/AccountView.js b/StoneIsland/platforms/ios/www/js/lib/account/AccountView.js
index 4605416c..8ac7c193 100755
--- a/StoneIsland/platforms/ios/www/js/lib/account/AccountView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/account/AccountView.js
@@ -105,6 +105,7 @@ var AccountView = View.extend({
cb && cb()
}
console.log('logged in')
+ app.account.consent.check()
if ( ! auth.has_cart() ) {
console.log('no cart')
app.curtain.show("loading")
@@ -132,9 +133,10 @@ var AccountView = View.extend({
console.log("navigating to deep link route from logged_in")
app.router.go(initialLoginPath)
}
- else {
+ else if (!app.last_view) {
app.router.go("account/profile")
}
+ app.account.consent.check()
app.curtain.hide("loading")
}
},
diff --git a/StoneIsland/platforms/ios/www/js/lib/account/ConsentModal.js b/StoneIsland/platforms/ios/www/js/lib/account/ConsentModal.js
index dfeb4fac..c9235498 100644
--- a/StoneIsland/platforms/ios/www/js/lib/account/ConsentModal.js
+++ b/StoneIsland/platforms/ios/www/js/lib/account/ConsentModal.js
@@ -18,11 +18,14 @@ var ConsentModal = View.extend({
check: function(){
var status = localStorage.getItem('account_terms.consent')
+ console.log('account_terms.consent', status)
if (status !== 'true') {
+ console.log('we demand consent!')
app.demand_consent = true
this.show()
return true
} else {
+ console.log('already received consent!')
this.hide()
app.demand_consent = false
return false
@@ -35,8 +38,10 @@ var ConsentModal = View.extend({
setTimeout(function(){
this.$el.addClass('visible')
}.bind(this), 20)
- app.curtain.show()
- app.curtain.classList.add('opaque')
+ app.curtain.show('opaque')
+ setTimeout(function(){
+ app.curtain.show('opaque')
+ }, 300)
},
hide: function(){
@@ -44,7 +49,7 @@ var ConsentModal = View.extend({
this.$el.removeClass('visible')
setTimeout(function(){
this.$el.hide()
- app.curtain.classList.remove('opaque')
+ app.curtain.$el.removeClass('opaque')
}.bind(this), 300)
},
diff --git a/StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js b/StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js
index aeb15d1d..c3d839a5 100755
--- a/StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/auth/LoginView.js
@@ -43,9 +43,7 @@ var LoginView = FormView.extend({
success: function(data){
console.log(data)
- app.account.logged_in(function(){
- app.router.go("store")
- })
+ app.account.logged_in(null, "store")
},
error: function(data){
diff --git a/StoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js b/StoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js
index 89091473..d3f76428 100755
--- a/StoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/auth/LogoutView.js
@@ -10,6 +10,7 @@ var LogoutView = View.extend({
app.header.set_cart_count(0)
app.footer.hide()
auth.log_out()
+ localStorage.setItem('account_terms.consent', 'false')
app.demand_consent = false
app.account.consent.hide()
app.account.logged_out()
diff --git a/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js b/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js
index 078f7c07..917644d2 100755
--- a/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/auth/SignupView.js
@@ -68,10 +68,12 @@ var SignupView = FormView.extend({
var now = new Date ()
var year = now.getFullYear()
- if (! data.Birthday) data.BirthDay = year + '-01-01'
- if (data.BirthDay.split('-')[0] || '2018')
+ 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) {
+ if (isNaN(birthday) || (new Date () - birthday) / (365*24*60*60*1000) < 18) {
errors.push(['BirthDay', 'You must be 18 or older to use the Stone Island app.'])
}
@@ -108,7 +110,7 @@ var SignupView = FormView.extend({
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") })
+ app.account.logged_in(null, "store")
},
error: function(data){