jquery.inputmask.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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-177
  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. case "option":
  37. if ("string" != typeof options) return this.each(function() {
  38. return void 0 !== this.inputmask ? this.inputmask.option(options) : void 0;
  39. });
  40. if (input = this.jquery && this.length > 0 ? this[0] : this, void 0 !== input.inputmask) return input.inputmask.option(options);
  41. break;
  42. default:
  43. return options.alias = fn, nptmask = new Inputmask(options), this.each(function() {
  44. nptmask.mask(this);
  45. });
  46. } else {
  47. if ("object" == typeof fn) return void 0 === fn.mask && void 0 === fn.alias ? this.each(function() {
  48. return void 0 !== this.inputmask ? this.inputmask.option(fn) : void 0;
  49. }) : (nptmask = new Inputmask(fn), this.each(function() {
  50. nptmask.mask(this);
  51. }));
  52. if (void 0 === fn) return this.each(function() {
  53. nptmask = new Inputmask(options), nptmask.mask(this);
  54. });
  55. }
  56. }), $.fn.inputmask;
  57. });