├── .gitignore
├── .travis.yml
├── Cakefile
├── LICENSE
├── README.md
├── bower.json
├── example
└── index.html
├── lib
└── jquery.mobilePhoneNumber.js
├── mobilephonenumber.jquery.json
├── package-lock.json
├── package.json
├── src
└── jquery.mobilePhoneNumber.coffee
├── test
└── index.coffee
└── vendor
└── jquery.caret.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - 9
4 |
--------------------------------------------------------------------------------
/Cakefile:
--------------------------------------------------------------------------------
1 | {spawn} = require 'child_process'
2 | path = require 'path'
3 |
4 | binPath = (bin) -> path.resolve(__dirname, "./node_modules/.bin/#{bin}")
5 |
6 | runExternal = (cmd, args) ->
7 | child = spawn(binPath(cmd), args, stdio: 'inherit')
8 | child.on('error', console.error)
9 | child.on('close', process.exit)
10 |
11 | task 'build', 'Build lib/ from src/', ->
12 | runExternal 'coffee', ['-c', '-o', 'lib', 'src']
13 |
14 | task 'watch', 'Watch src/ for changes', ->
15 | runExternal 'coffee', ['-w', '-c', '-o', 'lib', 'src']
16 |
17 | task 'test', 'Run tests', ->
18 | runExternal 'mocha', ['--require', 'coffeescript/register', 'test/**/*.{js,coffee}']
19 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014 Stripe
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Project status
2 |
3 | This project is deprecated.
4 |
5 | We will patch jquery.mobilePhoneNumber for critical security issues, but won't be adding any new features.
6 |
7 | # jQuery.mobilePhoneNumber [](https://travis-ci.org/stripe/jquery.mobilePhoneNumber) [](https://cdnjs.com/libraries/jquery.mobilephonenumber/)
8 |
9 | A general purpose library for validating and formatting mobile phone numbers.
10 |
11 | ```javascript
12 | $("input.phone-num").mobilePhoneNumber();
13 | ```
14 |
15 | You can bind to an event when the user changes the country of the phone number:
16 |
17 | ```javascript
18 | $("input.phone-num").bind("country.mobilePhoneNumber", function(e, country) {
19 | console.log("The new country code:", country);
20 | });
21 | ```
22 |
23 | You can find a [demo here](http://stripe.github.io/jquery.mobilePhoneNumber/example).
24 |
25 | Dependencies:
26 |
27 | - [jQuery.caret](http://plugins.jquery.com/caret)
28 | - Tested on jQuery 1.8.3 and 1.11.1
29 |
30 | ## API
31 |
32 | ### \$.fn.mobilePhoneNumber([options])
33 |
34 | Enables phone number formatting.
35 |
36 | Options:
37 |
38 | - `defaultPrefix`: allows the user to type a phone number without the prefix for this specific value.
39 |
40 | Example:
41 |
42 | ```javascript
43 | $("input.phone-num").mobilePhoneNumber({
44 | defaultPrefix: "+1"
45 | });
46 | ```
47 |
48 | ### \$.fn.mobilePhoneNumber('val')
49 |
50 | Returns the phone number value with prefix, but without other formatting.
51 |
52 | Example:
53 |
54 | ```javascript
55 | $("input.phone-num").val(); //=> '+1 (415) 123-5554'
56 | $("input.phone-num").mobilePhoneNumber("val"); //=> '+14151235554'
57 | ```
58 |
59 | ### \$.fn.mobilePhoneNumber('validate')
60 |
61 | Returns whether the phone number is valid.
62 |
63 | _Note:_ this implementation is very naive; it only validates that the phone number is longer than its prefix.
64 |
65 | Example:
66 |
67 | ```javascript
68 | $("input.phone-num").val(); //=> '+1 (415) 123-5554'
69 | $("input.phone-num").mobilePhoneNumber("validate"); //=> true
70 |
71 | $("input.phone-num").val(); //=> '+43'
72 | $("input.phone-num").mobilePhoneNumber("validate"); //=> false
73 | ```
74 |
75 | ### \$.fn.mobilePhoneNumber('country')
76 |
77 | Returns the two-letter country code of the phone number.
78 |
79 | Example:
80 |
81 | ```javascript
82 | $("input.phone-num").val(); //=> '+32 495 12 34 56'
83 | $("input.phone-num").mobilePhoneNumber("country"); //=> 'BE'
84 | ```
85 |
86 | ### \$.fn.mobilePhoneNumber('prefix')
87 |
88 | Returns the prefix of the phone number.
89 |
90 | Example:
91 |
92 | ```javascript
93 | $("input.phone-num").val(); //=> '+32 495 12 34 56'
94 | $("input.phone-num").mobilePhoneNumber("prefix"); //=> '+32'
95 | ```
96 |
97 | ### \$.formatMobilePhoneNumber(phone)
98 |
99 | Returns the formatted phone number.
100 |
101 | Example:
102 |
103 | ```javascript
104 | $.formatMobilePhoneNumber("14151235554"); //=> '+1 (415) 123-5554'
105 | ```
106 |
107 | ## Events
108 |
109 | ### country.mobilePhoneNumber
110 |
111 | Triggered when the country has changed.
112 |
113 | Example:
114 |
115 | ```javascript
116 | $("input.phone-num").bind("country.mobilePhoneNumber", function(e, country) {
117 | console.log("The new country code:", country);
118 | });
119 |
120 | // Simulate user input
121 | $("input.phone-num")
122 | .val("+32495123456")
123 | .keyup();
124 | //=> The new country code: BE
125 | ```
126 |
127 | ## Building
128 |
129 | Run `cake build`
130 |
131 | ## Running tests
132 |
133 | Run `cake test`
134 |
135 | ## Mobile recommendations
136 |
137 | We recommend you set the `pattern`, `type`, and `x-autocompletetype` attributes, which will trigger autocompletion and a numeric keypad to display on touch devices:
138 |
139 | ```html
140 |
141 | ```
142 |
143 | You may have to turn off HTML5 validation (using the `novalidate` form attribute) when using this `pattern`, since it won't permit spaces and other characters that appear in the formatted version of the phone number.
144 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery.mobilephonenumber",
3 | "version": "1.0.6",
4 | "main": "lib/jquery.mobilePhoneNumber.js",
5 | "dependencies": {
6 | "jquery": ">=1.5"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Demo (jQuery.mobilePhoneNumber)
5 |
6 |
7 |
8 |
9 |
24 |
25 |
34 |
35 |
36 |
37 |
38 | Demo (jQuery.mobilePhoneNumber)
39 |
40 |
41 |
42 |
43 | Try different phone numbers like:
44 |
45 | - 415 123 4567
46 | - +1 415 123 4567
47 | - +32 495 12 34 56
48 |
49 |
50 | View source code on Github
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/lib/jquery.mobilePhoneNumber.js:
--------------------------------------------------------------------------------
1 | // Generated by CoffeeScript 1.7.1
2 | (function() {
3 | var $, checkForCountryChange_, formatBack_, formatForPhone_, formatUp_, format_, formats, formattedPhoneNumber_, formattedPhone_, isEventAllowedChar_, isEventAllowed_, mobilePhoneNumber, prefixesAreSubsets_, restrictEventAndFormat_, supportSelectionEnd, withTimeout,
4 | __slice = [].slice;
5 |
6 | $ = jQuery;
7 |
8 | supportSelectionEnd = 'selectionEnd' in document.createElement('input');
9 |
10 | withTimeout = function(fn) {
11 | return setTimeout(fn, 50);
12 | };
13 |
14 | formatForPhone_ = function(phone, defaultPrefix) {
15 | var bestFormat, format, k, precision, prefix, v;
16 | if (defaultPrefix == null) {
17 | defaultPrefix = null;
18 | }
19 | if (phone.indexOf('+') !== 0 && defaultPrefix) {
20 | phone = defaultPrefix + phone.replace(/[^0-9]/g, '');
21 | } else {
22 | phone = '+' + phone.replace(/[^0-9]/g, '');
23 | }
24 | bestFormat = null;
25 | precision = 0;
26 | for (prefix in formats) {
27 | format = formats[prefix];
28 | if (phone.length >= prefix.length && phone.substring(0, prefix.length) === prefix && prefix.length > precision) {
29 | bestFormat = {};
30 | for (k in format) {
31 | v = format[k];
32 | bestFormat[k] = v;
33 | }
34 | bestFormat.prefix = prefix;
35 | precision = prefix.length;
36 | }
37 | }
38 | return bestFormat;
39 | };
40 |
41 | prefixesAreSubsets_ = function(prefixA, prefixB) {
42 | if (prefixA === prefixB) {
43 | return true;
44 | }
45 | if (prefixA.length < prefixB.length) {
46 | return prefixB.substring(0, prefixA.length) === prefixA;
47 | }
48 | return prefixA.substring(0, prefixB.length) === prefixB;
49 | };
50 |
51 | formattedPhoneNumber_ = function(phone, lastChar, defaultPrefix) {
52 | var format, formatChar, formatDigitCount, formattedPhone, i, phoneDigits, phoneFormat, phonePrefix, prefixPhoneFormat, _i, _j, _len, _ref;
53 | if (defaultPrefix == null) {
54 | defaultPrefix = null;
55 | }
56 | if (phone.length !== 0 && (phone.substring(0, 1) === "+" || defaultPrefix)) {
57 | format = formatForPhone_(phone, defaultPrefix);
58 | if (format && format.format) {
59 | phoneFormat = format.format;
60 | phonePrefix = format.prefix;
61 | if (defaultPrefix) {
62 | if ((defaultPrefix === phonePrefix || prefixesAreSubsets_(phonePrefix, defaultPrefix)) && (phone.indexOf('+') !== 0 || phone.length === 0)) {
63 | phoneFormat = phoneFormat.substring(Math.min(phonePrefix.length, defaultPrefix.length) + 1);
64 | if (format.nationalPrefix != null) {
65 | prefixPhoneFormat = "";
66 | for (i = _i = 0, _ref = format.nationalPrefix.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) {
67 | prefixPhoneFormat += ".";
68 | }
69 | phoneFormat = prefixPhoneFormat + phoneFormat;
70 | }
71 | }
72 | }
73 | if (phone.substring(0, 1) === "+") {
74 | phoneDigits = phone.substring(1);
75 | } else {
76 | phoneDigits = phone;
77 | }
78 | formatDigitCount = phoneFormat.match(/\./g).length;
79 | formattedPhone = "";
80 | for (_j = 0, _len = phoneFormat.length; _j < _len; _j++) {
81 | formatChar = phoneFormat[_j];
82 | if (formatChar === ".") {
83 | if (phoneDigits.length === 0) {
84 | break;
85 | }
86 | formattedPhone += phoneDigits.substring(0, 1);
87 | phoneDigits = phoneDigits.substring(1);
88 | } else if (lastChar || phoneDigits.length > 0) {
89 | formattedPhone += formatChar;
90 | }
91 | }
92 | phone = formattedPhone + phoneDigits;
93 | }
94 | }
95 | return phone;
96 | };
97 |
98 | isEventAllowed_ = function(e) {
99 | if (e.metaKey) {
100 | return true;
101 | }
102 | if (e.which === 32) {
103 | return false;
104 | }
105 | if (e.which === 0) {
106 | return true;
107 | }
108 | if (e.which < 33) {
109 | return true;
110 | }
111 | return isEventAllowedChar_(e);
112 | };
113 |
114 | isEventAllowedChar_ = function(e) {
115 | var char;
116 | char = String.fromCharCode(e.which);
117 | return !!/[\d\s+]/.test(char);
118 | };
119 |
120 | restrictEventAndFormat_ = function(e) {
121 | var caretEnd, value;
122 | if (!isEventAllowed_(e)) {
123 | return e.preventDefault();
124 | }
125 | if (!isEventAllowedChar_(e)) {
126 | return;
127 | }
128 | value = this.val();
129 | caretEnd = supportSelectionEnd ? this.get(0).selectionEnd : this.caret();
130 | value = value.substring(0, this.caret()) + String.fromCharCode(e.which) + value.substring(caretEnd, value.length);
131 | format_.call(this, value, e);
132 | return withTimeout((function(_this) {
133 | return function() {
134 | return _this.caret(_this.val().length);
135 | };
136 | })(this));
137 | };
138 |
139 | formatUp_ = function(e) {
140 | var value;
141 | checkForCountryChange_.call(this);
142 | value = this.val();
143 | if (e.keyCode === 8 && this.caret() === value.length) {
144 | return;
145 | }
146 | return format_.call(this, value, e);
147 | };
148 |
149 | formatBack_ = function(e) {
150 | var phone, value;
151 | if (!e) {
152 | return;
153 | }
154 | if (e.meta) {
155 | return;
156 | }
157 | value = this.val();
158 | if (value.length === 0) {
159 | return;
160 | }
161 | if (!(this.caret() === value.length)) {
162 | return;
163 | }
164 | if (e.keyCode !== 8) {
165 | return;
166 | }
167 | value = value.substring(0, value.length - 1);
168 | e.preventDefault();
169 | phone = formattedPhone_.call(this, value, false);
170 | if (this.val() !== phone) {
171 | return this.val(phone);
172 | }
173 | };
174 |
175 | format_ = function(value, e) {
176 | var phone, selection, selectionAtEnd;
177 | phone = formattedPhone_.call(this, value, true);
178 | if (phone !== this.val()) {
179 | selection = this.caret();
180 | selectionAtEnd = selection === this.val().length;
181 | e.preventDefault();
182 | this.val(phone);
183 | if (!selectionAtEnd) {
184 | return withTimeout((function(_this) {
185 | return function() {
186 | return _this.caret(selection);
187 | };
188 | })(this));
189 | }
190 | }
191 | };
192 |
193 | formattedPhone_ = function(phone, lastChar) {
194 | if (phone.indexOf('+') !== 0 && this.data('defaultPrefix')) {
195 | phone = phone.replace(/[^0-9]/g, '');
196 | } else {
197 | phone = '+' + phone.replace(/[^0-9]/g, '');
198 | }
199 | return formattedPhoneNumber_(phone, lastChar, this.data('defaultPrefix'));
200 | };
201 |
202 | checkForCountryChange_ = function() {
203 | var country, format, phone;
204 | phone = this.val();
205 | format = formatForPhone_(phone, this.data('defaultPrefix'));
206 | country = null;
207 | if (format) {
208 | country = format.country;
209 | }
210 | if (this.data('mobilePhoneCountry') !== country) {
211 | this.data('mobilePhoneCountry', country);
212 | return this.trigger('country.mobilePhoneNumber', country);
213 | }
214 | };
215 |
216 | mobilePhoneNumber = {};
217 |
218 | mobilePhoneNumber.init = function(options) {
219 | var _ref;
220 | if (options == null) {
221 | options = {};
222 | }
223 | if (!this.data('mobilePhoneNumberInited')) {
224 | this.data('mobilePhoneNumberInited', true);
225 | this.bind('keypress', (function(_this) {
226 | return function() {
227 | return restrictEventAndFormat_.apply($(_this), arguments);
228 | };
229 | })(this));
230 | this.bind('keyup', (function(_this) {
231 | return function() {
232 | return formatUp_.apply($(_this), arguments);
233 | };
234 | })(this));
235 | this.bind('keydown', (function(_this) {
236 | return function() {
237 | return formatBack_.apply($(_this), arguments);
238 | };
239 | })(this));
240 | }
241 | this.data('defaultPrefix', (_ref = options.allowPhoneWithoutPrefix) != null ? _ref : options.defaultPrefix);
242 | if (this.val() !== '') {
243 | this.val(formattedPhone_.call(this, this.val(), false));
244 | }
245 | return this;
246 | };
247 |
248 | mobilePhoneNumber.val = function() {
249 | var format, val;
250 | val = this.val().replace(/[^0-9]/g, '');
251 | format = formatForPhone_(val, this.data('defaultPrefix'));
252 | if (this.val().indexOf('+') === 0 || (this.data('defaultPrefix') == null)) {
253 | return '+' + val;
254 | } else {
255 | return this.data('defaultPrefix') + val;
256 | }
257 | };
258 |
259 | mobilePhoneNumber.validate = function() {
260 | var format, val;
261 | val = this.mobilePhoneNumber('val');
262 | format = formatForPhone_(val, this.data('defaultPrefix'));
263 | if (!format) {
264 | return true;
265 | }
266 | return val.length > format.prefix.length;
267 | };
268 |
269 | mobilePhoneNumber.country = function() {
270 | var format;
271 | format = formatForPhone_(this.mobilePhoneNumber('val'));
272 | if (format) {
273 | return format.country;
274 | }
275 | };
276 |
277 | mobilePhoneNumber.prefix = function() {
278 | var countryCode;
279 | countryCode = this.mobilePhoneNumber('country');
280 | if (countryCode == null) {
281 | return "";
282 | }
283 | return $.mobilePhoneNumberPrefixFromCountryCode(countryCode);
284 | };
285 |
286 | $.fn.mobilePhoneNumber = function() {
287 | var args, method;
288 | method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
289 | if ((method == null) || !(typeof method === 'string')) {
290 | if (method != null) {
291 | args = [method];
292 | }
293 | method = 'init';
294 | }
295 | return mobilePhoneNumber[method].apply(this, args);
296 | };
297 |
298 | $.formatMobilePhoneNumber = function(phone) {
299 | phone = '+' + phone.replace(/[^0-9\*]/g, '');
300 | return formattedPhoneNumber_(phone, true);
301 | };
302 |
303 | $.mobilePhoneNumberPrefixFromCountryCode = function(countryCode) {
304 | var format, prefix;
305 | for (prefix in formats) {
306 | format = formats[prefix];
307 | if (format.country.toLowerCase() === countryCode.toLowerCase()) {
308 | if (prefix.length === 5 && prefix[1] === '1') {
309 | return '+1';
310 | }
311 | return prefix;
312 | }
313 | }
314 | return null;
315 | };
316 |
317 | formats = {
318 | '+247': {
319 | country: 'AC'
320 | },
321 | '+376': {
322 | country: 'AD',
323 | format: '+... ... ...'
324 | },
325 | '+971': {
326 | country: 'AE',
327 | format: '+... .. ... ....'
328 | },
329 | '+93': {
330 | country: 'AF',
331 | format: '+.. .. ... ....'
332 | },
333 | '+1268': {
334 | country: 'AG'
335 | },
336 | '+1264': {
337 | country: 'AI'
338 | },
339 | '+355': {
340 | country: 'AL',
341 | format: '+... .. ... ....'
342 | },
343 | '+374': {
344 | country: 'AM',
345 | format: '+... .. ......'
346 | },
347 | '+244': {
348 | country: 'AO',
349 | format: '+... ... ... ...'
350 | },
351 | '+54': {
352 | country: 'AR',
353 | format: '+.. .. ..-....-....'
354 | },
355 | '+1684': {
356 | country: 'AS'
357 | },
358 | '+43': {
359 | country: 'AT',
360 | format: '+.. ... ......'
361 | },
362 | '+61': {
363 | country: 'AU',
364 | format: '+.. ... ... ...'
365 | },
366 | '+297': {
367 | country: 'AW',
368 | format: '+... ... ....'
369 | },
370 | '+994': {
371 | country: 'AZ',
372 | format: '+... .. ... .. ..'
373 | },
374 | '+387': {
375 | country: 'BA',
376 | format: '+... .. ...-...'
377 | },
378 | '+1246': {
379 | country: 'BB'
380 | },
381 | '+880': {
382 | country: 'BD',
383 | format: '+... ....-......'
384 | },
385 | '+32': {
386 | country: 'BE',
387 | format: '+.. ... .. .. ..'
388 | },
389 | '+226': {
390 | country: 'BF',
391 | format: '+... .. .. .. ..'
392 | },
393 | '+359': {
394 | country: 'BG',
395 | format: '+... ... ... ..'
396 | },
397 | '+973': {
398 | country: 'BH',
399 | format: '+... .... ....'
400 | },
401 | '+257': {
402 | country: 'BI',
403 | format: '+... .. .. .. ..'
404 | },
405 | '+229': {
406 | country: 'BJ',
407 | format: '+... .. .. .. ..'
408 | },
409 | '+1441': {
410 | country: 'BM'
411 | },
412 | '+673': {
413 | country: 'BN',
414 | format: '+... ... ....'
415 | },
416 | '+591': {
417 | country: 'BO',
418 | format: '+... ........'
419 | },
420 | '+55': {
421 | country: 'BR',
422 | format: '+.. .. .....-....'
423 | },
424 | '+1242': {
425 | country: 'BS'
426 | },
427 | '+975': {
428 | country: 'BT',
429 | format: '+... .. .. .. ..'
430 | },
431 | '+267': {
432 | country: 'BW',
433 | format: '+... .. ... ...'
434 | },
435 | '+375': {
436 | country: 'BY',
437 | format: '+... .. ...-..-..'
438 | },
439 | '+501': {
440 | country: 'BZ',
441 | format: '+... ...-....'
442 | },
443 | '+243': {
444 | country: 'CD',
445 | format: '+... ... ... ...'
446 | },
447 | '+236': {
448 | country: 'CF',
449 | format: '+... .. .. .. ..'
450 | },
451 | '+242': {
452 | country: 'CG',
453 | format: '+... .. ... ....'
454 | },
455 | '+41': {
456 | country: 'CH',
457 | format: '+.. .. ... .. ..'
458 | },
459 | '+225': {
460 | country: 'CI',
461 | format: '+... .. .. .. ..'
462 | },
463 | '+682': {
464 | country: 'CK',
465 | format: '+... .. ...'
466 | },
467 | '+56': {
468 | country: 'CL',
469 | format: '+.. . .... ....'
470 | },
471 | '+237': {
472 | country: 'CM',
473 | format: '+... .. .. .. ..'
474 | },
475 | '+86': {
476 | country: 'CN',
477 | format: '+.. ... .... ....'
478 | },
479 | '+57': {
480 | country: 'CO',
481 | format: '+.. ... .......'
482 | },
483 | '+506': {
484 | country: 'CR',
485 | format: '+... .... ....'
486 | },
487 | '+53': {
488 | country: 'CU',
489 | format: '+.. . .......'
490 | },
491 | '+238': {
492 | country: 'CV',
493 | format: '+... ... .. ..'
494 | },
495 | '+599': {
496 | country: 'CW',
497 | format: '+... . ... ....'
498 | },
499 | '+537': {
500 | country: 'CY'
501 | },
502 | '+357': {
503 | country: 'CY',
504 | format: '+... .. ......'
505 | },
506 | '+420': {
507 | country: 'CZ',
508 | format: '+... ... ... ...'
509 | },
510 | '+49': {
511 | country: 'DE',
512 | format: '+.. .... .......'
513 | },
514 | '+253': {
515 | country: 'DJ',
516 | format: '+... .. .. .. ..'
517 | },
518 | '+45': {
519 | country: 'DK',
520 | format: '+.. .. .. .. ..'
521 | },
522 | '+1767': {
523 | country: 'DM'
524 | },
525 | '+1849': {
526 | country: 'DO'
527 | },
528 | '+213': {
529 | country: 'DZ',
530 | format: '+... ... .. .. ..'
531 | },
532 | '+593': {
533 | country: 'EC',
534 | format: '+... .. ... ....'
535 | },
536 | '+372': {
537 | country: 'EE',
538 | format: '+... .... ....'
539 | },
540 | '+20': {
541 | country: 'EG',
542 | format: '+.. ... ... ....'
543 | },
544 | '+291': {
545 | country: 'ER',
546 | format: '+... . ... ...'
547 | },
548 | '+34': {
549 | country: 'ES',
550 | format: '+.. ... .. .. ..'
551 | },
552 | '+251': {
553 | country: 'ET',
554 | format: '+... .. ... ....'
555 | },
556 | '+358': {
557 | country: 'FI',
558 | format: '+... .. ... .. ..'
559 | },
560 | '+679': {
561 | country: 'FJ',
562 | format: '+... ... ....'
563 | },
564 | '+500': {
565 | country: 'FK'
566 | },
567 | '+691': {
568 | country: 'FM',
569 | format: '+... ... ....'
570 | },
571 | '+298': {
572 | country: 'FO',
573 | format: '+... ......'
574 | },
575 | '+33': {
576 | country: 'FR',
577 | format: '+.. . .. .. .. ..'
578 | },
579 | '+241': {
580 | country: 'GA',
581 | format: '+... .. .. .. ..'
582 | },
583 | '+44': {
584 | country: 'GB',
585 | format: '+.. .... ......'
586 | },
587 | '+1473': {
588 | country: 'GD'
589 | },
590 | '+995': {
591 | country: 'GE',
592 | format: '+... ... .. .. ..'
593 | },
594 | '+594': {
595 | country: 'GF',
596 | format: '+... ... .. .. ..'
597 | },
598 | '+233': {
599 | country: 'GH',
600 | format: '+... .. ... ....'
601 | },
602 | '+350': {
603 | country: 'GI',
604 | format: '+... ... .....'
605 | },
606 | '+299': {
607 | country: 'GL',
608 | format: '+... .. .. ..'
609 | },
610 | '+220': {
611 | country: 'GM',
612 | format: '+... ... ....'
613 | },
614 | '+224': {
615 | country: 'GN',
616 | format: '+... ... .. .. ..'
617 | },
618 | '+240': {
619 | country: 'GQ',
620 | format: '+... ... ... ...'
621 | },
622 | '+30': {
623 | country: 'GR',
624 | format: '+.. ... ... ....'
625 | },
626 | '+502': {
627 | country: 'GT',
628 | format: '+... .... ....'
629 | },
630 | '+1671': {
631 | country: 'GU'
632 | },
633 | '+245': {
634 | country: 'GW',
635 | format: '+... ... ....'
636 | },
637 | '+592': {
638 | country: 'GY',
639 | format: '+... ... ....'
640 | },
641 | '+852': {
642 | country: 'HK',
643 | format: '+... .... ....'
644 | },
645 | '+504': {
646 | country: 'HN',
647 | format: '+... ....-....'
648 | },
649 | '+385': {
650 | country: 'HR',
651 | format: '+... .. ... ....'
652 | },
653 | '+509': {
654 | country: 'HT',
655 | format: '+... .. .. ....'
656 | },
657 | '+36': {
658 | country: 'HU',
659 | format: '+.. .. ... ....'
660 | },
661 | '+62': {
662 | country: 'ID',
663 | format: '+.. ...-...-...'
664 | },
665 | '+353': {
666 | country: 'IE',
667 | format: '+... .. ... ....'
668 | },
669 | '+972': {
670 | country: 'IL',
671 | format: '+... ..-...-....'
672 | },
673 | '+91': {
674 | country: 'IN',
675 | format: '+.. .. .. ......'
676 | },
677 | '+246': {
678 | country: 'IO',
679 | format: '+... ... ....'
680 | },
681 | '+964': {
682 | country: 'IQ',
683 | format: '+... ... ... ....'
684 | },
685 | '+98': {
686 | country: 'IR',
687 | format: '+.. ... ... ....'
688 | },
689 | '+354': {
690 | country: 'IS',
691 | format: '+... ... ....'
692 | },
693 | '+39': {
694 | country: 'IT',
695 | format: '+.. .. .... ....'
696 | },
697 | '+1876': {
698 | country: 'JM'
699 | },
700 | '+962': {
701 | country: 'JO',
702 | format: '+... . .... ....'
703 | },
704 | '+81': {
705 | country: 'JP',
706 | format: '+.. ..-....-....',
707 | nationalPrefix: '0'
708 | },
709 | '+254': {
710 | country: 'KE',
711 | format: '+... .. .......'
712 | },
713 | '+996': {
714 | country: 'KG',
715 | format: '+... ... ... ...'
716 | },
717 | '+855': {
718 | country: 'KH',
719 | format: '+... .. ... ...'
720 | },
721 | '+686': {
722 | country: 'KI'
723 | },
724 | '+269': {
725 | country: 'KM',
726 | format: '+... ... .. ..'
727 | },
728 | '+1869': {
729 | country: 'KN'
730 | },
731 | '+850': {
732 | country: 'KP',
733 | format: '+... ... ... ....'
734 | },
735 | '+82': {
736 | country: 'KR',
737 | format: '+.. ..-....-....'
738 | },
739 | '+965': {
740 | country: 'KW',
741 | format: '+... ... .....'
742 | },
743 | '+345': {
744 | country: 'KY'
745 | },
746 | '+77': {
747 | country: 'KZ'
748 | },
749 | '+856': {
750 | country: 'LA',
751 | format: '+... .. .. ... ...'
752 | },
753 | '+961': {
754 | country: 'LB',
755 | format: '+... .. ... ...'
756 | },
757 | '+1758': {
758 | country: 'LC'
759 | },
760 | '+423': {
761 | country: 'LI',
762 | format: '+... ... ... ...'
763 | },
764 | '+94': {
765 | country: 'LK',
766 | format: '+.. .. . ......'
767 | },
768 | '+231': {
769 | country: 'LR',
770 | format: '+... ... ... ...'
771 | },
772 | '+266': {
773 | country: 'LS',
774 | format: '+... .... ....'
775 | },
776 | '+370': {
777 | country: 'LT',
778 | format: '+... ... .....'
779 | },
780 | '+352': {
781 | country: 'LU',
782 | format: '+... .. .. .. ...'
783 | },
784 | '+371': {
785 | country: 'LV',
786 | format: '+... .. ... ...'
787 | },
788 | '+218': {
789 | country: 'LY',
790 | format: '+... ..-.......'
791 | },
792 | '+212': {
793 | country: 'MA',
794 | format: '+... ...-......'
795 | },
796 | '+377': {
797 | country: 'MC',
798 | format: '+... . .. .. .. ..'
799 | },
800 | '+373': {
801 | country: 'MD',
802 | format: '+... ... .. ...'
803 | },
804 | '+382': {
805 | country: 'ME',
806 | format: '+... .. ... ...'
807 | },
808 | '+590': {
809 | country: 'MF'
810 | },
811 | '+261': {
812 | country: 'MG',
813 | format: '+... .. .. ... ..'
814 | },
815 | '+692': {
816 | country: 'MH',
817 | format: '+... ...-....'
818 | },
819 | '+389': {
820 | country: 'MK',
821 | format: '+... .. ... ...'
822 | },
823 | '+223': {
824 | country: 'ML',
825 | format: '+... .. .. .. ..'
826 | },
827 | '+95': {
828 | country: 'MM',
829 | format: '+.. . ... ....'
830 | },
831 | '+976': {
832 | country: 'MN',
833 | format: '+... .... ....'
834 | },
835 | '+853': {
836 | country: 'MO',
837 | format: '+... .... ....'
838 | },
839 | '+1670': {
840 | country: 'MP'
841 | },
842 | '+596': {
843 | country: 'MQ',
844 | format: '+... ... .. .. ..'
845 | },
846 | '+222': {
847 | country: 'MR',
848 | format: '+... .. .. .. ..'
849 | },
850 | '+1664': {
851 | country: 'MS'
852 | },
853 | '+356': {
854 | country: 'MT',
855 | format: '+... .... ....'
856 | },
857 | '+230': {
858 | country: 'MU',
859 | format: '+... .... ....'
860 | },
861 | '+960': {
862 | country: 'MV',
863 | format: '+... ...-....'
864 | },
865 | '+265': {
866 | country: 'MW',
867 | format: '+... ... .. .. ..'
868 | },
869 | '+52': {
870 | country: 'MX',
871 | format: '+.. ... ... ... ....'
872 | },
873 | '+60': {
874 | country: 'MY',
875 | format: '+.. ..-... ....'
876 | },
877 | '+258': {
878 | country: 'MZ',
879 | format: '+... .. ... ....'
880 | },
881 | '+264': {
882 | country: 'NA',
883 | format: '+... .. ... ....'
884 | },
885 | '+687': {
886 | country: 'NC',
887 | format: '+... ........'
888 | },
889 | '+227': {
890 | country: 'NE',
891 | format: '+... .. .. .. ..'
892 | },
893 | '+672': {
894 | country: 'NF',
895 | format: '+... .. ....'
896 | },
897 | '+234': {
898 | country: 'NG',
899 | format: '+... ... ... ....'
900 | },
901 | '+505': {
902 | country: 'NI',
903 | format: '+... .... ....'
904 | },
905 | '+31': {
906 | country: 'NL',
907 | format: '+.. . ........'
908 | },
909 | '+47': {
910 | country: 'NO',
911 | format: '+.. ... .. ...'
912 | },
913 | '+977': {
914 | country: 'NP',
915 | format: '+... ...-.......'
916 | },
917 | '+674': {
918 | country: 'NR',
919 | format: '+... ... ....'
920 | },
921 | '+683': {
922 | country: 'NU'
923 | },
924 | '+64': {
925 | country: 'NZ',
926 | format: '+.. .. ... ....'
927 | },
928 | '+968': {
929 | country: 'OM',
930 | format: '+... .... ....'
931 | },
932 | '+507': {
933 | country: 'PA',
934 | format: '+... ....-....'
935 | },
936 | '+51': {
937 | country: 'PE',
938 | format: '+.. ... ... ...'
939 | },
940 | '+689': {
941 | country: 'PF',
942 | format: '+... .. .. ..'
943 | },
944 | '+675': {
945 | country: 'PG',
946 | format: '+... ... ....'
947 | },
948 | '+63': {
949 | country: 'PH',
950 | format: '+.. .... ......'
951 | },
952 | '+92': {
953 | country: 'PK',
954 | format: '+.. ... .......'
955 | },
956 | '+48': {
957 | country: 'PL',
958 | format: '+.. .. ... .. ..'
959 | },
960 | '+508': {
961 | country: 'PM',
962 | format: '+... .. .. ..'
963 | },
964 | '+872': {
965 | country: 'PN'
966 | },
967 | '+1939': {
968 | country: 'PR'
969 | },
970 | '+970': {
971 | country: 'PS',
972 | format: '+... ... ... ...'
973 | },
974 | '+351': {
975 | country: 'PT',
976 | format: '+... ... ... ...'
977 | },
978 | '+680': {
979 | country: 'PW',
980 | format: '+... ... ....'
981 | },
982 | '+595': {
983 | country: 'PY',
984 | format: '+... .. .......'
985 | },
986 | '+974': {
987 | country: 'QA',
988 | format: '+... .... ....'
989 | },
990 | '+262': {
991 | country: 'RE'
992 | },
993 | '+40': {
994 | country: 'RO',
995 | format: '+.. .. ... ....'
996 | },
997 | '+381': {
998 | country: 'RS',
999 | format: '+... .. .......'
1000 | },
1001 | '+7': {
1002 | country: 'RU',
1003 | format: '+. ... ...-..-..'
1004 | },
1005 | '+250': {
1006 | country: 'RW',
1007 | format: '+... ... ... ...'
1008 | },
1009 | '+966': {
1010 | country: 'SA',
1011 | format: '+... .. ... ....'
1012 | },
1013 | '+677': {
1014 | country: 'SB',
1015 | format: '+... ... ....'
1016 | },
1017 | '+248': {
1018 | country: 'SC',
1019 | format: '+... . ... ...'
1020 | },
1021 | '+249': {
1022 | country: 'SD',
1023 | format: '+... .. ... ....'
1024 | },
1025 | '+46': {
1026 | country: 'SE',
1027 | format: '+.. ..-... .. ..'
1028 | },
1029 | '+65': {
1030 | country: 'SG',
1031 | format: '+.. .... ....'
1032 | },
1033 | '+290': {
1034 | country: 'SH'
1035 | },
1036 | '+386': {
1037 | country: 'SI',
1038 | format: '+... .. ... ...'
1039 | },
1040 | '+421': {
1041 | country: 'SK',
1042 | format: '+... ... ... ...'
1043 | },
1044 | '+232': {
1045 | country: 'SL',
1046 | format: '+... .. ......'
1047 | },
1048 | '+378': {
1049 | country: 'SM',
1050 | format: '+... .. .. .. ..'
1051 | },
1052 | '+221': {
1053 | country: 'SN',
1054 | format: '+... .. ... .. ..'
1055 | },
1056 | '+252': {
1057 | country: 'SO',
1058 | format: '+... .. .......'
1059 | },
1060 | '+597': {
1061 | country: 'SR',
1062 | format: '+... ...-....'
1063 | },
1064 | '+211': {
1065 | country: 'SS',
1066 | format: '+... ... ... ...'
1067 | },
1068 | '+239': {
1069 | country: 'ST',
1070 | format: '+... ... ....'
1071 | },
1072 | '+503': {
1073 | country: 'SV',
1074 | format: '+... .... ....'
1075 | },
1076 | '+963': {
1077 | country: 'SY',
1078 | format: '+... ... ... ...'
1079 | },
1080 | '+268': {
1081 | country: 'SZ',
1082 | format: '+... .... ....'
1083 | },
1084 | '+1649': {
1085 | country: 'TC'
1086 | },
1087 | '+235': {
1088 | country: 'TD',
1089 | format: '+... .. .. .. ..'
1090 | },
1091 | '+228': {
1092 | country: 'TG',
1093 | format: '+... .. .. .. ..'
1094 | },
1095 | '+66': {
1096 | country: 'TH',
1097 | format: '+.. .. ... ....'
1098 | },
1099 | '+992': {
1100 | country: 'TJ',
1101 | format: '+... ... .. ....'
1102 | },
1103 | '+690': {
1104 | country: 'TK'
1105 | },
1106 | '+670': {
1107 | country: 'TL',
1108 | format: '+... .... ....'
1109 | },
1110 | '+993': {
1111 | country: 'TM',
1112 | format: '+... .. ..-..-..'
1113 | },
1114 | '+216': {
1115 | country: 'TN',
1116 | format: '+... .. ... ...'
1117 | },
1118 | '+676': {
1119 | country: 'TO',
1120 | format: '+... ... ....'
1121 | },
1122 | '+90': {
1123 | country: 'TR',
1124 | format: '+.. ... ... ....'
1125 | },
1126 | '+1868': {
1127 | country: 'TT'
1128 | },
1129 | '+688': {
1130 | country: 'TV'
1131 | },
1132 | '+886': {
1133 | country: 'TW',
1134 | format: '+... ... ... ...'
1135 | },
1136 | '+255': {
1137 | country: 'TZ',
1138 | format: '+... ... ... ...'
1139 | },
1140 | '+380': {
1141 | country: 'UA',
1142 | format: '+... .. ... ....'
1143 | },
1144 | '+256': {
1145 | country: 'UG',
1146 | format: '+... ... ......'
1147 | },
1148 | '+1': {
1149 | country: 'US'
1150 | },
1151 | '+598': {
1152 | country: 'UY',
1153 | format: '+... .... ....'
1154 | },
1155 | '+998': {
1156 | country: 'UZ',
1157 | format: '+... .. ... .. ..'
1158 | },
1159 | '+379': {
1160 | country: 'VA'
1161 | },
1162 | '+1784': {
1163 | country: 'VC'
1164 | },
1165 | '+58': {
1166 | country: 'VE',
1167 | format: '+.. ...-.......'
1168 | },
1169 | '+1284': {
1170 | country: 'VG'
1171 | },
1172 | '+1340': {
1173 | country: 'VI'
1174 | },
1175 | '+84': {
1176 | country: 'VN',
1177 | format: '+.. .. ... .. ..'
1178 | },
1179 | '+678': {
1180 | country: 'VU',
1181 | format: '+... ... ....'
1182 | },
1183 | '+681': {
1184 | country: 'WF',
1185 | format: '+... .. .. ..'
1186 | },
1187 | '+685': {
1188 | country: 'WS'
1189 | },
1190 | '+967': {
1191 | country: 'YE',
1192 | format: '+... ... ... ...'
1193 | },
1194 | '+27': {
1195 | country: 'ZA',
1196 | format: '+.. .. ... ....'
1197 | },
1198 | '+260': {
1199 | country: 'ZM',
1200 | format: '+... .. .......'
1201 | },
1202 | '+263': {
1203 | country: 'ZW',
1204 | format: '+... .. ... ....'
1205 | }
1206 | };
1207 |
1208 | (function(formats) {
1209 | var canadaPrefixes, format, prefix, _i, _len, _results;
1210 | canadaPrefixes = [403, 587, 780, 250, 604, 778, 204, 506, 709, 902, 226, 249, 289, 343, 416, 519, 613, 647, 705, 807, 905, 418, 438, 450, 514, 579, 581, 819, 873, 306, 867];
1211 | for (_i = 0, _len = canadaPrefixes.length; _i < _len; _i++) {
1212 | prefix = canadaPrefixes[_i];
1213 | formats['+1' + prefix] = {
1214 | country: 'CA'
1215 | };
1216 | }
1217 | _results = [];
1218 | for (prefix in formats) {
1219 | format = formats[prefix];
1220 | if (prefix.substring(0, 2) === "+1") {
1221 | _results.push(format.format = '+. (...) ...-....');
1222 | } else {
1223 | _results.push(void 0);
1224 | }
1225 | }
1226 | return _results;
1227 | })(formats);
1228 |
1229 | }).call(this);
1230 |
--------------------------------------------------------------------------------
/mobilephonenumber.jquery.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "mobilephonenumber",
3 | "version": "1.0.5",
4 | "title": "jQuery.mobilePhoneNumber",
5 | "description": "A general purpose library for validating and formatting mobile phone numbers.",
6 | "keywords": [
7 | "phone"
8 | ],
9 | "author": {
10 | "name": "Stripe",
11 | "url": "https://www.stripe.com",
12 | "email": "support+github@stripe.com"
13 | },
14 | "licenses": [
15 | {
16 | "type": "MIT",
17 | "url": "https://github.com/stripe/jquery.mobilePhoneNumber/blob/master/LICENSE"
18 | }
19 | ],
20 | "homepage": "https://github.com/stripe/jquery.mobilePhoneNumber",
21 | "docs": "https://github.com/stripe/jquery.mobilePhoneNumber",
22 | "bugs": "https://github.com/stripe/jquery.mobilePhoneNumber/issues",
23 | "demo": "http://stripe.github.io/jquery.mobilePhoneNumber/example",
24 | "dependencies": {
25 | "jquery": ">=1.5",
26 | "caret": ">=1.3.1"
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery.mobilephonenumber",
3 | "version": "1.0.8",
4 | "lockfileVersion": 1,
5 | "requires": true,
6 | "dependencies": {
7 | "abab": {
8 | "version": "1.0.4",
9 | "resolved": "https://registry.npmjs.org/abab/-/abab-1.0.4.tgz",
10 | "integrity": "sha1-X6rZwsB/YN12dw9xzwJbYqY8/U4=",
11 | "dev": true
12 | },
13 | "acorn": {
14 | "version": "5.7.4",
15 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz",
16 | "integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==",
17 | "dev": true
18 | },
19 | "acorn-globals": {
20 | "version": "4.1.0",
21 | "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.1.0.tgz",
22 | "integrity": "sha512-KjZwU26uG3u6eZcfGbTULzFcsoz6pegNKtHPksZPOUsiKo5bUmiBPa38FuHZ/Eun+XYh/JCCkS9AS3Lu4McQOQ==",
23 | "dev": true,
24 | "requires": {
25 | "acorn": "^5.0.0"
26 | }
27 | },
28 | "ajv": {
29 | "version": "5.5.2",
30 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
31 | "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
32 | "dev": true,
33 | "requires": {
34 | "co": "^4.6.0",
35 | "fast-deep-equal": "^1.0.0",
36 | "fast-json-stable-stringify": "^2.0.0",
37 | "json-schema-traverse": "^0.3.0"
38 | }
39 | },
40 | "array-equal": {
41 | "version": "1.0.0",
42 | "resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz",
43 | "integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=",
44 | "dev": true
45 | },
46 | "asn1": {
47 | "version": "0.2.4",
48 | "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
49 | "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==",
50 | "dev": true,
51 | "requires": {
52 | "safer-buffer": "~2.1.0"
53 | }
54 | },
55 | "assert-plus": {
56 | "version": "1.0.0",
57 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
58 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=",
59 | "dev": true
60 | },
61 | "async-limiter": {
62 | "version": "1.0.0",
63 | "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
64 | "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==",
65 | "dev": true
66 | },
67 | "asynckit": {
68 | "version": "0.4.0",
69 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
70 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
71 | "dev": true
72 | },
73 | "aws-sign2": {
74 | "version": "0.7.0",
75 | "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
76 | "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=",
77 | "dev": true
78 | },
79 | "aws4": {
80 | "version": "1.8.0",
81 | "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz",
82 | "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==",
83 | "dev": true
84 | },
85 | "balanced-match": {
86 | "version": "1.0.0",
87 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
88 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
89 | "dev": true
90 | },
91 | "bcrypt-pbkdf": {
92 | "version": "1.0.2",
93 | "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
94 | "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=",
95 | "dev": true,
96 | "requires": {
97 | "tweetnacl": "^0.14.3"
98 | }
99 | },
100 | "brace-expansion": {
101 | "version": "1.1.11",
102 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
103 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
104 | "dev": true,
105 | "requires": {
106 | "balanced-match": "^1.0.0",
107 | "concat-map": "0.0.1"
108 | }
109 | },
110 | "browser-process-hrtime": {
111 | "version": "0.1.2",
112 | "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.2.tgz",
113 | "integrity": "sha1-Ql1opY00R/AqBKqJQYf86K+Le44=",
114 | "dev": true
115 | },
116 | "browser-stdout": {
117 | "version": "1.3.1",
118 | "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
119 | "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
120 | "dev": true
121 | },
122 | "cake": {
123 | "version": "0.1.1",
124 | "resolved": "https://registry.npmjs.org/cake/-/cake-0.1.1.tgz",
125 | "integrity": "sha1-SmXQ2vsBgYAjFipxc0DdiOB4Wzc=",
126 | "dev": true,
127 | "requires": {
128 | "coffee-script": "^1.12.7"
129 | },
130 | "dependencies": {
131 | "coffee-script": {
132 | "version": "1.12.7",
133 | "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.12.7.tgz",
134 | "integrity": "sha512-fLeEhqwymYat/MpTPUjSKHVYYl0ec2mOyALEMLmzr5i1isuG+6jfI2j2d5oBO3VIzgUXgBVIcOT9uH1TFxBckw==",
135 | "dev": true
136 | }
137 | }
138 | },
139 | "caseless": {
140 | "version": "0.12.0",
141 | "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
142 | "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=",
143 | "dev": true
144 | },
145 | "co": {
146 | "version": "4.6.0",
147 | "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
148 | "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
149 | "dev": true
150 | },
151 | "coffeescript": {
152 | "version": "1.7.0",
153 | "resolved": "https://registry.npmjs.org/coffeescript/-/coffeescript-1.7.0.tgz",
154 | "integrity": "sha1-n3vfsoXsZXom8ZMBN5/fcCJNtv0=",
155 | "dev": true,
156 | "requires": {
157 | "mkdirp": "~0.3.5"
158 | }
159 | },
160 | "combined-stream": {
161 | "version": "1.0.7",
162 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz",
163 | "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==",
164 | "dev": true,
165 | "requires": {
166 | "delayed-stream": "~1.0.0"
167 | }
168 | },
169 | "commander": {
170 | "version": "2.15.1",
171 | "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz",
172 | "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==",
173 | "dev": true
174 | },
175 | "concat-map": {
176 | "version": "0.0.1",
177 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
178 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
179 | "dev": true
180 | },
181 | "content-type-parser": {
182 | "version": "1.0.2",
183 | "resolved": "https://registry.npmjs.org/content-type-parser/-/content-type-parser-1.0.2.tgz",
184 | "integrity": "sha512-lM4l4CnMEwOLHAHr/P6MEZwZFPJFtAAKgL6pogbXmVZggIqXhdB6RbBtPOTsw2FcXwYhehRGERJmRrjOiIB8pQ==",
185 | "dev": true
186 | },
187 | "core-util-is": {
188 | "version": "1.0.2",
189 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
190 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
191 | "dev": true
192 | },
193 | "cssom": {
194 | "version": "0.3.2",
195 | "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.2.tgz",
196 | "integrity": "sha1-uANhcMefB6kP8vFuIihAJ6JDhIs=",
197 | "dev": true
198 | },
199 | "cssstyle": {
200 | "version": "0.2.37",
201 | "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-0.2.37.tgz",
202 | "integrity": "sha1-VBCXI0yyUTyDzu06zdwn/yeYfVQ=",
203 | "dev": true,
204 | "requires": {
205 | "cssom": "0.3.x"
206 | }
207 | },
208 | "dashdash": {
209 | "version": "1.14.1",
210 | "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
211 | "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=",
212 | "dev": true,
213 | "requires": {
214 | "assert-plus": "^1.0.0"
215 | }
216 | },
217 | "debug": {
218 | "version": "3.1.0",
219 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
220 | "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
221 | "dev": true,
222 | "requires": {
223 | "ms": "2.0.0"
224 | }
225 | },
226 | "deep-is": {
227 | "version": "0.1.3",
228 | "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
229 | "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=",
230 | "dev": true
231 | },
232 | "delayed-stream": {
233 | "version": "1.0.0",
234 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
235 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
236 | "dev": true
237 | },
238 | "diff": {
239 | "version": "3.5.0",
240 | "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
241 | "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
242 | "dev": true
243 | },
244 | "domexception": {
245 | "version": "1.0.1",
246 | "resolved": "https://registry.npmjs.org/domexception/-/domexception-1.0.1.tgz",
247 | "integrity": "sha512-raigMkn7CJNNo6Ihro1fzG7wr3fHuYVytzquZKX5n0yizGsTcYgzdIUwj1X9pK0VvjeihV+XiclP+DjwbsSKug==",
248 | "dev": true,
249 | "requires": {
250 | "webidl-conversions": "^4.0.2"
251 | }
252 | },
253 | "ecc-jsbn": {
254 | "version": "0.1.2",
255 | "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz",
256 | "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=",
257 | "dev": true,
258 | "requires": {
259 | "jsbn": "~0.1.0",
260 | "safer-buffer": "^2.1.0"
261 | }
262 | },
263 | "escape-string-regexp": {
264 | "version": "1.0.5",
265 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
266 | "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
267 | "dev": true
268 | },
269 | "escodegen": {
270 | "version": "1.9.0",
271 | "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.9.0.tgz",
272 | "integrity": "sha512-v0MYvNQ32bzwoG2OSFzWAkuahDQHK92JBN0pTAALJ4RIxEZe766QJPDR8Hqy7XNUy5K3fnVL76OqYAdc4TZEIw==",
273 | "dev": true,
274 | "requires": {
275 | "esprima": "^3.1.3",
276 | "estraverse": "^4.2.0",
277 | "esutils": "^2.0.2",
278 | "optionator": "^0.8.1",
279 | "source-map": "~0.5.6"
280 | }
281 | },
282 | "esprima": {
283 | "version": "3.1.3",
284 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz",
285 | "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=",
286 | "dev": true
287 | },
288 | "estraverse": {
289 | "version": "4.2.0",
290 | "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz",
291 | "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=",
292 | "dev": true
293 | },
294 | "esutils": {
295 | "version": "2.0.2",
296 | "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
297 | "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=",
298 | "dev": true
299 | },
300 | "extend": {
301 | "version": "3.0.2",
302 | "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz",
303 | "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
304 | "dev": true
305 | },
306 | "extsprintf": {
307 | "version": "1.3.0",
308 | "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz",
309 | "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=",
310 | "dev": true
311 | },
312 | "fast-deep-equal": {
313 | "version": "1.1.0",
314 | "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
315 | "integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
316 | "dev": true
317 | },
318 | "fast-json-stable-stringify": {
319 | "version": "2.0.0",
320 | "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz",
321 | "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=",
322 | "dev": true
323 | },
324 | "fast-levenshtein": {
325 | "version": "2.0.6",
326 | "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
327 | "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=",
328 | "dev": true
329 | },
330 | "forever-agent": {
331 | "version": "0.6.1",
332 | "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
333 | "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=",
334 | "dev": true
335 | },
336 | "form-data": {
337 | "version": "2.3.2",
338 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
339 | "integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
340 | "dev": true,
341 | "requires": {
342 | "asynckit": "^0.4.0",
343 | "combined-stream": "1.0.6",
344 | "mime-types": "^2.1.12"
345 | },
346 | "dependencies": {
347 | "combined-stream": {
348 | "version": "1.0.6",
349 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
350 | "integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
351 | "dev": true,
352 | "requires": {
353 | "delayed-stream": "~1.0.0"
354 | }
355 | }
356 | }
357 | },
358 | "fs.realpath": {
359 | "version": "1.0.0",
360 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
361 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
362 | "dev": true
363 | },
364 | "getpass": {
365 | "version": "0.1.7",
366 | "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz",
367 | "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=",
368 | "dev": true,
369 | "requires": {
370 | "assert-plus": "^1.0.0"
371 | }
372 | },
373 | "glob": {
374 | "version": "7.1.2",
375 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
376 | "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
377 | "dev": true,
378 | "requires": {
379 | "fs.realpath": "^1.0.0",
380 | "inflight": "^1.0.4",
381 | "inherits": "2",
382 | "minimatch": "^3.0.4",
383 | "once": "^1.3.0",
384 | "path-is-absolute": "^1.0.0"
385 | }
386 | },
387 | "growl": {
388 | "version": "1.10.5",
389 | "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz",
390 | "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==",
391 | "dev": true
392 | },
393 | "har-schema": {
394 | "version": "2.0.0",
395 | "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz",
396 | "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=",
397 | "dev": true
398 | },
399 | "har-validator": {
400 | "version": "5.1.0",
401 | "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.0.tgz",
402 | "integrity": "sha512-+qnmNjI4OfH2ipQ9VQOw23bBd/ibtfbVdK2fYbY4acTDqKTW/YDp9McimZdDbG8iV9fZizUqQMD5xvriB146TA==",
403 | "dev": true,
404 | "requires": {
405 | "ajv": "^5.3.0",
406 | "har-schema": "^2.0.0"
407 | }
408 | },
409 | "has-flag": {
410 | "version": "3.0.0",
411 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
412 | "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
413 | "dev": true
414 | },
415 | "he": {
416 | "version": "1.1.1",
417 | "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz",
418 | "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=",
419 | "dev": true
420 | },
421 | "html-encoding-sniffer": {
422 | "version": "1.0.2",
423 | "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-1.0.2.tgz",
424 | "integrity": "sha512-71lZziiDnsuabfdYiUeWdCVyKuqwWi23L8YeIgV9jSSZHCtb6wB1BKWooH7L3tn4/FuZJMVWyNaIDr4RGmaSYw==",
425 | "dev": true,
426 | "requires": {
427 | "whatwg-encoding": "^1.0.1"
428 | }
429 | },
430 | "http-signature": {
431 | "version": "1.2.0",
432 | "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz",
433 | "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=",
434 | "dev": true,
435 | "requires": {
436 | "assert-plus": "^1.0.0",
437 | "jsprim": "^1.2.2",
438 | "sshpk": "^1.7.0"
439 | }
440 | },
441 | "iconv-lite": {
442 | "version": "0.4.19",
443 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz",
444 | "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==",
445 | "dev": true
446 | },
447 | "inflight": {
448 | "version": "1.0.6",
449 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
450 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
451 | "dev": true,
452 | "requires": {
453 | "once": "^1.3.0",
454 | "wrappy": "1"
455 | }
456 | },
457 | "inherits": {
458 | "version": "2.0.3",
459 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
460 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
461 | "dev": true
462 | },
463 | "is-typedarray": {
464 | "version": "1.0.0",
465 | "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz",
466 | "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=",
467 | "dev": true
468 | },
469 | "isstream": {
470 | "version": "0.1.2",
471 | "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz",
472 | "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=",
473 | "dev": true
474 | },
475 | "jquery": {
476 | "version": "3.4.1",
477 | "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz",
478 | "integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw=="
479 | },
480 | "jsbn": {
481 | "version": "0.1.1",
482 | "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
483 | "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
484 | "dev": true
485 | },
486 | "jsdom": {
487 | "version": "11.6.0",
488 | "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-11.6.0.tgz",
489 | "integrity": "sha512-4lMxDCiQYK7qfVi9fKhDf2PpvXXeH/KAmcH6o0Ga7fApi8+lTBxRqGHWZ9B11SsK/pxQKOtsw413utw0M+hUrg==",
490 | "dev": true,
491 | "requires": {
492 | "abab": "^1.0.4",
493 | "acorn": "^5.3.0",
494 | "acorn-globals": "^4.1.0",
495 | "array-equal": "^1.0.0",
496 | "browser-process-hrtime": "^0.1.2",
497 | "content-type-parser": "^1.0.2",
498 | "cssom": ">= 0.3.2 < 0.4.0",
499 | "cssstyle": ">= 0.2.37 < 0.3.0",
500 | "domexception": "^1.0.0",
501 | "escodegen": "^1.9.0",
502 | "html-encoding-sniffer": "^1.0.2",
503 | "left-pad": "^1.2.0",
504 | "nwmatcher": "^1.4.3",
505 | "parse5": "^4.0.0",
506 | "pn": "^1.1.0",
507 | "request": "^2.83.0",
508 | "request-promise-native": "^1.0.5",
509 | "sax": "^1.2.4",
510 | "symbol-tree": "^3.2.2",
511 | "tough-cookie": "^2.3.3",
512 | "w3c-hr-time": "^1.0.1",
513 | "webidl-conversions": "^4.0.2",
514 | "whatwg-encoding": "^1.0.3",
515 | "whatwg-url": "^6.4.0",
516 | "ws": "^4.0.0",
517 | "xml-name-validator": "^3.0.0"
518 | }
519 | },
520 | "json-schema": {
521 | "version": "0.2.3",
522 | "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz",
523 | "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=",
524 | "dev": true
525 | },
526 | "json-schema-traverse": {
527 | "version": "0.3.1",
528 | "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
529 | "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=",
530 | "dev": true
531 | },
532 | "json-stringify-safe": {
533 | "version": "5.0.1",
534 | "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
535 | "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=",
536 | "dev": true
537 | },
538 | "jsprim": {
539 | "version": "1.4.1",
540 | "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz",
541 | "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=",
542 | "dev": true,
543 | "requires": {
544 | "assert-plus": "1.0.0",
545 | "extsprintf": "1.3.0",
546 | "json-schema": "0.2.3",
547 | "verror": "1.10.0"
548 | }
549 | },
550 | "left-pad": {
551 | "version": "1.2.0",
552 | "resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.2.0.tgz",
553 | "integrity": "sha1-0wpzxrggHY99jnlWupYWCHpo4O4=",
554 | "dev": true
555 | },
556 | "levn": {
557 | "version": "0.3.0",
558 | "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz",
559 | "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=",
560 | "dev": true,
561 | "requires": {
562 | "prelude-ls": "~1.1.2",
563 | "type-check": "~0.3.2"
564 | }
565 | },
566 | "lodash": {
567 | "version": "4.17.14",
568 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.14.tgz",
569 | "integrity": "sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==",
570 | "dev": true
571 | },
572 | "lodash.sortby": {
573 | "version": "4.7.0",
574 | "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz",
575 | "integrity": "sha1-7dFMgk4sycHgsKG0K7UhBRakJDg=",
576 | "dev": true
577 | },
578 | "mime-db": {
579 | "version": "1.36.0",
580 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.36.0.tgz",
581 | "integrity": "sha512-L+xvyD9MkoYMXb1jAmzI/lWYAxAMCPvIBSWur0PZ5nOf5euahRLVqH//FKW9mWp2lkqUgYiXPgkzfMUFi4zVDw==",
582 | "dev": true
583 | },
584 | "mime-types": {
585 | "version": "2.1.20",
586 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz",
587 | "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==",
588 | "dev": true,
589 | "requires": {
590 | "mime-db": "~1.36.0"
591 | }
592 | },
593 | "minimatch": {
594 | "version": "3.0.4",
595 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
596 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
597 | "dev": true,
598 | "requires": {
599 | "brace-expansion": "^1.1.7"
600 | }
601 | },
602 | "minimist": {
603 | "version": "0.0.8",
604 | "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
605 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
606 | "dev": true
607 | },
608 | "mkdirp": {
609 | "version": "0.3.5",
610 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz",
611 | "integrity": "sha1-3j5fiWHIjHh+4TaN+EmsRBPsqNc=",
612 | "dev": true
613 | },
614 | "mocha": {
615 | "version": "5.2.0",
616 | "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz",
617 | "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==",
618 | "dev": true,
619 | "requires": {
620 | "browser-stdout": "1.3.1",
621 | "commander": "2.15.1",
622 | "debug": "3.1.0",
623 | "diff": "3.5.0",
624 | "escape-string-regexp": "1.0.5",
625 | "glob": "7.1.2",
626 | "growl": "1.10.5",
627 | "he": "1.1.1",
628 | "minimatch": "3.0.4",
629 | "mkdirp": "0.5.1",
630 | "supports-color": "5.4.0"
631 | },
632 | "dependencies": {
633 | "mkdirp": {
634 | "version": "0.5.1",
635 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
636 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
637 | "dev": true,
638 | "requires": {
639 | "minimist": "0.0.8"
640 | }
641 | }
642 | }
643 | },
644 | "ms": {
645 | "version": "2.0.0",
646 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
647 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
648 | "dev": true
649 | },
650 | "nwmatcher": {
651 | "version": "1.4.4",
652 | "resolved": "https://registry.npmjs.org/nwmatcher/-/nwmatcher-1.4.4.tgz",
653 | "integrity": "sha512-3iuY4N5dhgMpCUrOVnuAdGrgxVqV2cJpM+XNccjR2DKOB1RUP0aA+wGXEiNziG/UKboFyGBIoKOaNlJxx8bciQ=="
654 | },
655 | "oauth-sign": {
656 | "version": "0.9.0",
657 | "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz",
658 | "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==",
659 | "dev": true
660 | },
661 | "once": {
662 | "version": "1.4.0",
663 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
664 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
665 | "dev": true,
666 | "requires": {
667 | "wrappy": "1"
668 | }
669 | },
670 | "optionator": {
671 | "version": "0.8.2",
672 | "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz",
673 | "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=",
674 | "dev": true,
675 | "requires": {
676 | "deep-is": "~0.1.3",
677 | "fast-levenshtein": "~2.0.4",
678 | "levn": "~0.3.0",
679 | "prelude-ls": "~1.1.2",
680 | "type-check": "~0.3.2",
681 | "wordwrap": "~1.0.0"
682 | }
683 | },
684 | "parse5": {
685 | "version": "4.0.0",
686 | "resolved": "https://registry.npmjs.org/parse5/-/parse5-4.0.0.tgz",
687 | "integrity": "sha512-VrZ7eOd3T1Fk4XWNXMgiGBK/z0MG48BWG2uQNU4I72fkQuKUTZpl+u9k+CxEG0twMVzSmXEEz12z5Fnw1jIQFA==",
688 | "dev": true
689 | },
690 | "path-is-absolute": {
691 | "version": "1.0.1",
692 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
693 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
694 | "dev": true
695 | },
696 | "performance-now": {
697 | "version": "2.1.0",
698 | "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
699 | "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=",
700 | "dev": true
701 | },
702 | "pn": {
703 | "version": "1.1.0",
704 | "resolved": "https://registry.npmjs.org/pn/-/pn-1.1.0.tgz",
705 | "integrity": "sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==",
706 | "dev": true
707 | },
708 | "prelude-ls": {
709 | "version": "1.1.2",
710 | "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
711 | "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=",
712 | "dev": true
713 | },
714 | "psl": {
715 | "version": "1.1.29",
716 | "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.29.tgz",
717 | "integrity": "sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ==",
718 | "dev": true
719 | },
720 | "punycode": {
721 | "version": "1.4.1",
722 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz",
723 | "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=",
724 | "dev": true
725 | },
726 | "qs": {
727 | "version": "6.5.2",
728 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
729 | "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==",
730 | "dev": true
731 | },
732 | "request": {
733 | "version": "2.88.0",
734 | "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz",
735 | "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==",
736 | "dev": true,
737 | "requires": {
738 | "aws-sign2": "~0.7.0",
739 | "aws4": "^1.8.0",
740 | "caseless": "~0.12.0",
741 | "combined-stream": "~1.0.6",
742 | "extend": "~3.0.2",
743 | "forever-agent": "~0.6.1",
744 | "form-data": "~2.3.2",
745 | "har-validator": "~5.1.0",
746 | "http-signature": "~1.2.0",
747 | "is-typedarray": "~1.0.0",
748 | "isstream": "~0.1.2",
749 | "json-stringify-safe": "~5.0.1",
750 | "mime-types": "~2.1.19",
751 | "oauth-sign": "~0.9.0",
752 | "performance-now": "^2.1.0",
753 | "qs": "~6.5.2",
754 | "safe-buffer": "^5.1.2",
755 | "tough-cookie": "~2.4.3",
756 | "tunnel-agent": "^0.6.0",
757 | "uuid": "^3.3.2"
758 | },
759 | "dependencies": {
760 | "safe-buffer": {
761 | "version": "5.1.2",
762 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
763 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
764 | "dev": true
765 | },
766 | "tough-cookie": {
767 | "version": "2.4.3",
768 | "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz",
769 | "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==",
770 | "dev": true,
771 | "requires": {
772 | "psl": "^1.1.24",
773 | "punycode": "^1.4.1"
774 | }
775 | }
776 | }
777 | },
778 | "request-promise-core": {
779 | "version": "1.1.1",
780 | "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz",
781 | "integrity": "sha1-Pu4AssWqgyOc+wTFcA2jb4HNCLY=",
782 | "dev": true,
783 | "requires": {
784 | "lodash": "^4.13.1"
785 | }
786 | },
787 | "request-promise-native": {
788 | "version": "1.0.5",
789 | "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.5.tgz",
790 | "integrity": "sha1-UoF3D2jgyXGeUWP9P6tIIhX0/aU=",
791 | "dev": true,
792 | "requires": {
793 | "request-promise-core": "1.1.1",
794 | "stealthy-require": "^1.1.0",
795 | "tough-cookie": ">=2.3.3"
796 | }
797 | },
798 | "safe-buffer": {
799 | "version": "5.1.1",
800 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz",
801 | "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==",
802 | "dev": true
803 | },
804 | "safer-buffer": {
805 | "version": "2.1.2",
806 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
807 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
808 | "dev": true
809 | },
810 | "sax": {
811 | "version": "1.2.4",
812 | "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
813 | "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==",
814 | "dev": true
815 | },
816 | "source-map": {
817 | "version": "0.5.7",
818 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
819 | "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=",
820 | "dev": true,
821 | "optional": true
822 | },
823 | "sshpk": {
824 | "version": "1.15.1",
825 | "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.1.tgz",
826 | "integrity": "sha512-mSdgNUaidk+dRU5MhYtN9zebdzF2iG0cNPWy8HG+W8y+fT1JnSkh0fzzpjOa0L7P8i1Rscz38t0h4gPcKz43xA==",
827 | "dev": true,
828 | "requires": {
829 | "asn1": "~0.2.3",
830 | "assert-plus": "^1.0.0",
831 | "bcrypt-pbkdf": "^1.0.0",
832 | "dashdash": "^1.12.0",
833 | "ecc-jsbn": "~0.1.1",
834 | "getpass": "^0.1.1",
835 | "jsbn": "~0.1.0",
836 | "safer-buffer": "^2.0.2",
837 | "tweetnacl": "~0.14.0"
838 | }
839 | },
840 | "stealthy-require": {
841 | "version": "1.1.1",
842 | "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz",
843 | "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=",
844 | "dev": true
845 | },
846 | "supports-color": {
847 | "version": "5.4.0",
848 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
849 | "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
850 | "dev": true,
851 | "requires": {
852 | "has-flag": "^3.0.0"
853 | }
854 | },
855 | "symbol-tree": {
856 | "version": "3.2.2",
857 | "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz",
858 | "integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=",
859 | "dev": true
860 | },
861 | "tough-cookie": {
862 | "version": "2.3.3",
863 | "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.3.tgz",
864 | "integrity": "sha1-C2GKVWW23qkL80JdBNVe3EdadWE=",
865 | "dev": true,
866 | "requires": {
867 | "punycode": "^1.4.1"
868 | }
869 | },
870 | "tr46": {
871 | "version": "1.0.1",
872 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz",
873 | "integrity": "sha1-qLE/1r/SSJUZZ0zN5VujaTtwbQk=",
874 | "dev": true,
875 | "requires": {
876 | "punycode": "^2.1.0"
877 | },
878 | "dependencies": {
879 | "punycode": {
880 | "version": "2.1.0",
881 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.0.tgz",
882 | "integrity": "sha1-X4Y+3Im5bbCQdLrXlHvwkFbKTn0=",
883 | "dev": true
884 | }
885 | }
886 | },
887 | "tunnel-agent": {
888 | "version": "0.6.0",
889 | "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz",
890 | "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=",
891 | "dev": true,
892 | "requires": {
893 | "safe-buffer": "^5.0.1"
894 | }
895 | },
896 | "tweetnacl": {
897 | "version": "0.14.5",
898 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz",
899 | "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=",
900 | "dev": true
901 | },
902 | "type-check": {
903 | "version": "0.3.2",
904 | "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
905 | "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=",
906 | "dev": true,
907 | "requires": {
908 | "prelude-ls": "~1.1.2"
909 | }
910 | },
911 | "ultron": {
912 | "version": "1.1.1",
913 | "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz",
914 | "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==",
915 | "dev": true
916 | },
917 | "uuid": {
918 | "version": "3.3.2",
919 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz",
920 | "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==",
921 | "dev": true
922 | },
923 | "verror": {
924 | "version": "1.10.0",
925 | "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz",
926 | "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=",
927 | "dev": true,
928 | "requires": {
929 | "assert-plus": "^1.0.0",
930 | "core-util-is": "1.0.2",
931 | "extsprintf": "^1.2.0"
932 | }
933 | },
934 | "w3c-hr-time": {
935 | "version": "1.0.1",
936 | "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz",
937 | "integrity": "sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=",
938 | "dev": true,
939 | "requires": {
940 | "browser-process-hrtime": "^0.1.2"
941 | }
942 | },
943 | "webidl-conversions": {
944 | "version": "4.0.2",
945 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz",
946 | "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==",
947 | "dev": true
948 | },
949 | "whatwg-encoding": {
950 | "version": "1.0.3",
951 | "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.3.tgz",
952 | "integrity": "sha512-jLBwwKUhi8WtBfsMQlL4bUUcT8sMkAtQinscJAe/M4KHCkHuUJAF6vuB0tueNIw4c8ziO6AkRmgY+jL3a0iiPw==",
953 | "dev": true,
954 | "requires": {
955 | "iconv-lite": "0.4.19"
956 | }
957 | },
958 | "whatwg-url": {
959 | "version": "6.4.0",
960 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-6.4.0.tgz",
961 | "integrity": "sha512-Z0CVh/YE217Foyb488eo+iBv+r7eAQ0wSTyApi9n06jhcA3z6Nidg/EGvl0UFkg7kMdKxfBzzr+o9JF+cevgMg==",
962 | "dev": true,
963 | "requires": {
964 | "lodash.sortby": "^4.7.0",
965 | "tr46": "^1.0.0",
966 | "webidl-conversions": "^4.0.1"
967 | }
968 | },
969 | "wordwrap": {
970 | "version": "1.0.0",
971 | "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
972 | "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=",
973 | "dev": true
974 | },
975 | "wrappy": {
976 | "version": "1.0.2",
977 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
978 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
979 | "dev": true
980 | },
981 | "ws": {
982 | "version": "4.0.0",
983 | "resolved": "https://registry.npmjs.org/ws/-/ws-4.0.0.tgz",
984 | "integrity": "sha512-QYslsH44bH8O7/W2815u5DpnCpXWpEK44FmaHffNwgJI4JMaSZONgPBTOfrxJ29mXKbXak+LsJ2uAkDTYq2ptQ==",
985 | "dev": true,
986 | "requires": {
987 | "async-limiter": "~1.0.0",
988 | "safe-buffer": "~5.1.0",
989 | "ultron": "~1.1.0"
990 | }
991 | },
992 | "xml-name-validator": {
993 | "version": "3.0.0",
994 | "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
995 | "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==",
996 | "dev": true
997 | }
998 | }
999 | }
1000 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "jquery.mobilephonenumber",
3 | "version": "1.0.8",
4 | "description": "A general purpose library for validating and formatting mobile phone numbers.",
5 | "license": "MIT",
6 | "keywords": [
7 | "phone"
8 | ],
9 | "author": "Stripe (https://www.stripe.com)",
10 | "repository": {
11 | "type": "git",
12 | "url": "https://github.com/stripe/jquery.mobilePhoneNumber.git"
13 | },
14 | "main": "lib/jquery.mobilePhoneNumber.js",
15 | "scripts": {
16 | "test": "cake test"
17 | },
18 | "//": "nwmatcher is a dep of jquery; pinning version for security issue; ok to remove when upgrading jquery past 3.4.1",
19 | "dependencies": {
20 | "jquery": "^3.4.1",
21 | "nwmatcher": "^1.4.4"
22 | },
23 | "devDependencies": {
24 | "cake": "~0.1",
25 | "coffeescript": "~1.7",
26 | "jsdom": "^11.6.0",
27 | "mocha": "^5.2.0"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/jquery.mobilePhoneNumber.coffee:
--------------------------------------------------------------------------------
1 | $ = jQuery
2 |
3 | supportSelectionEnd = 'selectionEnd' of document.createElement('input')
4 |
5 | # Timeout to work around cursor bugs in Android Firefox
6 | withTimeout = (fn) -> setTimeout(fn, 50)
7 |
8 | formatForPhone_ = (phone, defaultPrefix = null) ->
9 | if phone.indexOf('+') != 0 and defaultPrefix
10 | phone = defaultPrefix + phone.replace(/[^0-9]/g, '')
11 | else
12 | phone = '+' + phone.replace(/[^0-9]/g, '')
13 | bestFormat = null
14 | precision = 0
15 | for prefix, format of formats
16 | if phone.length >= prefix.length && phone.substring(0, prefix.length) == prefix && prefix.length > precision
17 | bestFormat = {}
18 | for k, v of format
19 | bestFormat[k] = v
20 | bestFormat.prefix = prefix
21 | precision = prefix.length
22 | bestFormat
23 |
24 | prefixesAreSubsets_ = (prefixA, prefixB) ->
25 | return true if prefixA == prefixB
26 | if prefixA.length < prefixB.length
27 | return prefixB.substring(0, prefixA.length) == prefixA
28 | return prefixA.substring(0, prefixB.length) == prefixB
29 |
30 | formattedPhoneNumber_ = (phone, lastChar, defaultPrefix = null) ->
31 | if phone.length != 0 and (phone.substring(0, 1) == "+" or defaultPrefix)
32 | format = formatForPhone_(phone, defaultPrefix)
33 | if format && format.format
34 | phoneFormat = format.format
35 | phonePrefix = format.prefix
36 |
37 | if defaultPrefix
38 | if (defaultPrefix == phonePrefix or prefixesAreSubsets_(phonePrefix, defaultPrefix)) and (phone.indexOf('+') != 0 or phone.length == 0)
39 | phoneFormat = phoneFormat.substring(Math.min(phonePrefix.length, defaultPrefix.length) + 1)
40 | if format.nationalPrefix?
41 | prefixPhoneFormat = ""
42 | for i in [0...format.nationalPrefix.length]
43 | prefixPhoneFormat += "."
44 | phoneFormat = prefixPhoneFormat + phoneFormat
45 |
46 | if phone.substring(0, 1) == "+"
47 | phoneDigits = phone.substring(1)
48 | else
49 | phoneDigits = phone
50 | formatDigitCount = phoneFormat.match(/\./g).length
51 |
52 | formattedPhone = ""
53 | for formatChar in phoneFormat
54 | if formatChar == "."
55 | if phoneDigits.length == 0
56 | break
57 | formattedPhone += phoneDigits.substring(0, 1)
58 | phoneDigits = phoneDigits.substring(1)
59 | else if lastChar || phoneDigits.length > 0
60 | formattedPhone += formatChar
61 | phone = formattedPhone + phoneDigits
62 | phone
63 |
64 | isEventAllowed_ = (e) ->
65 | # Key event is for a browser shortcut
66 | return true if e.metaKey
67 | # If keycode is a space
68 | return false if e.which is 32
69 | # If keycode is a special char (WebKit)
70 | return true if e.which is 0
71 | # If char is a special char (Firefox)
72 | return true if e.which < 33
73 | isEventAllowedChar_(e)
74 |
75 | isEventAllowedChar_ = (e) ->
76 | char = String.fromCharCode(e.which)
77 | # Char is a number or a space or a +
78 | !!/[\d\s+]/.test(char)
79 |
80 | restrictEventAndFormat_ = (e) ->
81 | if !isEventAllowed_(e)
82 | return e.preventDefault()
83 |
84 | return if !isEventAllowedChar_(e)
85 | value = @val()
86 | caretEnd = if supportSelectionEnd then @get(0).selectionEnd else @caret()
87 | value = value.substring(0, @caret()) +
88 | String.fromCharCode(e.which) +
89 | value.substring(caretEnd, value.length)
90 | format_.call(@, value, e)
91 | withTimeout => @caret(@val().length)
92 |
93 | formatUp_ = (e) ->
94 | checkForCountryChange_.call(@)
95 | value = @val()
96 | return if e.keyCode == 8 && @caret() == value.length
97 | format_.call(@, value, e)
98 |
99 | formatBack_ = (e) ->
100 | return if !e
101 | return if e.meta
102 | value = @val()
103 | return if value.length == 0
104 | return if !(@caret() == value.length)
105 | return if e.keyCode != 8
106 |
107 | value = value.substring(0, value.length - 1)
108 | e.preventDefault()
109 | phone = formattedPhone_.call(@, value, false)
110 | if @val() != phone
111 | @val(phone)
112 |
113 | format_ = (value, e) ->
114 | phone = formattedPhone_.call(@, value, true)
115 | if phone != @val()
116 | selection = @caret()
117 | selectionAtEnd = selection == @val().length
118 | e.preventDefault()
119 | @val(phone)
120 | if !selectionAtEnd
121 | withTimeout => @caret(selection)
122 |
123 | formattedPhone_ = (phone, lastChar) ->
124 | if phone.indexOf('+') != 0 && @data('defaultPrefix')
125 | phone = phone.replace(/[^0-9]/g, '')
126 | else
127 | phone = '+' + phone.replace(/[^0-9]/g, '')
128 | formattedPhoneNumber_(phone, lastChar, @data('defaultPrefix'))
129 |
130 | checkForCountryChange_ = ->
131 | phone = @val()
132 | format = formatForPhone_(phone, @data('defaultPrefix'))
133 | country = null
134 | country = format.country if format
135 | if @data('mobilePhoneCountry') != country
136 | @data('mobilePhoneCountry', country)
137 | @trigger('country.mobilePhoneNumber', country)
138 |
139 | mobilePhoneNumber = {}
140 | mobilePhoneNumber.init = (options = {}) ->
141 | unless @data('mobilePhoneNumberInited')
142 | @data('mobilePhoneNumberInited', true)
143 | @bind 'keypress', =>
144 | restrictEventAndFormat_.apply($(@), arguments)
145 | @bind 'keyup', =>
146 | formatUp_.apply($(@), arguments)
147 | @bind 'keydown', =>
148 | formatBack_.apply($(@), arguments)
149 |
150 | @data('defaultPrefix', options.allowPhoneWithoutPrefix ? options.defaultPrefix)
151 | if @val() != ''
152 | @val(formattedPhone_.call(this, @val(), false))
153 | @
154 |
155 | mobilePhoneNumber.val = ->
156 | val = @val().replace(/[^0-9]/g, '')
157 | format = formatForPhone_(val, @data('defaultPrefix'))
158 | if @val().indexOf('+') == 0 or !@data('defaultPrefix')?
159 | '+' + val
160 | else
161 | @data('defaultPrefix') + val
162 |
163 | mobilePhoneNumber.validate = ->
164 | val = @mobilePhoneNumber('val')
165 | format = formatForPhone_(val, @data('defaultPrefix'))
166 | return true unless format
167 | return val.length > format.prefix.length
168 |
169 | mobilePhoneNumber.country = ->
170 | format = formatForPhone_(@mobilePhoneNumber('val'))
171 | format.country if format
172 |
173 | mobilePhoneNumber.prefix = ->
174 | countryCode = @mobilePhoneNumber('country')
175 | return "" if !countryCode?
176 | $.mobilePhoneNumberPrefixFromCountryCode(countryCode)
177 |
178 | $.fn.mobilePhoneNumber = (method, args...) ->
179 | if !method? or !(typeof(method) == 'string')
180 | args = [ method ] if method?
181 | method = 'init'
182 | mobilePhoneNumber[method].apply(this, args)
183 |
184 | $.formatMobilePhoneNumber = (phone) ->
185 | phone = '+' + phone.replace(/[^0-9\*]/g, '')
186 | formattedPhoneNumber_(phone, true)
187 |
188 | $.mobilePhoneNumberPrefixFromCountryCode = (countryCode) ->
189 | for prefix, format of formats
190 | if format.country.toLowerCase() == countryCode.toLowerCase()
191 | if prefix.length == 5 and prefix[1] == '1'
192 | return '+1'
193 | return prefix
194 | return null
195 |
196 | formats =
197 | '+247' :
198 | country : 'AC',
199 | '+376' :
200 | country : 'AD',
201 | format : '+... ... ...',
202 | '+971' :
203 | country : 'AE',
204 | format : '+... .. ... ....',
205 | '+93' :
206 | country : 'AF',
207 | format : '+.. .. ... ....',
208 | '+1268' :
209 | country : 'AG',
210 | '+1264' :
211 | country : 'AI',
212 | '+355' :
213 | country : 'AL',
214 | format : '+... .. ... ....',
215 | '+374' :
216 | country : 'AM',
217 | format : '+... .. ......',
218 | '+244' :
219 | country : 'AO',
220 | format : '+... ... ... ...',
221 | '+54' :
222 | country : 'AR',
223 | format : '+.. .. ..-....-....',
224 | '+1684' :
225 | country : 'AS',
226 | '+43' :
227 | country : 'AT',
228 | format : '+.. ... ......',
229 | '+61' :
230 | country : 'AU',
231 | format : '+.. ... ... ...',
232 | '+297' :
233 | country : 'AW',
234 | format : '+... ... ....',
235 | '+994' :
236 | country : 'AZ',
237 | format : '+... .. ... .. ..',
238 | '+387' :
239 | country : 'BA',
240 | format : '+... .. ...-...',
241 | '+1246' :
242 | country : 'BB',
243 | '+880' :
244 | country : 'BD',
245 | format : '+... ....-......',
246 | '+32' :
247 | country : 'BE',
248 | format : '+.. ... .. .. ..',
249 | '+226' :
250 | country : 'BF',
251 | format : '+... .. .. .. ..',
252 | '+359' :
253 | country : 'BG',
254 | format : '+... ... ... ..',
255 | '+973' :
256 | country : 'BH',
257 | format : '+... .... ....',
258 | '+257' :
259 | country : 'BI',
260 | format : '+... .. .. .. ..',
261 | '+229' :
262 | country : 'BJ',
263 | format : '+... .. .. .. ..',
264 | '+1441' :
265 | country : 'BM',
266 | '+673' :
267 | country : 'BN',
268 | format : '+... ... ....',
269 | '+591' :
270 | country : 'BO',
271 | format : '+... ........',
272 | '+55' :
273 | country : 'BR',
274 | format : '+.. .. .....-....',
275 | '+1242' :
276 | country : 'BS',
277 | '+975' :
278 | country : 'BT',
279 | format : '+... .. .. .. ..',
280 | '+267' :
281 | country : 'BW',
282 | format : '+... .. ... ...',
283 | '+375' :
284 | country : 'BY',
285 | format : '+... .. ...-..-..',
286 | '+501' :
287 | country : 'BZ',
288 | format : '+... ...-....',
289 | '+243' :
290 | country : 'CD',
291 | format : '+... ... ... ...',
292 | '+236' :
293 | country : 'CF',
294 | format : '+... .. .. .. ..',
295 | '+242' :
296 | country : 'CG',
297 | format : '+... .. ... ....',
298 | '+41' :
299 | country : 'CH',
300 | format : '+.. .. ... .. ..',
301 | '+225' :
302 | country : 'CI',
303 | format : '+... .. .. .. ..',
304 | '+682' :
305 | country : 'CK',
306 | format : '+... .. ...',
307 | '+56' :
308 | country : 'CL',
309 | format : '+.. . .... ....',
310 | '+237' :
311 | country : 'CM',
312 | format : '+... .. .. .. ..',
313 | '+86' :
314 | country : 'CN',
315 | format : '+.. ... .... ....',
316 | '+57' :
317 | country : 'CO',
318 | format : '+.. ... .......',
319 | '+506' :
320 | country : 'CR',
321 | format : '+... .... ....',
322 | '+53' :
323 | country : 'CU',
324 | format : '+.. . .......',
325 | '+238' :
326 | country : 'CV',
327 | format : '+... ... .. ..',
328 | '+599' :
329 | country : 'CW',
330 | format : '+... . ... ....',
331 | '+537' :
332 | country : 'CY',
333 | '+357' :
334 | country : 'CY',
335 | format : '+... .. ......',
336 | '+420' :
337 | country : 'CZ',
338 | format : '+... ... ... ...',
339 | '+49' :
340 | country : 'DE',
341 | format : '+.. .... .......',
342 | '+253' :
343 | country : 'DJ',
344 | format : '+... .. .. .. ..',
345 | '+45' :
346 | country : 'DK',
347 | format : '+.. .. .. .. ..',
348 | '+1767' :
349 | country : 'DM',
350 | '+1849' :
351 | country : 'DO',
352 | '+213' :
353 | country : 'DZ',
354 | format : '+... ... .. .. ..',
355 | '+593' :
356 | country : 'EC',
357 | format : '+... .. ... ....',
358 | '+372' :
359 | country : 'EE',
360 | format : '+... .... ....',
361 | '+20' :
362 | country : 'EG',
363 | format : '+.. ... ... ....',
364 | '+291' :
365 | country : 'ER',
366 | format : '+... . ... ...',
367 | '+34' :
368 | country : 'ES',
369 | format : '+.. ... .. .. ..',
370 | '+251' :
371 | country : 'ET',
372 | format : '+... .. ... ....',
373 | '+358' :
374 | country : 'FI',
375 | format : '+... .. ... .. ..',
376 | '+679' :
377 | country : 'FJ',
378 | format : '+... ... ....',
379 | '+500' :
380 | country : 'FK',
381 | '+691' :
382 | country : 'FM',
383 | format : '+... ... ....',
384 | '+298' :
385 | country : 'FO',
386 | format : '+... ......',
387 | '+33' :
388 | country : 'FR',
389 | format : '+.. . .. .. .. ..',
390 | '+241' :
391 | country : 'GA',
392 | format : '+... .. .. .. ..',
393 | '+44' :
394 | country : 'GB',
395 | format : '+.. .... ......',
396 | '+1473' :
397 | country : 'GD',
398 | '+995' :
399 | country : 'GE',
400 | format : '+... ... .. .. ..',
401 | '+594' :
402 | country : 'GF',
403 | format : '+... ... .. .. ..',
404 | '+233' :
405 | country : 'GH',
406 | format : '+... .. ... ....',
407 | '+350' :
408 | country : 'GI',
409 | format : '+... ... .....',
410 | '+299' :
411 | country : 'GL',
412 | format : '+... .. .. ..',
413 | '+220' :
414 | country : 'GM',
415 | format : '+... ... ....',
416 | '+224' :
417 | country : 'GN',
418 | format : '+... ... .. .. ..',
419 | '+240' :
420 | country : 'GQ',
421 | format : '+... ... ... ...',
422 | '+30' :
423 | country : 'GR',
424 | format : '+.. ... ... ....',
425 | '+502' :
426 | country : 'GT',
427 | format : '+... .... ....',
428 | '+1671' :
429 | country : 'GU',
430 | '+245' :
431 | country : 'GW',
432 | format : '+... ... ....',
433 | '+592' :
434 | country : 'GY',
435 | format : '+... ... ....',
436 | '+852' :
437 | country : 'HK',
438 | format : '+... .... ....',
439 | '+504' :
440 | country : 'HN',
441 | format : '+... ....-....',
442 | '+385' :
443 | country : 'HR',
444 | format : '+... .. ... ....',
445 | '+509' :
446 | country : 'HT',
447 | format : '+... .. .. ....',
448 | '+36' :
449 | country : 'HU',
450 | format : '+.. .. ... ....',
451 | '+62' :
452 | country : 'ID',
453 | format : '+.. ...-...-...',
454 | '+353' :
455 | country : 'IE',
456 | format : '+... .. ... ....',
457 | '+972' :
458 | country : 'IL',
459 | format : '+... ..-...-....',
460 | '+91' :
461 | country : 'IN',
462 | format : '+.. .. .. ......',
463 | '+246' :
464 | country : 'IO',
465 | format : '+... ... ....',
466 | '+964' :
467 | country : 'IQ',
468 | format : '+... ... ... ....',
469 | '+98' :
470 | country : 'IR',
471 | format : '+.. ... ... ....',
472 | '+354' :
473 | country : 'IS',
474 | format : '+... ... ....',
475 | '+39' :
476 | country : 'IT',
477 | format : '+.. .. .... ....',
478 | '+1876' :
479 | country : 'JM',
480 | '+962' :
481 | country : 'JO',
482 | format : '+... . .... ....',
483 | '+81' :
484 | country : 'JP',
485 | format : '+.. ..-....-....',
486 | nationalPrefix: '0',
487 | '+254' :
488 | country : 'KE',
489 | format : '+... .. .......',
490 | '+996' :
491 | country : 'KG',
492 | format : '+... ... ... ...',
493 | '+855' :
494 | country : 'KH',
495 | format : '+... .. ... ...',
496 | '+686' :
497 | country : 'KI',
498 | '+269' :
499 | country : 'KM',
500 | format : '+... ... .. ..',
501 | '+1869' :
502 | country : 'KN',
503 | '+850' :
504 | country : 'KP',
505 | format : '+... ... ... ....',
506 | '+82' :
507 | country : 'KR',
508 | format : '+.. ..-....-....',
509 | '+965' :
510 | country : 'KW',
511 | format : '+... ... .....',
512 | '+345' :
513 | country : 'KY',
514 | '+77' :
515 | country : 'KZ',
516 | '+856' :
517 | country : 'LA',
518 | format : '+... .. .. ... ...',
519 | '+961' :
520 | country : 'LB',
521 | format : '+... .. ... ...',
522 | '+1758' :
523 | country : 'LC',
524 | '+423' :
525 | country : 'LI',
526 | format : '+... ... ... ...',
527 | '+94' :
528 | country : 'LK',
529 | format : '+.. .. . ......',
530 | '+231' :
531 | country : 'LR',
532 | format : '+... ... ... ...',
533 | '+266' :
534 | country : 'LS',
535 | format : '+... .... ....',
536 | '+370' :
537 | country : 'LT',
538 | format : '+... ... .....',
539 | '+352' :
540 | country : 'LU',
541 | format : '+... .. .. .. ...',
542 | '+371' :
543 | country : 'LV',
544 | format : '+... .. ... ...',
545 | '+218' :
546 | country : 'LY',
547 | format : '+... ..-.......',
548 | '+212' :
549 | country : 'MA',
550 | format : '+... ...-......',
551 | '+377' :
552 | country : 'MC',
553 | format : '+... . .. .. .. ..',
554 | '+373' :
555 | country : 'MD',
556 | format : '+... ... .. ...',
557 | '+382' :
558 | country : 'ME',
559 | format : '+... .. ... ...',
560 | '+590' :
561 | country : 'MF',
562 | '+261' :
563 | country : 'MG',
564 | format : '+... .. .. ... ..',
565 | '+692' :
566 | country : 'MH',
567 | format : '+... ...-....',
568 | '+389' :
569 | country : 'MK',
570 | format : '+... .. ... ...',
571 | '+223' :
572 | country : 'ML',
573 | format : '+... .. .. .. ..',
574 | '+95' :
575 | country : 'MM',
576 | format : '+.. . ... ....',
577 | '+976' :
578 | country : 'MN',
579 | format : '+... .... ....',
580 | '+853' :
581 | country : 'MO',
582 | format : '+... .... ....',
583 | '+1670' :
584 | country : 'MP',
585 | '+596' :
586 | country : 'MQ',
587 | format : '+... ... .. .. ..',
588 | '+222' :
589 | country : 'MR',
590 | format : '+... .. .. .. ..',
591 | '+1664' :
592 | country : 'MS',
593 | '+356' :
594 | country : 'MT',
595 | format : '+... .... ....',
596 | '+230' :
597 | country : 'MU',
598 | format : '+... .... ....',
599 | '+960' :
600 | country : 'MV',
601 | format : '+... ...-....',
602 | '+265' :
603 | country : 'MW',
604 | format : '+... ... .. .. ..',
605 | '+52' :
606 | country : 'MX',
607 | format : '+.. ... ... ... ....',
608 | '+60' :
609 | country : 'MY',
610 | format : '+.. ..-... ....',
611 | '+258' :
612 | country : 'MZ',
613 | format : '+... .. ... ....',
614 | '+264' :
615 | country : 'NA',
616 | format : '+... .. ... ....',
617 | '+687' :
618 | country : 'NC',
619 | format : '+... ........',
620 | '+227' :
621 | country : 'NE',
622 | format : '+... .. .. .. ..',
623 | '+672' :
624 | country : 'NF',
625 | format : '+... .. ....',
626 | '+234' :
627 | country : 'NG',
628 | format : '+... ... ... ....',
629 | '+505' :
630 | country : 'NI',
631 | format : '+... .... ....',
632 | '+31' :
633 | country : 'NL',
634 | format : '+.. . ........',
635 | '+47' :
636 | country : 'NO',
637 | format : '+.. ... .. ...',
638 | '+977' :
639 | country : 'NP',
640 | format : '+... ...-.......',
641 | '+674' :
642 | country : 'NR',
643 | format : '+... ... ....',
644 | '+683' :
645 | country : 'NU',
646 | '+64' :
647 | country : 'NZ',
648 | format : '+.. .. ... ....',
649 | '+968' :
650 | country : 'OM',
651 | format : '+... .... ....',
652 | '+507' :
653 | country : 'PA',
654 | format : '+... ....-....',
655 | '+51' :
656 | country : 'PE',
657 | format : '+.. ... ... ...',
658 | '+689' :
659 | country : 'PF',
660 | format : '+... .. .. ..',
661 | '+675' :
662 | country : 'PG',
663 | format : '+... ... ....',
664 | '+63' :
665 | country : 'PH',
666 | format : '+.. .... ......',
667 | '+92' :
668 | country : 'PK',
669 | format : '+.. ... .......',
670 | '+48' :
671 | country : 'PL',
672 | format : '+.. .. ... .. ..',
673 | '+508' :
674 | country : 'PM',
675 | format : '+... .. .. ..',
676 | '+872' :
677 | country : 'PN',
678 | '+1939' :
679 | country : 'PR',
680 | '+970' :
681 | country : 'PS',
682 | format : '+... ... ... ...',
683 | '+351' :
684 | country : 'PT',
685 | format : '+... ... ... ...',
686 | '+680' :
687 | country : 'PW',
688 | format : '+... ... ....',
689 | '+595' :
690 | country : 'PY',
691 | format : '+... .. .......',
692 | '+974' :
693 | country : 'QA',
694 | format : '+... .... ....',
695 | '+262' :
696 | country : 'RE',
697 | '+40' :
698 | country : 'RO',
699 | format : '+.. .. ... ....',
700 | '+381' :
701 | country : 'RS',
702 | format : '+... .. .......',
703 | '+7' :
704 | country : 'RU',
705 | format : '+. ... ...-..-..',
706 | '+250' :
707 | country : 'RW',
708 | format : '+... ... ... ...',
709 | '+966' :
710 | country : 'SA',
711 | format : '+... .. ... ....',
712 | '+677' :
713 | country : 'SB',
714 | format : '+... ... ....',
715 | '+248' :
716 | country : 'SC',
717 | format : '+... . ... ...',
718 | '+249' :
719 | country : 'SD',
720 | format : '+... .. ... ....',
721 | '+46' :
722 | country : 'SE',
723 | format : '+.. ..-... .. ..',
724 | '+65' :
725 | country : 'SG',
726 | format : '+.. .... ....',
727 | '+290' :
728 | country : 'SH',
729 | '+386' :
730 | country : 'SI',
731 | format : '+... .. ... ...',
732 | '+421' :
733 | country : 'SK',
734 | format : '+... ... ... ...',
735 | '+232' :
736 | country : 'SL',
737 | format : '+... .. ......',
738 | '+378' :
739 | country : 'SM',
740 | format : '+... .. .. .. ..',
741 | '+221' :
742 | country : 'SN',
743 | format : '+... .. ... .. ..',
744 | '+252' :
745 | country : 'SO',
746 | format : '+... .. .......',
747 | '+597' :
748 | country : 'SR',
749 | format : '+... ...-....',
750 | '+211' :
751 | country : 'SS',
752 | format : '+... ... ... ...',
753 | '+239' :
754 | country : 'ST',
755 | format : '+... ... ....',
756 | '+503' :
757 | country : 'SV',
758 | format : '+... .... ....',
759 | '+963' :
760 | country : 'SY',
761 | format : '+... ... ... ...',
762 | '+268' :
763 | country : 'SZ',
764 | format : '+... .... ....',
765 | '+1649' :
766 | country : 'TC',
767 | '+235' :
768 | country : 'TD',
769 | format : '+... .. .. .. ..',
770 | '+228' :
771 | country : 'TG',
772 | format : '+... .. .. .. ..',
773 | '+66' :
774 | country : 'TH',
775 | format : '+.. .. ... ....',
776 | '+992' :
777 | country : 'TJ',
778 | format : '+... ... .. ....',
779 | '+690' :
780 | country : 'TK',
781 | '+670' :
782 | country : 'TL',
783 | format : '+... .... ....',
784 | '+993' :
785 | country : 'TM',
786 | format : '+... .. ..-..-..',
787 | '+216' :
788 | country : 'TN',
789 | format : '+... .. ... ...',
790 | '+676' :
791 | country : 'TO',
792 | format : '+... ... ....',
793 | '+90' :
794 | country : 'TR',
795 | format : '+.. ... ... ....',
796 | '+1868' :
797 | country : 'TT',
798 | '+688' :
799 | country : 'TV',
800 | '+886' :
801 | country : 'TW',
802 | format : '+... ... ... ...',
803 | '+255' :
804 | country : 'TZ',
805 | format : '+... ... ... ...',
806 | '+380' :
807 | country : 'UA',
808 | format : '+... .. ... ....',
809 | '+256' :
810 | country : 'UG',
811 | format : '+... ... ......',
812 | '+1' :
813 | country : 'US',
814 | '+598' :
815 | country : 'UY',
816 | format : '+... .... ....',
817 | '+998' :
818 | country : 'UZ',
819 | format : '+... .. ... .. ..',
820 | '+379' :
821 | country : 'VA',
822 | '+1784' :
823 | country : 'VC',
824 | '+58' :
825 | country : 'VE',
826 | format : '+.. ...-.......',
827 | '+1284' :
828 | country : 'VG',
829 | '+1340' :
830 | country : 'VI',
831 | '+84' :
832 | country : 'VN',
833 | format : '+.. .. ... .. ..',
834 | '+678' :
835 | country : 'VU',
836 | format : '+... ... ....',
837 | '+681' :
838 | country : 'WF',
839 | format : '+... .. .. ..',
840 | '+685' :
841 | country : 'WS',
842 | '+967' :
843 | country : 'YE',
844 | format : '+... ... ... ...',
845 | '+27' :
846 | country : 'ZA',
847 | format : '+.. .. ... ....',
848 | '+260' :
849 | country : 'ZM',
850 | format : '+... .. .......',
851 | '+263' :
852 | country : 'ZW',
853 | format : '+... .. ... ....',
854 |
855 | do (formats) ->
856 | # Canada
857 | canadaPrefixes = [403, 587, 780, 250, 604, 778, 204, 506, 709, 902, 226, 249, 289, 343, 416, 519, 613, 647, 705, 807, 905, 418, 438, 450, 514, 579, 581, 819, 873, 306, 867]
858 | for prefix in canadaPrefixes
859 | formats['+1' + prefix] = { country: 'CA' }
860 |
861 | for prefix, format of formats
862 | if prefix.substring(0, 2) == "+1"
863 | format.format = '+. (...) ...-....'
864 |
--------------------------------------------------------------------------------
/test/index.coffee:
--------------------------------------------------------------------------------
1 | assert = require('assert')
2 | JSDOM = require('jsdom').JSDOM
3 | dom = new JSDOM('')
4 | global.document = dom.window.document
5 | global.window = dom.window
6 | $ = require('jquery')
7 | global.jQuery = $
8 |
9 | # jsdom doesn't support selection, so we just hack it into document.createElement
10 | createElement = document.createElement
11 | document.createElement = ->
12 | el = createElement.apply(document, arguments)
13 | if arguments[0] == 'input'
14 | el.selectionStart = el.selectionEnd = 0
15 | el
16 |
17 | require('../src/jquery.mobilePhoneNumber')
18 | require('../vendor/jquery.caret')
19 |
20 | createInput = ->
21 | $input = $('')
22 | # jsdom doesn't support selection, so we just define it
23 | $input[0].selectionStart = $input[0].selectionEnd = 0
24 | $input
25 |
26 | triggerKey = ($input, which) ->
27 | for type in ['keydown', 'keypress', 'keyup']
28 | $input.trigger(
29 | type: type
30 | which: which
31 | )
32 |
33 | type = ($input, digits) ->
34 | for digit in digits
35 | do (digit) ->
36 | triggerKey($input, digit.charCodeAt(0))
37 |
38 | # jsdom doesn't support selection
39 | # hack to push the selection to the end
40 | $input[0].selectionStart = $input[0].selectionEnd = 1000
41 |
42 | describe 'jquery.mobilePhoneNumber', ->
43 | describe 'mobilePhoneNumber', ->
44 | it 'shouldnt change the input value when enabling if value was null', ->
45 | $phone = createInput().val('').mobilePhoneNumber()
46 |
47 | assert.equal $phone.val(), ''
48 |
49 | it 'should correctly format US phone', ->
50 | $phone = createInput().val('').mobilePhoneNumber()
51 |
52 | type $phone, '1'
53 | assert.equal $phone.val(), '+1 ('
54 |
55 | type $phone, '4'
56 | assert.equal $phone.val(), '+1 (4'
57 |
58 | type $phone, '15'
59 | assert.equal $phone.val(), '+1 (415) '
60 |
61 | type $phone, '12'
62 | assert.equal $phone.val(), '+1 (415) 12'
63 |
64 | type $phone, '3'
65 | assert.equal $phone.val(), '+1 (415) 123-'
66 |
67 | type $phone, '4567'
68 | assert.equal $phone.val(), '+1 (415) 123-4567'
69 |
70 | it 'should correctly format US phone with defaultPrefix +1', ->
71 | $phone = createInput().val('').mobilePhoneNumber({ defaultPrefix: '+1' })
72 |
73 | type $phone, '415'
74 | assert.equal $phone.val(), '(415) '
75 |
76 | type $phone, '1234567'
77 | assert.equal $phone.val(), '(415) 123-4567'
78 |
79 | it 'should correctly format JP phone with defaultPrefix +81', ->
80 | $phone = createInput().val('').mobilePhoneNumber({ defaultPrefix: '+81' })
81 |
82 | type $phone, '08043691337'
83 | assert.equal $phone.val(), '080-4369-1337'
84 |
85 | it 'should correctly format BE phone', ->
86 | $phone = createInput().val('').mobilePhoneNumber()
87 |
88 | type $phone, '+32'
89 | assert.equal $phone.val(), '+32 '
90 |
91 | type $phone, '49'
92 | assert.equal $phone.val(), '+32 49'
93 |
94 | type $phone, '5'
95 | assert.equal $phone.val(), '+32 495 '
96 |
97 | type $phone, '1'
98 | assert.equal $phone.val(), '+32 495 1'
99 |
100 | type $phone, '2'
101 | assert.equal $phone.val(), '+32 495 12 '
102 |
103 | type $phone, '3456'
104 | assert.equal $phone.val(), '+32 495 12 34 56'
105 |
106 | it 'should correctly format BE phone with defaultPrefix +1', ->
107 | $phone = createInput().val('').mobilePhoneNumber({ defaultPrefix: '+1' })
108 |
109 | type $phone, '+32'
110 | assert.equal $phone.val(), '+32 '
111 |
112 | type $phone, '123456789'
113 | assert.equal $phone.val(), '+32 123 45 67 89'
114 |
115 | it 'should correctly replace when select all + type', ->
116 | $phone = createInput().val('123456789').mobilePhoneNumber()
117 |
118 | $phone.get(0).selectionStart = 0
119 | $phone.get(0).selectionEnd = 20
120 |
121 | type $phone, '0'
122 |
123 | assert.equal $phone.val(), '+0'
124 |
125 | it 'should correctly format the current value before typing', ->
126 | $phone = createInput().val('4151234567').mobilePhoneNumber({ defaultPrefix: '+1' })
127 | assert.equal $phone.val(), '(415) 123-4567'
128 |
129 | describe 'mobilePhoneNumber("country")', ->
130 | it 'should correctly find the country', ->
131 | $phone = createInput().mobilePhoneNumber()
132 |
133 | $phone.val('+1415123')
134 | assert.equal $phone.mobilePhoneNumber('country'), 'US'
135 |
136 | $phone.val('+3212345')
137 | assert.equal $phone.mobilePhoneNumber('country'), 'BE'
138 |
139 | $phone.val('+3312345')
140 | assert.equal $phone.mobilePhoneNumber('country'), 'FR'
141 |
142 | $phone.val('+1403123')
143 | assert.equal $phone.mobilePhoneNumber('country'), 'CA'
144 |
145 | describe 'mobilePhoneNumber("prefix")', ->
146 | it 'should correctly find the prefix', ->
147 | $phone = createInput().mobilePhoneNumber()
148 |
149 | $phone.val('+1415123')
150 | assert.equal $phone.mobilePhoneNumber('prefix'), '+1'
151 |
152 | $phone.val('+3212345')
153 | assert.equal $phone.mobilePhoneNumber('prefix'), '+32'
154 |
155 | $phone.val('+3312345')
156 | assert.equal $phone.mobilePhoneNumber('prefix'), '+33'
157 |
158 | $phone.val('+1403123')
159 | assert.equal $phone.mobilePhoneNumber('prefix'), '+1'
160 |
161 | describe 'mobilePhoneNumber("val")', ->
162 | it 'should correctly returns the val with defaultPrefix on', ->
163 | $phone = createInput().mobilePhoneNumber({defaultPrefix: '+1'})
164 |
165 | $phone.val('4151234567')
166 | assert.equal $phone.mobilePhoneNumber('val'), '+14151234567'
167 |
168 | $phone.val('+32123456789')
169 | assert.equal $phone.mobilePhoneNumber('val'), '+32123456789'
170 |
171 | it 'should correctly returns the val with defaultPrefix off', ->
172 | $phone = createInput().mobilePhoneNumber()
173 |
174 | $phone.val('+14151234567')
175 | assert.equal $phone.mobilePhoneNumber('val'), '+14151234567'
176 |
177 | $phone.val('+32123456789')
178 | assert.equal $phone.mobilePhoneNumber('val'), '+32123456789'
179 |
180 | describe 'event country.mobilePhoneNumber', ->
181 | it 'is triggered correctly with US number', (done) ->
182 | $phone = createInput().val('').mobilePhoneNumber()
183 | $phone.bind('country.mobilePhoneNumber', (e, country) ->
184 | if country == 'US'
185 | done()
186 | )
187 | type $phone, '+1415'
188 |
189 | it 'is triggered correctly with BE number and then US number', (done) ->
190 | $phone = createInput().val('').mobilePhoneNumber()
191 | isFirst = true
192 | $phone.bind('country.mobilePhoneNumber', (e, country) ->
193 | if isFirst
194 | if country == 'BE'
195 | isFirst = false
196 | else
197 | if country == 'US'
198 | done()
199 | )
200 | type $phone, '+32495'
201 | $phone.val('')
202 | type $phone, '+1415'
203 |
--------------------------------------------------------------------------------
/vendor/jquery.caret.js:
--------------------------------------------------------------------------------
1 | (function($) {
2 | $.fn.caret = function(pos) {
3 | var target = this[0];
4 | var isContentEditable = target.contentEditable === 'true';
5 | //get
6 | if (arguments.length == 0) {
7 | //HTML5
8 | if (window.getSelection) {
9 | //contenteditable
10 | if (isContentEditable) {
11 | target.focus();
12 | var range1 = window.getSelection().getRangeAt(0),
13 | range2 = range1.cloneRange();
14 | range2.selectNodeContents(target);
15 | range2.setEnd(range1.endContainer, range1.endOffset);
16 | return range2.toString().length;
17 | }
18 | //textarea
19 | return target.selectionStart;
20 | }
21 | //IE<9
22 | if (document.selection) {
23 | target.focus();
24 | //contenteditable
25 | if (isContentEditable) {
26 | var range1 = document.selection.createRange(),
27 | range2 = document.body.createTextRange();
28 | range2.moveToElementText(target);
29 | range2.setEndPoint('EndToEnd', range1);
30 | return range2.text.length;
31 | }
32 | //textarea
33 | var pos = 0,
34 | range = target.createTextRange(),
35 | range2 = document.selection.createRange().duplicate(),
36 | bookmark = range2.getBookmark();
37 | range.moveToBookmark(bookmark);
38 | while (range.moveStart('character', -1) !== 0) pos++;
39 | return pos;
40 | }
41 | // Addition for jsdom support
42 | if (target.selectionStart)
43 | return target.selectionStart;
44 | //not supported
45 | return 0;
46 | }
47 | //set
48 | if (pos == -1)
49 | pos = this[isContentEditable? 'text' : 'val']().length;
50 | //HTML5
51 | if (window.getSelection) {
52 | //contenteditable
53 | if (isContentEditable) {
54 | target.focus();
55 | window.getSelection().collapse(target.firstChild, pos);
56 | }
57 | //textarea
58 | else
59 | target.setSelectionRange(pos, pos);
60 | }
61 | //IE<9
62 | else if (document.body.createTextRange) {
63 | if (isContentEditable) {
64 | var range = document.body.createTextRange();
65 | range.moveToElementText(target);
66 | range.moveStart('character', pos);
67 | range.collapse(true);
68 | range.select();
69 | } else {
70 | var range = target.createTextRange();
71 | range.move('character', pos);
72 | range.select();
73 | }
74 | }
75 | if (!isContentEditable)
76 | target.focus();
77 | return pos;
78 | }
79 | })(jQuery);
80 |
--------------------------------------------------------------------------------