summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib/account
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/www/js/lib/account')
-rwxr-xr-xStoneIsland/www/js/lib/account/AccountView.js1
-rw-r--r--StoneIsland/www/js/lib/account/ConsentModal.js74
-rwxr-xr-xStoneIsland/www/js/lib/account/OrdersView.js1
-rwxr-xr-xStoneIsland/www/js/lib/account/PaymentView.js1
-rwxr-xr-xStoneIsland/www/js/lib/account/ProfileView.js12
-rwxr-xr-xStoneIsland/www/js/lib/account/SettingsView.js1
-rwxr-xr-xStoneIsland/www/js/lib/account/ShippingView.js1
7 files changed, 90 insertions, 1 deletions
diff --git a/StoneIsland/www/js/lib/account/AccountView.js b/StoneIsland/www/js/lib/account/AccountView.js
index 4a6ff9e0..4605416c 100755
--- a/StoneIsland/www/js/lib/account/AccountView.js
+++ b/StoneIsland/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/www/js/lib/account/ConsentModal.js b/StoneIsland/www/js/lib/account/ConsentModal.js
new file mode 100644
index 00000000..fcf2804c
--- /dev/null
+++ b/StoneIsland/www/js/lib/account/ConsentModal.js
@@ -0,0 +1,74 @@
+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]")
+ },
+
+ check: function(){
+ var status = localStorage.getItem('account_terms.consent')
+ if (status !== 'true') {
+ this.show()
+ } else {
+ this.hide()
+ }
+ },
+
+ show: function(){
+ this.$el.show()
+ setTimeout(function(){
+ this.$el.addClass('visible')
+ }.bind(this), 20)
+ app.curtain.show()
+ },
+
+ hide: function(){
+ app.curtain.hide()
+ this.$el.removeClass('visible')
+ setTimeout(function(){
+ this.$el.hide()
+ }.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.$el.addClass('consent-yes').removeClass('consent-no')
+ } else {
+ this.$el.addClass('consent-no').removeClass('consent-yes')
+ }
+ },
+
+ proceed: function(){
+ var state = this.$checkbox.prop("checked")
+ if (!state) {
+ return
+ }
+ this.hide()
+ localStorage.setItem('account_terms.consent', 'true')
+ },
+
+ logout: function(){
+ this.hide()
+ localStorage.setItem('account_terms.consent', 'false')
+ app.router.go("account/logout")
+ },
+
+}) \ No newline at end of file
diff --git a/StoneIsland/www/js/lib/account/OrdersView.js b/StoneIsland/www/js/lib/account/OrdersView.js
index b3ff3e7a..ee0eb277 100755
--- a/StoneIsland/www/js/lib/account/OrdersView.js
+++ b/StoneIsland/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/www/js/lib/account/PaymentView.js b/StoneIsland/www/js/lib/account/PaymentView.js
index 69d4f943..0fcf7e8f 100755
--- a/StoneIsland/www/js/lib/account/PaymentView.js
+++ b/StoneIsland/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()
diff --git a/StoneIsland/www/js/lib/account/ProfileView.js b/StoneIsland/www/js/lib/account/ProfileView.js
index ee39374b..a4e06791 100755
--- a/StoneIsland/www/js/lib/account/ProfileView.js
+++ b/StoneIsland/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/www/js/lib/account/SettingsView.js b/StoneIsland/www/js/lib/account/SettingsView.js
index 90ace549..5586e0fd 100755
--- a/StoneIsland/www/js/lib/account/SettingsView.js
+++ b/StoneIsland/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/www/js/lib/account/ShippingView.js b/StoneIsland/www/js/lib/account/ShippingView.js
index abc12818..c1bac782 100755
--- a/StoneIsland/www/js/lib/account/ShippingView.js
+++ b/StoneIsland/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()