summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2019-09-03 15:18:23 +0200
committerJules Laplace <julescarbon@gmail.com>2019-09-03 15:18:23 +0200
commit6f2af841c17ff4ed28d40121114825a40e8cf6fa (patch)
tree5cc68e65c61e85ada066e45cf62805b60b24cf67 /StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
parentbea0583348a3e7de85d4fed5e7fe206fb90fcc73 (diff)
updating rems
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js')
-rwxr-xr-xStoneIsland/platforms/ios/www/js/lib/nav/AddressView.js18
1 files changed, 13 insertions, 5 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js b/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
index 9e0c49b6..fd0fa59d 100755
--- a/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
@@ -1,4 +1,6 @@
+var AddressViewID = Math.round(Date.now() % 1000)
+
var AddressView = SerializableView.extend({
template: $("#address_template").html(),
@@ -14,7 +16,7 @@ var AddressView = SerializableView.extend({
this.parent = opt.parent
this.checkPhone = 'checkPhone' in opt ? opt.checkPhone : true
this.setElement( this.parent.$(".address") )
- this.$el.html(this.template)
+ this.$el.html(this.template.replace(/{{_id}}/g, AddressViewID++))
},
populate: function(data){
@@ -34,12 +36,15 @@ var AddressView = SerializableView.extend({
"Address1": "Please enter your street address.",
"City": "Please enter your city.",
"ZipCode": "Please enter your zip code.",
+ "Phone": "Please enter your phone number.",
},
validate_fields: function(data, errors){
if (this.disabled) { return }
if (this.checkPhone) {
- var phone_number = data.Phone ? data.Phone.replace(/[^0-9]/g, "") : ""
+ var phone_number = data.Phone ? String(data.Phone).replace(/[^0-9]/g, "").replace(/^[01]+/, '') : ""
+ data.Phone = phone_number
+ this.$('[name=Phone]').val(phone_number)
var phone_length = phone_number.length
if (phone_length === 0 || ! data.Phone) {
errors.push([ "Phone", "Please enter your phone number." ])
@@ -50,10 +55,10 @@ var AddressView = SerializableView.extend({
else if (phone_length > 10) {
errors.push([ "Phone", "International phone numbers are not accepted." ])
}
- else if (data.Phone[0] === '+') {
+ else if (phone_number.charAt(0) === '+') {
errors.push([ "Phone", "Please enter a valid 10 digit US/Canada phone number. International phone numbers are not accepted." ])
}
- else if (phone_number[0] === '1') {
+ else if (phone_number.charAt(0) === '1') {
errors.push([ "Phone", "Please enter a valid 10 digit US/Canada phone number. International phone numbers are not accepted." ])
}
}
@@ -81,7 +86,10 @@ var AddressView = SerializableView.extend({
},
scroll_up_to_phone: function(e){
- app.view.scroller && app.view.scroller.scrollTo(0, -$(e.currentTarget).position().top)
+ var position = $(e.currentTarget).prev('label').position()
+ if (app.view.scroller && position) {
+ app.view.scroller.scrollTo(0, -position.top)
+ }
},
})