Skip to content

Commit

Permalink
add country detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Bellardia committed Nov 23, 2018
1 parent 3195277 commit b9c5f4c
Show file tree
Hide file tree
Showing 10 changed files with 5,685 additions and 299 deletions.
2,973 changes: 2,827 additions & 146 deletions dist/elTelInput.common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/elTelInput.common.js.map

Large diffs are not rendered by default.

2,973 changes: 2,827 additions & 146 deletions dist/elTelInput.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/elTelInput.umd.js.map

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion dist/elTelInput.umd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/elTelInput.umd.min.js.map

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jumbleberry/el-tel-input",
"version": "1.0.3",
"version": "1.0.4",
"private": true,
"main": "./dist/elTelInput.common.js",
"homepage": "https://github.com/Jumbleberry/el-tel-input/",
Expand All @@ -27,6 +27,7 @@
"@vue/cli-service": "^3.1.4",
"@vue/eslint-config-prettier": "^3.0.5",
"@vue/test-utils": "^1.0.0-beta.25",
"axios": "^0.18.0",
"babel-eslint": "^10.0.1",
"babel-plugin-component": "^1.1.1",
"chai": "^4.1.2",
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default {
name: 'ElTelInputDemo',
data() {
return {
telNumber: '+56996504804',
telNumber: '',
telNumberDetails: {
country: '',
countryCallingCode: '',
Expand Down
6 changes: 6 additions & 0 deletions src/components/ElTelInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
</div>
</template>
<script>
import axios from 'axios';
import allCountries from '@/assets/data/all-countries';
import ElFlaggedLabel from '@/components/ElFlaggedLabel';
import { parsePhoneNumber } from 'libphonenumber-js';
Expand Down Expand Up @@ -60,6 +61,11 @@ export default {
components: {
ElFlaggedLabel
},
async created() {
const response = await axios.get('https://ipinfo.io/json').catch(() => {}) || { data: { country: "US" }};
if (response && response.data && response.data.country)
this.handleCountryCodeInput(response.data.country)
},
computed: {
sortedCountries() {
let normalizePreferredCountries = this.preferredCountries.map(c => c.toUpperCase());
Expand Down

0 comments on commit b9c5f4c

Please sign in to comment.