From 8ae7e99a657ce598a0e49aa5300208842ba72502 Mon Sep 17 00:00:00 2001 From: Markus Peter Date: Tue, 26 Sep 2017 18:57:59 +0200 Subject: [PATCH 1/2] Added option "greedy" for translations which lets pattern greedily and repeatedly match --- src/jquery.mask.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/jquery.mask.js b/src/jquery.mask.js index d60966fc..24269259 100755 --- a/src/jquery.mask.js +++ b/src/jquery.mask.js @@ -305,7 +305,7 @@ if (translation) { if (valDigit.match(translation.pattern)) { buf[addMethod](valDigit); - if (translation.recursive) { + if (translation.recursive) { if (resetPos === -1) { resetPos = m; } else if (m === lastMaskChar) { @@ -316,14 +316,15 @@ m -= offset; } } - m += offset; + if( !translation.greedy ) + m += offset; } else if (valDigit === lastUntranslatedMaskChar) { // matched the last untranslated (raw) mask character that we encountered // likely an insert offset the mask character from the last entry; fall // through and only increment v maskDigitCount--; lastUntranslatedMaskChar = undefined; - } else if (translation.optional) { + } else if (translation.optional || translation.greedy ) { m += offset; v -= offset; } else if (translation.fallback) { From 2d15a99c7f7d6675c3aa8c3ebecfbbd6b80250f4 Mon Sep 17 00:00:00 2001 From: Markus Peter Date: Tue, 26 Sep 2017 19:28:32 +0200 Subject: [PATCH 2/2] Changed to conform to jshint rules of master --- src/jquery.mask.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jquery.mask.js b/src/jquery.mask.js index 24269259..9c182f2f 100755 --- a/src/jquery.mask.js +++ b/src/jquery.mask.js @@ -316,8 +316,9 @@ m -= offset; } } - if( !translation.greedy ) + if( !translation.greedy ) { m += offset; + } } else if (valDigit === lastUntranslatedMaskChar) { // matched the last untranslated (raw) mask character that we encountered // likely an insert offset the mask character from the last entry; fall