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 = this[0]; 23 if (options === undefined) options = {}; 24 if (typeof fn === "string") { 25 switch (fn) { 26 case "unmaskedvalue": 27 return input && input.inputmask ? input.inputmask.unmaskedvalue() : $(input).val(); 28 case "remove": 29 return this.each(function () { 30 if (this.inputmask) this.inputmask.remove(); 31 }); 32 case "getemptymask": 33 return input && input.inputmask ? input.inputmask.getemptymask() : ""; 34 case "hasMaskedValue": //check wheter the returned value is masked or not; currently only works reliable when using jquery.val fn to retrieve the value 35 return input && input.inputmask ? input.inputmask.hasMaskedValue() : false; 36 case "isComplete": 37 return input && input.inputmask ? input.inputmask.isComplete() : true; 38 case "getmetadata": //return mask metadata if exists 39 return input && input.inputmask ? input.inputmask.getmetadata() : undefined; 40 case "setvalue": 41 $(input).val(options); 42 if (input && input.inputmask === undefined) { //reactivate jquery.clone 43 $(input).triggerHandler("setvalue"); 44 } 45 break; 46 case "option": 47 if (typeof options === "string") { 48 if (input && input.inputmask !== undefined) { 49 return input.inputmask.option(options); 50 } 51 } else { 52 return this.each(function () { 53 if (this.inputmask !== undefined) { 54 return this.inputmask.option(options); 55 } 56 }); 57 } 58 break; 59 default: 60 options.alias = fn; 61 nptmask = new Inputmask(options); 62 return this.each(function () { 63 nptmask.mask(this); 64 }); 65 } 66 } else if (typeof fn == "object") { 67 nptmask = new Inputmask(fn); 68 if (fn.mask === undefined && fn.alias === undefined) { 69 return this.each(function () { 70 if (this.inputmask !== undefined) { 71 return this.inputmask.option(fn); 72 } else nptmask.mask(this); 73 }); 74 } else { 75 return this.each(function () { 76 nptmask.mask(this); 77 }); 78 } 79 } else if (fn === undefined) { 80 //look for data-inputmask atributes 81 return this.each(function () { 82 nptmask = new Inputmask(options); 83 nptmask.mask(this); 84 }); 85 } 86 }; 87 } 88 return $.fn.inputmask; 89}));
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.