jquery.inputmask.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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-45
  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 && ($.inputmask = inputmask.prototype, $.fn.inputmask = function(fn, options) {
  12. var nptmask;
  13. if ("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 = options || {}, options.alias = fn, nptmask = new inputmask(options),
  39. this.each(function() {
  40. nptmask.mask(this);
  41. });
  42. } else {
  43. if ("object" == typeof fn) return nptmask = new inputmask(fn), this.each(function() {
  44. nptmask.mask(this);
  45. });
  46. if (void 0 == fn) return this.each(function() {
  47. nptmask = new inputmask(), nptmask.mask(this);
  48. });
  49. }
  50. }), $.fn.inputmask;
  51. });