jquery.inputmask.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*!
  2. * jquery.inputmask.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.64-110
  7. */
  8. !function(factory) {
  9. "function" == typeof define && define.amd ? define([ "jquery", "./inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./inputmask")) : factory(jQuery);
  10. }(function($) {
  11. return void 0 === $.fn.inputmask && ($.fn.inputmask = function(fn, options) {
  12. var nptmask;
  13. if (options = options || {}, "string" == typeof fn) switch (fn) {
  14. case "mask":
  15. return nptmask = new inputmask(options), this.each(function() {
  16. nptmask.mask(this);
  17. });
  18. case "unmaskedvalue":
  19. var input = this.jquery && this.length > 0 ? this[0] : this;
  20. return input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val();
  21. case "remove":
  22. return this.each(function() {
  23. this.inputmask && this.inputmask.remove();
  24. });
  25. case "getemptymask":
  26. var input = this.jquery && this.length > 0 ? this[0] : this;
  27. return input.inputmask ? input.inputmask.getemptymask() : "";
  28. case "hasMaskedValue":
  29. var input = this.jquery && this.length > 0 ? this[0] : this;
  30. return input.inputmask ? input.inputmask.hasMaskedValue() : !1;
  31. case "isComplete":
  32. var input = this.jquery && this.length > 0 ? this[0] : this;
  33. return input.inputmask ? input.inputmask.isComplete() : !0;
  34. case "getmetadata":
  35. var input = this.jquery && this.length > 0 ? this[0] : this;
  36. return input.inputmask ? input.inputmask.getmetadata() : void 0;
  37. default:
  38. return options.alias = fn, nptmask = new inputmask(options), this.each(function() {
  39. nptmask.mask(this);
  40. });
  41. } else {
  42. if ("object" == typeof fn) return nptmask = new inputmask(fn), this.each(function() {
  43. nptmask.mask(this);
  44. });
  45. if (void 0 == fn) return this.each(function() {
  46. nptmask = new inputmask(options), nptmask.mask(this);
  47. });
  48. }
  49. }), $.fn.inputmask;
  50. });