Browse Source

backspace fix on radixpoint + inputmask class

Robin Herbots 10 years ago
parent
commit
7590bf9e84

+ 39 - 39
README.md

@@ -52,7 +52,7 @@ $(document).ready(function(){
    $(selector).inputmask("99-9999999");  //static mask
    $(selector).inputmask("mask", {"mask": "(999) 999-9999"}); //specifying fn & options
    $(selector).inputmask({"mask": "99-9999999"}); //specifying options only
-   $(selector).inputmask("9-a{1,3}9{1,3}"); //mask with dynamic syntax 
+   $(selector).inputmask("9-a{1,3}9{1,3}"); //mask with dynamic syntax
 });
 ```
 
@@ -83,7 +83,7 @@ $(document).ready(function(){
 ```
 #### Allowed HTML-elements
 
-- input type="text" 
+- input type="text"
 - input type="tel"
 - div contenteditable="true" (and all others supported by contenteditable)
 - any html-element (mask text content or set maskedvalue with jQuery.val)
@@ -92,7 +92,7 @@ $(document).ready(function(){
 
   - 9 : numeric
   - a : alphabetical
-  - * : alphanumeric 
+  - * : alphanumeric
 
 There are more definitions defined within the extensions.  
 You can find info within the js-files or by further exploring the options.
@@ -151,7 +151,7 @@ When defining an optional mask together with the greedy: false option, the input
 $(selector).inputmask({ mask: "99999[-9999]", greedy: false });
 ```
 
-The initial mask shown will be "_____" instead of "_____-____". 
+The initial mask shown will be "_____" instead of "_____-____".
 
 ### Dynamic masks
 
@@ -167,7 +167,7 @@ $(document).ready(function(){
    $(selector).inputmask("aa-9{4}");  //static mask with dynamic syntax
    $(selector).inputmask("aa-9{1,4}");  //dynamic mask ~ the 9 def can be occur 1 to 4 times
 
-   //email mask	
+   //email mask
    $(selector).inputmask({
             mask: "*{1,20}[.*{1,20}][.*{1,20}][.*{1,20}]@*{1,20}[.*{2,6}][.*{1,2}]",
             greedy: false,
@@ -233,10 +233,10 @@ The preprocessing fn should return a valid mask definition.
 ## Define custom definitions
 
 You can define your own definitions to use in your mask.  
-Start by choosing a masksymbol. 
+Start by choosing a masksymbol.
 
 ##### validator(chrs, maskset, pos, strict, opts)
-Next define your validator.  The validator can be a regular expression or a function. 
+Next define your validator.  The validator can be a regular expression or a function.
 
 The return value of a validator can be true,  false or a command object.  
 ###### Options of the command object
@@ -248,7 +248,7 @@ The return value of a validator can be true,  false or a command object.
 - insert : position(s) to add :  
     - { pos : position to insert, c : character to insert }  
 	- [{ pos : position to insert, c : character to insert }, { ...}, ... ]
-- refreshFromBuffer : 
+- refreshFromBuffer :
 	- true => refresh validPositions from the complete buffer
 	- { start: , end: } => refresh from start to end
 
@@ -256,7 +256,7 @@ The return value of a validator can be true,  false or a command object.
 Cardinality specifies how many characters are represented and validated for the definition.
 
 ##### prevalidator(chrs, maskset, pos, strict, opts)
-The prevalidator option is 
+The prevalidator option is
 used to validate the characters before the definition cardinality is reached. (see 'j' example)
 
 ##### definitionSymbol
@@ -271,9 +271,9 @@ $.extend($.inputmask.defaults.definitions, {
         'prevalidator': null
     },
 	'g': {
-        "validator": function (chrs, buffer, pos, strict, opts) { 
+        "validator": function (chrs, buffer, pos, strict, opts) {
 			//do some logic and return true, false, or { "pos": new position, "c": character to place }
-		}		
+		}
         "cardinality": 1,
         'prevalidator': null
     },
@@ -285,7 +285,7 @@ $.extend($.inputmask.defaults.definitions, {
                         { validator: "(19|20)", cardinality: 2 },
                         { validator: "(19|20)\\d", cardinality: 3 }
             ]
-     }, 
+     },
 	 'x': {
         validator: "[0-2]",
         cardinality: 1,
@@ -495,10 +495,10 @@ $(document).ready(function(){
 
 Definitions of aliases.
 
-With an alias you can define a complex mask definition and call it by using an alias name.  So this is mainly to simplify the use of your masks.  Some aliases found in the extensions are: email, currency, decimal, integer, date, datetime, dd/mm/yyyy, etc. 
+With an alias you can define a complex mask definition and call it by using an alias name.  So this is mainly to simplify the use of your masks.  Some aliases found in the extensions are: email, currency, decimal, integer, date, datetime, dd/mm/yyyy, etc.
 
 
-First you have to create an alias definition.  The alias definition can contain options for the mask, custom definitions, the mask to use etc. 
+First you have to create an alias definition.  The alias definition can contain options for the mask, custom definitions, the mask to use etc.
 
 When you pass in an alias, the alias is first resolved and then the other options are applied.  So you can call an alias and pass another mask to be applied over the alias.
 This also means that you can write aliases which "inherit" from another alias.
@@ -536,12 +536,12 @@ The alias to use.
 Callback to implement autocomplete on certain keys for example
 
 Function arguments: event, buffer, caretPos, opts  
-Function return: 
+Function return:
 
 #### onBeforeMask
 
 Executes before masking the initial value to allow preprocessing of the initial value.
-  
+
 Function arguments: initialValue, opts  
 Function return: processedValue
 
@@ -553,7 +553,7 @@ $(selector).inputmask({
                                 if (processedValue.indexOf("32") > 1 || 	processedValue.indexOf("32") == -1) {
                                     processedValue = "32" + processedValue;
                                 }
-                                      
+
                                 return processedValue;
                             }
             });
@@ -573,12 +573,12 @@ $(selector).inputmask({
                 placeholder: ' ',
                 showMaskOnHover: false,
                 showMaskOnFocus: false,
-                onBeforePaste: function (pastedValue, opts) { 
-					var processedValue = pastedValue; 
+                onBeforePaste: function (pastedValue, opts) {
+					var processedValue = pastedValue;
 
 					//do something with it
 
-					return processedValue; 
+					return processedValue;
 				}
             });
 ```
@@ -587,18 +587,18 @@ You can also disable pasting a value by returning false in the onBeforePaste cal
 
 #### onBeforeWrite
 
-Executes before writing to the masked element 
+Executes before writing to the masked element
 
 Use this to do some extra processing of the input.
 This can be usefull when implementing an alias, ex. decimal alias, autofill the digits when leaving the inputfield.
- 
+
 Function arguments: event, buffer, caretPos, opts  
 Function return: command object (see Define custom definitions)
 
 
 #### onUnMask
 
-Executes after unmasking to allow post-processing of the unmaskedvalue. 
+Executes after unmasking to allow post-processing of the unmaskedvalue.
 
 Function arguments: maskedValue, unmaskedValue  
 Function return: processedValue
@@ -679,7 +679,7 @@ $(document).ready(function(){
 #### undoOnEscape
 Make escape behave like undo. (ctrl-Z)  
 Pressing escape reverts the value to the value before focus.  
-Default: true 
+Default: true
 
 #### radixPoint
 
@@ -692,23 +692,23 @@ Position the caret to the radixpoint on the initial click into the inputfield.
 Default: false
 
 #### nojumps
- 
+
 Do not jump over fixed parts in the mask.  
 Default: false
 #### nojumpsThreshold
 
 Start nojumps as of  
 Default: 0
- 
+
 #### keepStatic
-Default: undefined (~false)   
+Default: undefined (~false)
 Use in combination with the alternator syntax
 Try to keep the mask static while typing. Decisions to alter the mask will be posponed if possible.
 
 ex.
 $(selector).inputmask({ mask: ["+55-99-9999-9999", "+55-99-99999-9999", ], keepStatic: true });
 
-typing 1212345123 => should result in +55-12-1234-5123 
+typing 1212345123 => should result in +55-12-1234-5123
 type extra 4 => switch to +55-12-12345-1234
 
 When passing multiple masks (an array of masks) keepStatic is automatically set to true unless explicitly set through the options.
@@ -719,12 +719,12 @@ When passing multiple masks (an array of masks) keepStatic is automatically set
 #### isComplete
 
 With this call-in (hook) you can override the default implementation of the isComplete function.  
-Args => buffer, opts   
+Args => buffer, opts
 Return => true|false
 
 ```javascript
-$(selector).inputmask("Regex", { 
-	regex: "[0-9]*", 
+$(selector).inputmask("Regex", {
+	regex: "[0-9]*",
 	isComplete: function(buffer, opts) {
 		return new RegExp(opts.regex).test(buffer.join(''));
 	}
@@ -776,7 +776,7 @@ $(document).ready(function(){
 
 #### hasMaskedValue
 
-Check whether the returned value is masked or not; currently only works reliably when using jquery.val fn to retrieve the value 
+Check whether the returned value is masked or not; currently only works reliably when using jquery.val fn to retrieve the value
 
 ```javascript
 $(document).ready(function(){
@@ -785,8 +785,8 @@ $(document).ready(function(){
 
 	var val = $("#test").val();
     if($("#test").inputmask("hasMaskedValue"))
-	  validateMaskedValue(val); 
-   else validateValue(val); 
+	  validateMaskedValue(val);
+   else validateValue(val);
 });
 ```
 
@@ -848,7 +848,7 @@ You can define within a definition to automatically lowercase or uppercase the e
 Casing can be null, "upper" or "lower"
 ```javascript
     $.extend($.inputmask.defaults.definitions, {
-        'A': { 
+        'A': {
             validator: "[A-Za-z]",
             cardinality: 1,
             casing: "upper" //auto uppercasing
@@ -907,7 +907,7 @@ $(document).ready(function(){
 ```
 ### data-inputmask-<option\> attribute
 
-All options can also be passed through data-attributes. 
+All options can also be passed through data-attributes.
 
 
 ```html
@@ -1003,7 +1003,7 @@ $(document).ready(function(){
 ### jqueryui.datepicker example
 ```javascript
     $('#calender').datepicker({
-                dateFormat: 'dd/mm/yy',                
+                dateFormat: 'dd/mm/yy',
                 changeMonth: true,
                 changeYear: true
     }).inputmask('dd/mm/yyyy');
@@ -1067,10 +1067,10 @@ Uses the phone mask definitions from https://github.com/andr-04/inputmask-multi
 
 ```javascript
  $(selector).inputmask("phone", {
-                url: "Scripts/jquery.inputmask/phone-codes/phone-codes.json", 
+                url: "Scripts/jquery.inputmask/phone-codes/phone-codes.json",
                 onKeyValidation: function () { //show some metadata in the console
                     console.log($(this).inputmask("getmetadata")["name_en"]);
-                } 
+                }
   });
 ```
 

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.1.64-16",
+  "version": "3.1.64-19",
   "main": [
     "./dist/inputmask/jquery.inputmask.js",
     "./dist/inputmask/jquery.inputmask.extensions.js",

+ 1 - 1
component.json

@@ -2,7 +2,7 @@
     "name": "jquery_inputmask",
     "repository": "robinherbots/jquery.inputmask",
     "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-    "version": "3.1.64-16",
+    "version": "3.1.64-19",
     "keywords": [ "jquery", "plugins", "input", "form", "inputmask", "mask" ],
     "main": "./dist/jquery.inputmask.bundle.js",
     "scripts": [

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
     "name": "robinherbots/jquery.inputmask",
     "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-	"version": "3.1.64-16",
+	"version": "3.1.64-19",
     "type": "library",
     "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
     "homepage": "http://robinherbots.github.io/jquery.inputmask",

+ 1 - 1
dist/inputmask/jquery.inputmask.date.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.1.64-16
+* Version: 3.1.64-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./jquery.inputmask")) : factory(jQuery);

File diff suppressed because it is too large
+ 1 - 1
dist/inputmask/jquery.inputmask.date.extensions.min.js


+ 1 - 1
dist/inputmask/jquery.inputmask.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.1.64-16
+* Version: 3.1.64-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./jquery.inputmask")) : factory(jQuery);

File diff suppressed because it is too large
+ 1 - 1
dist/inputmask/jquery.inputmask.extensions.min.js


+ 16 - 10
dist/inputmask/jquery.inputmask.js

@@ -3,11 +3,15 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.1.64-16
+* Version: 3.1.64-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery")) : factory(jQuery);
 }(function($) {
+    function inputmask(options) {
+        this.opts = $.extend(!0, {}, this.defaults, options), this.noMasksCache = options && void 0 !== options.definitions, 
+        resolveAlias(this.opts.alias, options, this.opts);
+    }
     function isInputEventSupported(eventName) {
         var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
         return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]), 
@@ -255,8 +259,7 @@
         }
         function stripValidPositions(start, end, nocheck, strict) {
             var i, startPos = start;
-            getMaskSet().p = start, void 0 != getMaskSet().validPositions[start] && getMaskSet().validPositions[start].input == opts.radixPoint && (end++, 
-            startPos++);
+            getMaskSet().p = start;
             for (i = startPos; end > i; i++) void 0 != getMaskSet().validPositions[i] && (nocheck === !0 || 0 != opts.canClearPosition(getMaskSet(), i, getLastValidPosition(), strict, opts)) && delete getMaskSet().validPositions[i];
             for (resetMaskSet(!0), i = startPos + 1; i <= getLastValidPosition(); ) {
                 for (;void 0 != getMaskSet().validPositions[startPos]; ) startPos++;
@@ -267,7 +270,7 @@
                 i++), startPos++) : i++;
             }
             var lvp = getLastValidPosition(), ml = getMaskLength();
-            for (lvp >= start && void 0 != getMaskSet().validPositions[lvp] && getMaskSet().validPositions[lvp].input == opts.radixPoint && delete getMaskSet().validPositions[lvp], 
+            for (void 0 != getMaskSet().validPositions[lvp] && getMaskSet().validPositions[lvp].input == opts.radixPoint && delete getMaskSet().validPositions[lvp], 
             i = lvp + 1; ml >= i; i++) getMaskSet().validPositions[i] && delete getMaskSet().validPositions[i];
             resetMaskSet(!0);
         }
@@ -865,7 +868,9 @@
                 var pend = pos.end;
                 pos.end = pos.begin, pos.begin = pend;
             }
-            if (k == $.inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || 0 == opts.insertMode) ? pos.begin = seekPrevious(pos.begin) : k == $.inputmask.keyCode.DELETE && pos.begin == pos.end && (pos.end = isMask(pos.end) ? pos.end + 1 : seekNext(pos.end) + 1), 
+            if (k == $.inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || 0 == opts.insertMode) ? (pos.begin = seekPrevious(pos.begin), 
+            void 0 != getMaskSet().validPositions[pos.begin] && getMaskSet().validPositions[pos.begin].input == opts.radixPoint && pos.begin--) : k == $.inputmask.keyCode.DELETE && pos.begin == pos.end && (pos.end = isMask(pos.end) ? pos.end + 1 : seekNext(pos.end) + 1, 
+            void 0 != getMaskSet().validPositions[pos.begin] && getMaskSet().validPositions[pos.begin].input == opts.radixPoint && pos.end++), 
             stripValidPositions(pos.begin, pos.end, !1, strict), strict !== !0) {
                 generalize();
                 var lvp = getLastValidPosition(pos.begin);
@@ -1139,10 +1144,7 @@
         }
     }
     if (void 0 === $.fn.inputmask) {
-        var ua = navigator.userAgent, iphone = null !== ua.match(new RegExp("iphone", "i")), androidchrome = (null !== ua.match(new RegExp("android.*safari.*", "i")), 
-        null !== ua.match(new RegExp("android.*chrome.*", "i"))), androidfirefox = null !== ua.match(new RegExp("android.*firefox.*", "i")), PasteEventType = (/Kindle/i.test(ua) || /Silk/i.test(ua) || /KFTT/i.test(ua) || /KFOT/i.test(ua) || /KFJWA/i.test(ua) || /KFJWI/i.test(ua) || /KFSOWI/i.test(ua) || /KFTHWA/i.test(ua) || /KFTHWI/i.test(ua) || /KFAPWA/i.test(ua) || /KFAPWI/i.test(ua), 
-        isInputEventSupported("paste") ? "paste" : isInputEventSupported("input") ? "input" : "propertychange");
-        $.inputmask = {
+        inputmask.prototype = {
             defaults: {
                 placeholder: "_",
                 optionalmarker: {
@@ -1265,7 +1267,11 @@
                     value: value
                 }, generateMaskSet(opts, options && void 0 !== options.definitions), opts);
             }
-        }, $.fn.inputmask = function(fn, options) {
+        };
+        var ua = navigator.userAgent, iphone = null !== ua.match(new RegExp("iphone", "i")), androidchrome = (null !== ua.match(new RegExp("android.*safari.*", "i")), 
+        null !== ua.match(new RegExp("android.*chrome.*", "i"))), androidfirefox = null !== ua.match(new RegExp("android.*firefox.*", "i")), PasteEventType = (/Kindle/i.test(ua) || /Silk/i.test(ua) || /KFTT/i.test(ua) || /KFOT/i.test(ua) || /KFJWA/i.test(ua) || /KFJWI/i.test(ua) || /KFSOWI/i.test(ua) || /KFTHWA/i.test(ua) || /KFTHWI/i.test(ua) || /KFAPWA/i.test(ua) || /KFAPWI/i.test(ua), 
+        isInputEventSupported("paste") ? "paste" : isInputEventSupported("input") ? "input" : "propertychange");
+        $.inputmask = inputmask.prototype, $.fn.inputmask = function(fn, options) {
             function importAttributeOptions(npt, opts, importedOptionsContainer) {
                 var $npt = $(npt);
                 $npt.data("inputmask-alias") && resolveAlias($npt.data("inputmask-alias"), $.extend(!0, {}, opts), opts);

File diff suppressed because it is too large
+ 3 - 3
dist/inputmask/jquery.inputmask.min.js


+ 5 - 4
dist/inputmask/jquery.inputmask.numeric.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.1.64-16
+* Version: 3.1.64-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./jquery.inputmask")) : factory(jQuery);
@@ -58,7 +58,7 @@
                 buffer.length >= opts.suffix.length && buffer.join("").indexOf(opts.suffix) == buffer.length - opts.suffix.length && (buffer.length = buffer.length - opts.suffix.length, 
                 suffixStripped = !0), pos = pos >= buffer.length ? buffer.length - 1 : pos < opts.prefix.length ? opts.prefix.length : pos;
                 var needsRefresh = !1, charAtPos = buffer[pos];
-                if ("" == opts.groupSeparator || -1 != $.inArray(opts.radixPoint, buffer) && pos >= $.inArray(opts.radixPoint, buffer) || new RegExp("[" + $.inputmask.escapeRegex(opts.negationSymbol.front) + "+]").test(charAtPos)) {
+                if ("" == opts.groupSeparator || -1 != $.inArray(opts.radixPoint, buffer) && pos > $.inArray(opts.radixPoint, buffer) || new RegExp("[" + $.inputmask.escapeRegex(opts.negationSymbol.front) + "+]").test(charAtPos)) {
                     if (suffixStripped) for (var i = 0, l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
                     return {
                         pos: pos
@@ -66,7 +66,7 @@
                 }
                 var cbuf = buffer.slice();
                 charAtPos == opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]), 
-                reformatOnly ? cbuf[pos] = "?" : cbuf.splice(pos, 0, "?");
+                reformatOnly ? charAtPos != opts.radixPoint && (cbuf[pos] = "?") : cbuf.splice(pos, 0, "?");
                 var bufVal = cbuf.join(""), bufValOrigin = bufVal;
                 if (bufVal.length > 0 && opts.autoGroup || reformatOnly && -1 != bufVal.indexOf(opts.groupSeparator)) {
                     var escapedGroupSeparator = $.inputmask.escapeRegex(opts.groupSeparator);
@@ -79,7 +79,8 @@
                 needsRefresh = bufValOrigin != bufVal, buffer.length = bufVal.length;
                 for (var i = 0, l = bufVal.length; l > i; i++) buffer[i] = bufVal.charAt(i);
                 var newPos = $.inArray("?", buffer);
-                if (reformatOnly ? buffer[newPos] = charAtPos : buffer.splice(newPos, 1), !needsRefresh && suffixStripped) for (var i = 0, l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
+                if (-1 == newPos && (newPos = pos), reformatOnly ? buffer[newPos] = charAtPos : buffer.splice(newPos, 1), 
+                !needsRefresh && suffixStripped) for (var i = 0, l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
                 return {
                     pos: newPos,
                     refreshFromBuffer: needsRefresh,

File diff suppressed because it is too large
+ 2 - 2
dist/inputmask/jquery.inputmask.numeric.extensions.min.js


+ 1 - 1
dist/inputmask/jquery.inputmask.phone.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.1.64-16
+* Version: 3.1.64-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./jquery.inputmask")) : factory(jQuery);

File diff suppressed because it is too large
+ 1 - 1
dist/inputmask/jquery.inputmask.phone.extensions.min.js


+ 1 - 1
dist/inputmask/jquery.inputmask.regex.extensions.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.1.64-16
+* Version: 3.1.64-19
 */
 !function(factory) {
     "function" == typeof define && define.amd ? define([ "jquery", "./jquery.inputmask" ], factory) : "object" == typeof exports ? module.exports = factory(require("jquery"), require("./jquery.inputmask")) : factory(jQuery);

File diff suppressed because it is too large
+ 1 - 1
dist/inputmask/jquery.inputmask.regex.extensions.min.js


+ 20 - 13
dist/jquery.inputmask.bundle.js

@@ -3,9 +3,13 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2015 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 3.1.64-16
+* Version: 3.1.64-19
 */
 !function($) {
+    function inputmask(options) {
+        this.opts = $.extend(!0, {}, this.defaults, options), this.noMasksCache = options && void 0 !== options.definitions, 
+        resolveAlias(this.opts.alias, options, this.opts);
+    }
     function isInputEventSupported(eventName) {
         var el = document.createElement("input"), evName = "on" + eventName, isSupported = evName in el;
         return isSupported || (el.setAttribute(evName, "return;"), isSupported = "function" == typeof el[evName]), 
@@ -253,8 +257,7 @@
         }
         function stripValidPositions(start, end, nocheck, strict) {
             var i, startPos = start;
-            getMaskSet().p = start, void 0 != getMaskSet().validPositions[start] && getMaskSet().validPositions[start].input == opts.radixPoint && (end++, 
-            startPos++);
+            getMaskSet().p = start;
             for (i = startPos; end > i; i++) void 0 != getMaskSet().validPositions[i] && (nocheck === !0 || 0 != opts.canClearPosition(getMaskSet(), i, getLastValidPosition(), strict, opts)) && delete getMaskSet().validPositions[i];
             for (resetMaskSet(!0), i = startPos + 1; i <= getLastValidPosition(); ) {
                 for (;void 0 != getMaskSet().validPositions[startPos]; ) startPos++;
@@ -265,7 +268,7 @@
                 i++), startPos++) : i++;
             }
             var lvp = getLastValidPosition(), ml = getMaskLength();
-            for (lvp >= start && void 0 != getMaskSet().validPositions[lvp] && getMaskSet().validPositions[lvp].input == opts.radixPoint && delete getMaskSet().validPositions[lvp], 
+            for (void 0 != getMaskSet().validPositions[lvp] && getMaskSet().validPositions[lvp].input == opts.radixPoint && delete getMaskSet().validPositions[lvp], 
             i = lvp + 1; ml >= i; i++) getMaskSet().validPositions[i] && delete getMaskSet().validPositions[i];
             resetMaskSet(!0);
         }
@@ -863,7 +866,9 @@
                 var pend = pos.end;
                 pos.end = pos.begin, pos.begin = pend;
             }
-            if (k == $.inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || 0 == opts.insertMode) ? pos.begin = seekPrevious(pos.begin) : k == $.inputmask.keyCode.DELETE && pos.begin == pos.end && (pos.end = isMask(pos.end) ? pos.end + 1 : seekNext(pos.end) + 1), 
+            if (k == $.inputmask.keyCode.BACKSPACE && (pos.end - pos.begin < 1 || 0 == opts.insertMode) ? (pos.begin = seekPrevious(pos.begin), 
+            void 0 != getMaskSet().validPositions[pos.begin] && getMaskSet().validPositions[pos.begin].input == opts.radixPoint && pos.begin--) : k == $.inputmask.keyCode.DELETE && pos.begin == pos.end && (pos.end = isMask(pos.end) ? pos.end + 1 : seekNext(pos.end) + 1, 
+            void 0 != getMaskSet().validPositions[pos.begin] && getMaskSet().validPositions[pos.begin].input == opts.radixPoint && pos.end++), 
             stripValidPositions(pos.begin, pos.end, !1, strict), strict !== !0) {
                 generalize();
                 var lvp = getLastValidPosition(pos.begin);
@@ -1137,10 +1142,7 @@
         }
     }
     if (void 0 === $.fn.inputmask) {
-        var ua = navigator.userAgent, iphone = null !== ua.match(new RegExp("iphone", "i")), androidchrome = (null !== ua.match(new RegExp("android.*safari.*", "i")), 
-        null !== ua.match(new RegExp("android.*chrome.*", "i"))), androidfirefox = null !== ua.match(new RegExp("android.*firefox.*", "i")), PasteEventType = (/Kindle/i.test(ua) || /Silk/i.test(ua) || /KFTT/i.test(ua) || /KFOT/i.test(ua) || /KFJWA/i.test(ua) || /KFJWI/i.test(ua) || /KFSOWI/i.test(ua) || /KFTHWA/i.test(ua) || /KFTHWI/i.test(ua) || /KFAPWA/i.test(ua) || /KFAPWI/i.test(ua), 
-        isInputEventSupported("paste") ? "paste" : isInputEventSupported("input") ? "input" : "propertychange");
-        $.inputmask = {
+        inputmask.prototype = {
             defaults: {
                 placeholder: "_",
                 optionalmarker: {
@@ -1263,7 +1265,11 @@
                     value: value
                 }, generateMaskSet(opts, options && void 0 !== options.definitions), opts);
             }
-        }, $.fn.inputmask = function(fn, options) {
+        };
+        var ua = navigator.userAgent, iphone = null !== ua.match(new RegExp("iphone", "i")), androidchrome = (null !== ua.match(new RegExp("android.*safari.*", "i")), 
+        null !== ua.match(new RegExp("android.*chrome.*", "i"))), androidfirefox = null !== ua.match(new RegExp("android.*firefox.*", "i")), PasteEventType = (/Kindle/i.test(ua) || /Silk/i.test(ua) || /KFTT/i.test(ua) || /KFOT/i.test(ua) || /KFJWA/i.test(ua) || /KFJWI/i.test(ua) || /KFSOWI/i.test(ua) || /KFTHWA/i.test(ua) || /KFTHWI/i.test(ua) || /KFAPWA/i.test(ua) || /KFAPWI/i.test(ua), 
+        isInputEventSupported("paste") ? "paste" : isInputEventSupported("input") ? "input" : "propertychange");
+        $.inputmask = inputmask.prototype, $.fn.inputmask = function(fn, options) {
             function importAttributeOptions(npt, opts, importedOptionsContainer) {
                 var $npt = $(npt);
                 $npt.data("inputmask-alias") && resolveAlias($npt.data("inputmask-alias"), $.extend(!0, {}, opts), opts);
@@ -1962,7 +1968,7 @@
                 buffer.length >= opts.suffix.length && buffer.join("").indexOf(opts.suffix) == buffer.length - opts.suffix.length && (buffer.length = buffer.length - opts.suffix.length, 
                 suffixStripped = !0), pos = pos >= buffer.length ? buffer.length - 1 : pos < opts.prefix.length ? opts.prefix.length : pos;
                 var needsRefresh = !1, charAtPos = buffer[pos];
-                if ("" == opts.groupSeparator || -1 != $.inArray(opts.radixPoint, buffer) && pos >= $.inArray(opts.radixPoint, buffer) || new RegExp("[" + $.inputmask.escapeRegex(opts.negationSymbol.front) + "+]").test(charAtPos)) {
+                if ("" == opts.groupSeparator || -1 != $.inArray(opts.radixPoint, buffer) && pos > $.inArray(opts.radixPoint, buffer) || new RegExp("[" + $.inputmask.escapeRegex(opts.negationSymbol.front) + "+]").test(charAtPos)) {
                     if (suffixStripped) for (var i = 0, l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
                     return {
                         pos: pos
@@ -1970,7 +1976,7 @@
                 }
                 var cbuf = buffer.slice();
                 charAtPos == opts.groupSeparator && (cbuf.splice(pos--, 1), charAtPos = cbuf[pos]), 
-                reformatOnly ? cbuf[pos] = "?" : cbuf.splice(pos, 0, "?");
+                reformatOnly ? charAtPos != opts.radixPoint && (cbuf[pos] = "?") : cbuf.splice(pos, 0, "?");
                 var bufVal = cbuf.join(""), bufValOrigin = bufVal;
                 if (bufVal.length > 0 && opts.autoGroup || reformatOnly && -1 != bufVal.indexOf(opts.groupSeparator)) {
                     var escapedGroupSeparator = $.inputmask.escapeRegex(opts.groupSeparator);
@@ -1983,7 +1989,8 @@
                 needsRefresh = bufValOrigin != bufVal, buffer.length = bufVal.length;
                 for (var i = 0, l = bufVal.length; l > i; i++) buffer[i] = bufVal.charAt(i);
                 var newPos = $.inArray("?", buffer);
-                if (reformatOnly ? buffer[newPos] = charAtPos : buffer.splice(newPos, 1), !needsRefresh && suffixStripped) for (var i = 0, l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
+                if (-1 == newPos && (newPos = pos), reformatOnly ? buffer[newPos] = charAtPos : buffer.splice(newPos, 1), 
+                !needsRefresh && suffixStripped) for (var i = 0, l = opts.suffix.length; l > i; i++) buffer.push(opts.suffix.charAt(i));
                 return {
                     pos: newPos,
                     refreshFromBuffer: needsRefresh,

File diff suppressed because it is too large
+ 4 - 4
dist/jquery.inputmask.bundle.min.js


File diff suppressed because it is too large
+ 2592 - 2317
js/jquery.inputmask.js


+ 6 - 2
js/jquery.inputmask.numeric.extensions.js

@@ -103,7 +103,7 @@ Optional extensions on the jquery.inputmask base
 
                 var needsRefresh = false, charAtPos = buffer[pos];
                 if (opts.groupSeparator == "" ||
-                        ($.inArray(opts.radixPoint, buffer) != -1 && pos >= $.inArray(opts.radixPoint, buffer)) ||
+                        ($.inArray(opts.radixPoint, buffer) != -1 && pos > $.inArray(opts.radixPoint, buffer)) ||
                         new RegExp('[' + $.inputmask.escapeRegex(opts.negationSymbol.front) + '\+]').test(charAtPos)
                 ) {
                     if (suffixStripped) {
@@ -114,12 +114,15 @@ Optional extensions on the jquery.inputmask base
                     //console.log("return input " + buffer);
                     return { pos: pos };
                 }
+
                 var cbuf = buffer.slice();
                 if (charAtPos == opts.groupSeparator) {
                     cbuf.splice(pos--, 1);
                     charAtPos = cbuf[pos];
                 }
-                if (reformatOnly) cbuf[pos] = "?"; else cbuf.splice(pos, 0, "?"); //set position indicator
+                if (reformatOnly) {
+                    if(charAtPos != opts.radixPoint) cbuf[pos] = "?";
+                } else cbuf.splice(pos, 0, "?"); //set position indicator
                 var bufVal = cbuf.join(''), bufValOrigin = bufVal;
                 if (bufVal.length > 0 && opts.autoGroup || (reformatOnly && bufVal.indexOf(opts.groupSeparator) != -1)) {
                     var escapedGroupSeparator = $.inputmask.escapeRegex(opts.groupSeparator);
@@ -144,6 +147,7 @@ Optional extensions on the jquery.inputmask base
                     buffer[i] = bufVal.charAt(i);
                 }
                 var newPos = $.inArray("?", buffer);
+                if(newPos == -1) newPos = pos;
                 if (reformatOnly) buffer[newPos] = charAtPos; else buffer.splice(newPos, 1);
 
                 if (!needsRefresh && suffixStripped) {

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "jquery.inputmask",
-  "version": "3.1.64-16",
+  "version": "3.1.64-19",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": "./dist/inputmask/jquery.inputmask.js",
   "files": [

+ 38 - 7
qunit/tests_numeric.js

@@ -308,8 +308,8 @@ test("inputmask(\"decimal\", { autoGroup: true, groupSeparator: \",\" }\") - inp
     $("#testmask").remove();
 });
 
-test("inputmask(\"decimal\", { autoGroup: true, groupSeparator: \",\", decimalProtect: true }\") - input 12345.123 + remove .123", function () {
-    var $fixture = $("#qunit-fixture");
+asyncTest("inputmask(\"decimal\", { autoGroup: true, groupSeparator: \",\", decimalProtect: true }\") - input 12345.123 + remove .123", function () {
+    var $fixture = $("body");
     $fixture.append('<input type="text" id="testmask" />');
     $("#testmask").inputmask("decimal", { autoGroup: true, groupSeparator: ",", decimalProtect: true });
 
@@ -319,10 +319,12 @@ test("inputmask(\"decimal\", { autoGroup: true, groupSeparator: \",\", decimalPr
     $("#testmask").SendKey($.inputmask.keyCode.BACKSPACE);
     $("#testmask").SendKey($.inputmask.keyCode.BACKSPACE);
     $("#testmask").SendKey($.inputmask.keyCode.BACKSPACE);
-    $("#testmask").SendKey($.inputmask.keyCode.BACKSPACE);
-
-    equal($("#testmask").val(), "12,345", "Result " + $("#testmask").val());
-    $("#testmask").remove();
+    $("#testmask").blur();
+    setTimeout(function(){
+      start();
+      equal($("#testmask").val(), "12,345", "Result " + $("#testmask").val());
+      //$("#testmask").remove();
+    }, 0);
 });
 test("inputmask(\"decimal\", { autoGroup: true, groupSeparator: \",\" }\") - input 12345.123 + replace .123 => .789", function () {
     var $fixture = $("#qunit-fixture");
@@ -1246,4 +1248,33 @@ test("decimal alias - type 12345.12 add 6 in front - freeze - DatXN", function (
     $("#testmask").SendKey("6");
     equal($("#testmask")[0]._valueGet(), "12345.12", "Result " + $("#testmask")[0]._valueGet());
     $("#testmask").remove();
-});
+});
+
+test("decimal alias - type 123456789 - add , before 8 - jpontet", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("decimal", {allowMinus: true, integerDigits: 12, digits: 2, radixPoint: ",", autoGroup: true, groupSeparator: " ", groupSize: 3, rightAlign: false});
+
+    $("#testmask")[0].focus();
+    $("#testmask").click();
+    $("#testmask").Type("123456789");
+    $.caret($("#testmask"), 9);
+    $("#testmask").SendKey(",");
+    equal($("#testmask")[0]._valueGet(), "1 234 567,89", "Result " + $("#testmask")[0]._valueGet());
+    $("#testmask").remove();
+});
+
+test("decimal alias - type 123456789 - add , before 8 - backspace - jpontet", function () {
+    var $fixture = $("#qunit-fixture");
+    $fixture.append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("decimal", {allowMinus: true, integerDigits: 12, digits: 2, radixPoint: ",", autoGroup: true, groupSeparator: " ", groupSize: 3, rightAlign: false});
+
+    $("#testmask")[0].focus();
+    $("#testmask").click();
+    $("#testmask").Type("123456789");
+    $.caret($("#testmask"), 9);
+    $("#testmask").SendKey(",");
+    $("#testmask").SendKey($.inputmask.keyCode.BACKSPACE);
+    equal($("#testmask")[0]._valueGet(), "123 456,89", "Result " + $("#testmask")[0]._valueGet());
+    $("#testmask").remove();
+});