summaryrefslogtreecommitdiff
path: root/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
diff options
context:
space:
mode:
authorRene Ae <aehtyb@gmail.com>2015-11-30 15:24:27 -0600
committerRene Ae <aehtyb@gmail.com>2015-11-30 15:24:27 -0600
commit9d0e54228c79d151c30c527ea83efa7479793686 (patch)
tree3baf83427cd61cb1994e8551eefba5cd21d1a65b /StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
parentb208cb0283c23d68e8013c0dd5ddd4e5e6df8950 (diff)
parentd26e72aea3b3127c95c5ba7069c95f73cf52a2fd (diff)
Merge branch 'master' of https://github.com/okfocus/stone-island
Diffstat (limited to 'StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js')
-rw-r--r--StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js236
1 files changed, 224 insertions, 12 deletions
diff --git a/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js b/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
index 15a5784d..31e9d802 100644
--- a/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
+++ b/StoneIsland/platforms/ios/www/js/lib/nav/AddressView.js
@@ -3,24 +3,25 @@ var AddressView = SerializableView.extend({
template: $("#address_template").html(),
+ disabled: false,
+
events: {
},
initialize: function(opt){
this.parent = opt.parent
- this.$el = this.parent.$(".address")
- this.el = this.$el[0]
+ this.checkPhone = 'checkPhone' in opt ? opt.checkPhone : true
+ this.setElement( this.parent.$(".address") )
this.$el.html(this.template)
},
populate: function(data){
- this.parent.$(".address input").val("")
- Object.keys(data).forEach(function(key){
- this.parent$(".address [name=" + key + "]").val(data[key])
- }.bind(this))
- },
-
- deserialize: function(){
+ this.data = data
+ var address = data.Address.split("\n")
+ data.Address1 = address[0]
+ data.Address2 = address[1]
+ this.$(".address input").val("")
+ this.load_data(data)
},
validate_presence: {
@@ -28,12 +29,223 @@ var AddressView = SerializableView.extend({
"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.",
+ "ZipCode": "Please enter your zip code.",
},
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 (this.disabled) { return }
+ if (this.checkPhone && ! data.Phone) { errors.push([ "Phone", "Please enter your phone number." ]) }
+ if (this.checkPhone && data.Phone && data.Phone.replace(/[^0-9]/g, "").length < 10) { errors.push([ "Phone", "Phone numbers must be at least 10 digits." ]) }
+ if (! data.Province || 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
},
})
+
+
+var COUNTRIES = [
+ ['Country Name', 'NONE'],
+ ['United States', 'US'],
+ ['Abkhazia', 'GE'],
+ ['Afghanistan', 'AF'],
+ ['Albania', 'AL'],
+ ['Algeria', 'DZ'],
+ ['Andorra', 'AD'],
+ ['Angola', 'AO'],
+ ['Antigua and Barbuda', 'AG'],
+ ['Argentina', 'AR'],
+ ['Armenia', 'AM'],
+ ['Australia', 'AU'],
+ ['Austria', 'AT'],
+ ['Azerbaijan', 'AZ'],
+ ['Bahamas', 'BS'],
+ ['Bahrain', 'BH'],
+ ['Bangladesh', 'BD'],
+ ['Barbados', 'BB'],
+ ['Belarus', 'BY'],
+ ['Belgium', 'BE'],
+ ['Belize', 'BZ'],
+ ['Benin', 'BJ'],
+ ['Bhutan', 'BT'],
+ ['Bolivia', 'BO'],
+ ['Bosnia and Herzegovina', 'BA'],
+ ['Botswana', 'BW'],
+ ['Brazil', 'BR'],
+ ['Brunei', 'BN'],
+ ['Bulgaria', 'BG'],
+ ['Burkina Faso', 'BF'],
+ ['Burundi', 'BI'],
+ ['Cambodia', 'KH'],
+ ['Cameroon', 'CM'],
+ ['Canada', 'CA'],
+ ['Cape Verde', 'CV'],
+ ['Central African Republic', 'CF'],
+ ['Chad', 'TD'],
+ ['Chile', 'CL'],
+ ['China', 'CN'],
+ ['Colombia', 'CO'],
+ ['Comoros', 'KM'],
+ ['Congo', 'CD'],
+ ['Congo-Brazzaville', 'CG'],
+ ['Costa Rica', 'CR'],
+ ['Cote d\'Ivoire (Ivory Coast)', 'CI'],
+ ['Croatia', 'HR'],
+ ['Cuba', 'CU'],
+ ['Cyprus', 'CY'],
+ ['Czech Republic', 'CZ'],
+ ['Denmark', 'DK'],
+ ['Djibouti', 'DJ'],
+ ['Dominica', 'DM'],
+ ['Dominican Republic', 'DO'],
+ ['Ecuador', 'EC'],
+ ['Egypt', 'EG'],
+ ['El Salvador', 'SV'],
+ ['Equatorial Guinea', 'GQ'],
+ ['Eritrea', 'ER'],
+ ['Estonia', 'EE'],
+ ['Ethiopia', 'ET'],
+ ['Fiji', 'FJ'],
+ ['Finland', 'FI'],
+ ['France', 'FR'],
+ ['Gabon', 'GA'],
+ ['Gambia', '220'],
+ ['Georgia', 'GE'],
+ ['Germany', 'DE'],
+ ['Ghana', 'GH'],
+ ['Greece', 'GR'],
+ ['Grenada', 'GD'],
+ ['Guatemala', 'GT'],
+ ['Guinea', 'GN'],
+ ['Guinea-Bissau', 'GW'],
+ ['Guyana', 'GY'],
+ ['Haiti', 'HT'],
+ ['Honduras', 'HN'],
+ ['Hungary', 'HU'],
+ ['Iceland', 'IS'],
+ ['India', 'IN'],
+ ['Indonesia', 'ID'],
+ ['Iran', 'IR'],
+ ['Iraq', 'IQ'],
+ ['Ireland', 'IE'],
+ ['Israel', 'IL'],
+ ['Italy', 'IT'],
+ ['Jamaica', 'JM'],
+ ['Japan', 'JP'],
+ ['Jordan', 'JO'],
+ ['Kazakhstan', 'KZ'],
+ ['Kenya', 'KE'],
+ ['Kiribati', 'KI'],
+ ['Kuwait', 'KW'],
+ ['Kyrgyzstan', 'KG'],
+ ['Laos', 'LA'],
+ ['Latvia', 'LV'],
+ ['Lebanon', 'LB'],
+ ['Lesotho', 'LS'],
+ ['Liberia', 'LR'],
+ ['Libya', 'LY'],
+ ['Liechtenstein', 'LI'],
+ ['Lithuania', 'LT'],
+ ['Luxembourg', 'LU'],
+ ['Macedonia', 'MK'],
+ ['Madagascar', 'MG'],
+ ['Malawi', 'MW'],
+ ['Malaysia', 'MY'],
+ ['Maldives', 'MV'],
+ ['Mali', 'ML'],
+ ['Malta', 'MT'],
+ ['Marshall Islands', 'MH'],
+ ['Mauritania', 'MR'],
+ ['Mauritius', 'MU'],
+ ['Mexico', 'MX'],
+ ['Micronesia', 'FM'],
+ ['Moldova', 'MD'],
+ ['Monaco', 'MC'],
+ ['Mongolia', 'MN'],
+ ['Montenegro', 'ME'],
+ ['Morocco', 'MA'],
+ ['Mozambique', 'MZ'],
+ ['Myanmar', 'MM'],
+ ['Nagorno-Karabakh', 'AZ'],
+ ['Namibia', 'NA'],
+ ['Nauru', 'NR'],
+ ['Nepal', 'NP'],
+ ['Netherlands', 'NL'],
+ ['New Zealand', 'NZ'],
+ ['Nicaragua', 'NI'],
+ ['Niger', 'NE'],
+ ['Nigeria', 'NG'],
+ ['North Korea', 'KP'],
+ ['Northern Cyprus', 'CY'],
+ ['Norway', 'NO'],
+ ['Oman', 'OM'],
+ ['Pakistan', 'PK'],
+ ['Palau', 'PW'],
+ ['Panama', 'PA'],
+ ['Papua New Guinea', 'PG'],
+ ['Paraguay', 'PY'],
+ ['Peru', 'PE'],
+ ['Philippines', 'PH'],
+ ['Poland', 'PL'],
+ ['Portugal', 'PT'],
+ ['Qatar', 'QA'],
+ ['Romania', 'RO'],
+ ['Russia', 'RU'],
+ ['Rwanda', 'RW'],
+ ['Saint Kitts and Nevis', 'KN'],
+ ['Saint Lucia', 'LC'],
+ ['Saint Vincent and the Grenadines', 'VC'],
+ ['Samoa', 'WS'],
+ ['San Marino', 'SM'],
+ ['Sao Tome and Principe', 'ST'],
+ ['Saudi Arabia', 'SA'],
+ ['Senegal', 'SN'],
+ ['Serbia', 'RS'],
+ ['Seychelles', 'SC'],
+ ['Sierra Leone', 'SL'],
+ ['Singapore', 'SG'],
+ ['Slovakia', 'SK'],
+ ['Slovenia', 'SI'],
+ ['Solomon Islands', 'SB'],
+ ['Somalia', 'SO'],
+ ['Somaliland', 'SO'],
+ ['South Africa', 'Rand'],
+ ['South Korea', 'KR'],
+ ['South Ossetia', 'GE'],
+ ['Spain', 'ES'],
+ ['Sri Lanka', 'LK'],
+ ['Sudan', 'SD'],
+ ['Suriname', 'SR'],
+ ['Swaziland', 'SZ'],
+ ['Sweden', 'SE'],
+ ['Switzerland', 'CH'],
+ ['Syria', 'SY'],
+ ['Taiwan', 'TW'],
+ ['Tajikistan', 'TJ'],
+ ['Tanzania', 'TZ'],
+ ['Thailand', 'TH'],
+ ['Timor-Leste', 'TL'],
+ ['Togo', 'TG'],
+ ['Tonga', 'TO'],
+ ['Transnistria', 'MD'],
+ ['Trinidad and Tobago', 'TT'],
+ ['Tunisia', 'TN'],
+ ['Turkey', 'TR'],
+ ['Turkmenistan', 'TM'],
+ ['Tuvalu', 'TV'],
+ ['Uganda', 'UG'],
+ ['Ukraine', 'UA'],
+ ['United Arab Emirates', 'AE'],
+ ['United Kingdom', 'GB'],
+ ['Uruguay', 'UY'],
+ ['Uzbekistan', 'UZ'],
+ ['Vanuatu', 'VU'],
+ ['Vatican City', 'VA'],
+ ['Venezuela', 'VE'],
+ ['Vietnam', 'VN'],
+ ['Yemen', 'YE'],
+ ['Zambia', 'ZM'],
+ ['Zimbabwe', 'ZW'],
+]