jquery.inputmask.phone.extensions.js
1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*!
* jquery.inputmask.phone.extensions.js
* http://github.com/RobinHerbots/jquery.inputmask
* Copyright (c) 2010 - 2015 Robin Herbots
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
* Version: 3.1.63
*/
!function(factory) {
"function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./jquery.inputmask")) : factory(jQuery);
}(function($) {
return $.extend($.inputmask.defaults.aliases, {
phone: {
url: "phone-codes/phone-codes.js",
countrycode: "",
mask: function(opts) {
opts.definitions["#"] = opts.definitions[9];
var maskList = [];
return $.ajax({
url: opts.url,
async: !1,
dataType: "json",
success: function(response) {
maskList = response;
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + " - " + opts.url);
}
}), maskList = maskList.sort(function(a, b) {
return (a.mask || a) < (b.mask || b) ? -1 : 1;
});
},
keepStatic: !1,
nojumps: !0,
nojumpsThreshold: 1,
onBeforeMask: function(value, opts) {
var processedValue = value.replace(/^0/g, "");
return (processedValue.indexOf(opts.countrycode) > 1 || -1 == processedValue.indexOf(opts.countrycode)) && (processedValue = "+" + opts.countrycode + processedValue),
processedValue;
}
},
phonebe: {
alias: "phone",
url: "phone-codes/phone-be.js",
countrycode: "32",
nojumpsThreshold: 4
}
}), $.fn.inputmask;
});