mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2025-01-10 12:25:40 +00:00
60 lines
2.3 KiB
JavaScript
60 lines
2.3 KiB
JavaScript
/*!
|
|
* jquery.inputmask.phone.extensions.js
|
|
* http://github.com/RobinHerbots/jquery.inputmask
|
|
* Copyright (c) 2010 - 2014 Robin Herbots
|
|
* Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
* Version: 3.1.34
|
|
*/
|
|
!function(factory) {
|
|
"function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : factory(jQuery);
|
|
}(function($) {
|
|
return $.extend($.inputmask.defaults.aliases, {
|
|
phone: {
|
|
url: "phone-codes/phone-codes.js",
|
|
maskInit: "+pp(pp)pppppppp",
|
|
countrycode: "",
|
|
mask: function(opts) {
|
|
opts.definitions = {
|
|
p: {
|
|
validator: function() {
|
|
return !1;
|
|
},
|
|
cardinality: 1
|
|
},
|
|
"#": {
|
|
validator: "[0-9]",
|
|
cardinality: 1
|
|
}
|
|
};
|
|
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;
|
|
}), "" != opts.countrycode && (opts.maskInit = "+" + opts.countrycode + opts.maskInit.substring(3)),
|
|
maskList.splice(0, 0, opts.maskInit), maskList;
|
|
},
|
|
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;
|
|
}); |