Socket
Socket
Sign inDemoInstall

jquerysimplemask

Package Overview
Dependencies
6
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.8 to 1.0.9

2

dist/jQuery.SimpleMask.min.js

@@ -1,2 +0,2 @@

/* Version: 1.0.8 - Last modified: 2022-08-23 13:36:47 */
/* Version: 1.0.9 - Last modified: 2022-10-07 12:27:19 */
String.prototype.simpleMaskStringCount=function(e){return(this.length-this.replace(new RegExp(e,"g"),"").length)/e.length},function(h){var n={mask:"",nextInput:null,onComplete:null},o=[],t={init:function(e){var t=h.extend({},n,e);return this.each(function(){h.fn.simpleMask.process(h(this),t)})},unmask:function(){return this.each(function(){h.fn.simpleMask.unmask(this)})}};h.fn.simpleMask=function(e){return t[e]?t[e].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof e&&e?void h.error("Method "+e+" does not exist on jQuery.SimpleMask"):t.init.apply(this,arguments)},h.fn.simpleMask.makeId=function(){for(var e="",t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz0123456789",n=t.length,s=0;s<8;s++)e+=t.charAt(Math.floor(Math.random()*n));return e},h.fn.simpleMask._onComplete=function(e){e="object"==typeof e?h(e).attr("data-mask-ids"):e;null!==o[e].options.onComplete&&o[e].options.onComplete.call(this,o[e]),h.fn.simpleMask._nextInput(e)},h.fn.simpleMask.nextOnTabIndex=function(e){var n=h(e),s=!1,a=[];return n.closest("form").find("input,select").each(function(e){var t=h(this);if(s)return a=t,!1;t[0]==n[0]&&(s=!0)}),a},h.fn.simpleMask._nextInput=function(e){var t,e="object"==typeof e?h(e).attr("data-mask-ids"):e;null!==o[e].options.nextInput&&(!0===o[e].options.nextInput?0<(t=h.fn.simpleMask.nextOnTabIndex(o[e].element)).length&&t.select().focus():0<o[e].options.nextInput.length&&o[e].options.nextInput.select().focus())},h.fn.simpleMask.unmask=function(e){e="object"==typeof e?h(e).attr("data-mask-ids"):e;h(o[e].element).removeClass("input-masked").removeAttr("data-mask-ids"),""===h(o[e].element).attr("class")&&h(o[e].element).removeAttr("class"),h(document).off("keyup.simpleMask change.simpleMask",'input[data-mask-ids="'+e+'"]'),h(document).off("keydown.simpleMask",'input[data-mask-ids="'+e+'"]')},h.fn.simpleMask.isNumber=function(e){return""!==e.replace(/\D/g,"")},h.fn.simpleMask.onlyNumbers=function(e){return e.replace(/\D/g,"")},h.fn.simpleMask.onlyNumbersLength=function(e){return e.replace(/\D/g,"").length},h.fn.simpleMask.applyMask=function(e,t){var n,s=e.element,a=h(s)[0],a=(a.selectionStart,a.selectionEnd),l=e.oldvalue,o=h(s).val(),i=h.fn.simpleMask.onlyNumbers(h(s).val()),r=e.masks[0],m=e.masks[e.masks.length-1].simpleMaskStringCount("#"),p=(i=i.length>m?i.substr(0,m):i).length;for(n in e.masks)if(e.masks[n].simpleMaskStringCount("#")==p){r=e.masks[n];break}if(0<i.length){for(var u=r,k=(i=i.trim()).length,c=0;c<k;c++)u=u.replace("#",i.charAt(c));for(var m=u.indexOf("#"),f=(u=-1!=m?u.substr(0,m):u).substr(u.length-1,1),d=(u=""===h.fn.simpleMask.onlyNumbers(f)?u.substr(0,m-1):u).substr(u.length-1,1);0<u.length&&!1===h.fn.simpleMask.isNumber(d);)d=(u=u.substr(0,u.length-1)).substr(u.length-1,1);u!=o&&h(s).val(u),u!=l&&u.length==r.length&&u.length<=a&&u.length==e.maxlengthmask&&Number.isInteger(t)&&h.fn.simpleMask._onComplete(s.attr("data-mask-ids"))}else h(s).val("");e.oldvalue=h(s).val()},h.fn.simpleMask.process=function(e,t){for(var n=h.fn.simpleMask.makeId();void 0!==o[n];)n=h.fn.simpleMask.makeId();var s,a={},l=(a.element=e,a.options=t,a.nextInput=t.nextInput,a.onComplete=t.onComplete,a.oldvalue=h(e).val(),[]);for(s in l="string"==typeof t.mask?[t.mask]:t.mask)switch(l[s].toLowerCase()){case"cpf":l[s]="###.###.###-##";break;case"cnpj":l[s]="##.###.###/####-##";break;case"cep":l[s]="#####-###";break;case"date":case"data":l[s]="##/##/####";break;case"telefone":case"tel":l[s]="####-####";break;case"telefone9":case"tel9":l[s]="####-####",l.push("#####-####");break;case"ddd-telefone9":case"ddd-tel9":l[s]="(##) ####-####",l.push("(##) #####-####")}a.masks=l,a.masks.sort(function(e,t){return e.length-t.length}),a.maxlengthmask=a.masks[a.masks.length-1].length,o[n]=a,e.attr("data-mask-ids",n).addClass("input-masked"),h(document).on("keyup.simpleMask change.simpleMask",'input[data-mask-ids="'+n+'"]',function(e){h.fn.simpleMask.applyMask(a,parseInt(e.key))}),h(document).on("paste",'input[data-mask-ids="'+n+'"]',function(e){var t=h(this);setTimeout(function(){t.keyup()},100)}),h(document).on("keydown.simpleMask",'input[data-mask-ids="'+n+'"]',function(e){e.ctrlKey||65<=e.keyCode&&e.keyCode<=90&&(e.metaKey||e.preventDefault())}),h.fn.simpleMask.applyMask(a)}}(jQuery);
{
"name": "jquerysimplemask",
"version": "1.0.8",
"version": "1.0.9",
"description": "Simple and fast number input masks.",

@@ -27,3 +27,3 @@ "main": "dist/jQuery.SimpleMask.min.js",

"copyfiles": "^2.4.1",
"eslint": "^8.22.0",
"eslint": "^8.24.0",
"eslint-config-airbnb": "^19.0.4",

@@ -34,3 +34,3 @@ "eslint-config-prettier": "^8.5.0",

"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react": "^7.31.8",
"eslint-plugin-react-hooks": "^4.6.0",

@@ -45,3 +45,3 @@ "gulp": "^4.0.2",

"prettier": "^2.7.1",
"semver": "^7.3.7",
"semver": "^7.3.8",
"sprintf-js": "^1.1.2",

@@ -48,0 +48,0 @@ "strnow": "^1.0.2"

# jQuerySimpleMask
> Simple and fast number input masks
[![npm version](https://badge.fury.io/js/jquerysimplemask.svg)](https://badge.fury.io/js/jquerysimplemask) [![](https://data.jsdelivr.com/v1/package/npm/jquerysimplemask/badge)](https://www.jsdelivr.com/package/npm/jquerysimplemask) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Requirements Status](https://requires.io/github/DevUtils/jQuerySimpleMask/requirements.svg?branch=master)](https://requires.io/github/DevUtils/jQuerySimpleMask/requirements/?branch=master)
[![npm version](https://badge.fury.io/js/jquerysimplemask.svg)](https://badge.fury.io/js/jquerysimplemask) [![](https://data.jsdelivr.com/v1/package/npm/jquerysimplemask/badge)](https://www.jsdelivr.com/package/npm/jquerysimplemask) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

@@ -6,0 +6,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc