1/* 2 * Input Mask plugin for jquery 3 * http://github.com/RobinHerbots/jquery.inputmask 4 * Copyright (c) 2010 - Robin Herbots 5 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php) 6 * Version: 0.0.0-dev 7 */ 8 9(function(factory) { 10 if (typeof define === "function" && define.amd) { 11 define(["jquery", "inputmask"], factory); 12 } else if (typeof exports === "object") { 13 module.exports = factory(require("jquery"), require("./inputmask")); 14 } else { 15 factory(jQuery, window.Inputmask); 16 } 17 } 18 (function($, Inputmask) { 19 if ($.fn.inputmask === undefined) { 20 //jquery plugin 21 $.fn.inputmask = function(fn, options) { 22 var nptmask, input; 23 options = options || {}; 24 if (typeof fn === "string") { 25 switch (fn) { 26 case "mask": 27 nptmask = new Inputmask(options); 28 return this.each(function() { 29 nptmask.mask(this); 30 }); 31 case "unmaskedvalue": 32 input = this.jquery && this.length > 0 ? this[0] : this; 33 return input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val(); 34 case "remove": 35 return this.each(function() { 36 if (this.inputmask) this.inputmask.remove(); 37 }); 38 case "getemptymask": 39 input = this.jquery && this.length > 0 ? this[0] : this; 40 return input.inputmask ? input.inputmask.getemptymask() : ""; 41 case "hasMaskedValue": //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value 42 input = this.jquery && this.length > 0 ? this[0] : this; 43 return input.inputmask ? input.inputmask.hasMaskedValue() : false; 44 case "isComplete": 45 input = this.jquery && this.length > 0 ? this[0] : this; 46 return input.inputmask ? input.inputmask.isComplete() : true; 47 case "getmetadata": //return mask metadata if exists 48 input = this.jquery && this.length > 0 ? this[0] : this; 49 return input.inputmask ? input.inputmask.getmetadata() : undefined; 50 case "setvalue": 51 input = this.jquery && this.length > 0 ? this[0] : this; 52 $(input).val(options); 53 if (input.inputmask !== undefined) { 54 $(input).triggerHandler("setvalue.inputmask"); 55 } 56 break; 57 case "option": 58 if (typeof options === "string") { 59 input = this.jquery && this.length > 0 ? this[0] : this; 60 if (input.inputmask !== undefined) { 61 return input.inputmask.option(options); 62 } 63 } else { 64 return this.each(function() { 65 if (this.inputmask !== undefined) { 66 return this.inputmask.option(options); 67 } 68 }); 69 } 70 break; 71 default: 72 options.alias = fn; 73 nptmask = new Inputmask(options); 74 return this.each(function() { 75 nptmask.mask(this); 76 }); 77 } 78 } else if (typeof fn == "object") { 79 nptmask = new Inputmask(fn); 80 if (fn.mask === undefined && fn.alias === undefined) { 81 return this.each(function() { 82 if (this.inputmask !== undefined) { 83 return this.inputmask.option(fn); 84 } else nptmask.mask(this); 85 }); 86 } else { 87 return this.each(function() { 88 nptmask.mask(this); 89 }); 90 } 91 } else if (fn === undefined) { 92 //look for data-inputmask atributes 93 return this.each(function() { 94 nptmask = new Inputmask(options); 95 nptmask.mask(this); 96 }); 97 } 98 }; 99 } 100 return $.fn.inputmask; 101 }));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.