jquery.inputmask.phone.extensions.js 1.9 KB

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