Browse Source

update checkval + phone + package.json

Robin Herbots 11 years ago
parent
commit
d145e37e78

+ 3 - 3
dist/inputmask/jquery.inputmask.js

@@ -527,9 +527,9 @@
         function checkVal(input, writeOut, strict, nptvl) {
             var inputValue = void 0 != nptvl ? nptvl.slice() : input._valueGet().split("");
             if (resetMaskSet(), writeOut && input._valueSet(""), $.each(inputValue, function(ndx, charCode) {
-                var lvp = getLastValidPosition(), pos = -1 == lvp ? ndx : seekNext(lvp);
-                (-1 == $.inArray(charCode, getBufferTemplate().slice(lvp + 1, pos)) || strict) && (keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, strict, strict ? ndx : getMaskSet().p), 
-                strict = strict || ndx > 0 && ndx > getMaskSet().p);
+                var lvp = getLastValidPosition();
+                -1 == $.inArray(charCode, getBufferTemplate().slice(lvp + 1, getMaskSet().p)) || strict ? (keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, strict, strict ? ndx : getMaskSet().p), 
+                strict = strict || ndx > 0 && ndx > getMaskSet().p) : keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, !0, lvp + 1);
             }), writeOut) {
                 var keypressResult = opts.onKeyPress.call(this, void 0, getBuffer(), 0, opts);
                 handleOnKeyResult(input, keypressResult), writeBuffer(input, getBuffer(), $(input).is(":focus") ? seekNext(getLastValidPosition(0)) : void 0);

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

@@ -44,7 +44,12 @@
             alias: "phone",
             url: "phone-codes/phone-be.js",
             maskInit: "+32(pp)pppppppp",
-            nojumpsThreshold: 4
+            nojumpsThreshold: 4,
+            onBeforeMask: function(value) {
+                var processedValue = value.replace(/^0/g, "");
+                return (processedValue.indexOf("32") > 1 || -1 == processedValue.indexOf("32")) && (processedValue = "32" + processedValue), 
+                processedValue;
+            }
         }
     }), $.fn.inputmask;
 });

+ 9 - 4
dist/jquery.inputmask.bundle.js

@@ -525,9 +525,9 @@
         function checkVal(input, writeOut, strict, nptvl) {
             var inputValue = void 0 != nptvl ? nptvl.slice() : input._valueGet().split("");
             if (resetMaskSet(), writeOut && input._valueSet(""), $.each(inputValue, function(ndx, charCode) {
-                var lvp = getLastValidPosition(), pos = -1 == lvp ? ndx : seekNext(lvp);
-                (-1 == $.inArray(charCode, getBufferTemplate().slice(lvp + 1, pos)) || strict) && (keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, strict, strict ? ndx : getMaskSet().p), 
-                strict = strict || ndx > 0 && ndx > getMaskSet().p);
+                var lvp = getLastValidPosition();
+                -1 == $.inArray(charCode, getBufferTemplate().slice(lvp + 1, getMaskSet().p)) || strict ? (keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, strict, strict ? ndx : getMaskSet().p), 
+                strict = strict || ndx > 0 && ndx > getMaskSet().p) : keypressEvent.call(input, void 0, !0, charCode.charCodeAt(0), !1, !0, lvp + 1);
             }), writeOut) {
                 var keypressResult = opts.onKeyPress.call(this, void 0, getBuffer(), 0, opts);
                 handleOnKeyResult(input, keypressResult), writeBuffer(input, getBuffer(), $(input).is(":focus") ? seekNext(getLastValidPosition(0)) : void 0);
@@ -2007,7 +2007,12 @@
             alias: "phone",
             url: "phone-codes/phone-be.js",
             maskInit: "+32(pp)pppppppp",
-            nojumpsThreshold: 4
+            nojumpsThreshold: 4,
+            onBeforeMask: function(value) {
+                var processedValue = value.replace(/^0/g, "");
+                return (processedValue.indexOf("32") > 1 || -1 == processedValue.indexOf("32")) && (processedValue = "32" + processedValue), 
+                processedValue;
+            }
         }
     }), $.fn.inputmask;
 }(jQuery), function($) {

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


+ 4 - 3
js/jquery.inputmask.js

@@ -936,11 +936,12 @@
                 resetMaskSet();
                 if (writeOut) input._valueSet(""); //initial clear
                 $.each(inputValue, function (ndx, charCode) {
-                    var lvp = getLastValidPosition(),
-                        pos = lvp == -1 ? ndx : seekNext(lvp);
-                    if ($.inArray(charCode, getBufferTemplate().slice(lvp + 1, pos)) == -1 || strict) {
+                    var lvp = getLastValidPosition();
+                    if ($.inArray(charCode, getBufferTemplate().slice(lvp + 1, getMaskSet()["p"])) == -1 || strict) {
                         keypressEvent.call(input, undefined, true, charCode.charCodeAt(0), false, strict, strict ? ndx : getMaskSet()["p"]);
                         strict = strict || (ndx > 0 && ndx > getMaskSet()["p"]);
+                    } else {
+                        keypressEvent.call(input, undefined, true, charCode.charCodeAt(0), false, true, lvp + 1);
                     }
 
                 });

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

@@ -56,7 +56,15 @@ When using this extension make sure you specify the correct url to get the masks
             alias: "phone",
             url: "phone-codes/phone-be.js",
             maskInit: "+32(pp)pppppppp",
-            nojumpsThreshold: 4
+            nojumpsThreshold: 4,
+            onBeforeMask: function(value, opts) {
+                var processedValue = value.replace(/^0/g, "");
+                if (processedValue.indexOf("32") > 1 || processedValue.indexOf("32") == -1) {
+                    processedValue = "32" + processedValue;
+                }
+
+                return processedValue;
+            }
         }
     });
     return $.fn.inputmask;

+ 1 - 8
package.json

@@ -2,14 +2,7 @@
   "name": "jquery.inputmask",
   "version": "3.1.27",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
-  "main": [
-    "./dist/inputmask/jquery.inputmask.js",
-    "./dist/inputmask/jquery.inputmask.extensions.js",
-    "./dist/inputmask/jquery.inputmask.date.extensions.js",
-    "./dist/inputmask/jquery.inputmask.numeric.extensions.js",
-    "./dist/inputmask/jquery.inputmask.phone.extensions.js",
-    "./dist/inputmask/jquery.inputmask.regex.extensions.js"
-  ],
+  "main": "./dist/inputmask/jquery.inputmask.js",
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
   },