jquery.inputmask.js 2.5 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-172
  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, window.Inputmask);
  10. }(function($, Inputmask) {
  11. return void 0 === $.fn.inputmask && ($.fn.inputmask = function(fn, options) {
  12. var nptmask, input;
  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. return input = this.jquery && this.length > 0 ? this[0] : this, input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val();
  20. case "remove":
  21. return this.each(function() {
  22. this.inputmask && this.inputmask.remove();
  23. });
  24. case "getemptymask":
  25. return input = this.jquery && this.length > 0 ? this[0] : this, input.inputmask ? input.inputmask.getemptymask() : "";
  26. case "hasMaskedValue":
  27. return input = this.jquery && this.length > 0 ? this[0] : this, input.inputmask ? input.inputmask.hasMaskedValue() : !1;
  28. case "isComplete":
  29. return input = this.jquery && this.length > 0 ? this[0] : this, input.inputmask ? input.inputmask.isComplete() : !0;
  30. case "getmetadata":
  31. return input = this.jquery && this.length > 0 ? this[0] : this, input.inputmask ? input.inputmask.getmetadata() : void 0;
  32. case "setvalue":
  33. input = this.jquery && this.length > 0 ? this[0] : this, $(input).val(options),
  34. void 0 === input.Inputmask && $(input).triggerHandler("setvalue.inputmask");
  35. break;
  36. default:
  37. return options.alias = fn, nptmask = new Inputmask(options), this.each(function() {
  38. nptmask.mask(this);
  39. });
  40. } else {
  41. if ("object" == typeof fn) return nptmask = new Inputmask(fn), this.each(function() {
  42. nptmask.mask(this);
  43. });
  44. if (void 0 === fn) return this.each(function() {
  45. nptmask = new Inputmask(options), nptmask.mask(this);
  46. });
  47. }
  48. }), $.fn.inputmask;
  49. });