summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/lib
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2015-11-25 06:18:03 -0500
committerJules Laplace <jules@okfoc.us>2015-11-25 06:18:03 -0500
commit40e27113f79d2bcf6d5918d87e836e7981577004 (patch)
tree3d23c090708acf0202154b5052fe608b6ec87362 /StoneIsland/www/js/lib
parentcec1ab9102cc6943d7e8f77b97a69ed3925a227e (diff)
harmonize with YOOX
Diffstat (limited to 'StoneIsland/www/js/lib')
-rw-r--r--StoneIsland/www/js/lib/account/AccountView.js2
-rw-r--r--StoneIsland/www/js/lib/nav/AddressView.js19
-rw-r--r--StoneIsland/www/js/lib/view/Serializable.js1
3 files changed, 14 insertions, 8 deletions
diff --git a/StoneIsland/www/js/lib/account/AccountView.js b/StoneIsland/www/js/lib/account/AccountView.js
index 86c02056..e1d7ca71 100644
--- a/StoneIsland/www/js/lib/account/AccountView.js
+++ b/StoneIsland/www/js/lib/account/AccountView.js
@@ -26,9 +26,11 @@ var AccountView = View.extend({
data.AddressBook.addressBookItem.forEach(function(item){
if (item.isDefault) {
// populate app.shipping.address
+ app.shipping.address.populate(item)
}
else if (item.isBillingDefault) {
// populate app.billing.address
+ app.payment.address.populate(item)
}
})
},
diff --git a/StoneIsland/www/js/lib/nav/AddressView.js b/StoneIsland/www/js/lib/nav/AddressView.js
index 15a5784d..e63b0330 100644
--- a/StoneIsland/www/js/lib/nav/AddressView.js
+++ b/StoneIsland/www/js/lib/nav/AddressView.js
@@ -8,32 +8,35 @@ var AddressView = SerializableView.extend({
initialize: function(opt){
this.parent = opt.parent
- this.$el = this.parent.$(".address")
- this.el = this.$el[0]
+ this.setElement( this.parent.$(".address") )
this.$el.html(this.template)
},
populate: function(data){
- this.parent.$(".address input").val("")
+ var address = data.Address.split("\n")
+ data.Address1 = address[0]
+ data.Address2 = address[1]
+ this.$(".address input").val("")
Object.keys(data).forEach(function(key){
- this.parent$(".address [name=" + key + "]").val(data[key])
+ this.$(".address [name=" + key + "]").val(data[key])
}.bind(this))
},
- deserialize: 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(data, errors){
if (data.Phone.replace(/[^0-9]/g, "").length < 10) { errors.push([ "Phone", "Phone numbers must be at least 10 digits." ]) }
+ if (data.Province == "NONE") { errors.push([ "Province", "Please choose your state." ]) }
+ data.Address = data.Address1 + "\n" + data.Address2
+ data.UserId = auth.user_id
+ delete data.Address1
+ delete data.Address2
},
})
diff --git a/StoneIsland/www/js/lib/view/Serializable.js b/StoneIsland/www/js/lib/view/Serializable.js
index 8084b9f5..e3ef123c 100644
--- a/StoneIsland/www/js/lib/view/Serializable.js
+++ b/StoneIsland/www/js/lib/view/Serializable.js
@@ -3,6 +3,7 @@ var SerializableView = View.extend({
events: {
"change select": "update_select",
"focus input": "focus_input",
+ "submit form": "save",
},
preload: function(data){