summaryrefslogtreecommitdiff
path: root/StoneIsland
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland')
-rw-r--r--StoneIsland/www/index.html1
-rw-r--r--StoneIsland/www/js/lib/account/LoginView.js10
-rw-r--r--StoneIsland/www/js/lib/account/ProfileView.js15
-rw-r--r--StoneIsland/www/js/lib/account/SignupView.js30
-rw-r--r--StoneIsland/www/js/lib/nav/AddressView.js12
-rw-r--r--StoneIsland/www/js/lib/nav/CreditCardView.js10
-rw-r--r--StoneIsland/www/js/lib/nav/CurtainView.js3
-rw-r--r--StoneIsland/www/js/vendor/view/serializable.js17
8 files changed, 69 insertions, 29 deletions
diff --git a/StoneIsland/www/index.html b/StoneIsland/www/index.html
index 39946c98..410bd36d 100644
--- a/StoneIsland/www/index.html
+++ b/StoneIsland/www/index.html
@@ -373,6 +373,7 @@
<input type="text" name="CC" placeholder="CREDIT CARD NUMBER" required>
<input type="text" name="EXP" placeholder="EXPIRATION DATE" required>
<input type="text" name="CVV" placeholder="SECURITY CODE" required>
+ <span class="address"></span>
</script>
<script type="text/html" id="address_template">
diff --git a/StoneIsland/www/js/lib/account/LoginView.js b/StoneIsland/www/js/lib/account/LoginView.js
index f1ad3de8..30a4a735 100644
--- a/StoneIsland/www/js/lib/account/LoginView.js
+++ b/StoneIsland/www/js/lib/account/LoginView.js
@@ -5,7 +5,7 @@ var LoginView = SerializableView.extend({
action: sdk.account.login,
events: {
- "click .newuser": "newuser",
+ "click .newuser": "new_user",
"submit form": "save",
},
@@ -21,7 +21,7 @@ var LoginView = SerializableView.extend({
document.body.className = "login"
},
- newuser: function(){
+ new_user: function(){
app.router.go("account/signup")
},
@@ -29,5 +29,11 @@ var LoginView = SerializableView.extend({
"Email": "Please enter a valid email address.",
"Password": "Please enter your password.",
},
+
+ success: function(data){
+ },
+
+ error: function(data){
+ },
})
diff --git a/StoneIsland/www/js/lib/account/ProfileView.js b/StoneIsland/www/js/lib/account/ProfileView.js
index b93dcbc5..892ccbec 100644
--- a/StoneIsland/www/js/lib/account/ProfileView.js
+++ b/StoneIsland/www/js/lib/account/ProfileView.js
@@ -15,7 +15,20 @@ var ProfileView = View.extend({
document.body.className = "profile"
},
- save: function(){
+ validate_presence: {
+ "Name": "Please enter your first name.",
+ "Surname": "Please enter your last name.",
+ "Email": "Please enter a valid email address.",
+ },
+
+ validate_fields: function(errors){
+ if (data.Password && ! data.Password2) { errors.push("Password2", "Please enter your new password.") }
+ },
+
+ success: function(data){
+ },
+
+ error: function(data){
},
}) \ No newline at end of file
diff --git a/StoneIsland/www/js/lib/account/SignupView.js b/StoneIsland/www/js/lib/account/SignupView.js
index e695e26f..616fd9ea 100644
--- a/StoneIsland/www/js/lib/account/SignupView.js
+++ b/StoneIsland/www/js/lib/account/SignupView.js
@@ -2,6 +2,8 @@ var SignupView = SerializableView.extend({
el: "#signup",
+ action: sdk.account.login,
+
events: {
"submit form": "save",
},
@@ -18,25 +20,25 @@ var SignupView = SerializableView.extend({
document.body.className = "signup"
},
- validate: function(data){
- var errors = []
- if (! data.Name) { errors.push("Please enter your first name.") }
- if (! data.Surname) { errors.push("Please enter your last name.") }
- if (! data.Email) { errors.push("Please enter a valid email address.") }
- if (! data.Password) { errors.push("Please enter your password.") }
- if (! data.Password2) { errors.push("Please enter your password again.") }
- if (data.Password !== data.Password2) { errors.push("Passwords don't match.") }
- if (! data.DataProfiling) { errors.push("You must agree to share your data.") }
- return errors
+ validate_presence: {
+ "Name": "Please enter your first name.",
+ "Surname": "Please enter your last name.",
+ "Email": "Please enter a valid email address.",
+ "Password": "Please enter your password.",
+ "Password2": "Please enter your password again.",
+ "DataProfiling": "You must agree to data profiling.",
},
-
- save: function(e){
- e && e.preventDefault()
+
+ validate_fields: function(errors){
+ if (data.Password !== data.Password2) { errors.push("Password2", "Passwords don't match.") }
},
- success: function(){
+ success: function(data){
// change login in ui to logout or whatever
},
+
+ error: function(data){
+ },
/*
var new_user_data = {
diff --git a/StoneIsland/www/js/lib/nav/AddressView.js b/StoneIsland/www/js/lib/nav/AddressView.js
index fd482378..e5467250 100644
--- a/StoneIsland/www/js/lib/nav/AddressView.js
+++ b/StoneIsland/www/js/lib/nav/AddressView.js
@@ -23,7 +23,17 @@ var AddressView = SerializableView.extend({
deserialize: function(){
},
- validate: function(){
+ validate_presence: {
+ "Name": "Please enter your first name.",
+ "Surname": "Please enter your last name.",
+ "Address1": "Please enter your street address.",
+ "City": "Please enter your city.",
+ "State": "Please choose your state.",
+ "Phone": "Please enter your phone number.",
+ },
+
+ validate_fields: function(errors){
+ if (data.Phone.replace(/[^0-9]/g, "").length < 10) { errors.push("Phone", "Phone numbers must be at least 10 digits.") }
},
})
diff --git a/StoneIsland/www/js/lib/nav/CreditCardView.js b/StoneIsland/www/js/lib/nav/CreditCardView.js
index e54c1805..20705a9e 100644
--- a/StoneIsland/www/js/lib/nav/CreditCardView.js
+++ b/StoneIsland/www/js/lib/nav/CreditCardView.js
@@ -8,20 +8,20 @@ var CreditCardView = View.extend({
initialize: function(opt){
this.parent = opt.parent
- this.parent.$(".address").html(this.template)
+ this.parent.$(".cc").html(this.template)
},
populate: function(data){
- this.parent.$(".address input").val("")
+ this.parent.$(".cc input").val("")
Object.keys(data).forEach(function(key){
- this.parent$(".address [name=" + key + "]").val(data[key])
+ this.parent$(".cc [name=" + key + "]").val(data[key])
}.bind(this))
},
- deserialize: function(){
+ validate_presence: {
},
- serialize: function(){
+ validate_fields: function(errors){
},
})
diff --git a/StoneIsland/www/js/lib/nav/CurtainView.js b/StoneIsland/www/js/lib/nav/CurtainView.js
index ba10e232..ad478335 100644
--- a/StoneIsland/www/js/lib/nav/CurtainView.js
+++ b/StoneIsland/www/js/lib/nav/CurtainView.js
@@ -21,9 +21,6 @@ var CurtainView = View.extend({
if (document.body.classList.contains("nav")) {
app.nav.hide()
}
- else if (document.body.classList.contains("login")) {
- app.login.hide()
- }
},
}) \ No newline at end of file
diff --git a/StoneIsland/www/js/vendor/view/serializable.js b/StoneIsland/www/js/vendor/view/serializable.js
index 4ad5558f..ae742d75 100644
--- a/StoneIsland/www/js/vendor/view/serializable.js
+++ b/StoneIsland/www/js/vendor/view/serializable.js
@@ -15,12 +15,16 @@ var SerializableView = View.extend({
})
},
- validate: function(data){
+ validate: function(errors){
+ var data = this.serialize()
var errors = []
var presence_msgs = this.validate_presence
Object.keys(presence_msgs).forEach(function(k){
if (! data[k]) errors.push( [ k, presence_msgs[k] ] )
})
+ this.validate_fields && this.validate_fields(errors)
+ this.cc && this.cc.validate(errors)
+ this.address && this.address.validate(errors)
return errors.length ? errors : null
},
@@ -50,10 +54,17 @@ var SerializableView = View.extend({
this.hide_errors()
}
+ // app.curtain.show()
this.action({
data: data,
- success: this.success.bind(this),
- error: this.error.bind(this),
+ success: function(data){
+ // app.curtain.hide()
+ this.success(data)
+ }.bind(this),
+ error: function(data){
+ // app.curtain.hide()
+ this.error(data)
+ }.bind(this),
})
},