From 6f2af841c17ff4ed28d40121114825a40e8cf6fa Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 3 Sep 2019 15:18:23 +0200 Subject: updating rems --- .../platforms/ios/www/js/lib/nav/AddressView.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js') 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) + } }, }) -- cgit v1.2.3-70-g09d2