summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-12 00:14:04 -0500
committerJules Laplace <jules@okfoc.us>2015-11-12 00:24:41 -0500
commite474ead4fde530b1cb52f96e827269371120cb89 (patch)
treeaced17c219763f6839f6bb5bd916ce1a1477ffa6 /StoneIsland/www/js/lib
parente8a2441a1d53648906904d0e7e048502c2eca6e0 (diff)
form serialization class
Diffstat (limited to 'StoneIsland/www/js/lib')
-rw-r--r--StoneIsland/www/js/lib/_router.js3
-rw-r--r--StoneIsland/www/js/lib/account/LoginView.js18
-rw-r--r--StoneIsland/www/js/lib/account/SignupView.js12
-rw-r--r--StoneIsland/www/js/lib/cart/CartConfirm.js5
-rw-r--r--StoneIsland/www/js/lib/cart/CartSummary.js3
-rw-r--r--StoneIsland/www/js/lib/nav/AddressView.js8
-rw-r--r--StoneIsland/www/js/lib/nav/FooterView.js4
7 files changed, 34 insertions, 19 deletions
diff --git a/StoneIsland/www/js/lib/_router.js b/StoneIsland/www/js/lib/_router.js
index d010abef..8742ce44 100644
--- a/StoneIsland/www/js/lib/_router.js
+++ b/StoneIsland/www/js/lib/_router.js
@@ -33,10 +33,11 @@ var SiteRouter = Router.extend({
},
initialize: function(){
+ console.log("HI!")
var fn
for (var route in this.routes) {
fn = this.routes[route]
- if (! fn in this) {
+ if (! this[fn]) {
this[fn] = this.default_view(fn)
}
}
diff --git a/StoneIsland/www/js/lib/account/LoginView.js b/StoneIsland/www/js/lib/account/LoginView.js
index 334c58b2..f1ad3de8 100644
--- a/StoneIsland/www/js/lib/account/LoginView.js
+++ b/StoneIsland/www/js/lib/account/LoginView.js
@@ -2,6 +2,8 @@ var LoginView = SerializableView.extend({
el: "#login",
+ action: sdk.account.login,
+
events: {
"click .newuser": "newuser",
"submit form": "save",
@@ -23,17 +25,9 @@ var LoginView = SerializableView.extend({
app.router.go("account/signup")
},
- save: function(e){
- e && e.preventDefault()
-
- var data = this.serialize()
-
- sdk.account.login({ data: data }).done(function(data){
- console.log("LOGIN SUCCESS", data)
- }).fail(function(data){
- console.log("LOGIN FAIL", data)
- })
-
+ validate_presence: {
+ "Email": "Please enter a valid email address.",
+ "Password": "Please enter your password.",
},
-
+
})
diff --git a/StoneIsland/www/js/lib/account/SignupView.js b/StoneIsland/www/js/lib/account/SignupView.js
index d8459f9b..e695e26f 100644
--- a/StoneIsland/www/js/lib/account/SignupView.js
+++ b/StoneIsland/www/js/lib/account/SignupView.js
@@ -18,6 +18,18 @@ 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
+ },
+
save: function(e){
e && e.preventDefault()
},
diff --git a/StoneIsland/www/js/lib/cart/CartConfirm.js b/StoneIsland/www/js/lib/cart/CartConfirm.js
index 8e629e57..0ce94f22 100644
--- a/StoneIsland/www/js/lib/cart/CartConfirm.js
+++ b/StoneIsland/www/js/lib/cart/CartConfirm.js
@@ -13,7 +13,10 @@ var CartConfirm = View.extend({
app.cart.el.className = "confirm"
app.footer.show("PLACE ORDER", "CANCEL")
},
-
+
+ populate: function(){
+ },
+
save: function(){
},
diff --git a/StoneIsland/www/js/lib/cart/CartSummary.js b/StoneIsland/www/js/lib/cart/CartSummary.js
index 2f2da664..d91b801f 100644
--- a/StoneIsland/www/js/lib/cart/CartSummary.js
+++ b/StoneIsland/www/js/lib/cart/CartSummary.js
@@ -13,6 +13,9 @@ var CartSummary = View.extend({
app.cart.el.className = "summary"
app.footer.show("SHIPPING &gt;", "CANCEL")
},
+
+ populate: function(){
+ },
ok: function(){
},
diff --git a/StoneIsland/www/js/lib/nav/AddressView.js b/StoneIsland/www/js/lib/nav/AddressView.js
index 4ccc263c..fd482378 100644
--- a/StoneIsland/www/js/lib/nav/AddressView.js
+++ b/StoneIsland/www/js/lib/nav/AddressView.js
@@ -1,5 +1,5 @@
-var AddressView = View.extend({
+var AddressView = SerializableView.extend({
template: $("#address_template").html(),
@@ -8,7 +8,9 @@ var AddressView = View.extend({
initialize: function(opt){
this.parent = opt.parent
- this.parent.$(".address").html(this.template)
+ this.$el = this.parent.$(".address")
+ this.el = this.$el[0]
+ this.$el.html(this.template)
},
populate: function(data){
@@ -21,7 +23,7 @@ var AddressView = View.extend({
deserialize: function(){
},
- serialize: function(){
+ validate: function(){
},
})
diff --git a/StoneIsland/www/js/lib/nav/FooterView.js b/StoneIsland/www/js/lib/nav/FooterView.js
index 7f404581..74b249e6 100644
--- a/StoneIsland/www/js/lib/nav/FooterView.js
+++ b/StoneIsland/www/js/lib/nav/FooterView.js
@@ -30,11 +30,11 @@ var FooterView = View.extend({
},
ok: function(){
- (app.view.save || app.view.ok)()
+ (app.view.save || app.view.ok).bind(app.view)()
},
cancel: function(){
- (app.view.cancel || app.intro.show)()
+ app.view.cancel ? app.view.cancel() : app.intro.show()
},
}) \ No newline at end of file