Browse Source

add * as repeat option which allows for neverending repeats

Robin Herbots 12 years ago
parent
commit
5850a252ef

+ 2 - 0
README.md

@@ -108,6 +108,8 @@ $(document).ready(function(){
 });
 });
 ```
 ```
 
 
+With the non-greedy option set to false, you can specify * as repeat.  This makes an endless repeat.
+
 ### get the unmaskedvalue
 ### get the unmaskedvalue
 
 
 ```javascript
 ```javascript

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 
 build.major = 2
 build.major = 2
 build.minor = 2
 build.minor = 2
-build.revision = 63
+build.revision = 64
 
 
 target = jquery.inputmask.bundle.js
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js
 target.min = jquery.inputmask.bundle.min.js

+ 1 - 1
component.json

@@ -1,6 +1,6 @@
 {
 {
     "name": "jquery.inputmask",
     "name": "jquery.inputmask",
-    "version": "2.2.63",
+    "version": "2.2.64",
     "main": "./dist/jquery.inputmask.bundle.js",
     "main": "./dist/jquery.inputmask.bundle.js",
     "dependencies": {
     "dependencies": {
         "jquery": ">=1.5"
         "jquery": ">=1.5"

+ 21 - 12
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2013 Robin Herbots
 * Copyright (c) 2010 - 2013 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 2.2.63
+* Version: 2.2.64
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -21,7 +21,7 @@
                 oncomplete: $.noop, //executes when the mask is complete
                 oncomplete: $.noop, //executes when the mask is complete
                 onincomplete: $.noop, //executes when the mask is incomplete and focus is lost
                 onincomplete: $.noop, //executes when the mask is incomplete and focus is lost
                 oncleared: $.noop, //executes when the mask is cleared
                 oncleared: $.noop, //executes when the mask is cleared
-                repeat: 0, //repetitions of the mask
+                repeat: "*", //repetitions of the mask: * ~ forever, otherwise specify an integer
                 greedy: true, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
                 greedy: true, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
                 autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
                 autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
                 clearMaskOnLostFocus: true,
                 clearMaskOnLostFocus: true,
@@ -63,8 +63,12 @@
                 ignorables: [9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123],
                 ignorables: [9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123],
                 getMaskLength: function (buffer, greedy, repeat, currentBuffer, opts) {
                 getMaskLength: function (buffer, greedy, repeat, currentBuffer, opts) {
                     var calculatedLength = buffer.length;
                     var calculatedLength = buffer.length;
-                    if (!greedy && repeat > 1) {
-                        calculatedLength += (buffer.length * (repeat - 1));
+                    if (!greedy) { 
+                     	if(repeat == "*") {
+                     		calculatedLength = currentBuffer.length + 1;
+                     	} else if(repeat > 1) {
+                        	calculatedLength += (buffer.length * (repeat - 1));
+                    	}
                     }
                     }
                     return calculatedLength;
                     return calculatedLength;
                 }
                 }
@@ -228,6 +232,7 @@
             }
             }
             function getMaskTemplate(mask) {
             function getMaskTemplate(mask) {
                 var escaped = false, outCount = 0, greedy = opts.greedy, repeat = opts.repeat;
                 var escaped = false, outCount = 0, greedy = opts.greedy, repeat = opts.repeat;
+                if(repeat == "*") greedy = false;
                 if (mask.length == 1 && greedy == false) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
                 if (mask.length == 1 && greedy == false) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
                 var singleMask = $.map(mask.split(""), function (element, index) {
                 var singleMask = $.map(mask.split(""), function (element, index) {
                     var outElem = [];
                     var outElem = [];
@@ -1465,7 +1470,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.63
+Version: 2.2.64
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1567,7 +1572,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2012 Robin Herbots
 Copyright (c) 2010 - 2012 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.63
+Version: 2.2.64
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2036,7 +2041,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.63
+Version: 2.2.64
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2046,7 +2051,7 @@ Optional extensions on the jquery.inputmask base
         'decimal': {
         'decimal': {
             mask: "~",
             mask: "~",
             placeholder: "",
             placeholder: "",
-            repeat: 10,
+            repeat: "*",
             greedy: false,
             greedy: false,
             numericInput: true,
             numericInput: true,
             digits: "*", //numer of digits
             digits: "*", //numer of digits
@@ -2059,9 +2064,13 @@ Optional extensions on the jquery.inputmask base
             getMaskLength: function (buffer, greedy, repeat, currentBuffer, opts) { //custom getMaskLength to take the groupSeparator into account
             getMaskLength: function (buffer, greedy, repeat, currentBuffer, opts) { //custom getMaskLength to take the groupSeparator into account
                 var calculatedLength = buffer.length;
                 var calculatedLength = buffer.length;
 
 
-                if (!greedy && repeat > 1) {
-                    calculatedLength += (buffer.length * (repeat - 1));
-                }
+                if (!greedy) { 
+                     	if(repeat == "*") {
+                     		calculatedLength = currentBuffer.length + 1;
+                     	} else if(repeat > 1) {
+                        	calculatedLength += (buffer.length * (repeat - 1));
+                    	}
+                    }
 
 
                 var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
                 var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
                 var escapedRadixPoint = $.inputmask.escapeRegex.call(this, opts.radixPoint);
                 var escapedRadixPoint = $.inputmask.escapeRegex.call(this, opts.radixPoint);
@@ -2199,7 +2208,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.63
+Version: 2.2.64
 
 
 Regex extensions on the jquery.inputmask base
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
 Allows for using regular expressions as a mask

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


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


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


+ 1 - 1
jquery.inputmask.jquery.json

@@ -8,7 +8,7 @@
 		"inputmask",
 		"inputmask",
 		"mask"
 		"mask"
     ],
     ],
-    "version": "2.2.63",
+    "version": "2.2.64",
     "author": {
     "author": {
         "name": "Robin Herbots",
         "name": "Robin Herbots",
         "url": "http://github.com/RobinHerbots/jquery.inputmask"
         "url": "http://github.com/RobinHerbots/jquery.inputmask"

+ 8 - 3
js/jquery.inputmask.js

@@ -21,7 +21,7 @@
                 oncomplete: $.noop, //executes when the mask is complete
                 oncomplete: $.noop, //executes when the mask is complete
                 onincomplete: $.noop, //executes when the mask is incomplete and focus is lost
                 onincomplete: $.noop, //executes when the mask is incomplete and focus is lost
                 oncleared: $.noop, //executes when the mask is cleared
                 oncleared: $.noop, //executes when the mask is cleared
-                repeat: 0, //repetitions of the mask
+                repeat: "*", //repetitions of the mask: * ~ forever, otherwise specify an integer
                 greedy: true, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
                 greedy: true, //true: allocated buffer for the mask and repetitions - false: allocate only if needed
                 autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
                 autoUnmask: false, //automatically unmask when retrieving the value with $.fn.val or value if the browser supports __lookupGetter__ or getOwnPropertyDescriptor
                 clearMaskOnLostFocus: true,
                 clearMaskOnLostFocus: true,
@@ -63,8 +63,12 @@
                 ignorables: [9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123],
                 ignorables: [9, 13, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123],
                 getMaskLength: function (buffer, greedy, repeat, currentBuffer, opts) {
                 getMaskLength: function (buffer, greedy, repeat, currentBuffer, opts) {
                     var calculatedLength = buffer.length;
                     var calculatedLength = buffer.length;
-                    if (!greedy && repeat > 1) {
-                        calculatedLength += (buffer.length * (repeat - 1));
+                    if (!greedy) { 
+                     	if(repeat == "*") {
+                     		calculatedLength = currentBuffer.length + 1;
+                     	} else if(repeat > 1) {
+                        	calculatedLength += (buffer.length * (repeat - 1));
+                    	}
                     }
                     }
                     return calculatedLength;
                     return calculatedLength;
                 }
                 }
@@ -228,6 +232,7 @@
             }
             }
             function getMaskTemplate(mask) {
             function getMaskTemplate(mask) {
                 var escaped = false, outCount = 0, greedy = opts.greedy, repeat = opts.repeat;
                 var escaped = false, outCount = 0, greedy = opts.greedy, repeat = opts.repeat;
+                if(repeat == "*") greedy = false;
                 if (mask.length == 1 && greedy == false) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
                 if (mask.length == 1 && greedy == false) { opts.placeholder = ""; } //hide placeholder with single non-greedy mask
                 var singleMask = $.map(mask.split(""), function (element, index) {
                 var singleMask = $.map(mask.split(""), function (element, index) {
                     var outElem = [];
                     var outElem = [];

+ 8 - 4
js/jquery.inputmask.numeric.extensions.js

@@ -13,7 +13,7 @@ Optional extensions on the jquery.inputmask base
         'decimal': {
         'decimal': {
             mask: "~",
             mask: "~",
             placeholder: "",
             placeholder: "",
-            repeat: 10,
+            repeat: "*",
             greedy: false,
             greedy: false,
             numericInput: true,
             numericInput: true,
             digits: "*", //numer of digits
             digits: "*", //numer of digits
@@ -26,9 +26,13 @@ Optional extensions on the jquery.inputmask base
             getMaskLength: function (buffer, greedy, repeat, currentBuffer, opts) { //custom getMaskLength to take the groupSeparator into account
             getMaskLength: function (buffer, greedy, repeat, currentBuffer, opts) { //custom getMaskLength to take the groupSeparator into account
                 var calculatedLength = buffer.length;
                 var calculatedLength = buffer.length;
 
 
-                if (!greedy && repeat > 1) {
-                    calculatedLength += (buffer.length * (repeat - 1));
-                }
+                if (!greedy) { 
+                     	if(repeat == "*") {
+                     		calculatedLength = currentBuffer.length + 1;
+                     	} else if(repeat > 1) {
+                        	calculatedLength += (buffer.length * (repeat - 1));
+                    	}
+                    }
 
 
                 var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
                 var escapedGroupSeparator = $.inputmask.escapeRegex.call(this, opts.groupSeparator);
                 var escapedRadixPoint = $.inputmask.escapeRegex.call(this, opts.radixPoint);
                 var escapedRadixPoint = $.inputmask.escapeRegex.call(this, opts.radixPoint);