Skip to content

Commit

Permalink
added public getter and setter for country data object, and updated t…
Browse files Browse the repository at this point in the history
…ests
  • Loading branch information
jackocnr committed Oct 25, 2013
1 parent 33dcc92 commit 1631632
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 45 deletions.
32 changes: 23 additions & 9 deletions build/js/intlTelInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ author: Jack O'Connor (http://jackocnr.com)
});
},
// end of init()
/********************
* PRIVATE METHODS
********************/
// find the country data for the given country code
_getCountryData: function(countryCode) {
for (var i = 0; i < intlData.countries.length; i++) {
Expand All @@ -223,15 +226,6 @@ author: Jack O'Connor (http://jackocnr.com)
listItem.addClass("active");
return listItem;
},
// update the selected flag, and insert the dial code
selectCountry: function(countryCode) {
// check if already selected
if (!this.selectedFlagInner.hasClass(countryCode)) {
var listItem = this._selectFlag(countryCode);
var dialCode = listItem.attr("data-dial-code");
this.telInput.val("+" + dialCode + " ");
}
},
// called when the user selects a list item from the dropdown
_selectListItem: function(listItem) {
var countryCode = listItem.attr("data-country-code");
Expand Down Expand Up @@ -335,6 +329,26 @@ author: Jack O'Connor (http://jackocnr.com)
tmp += "</li>";
});
this.countryList.append(tmp);
},
/********************
* PUBLIC METHODS
********************/
// update the selected flag, and insert the dial code
selectCountry: function(countryCode) {
// check if already selected
if (!this.selectedFlagInner.hasClass(countryCode)) {
var listItem = this._selectFlag(countryCode);
var dialCode = listItem.attr("data-dial-code");
this.telInput.val("+" + dialCode + " ");
}
},
// get the country data object
getCountryData: function() {
return intlData;
},
// set the country data object
setCountryData: function(obj) {
intlData = obj;
}
};
// adapted to allow public functions
Expand Down
Loading

0 comments on commit 1631632

Please sign in to comment.