summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/android/assets/www/js/lib/account
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/platforms/android/assets/www/js/lib/account')
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/AccountView.js1
-rw-r--r--StoneIsland/platforms/android/assets/www/js/lib/account/ConsentModal.js85
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/OrdersView.js1
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/PaymentView.js4
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/ProfileView.js12
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/SettingsView.js1
-rwxr-xr-xStoneIsland/platforms/android/assets/www/js/lib/account/ShippingView.js4
7 files changed, 105 insertions, 3 deletions
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")
},