ソースを参照

fix mask cleanup when swithing mask, ... just clearing the tail is not enough in multimask

Robin Herbots 12 年 前
コミット
d507c4b4ff

+ 1 - 1
build.properties

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

BIN
dist/jQuery.InputMask.2.2.8.nupkg


BIN
dist/jQuery.InputMask.2.2.9.nupkg


+ 15 - 28
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.8
+* Version: 2.2.9
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -476,22 +476,7 @@
                     if (activeMaskset['lastValidPosition'] && (isRTL || opts.numericInput) ? activeMaskset['lastValidPosition'] <= pos : activeMaskset['lastValidPosition'] >= pos) {
                     if (activeMaskset['lastValidPosition'] && (isRTL || opts.numericInput) ? activeMaskset['lastValidPosition'] <= pos : activeMaskset['lastValidPosition'] >= pos) {
                         activeMasksetIndex = index;
                         activeMasksetIndex = index;
                         //reset to correct masktemplate
                         //reset to correct masktemplate
-                        if (activeMasksetIndex != currentActiveMasksetIndex) {
-                            var abl = getMaskLength(buffer), bufTemplate = getActiveBuffer();
-                            if (isRTL || opts.numericInput) {
-                                buffer.reverse();
-                                bufTemplate.reverse();
-                            }
-                            buffer.length = pos; //clearout beyond the current
-                            for (var i = pos; i < abl; i++) {
-                                var testPos = determineTestPosition(i);
-                                setBufferElement(buffer, i, getBufferElement(bufTemplate, testPos));
-                            }
-                            if (isRTL) {
-                                buffer.reverse();
-                            }
-                        }
-
+                        checkVal(undefined, buffer, false, false, buffer.join(''), isRTL);
                         return false; //breaks
                         return false; //breaks
                     }
                     }
                 });
                 });
@@ -596,9 +581,10 @@
                 setBufferElement(buffer, pos, getBufferElement(getActiveBuffer(), testPos));
                 setBufferElement(buffer, pos, getBufferElement(getActiveBuffer(), testPos));
             }
             }
 
 
-            function checkVal(input, buffer, clearInvalid, skipRadixHandling) {
-                var isRTL = $(input).data('inputmask')['isRTL'],
-                    inputValue = truncateInput(input._valueGet(), isRTL).split('');
+            //inputData can be used to override the value used to check
+            function checkVal(input, buffer, clearInvalid, skipRadixHandling, inputData, rtl) {
+                var isRTL = rtl != undefined ? rtl : $(input).data('inputmask')['isRTL'],
+                    inputValue = truncateInput(inputData != undefined ? inputData : input._valueGet(), isRTL).split('');
 
 
                 var maskL = getMaskLength(buffer);
                 var maskL = getMaskLength(buffer);
                 if (isRTL) { //align inputValue for RTL/numeric input
                 if (isRTL) { //align inputValue for RTL/numeric input
@@ -712,7 +698,7 @@
 
 
             var caretSavePoint;
             var caretSavePoint;
             function caret(input, begin, end) {
             function caret(input, begin, end) {
-                var npt = input.jquery && input.length > 0 ? input[0] : input, rabge;
+                var npt = input.jquery && input.length > 0 ? input[0] : input, range;
                 if (typeof begin == 'number') {
                 if (typeof begin == 'number') {
                     if (!$(input).is(':visible')) {
                     if (!$(input).is(':visible')) {
                         return;
                         return;
@@ -1122,8 +1108,9 @@
                             caret(input, checkVal(input, buffer, false));
                             caret(input, checkVal(input, buffer, false));
                         } else if ((pos.end - pos.begin) > 1 || ((pos.end - pos.begin) == 1 && opts.insertMode)) { //partial selection
                         } else if ((pos.end - pos.begin) > 1 || ((pos.end - pos.begin) == 1 && opts.insertMode)) { //partial selection
                             clearBuffer(buffer, pos.begin, pos.end);
                             clearBuffer(buffer, pos.begin, pos.end);
-                            determineActiveMasksetIndex(buffer, pos.begin, activeMasksetIndex);
-                            writeBuffer(input, buffer, isRTL ? checkVal(input, buffer, false) : pos.begin);
+                            determineActiveMasksetIndex(buffer, pos.begin, activeMasksetIndex, isRTL);
+                            writeBuffer(input, buffer);
+                            caret(input, isRTL ? checkVal(input, buffer, false) : pos.begin);
                         } else { //handle delete
                         } else { //handle delete
                             var beginPos = android533 ? pos.end : pos.begin;
                             var beginPos = android533 ? pos.end : pos.begin;
                             if (k == opts.keyCode.DELETE) {
                             if (k == opts.keyCode.DELETE) {
@@ -1141,7 +1128,7 @@
                                             beginPos = shiftL(beginPos, maskL);
                                             beginPos = shiftL(beginPos, maskL);
                                         }
                                         }
                                     }
                                     }
-                                    determineActiveMasksetIndex(buffer, beginPos, activeMasksetIndex);
+                                    determineActiveMasksetIndex(buffer, beginPos, activeMasksetIndex, isRTL);
                                     writeBuffer(input, buffer, beginPos);
                                     writeBuffer(input, buffer, beginPos);
                                 }
                                 }
                             } else if (k == opts.keyCode.BACKSPACE) { //handle backspace
                             } else if (k == opts.keyCode.BACKSPACE) { //handle backspace
@@ -1158,7 +1145,7 @@
                                             beginPos = shiftL(beginPos, maskL);
                                             beginPos = shiftL(beginPos, maskL);
                                         }
                                         }
                                     }
                                     }
-                                    determineActiveMasksetIndex(buffer, beginPos, activeMasksetIndex);
+                                    determineActiveMasksetIndex(buffer, beginPos, activeMasksetIndex, isRTL);
                                     writeBuffer(input, buffer, beginPos);
                                     writeBuffer(input, buffer, beginPos);
                                 } else if (activeMasksetIndex > 0) { //retry other masks
                                 } else if (activeMasksetIndex > 0) { //retry other masks
                                     activeMasksetIndex = 0; //reset
                                     activeMasksetIndex = 0; //reset
@@ -1342,7 +1329,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.8
+Version: 2.2.9
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1439,7 +1426,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.8
+Version: 2.2.9
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1932,7 +1919,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.8
+Version: 2.2.9
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */

ファイルの差分が大きいため隠しています
+ 60 - 60
dist/jquery.inputmask.bundle.min.js


ファイルの差分が大きいため隠しています
+ 37 - 37
dist/min/jquery.inputmask.js


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 9 - 23
js/jquery.inputmask.js

@@ -476,22 +476,7 @@
                     if (activeMaskset['lastValidPosition'] && (isRTL || opts.numericInput) ? activeMaskset['lastValidPosition'] <= pos : activeMaskset['lastValidPosition'] >= pos) {
                     if (activeMaskset['lastValidPosition'] && (isRTL || opts.numericInput) ? activeMaskset['lastValidPosition'] <= pos : activeMaskset['lastValidPosition'] >= pos) {
                         activeMasksetIndex = index;
                         activeMasksetIndex = index;
                         //reset to correct masktemplate
                         //reset to correct masktemplate
-                        if (activeMasksetIndex != currentActiveMasksetIndex) {
-                            var abl = getMaskLength(buffer), bufTemplate = getActiveBuffer();
-                            if (isRTL || opts.numericInput) {
-                                buffer.reverse();
-                                bufTemplate.reverse();
-                            }
-                            buffer.length = pos; //clearout beyond the current
-                            for (var i = pos; i < abl; i++) {
-                                var testPos = determineTestPosition(i);
-                                setBufferElement(buffer, i, getBufferElement(bufTemplate, testPos));
-                            }
-                            if (isRTL) {
-                                buffer.reverse();
-                            }
-                        }
-
+                        checkVal(undefined, buffer, false, false, buffer.join(''), isRTL);
                         return false; //breaks
                         return false; //breaks
                     }
                     }
                 });
                 });
@@ -596,9 +581,10 @@
                 setBufferElement(buffer, pos, getBufferElement(getActiveBuffer(), testPos));
                 setBufferElement(buffer, pos, getBufferElement(getActiveBuffer(), testPos));
             }
             }
 
 
-            function checkVal(input, buffer, clearInvalid, skipRadixHandling) {
-                var isRTL = $(input).data('inputmask')['isRTL'],
-                    inputValue = truncateInput(input._valueGet(), isRTL).split('');
+            //inputData can be used to override the value used to check
+            function checkVal(input, buffer, clearInvalid, skipRadixHandling, inputData, rtl) {
+                var isRTL = rtl != undefined ? rtl : $(input).data('inputmask')['isRTL'],
+                    inputValue = truncateInput(inputData != undefined ? inputData : input._valueGet(), isRTL).split('');
 
 
                 var maskL = getMaskLength(buffer);
                 var maskL = getMaskLength(buffer);
                 if (isRTL) { //align inputValue for RTL/numeric input
                 if (isRTL) { //align inputValue for RTL/numeric input
@@ -712,7 +698,7 @@
 
 
             var caretSavePoint;
             var caretSavePoint;
             function caret(input, begin, end) {
             function caret(input, begin, end) {
-                var npt = input.jquery && input.length > 0 ? input[0] : input, rabge;
+                var npt = input.jquery && input.length > 0 ? input[0] : input, range;
                 if (typeof begin == 'number') {
                 if (typeof begin == 'number') {
                     if (!$(input).is(':visible')) {
                     if (!$(input).is(':visible')) {
                         return;
                         return;
@@ -1122,7 +1108,7 @@
                             caret(input, checkVal(input, buffer, false));
                             caret(input, checkVal(input, buffer, false));
                         } else if ((pos.end - pos.begin) > 1 || ((pos.end - pos.begin) == 1 && opts.insertMode)) { //partial selection
                         } else if ((pos.end - pos.begin) > 1 || ((pos.end - pos.begin) == 1 && opts.insertMode)) { //partial selection
                             clearBuffer(buffer, pos.begin, pos.end);
                             clearBuffer(buffer, pos.begin, pos.end);
-                            determineActiveMasksetIndex(buffer, pos.begin, activeMasksetIndex);
+                            determineActiveMasksetIndex(buffer, pos.begin, activeMasksetIndex, isRTL);
                             writeBuffer(input, buffer);
                             writeBuffer(input, buffer);
                             caret(input, isRTL ? checkVal(input, buffer, false) : pos.begin);
                             caret(input, isRTL ? checkVal(input, buffer, false) : pos.begin);
                         } else { //handle delete
                         } else { //handle delete
@@ -1142,7 +1128,7 @@
                                             beginPos = shiftL(beginPos, maskL);
                                             beginPos = shiftL(beginPos, maskL);
                                         }
                                         }
                                     }
                                     }
-                                    determineActiveMasksetIndex(buffer, beginPos, activeMasksetIndex);
+                                    determineActiveMasksetIndex(buffer, beginPos, activeMasksetIndex, isRTL);
                                     writeBuffer(input, buffer, beginPos);
                                     writeBuffer(input, buffer, beginPos);
                                 }
                                 }
                             } else if (k == opts.keyCode.BACKSPACE) { //handle backspace
                             } else if (k == opts.keyCode.BACKSPACE) { //handle backspace
@@ -1159,7 +1145,7 @@
                                             beginPos = shiftL(beginPos, maskL);
                                             beginPos = shiftL(beginPos, maskL);
                                         }
                                         }
                                     }
                                     }
-                                    determineActiveMasksetIndex(buffer, beginPos, activeMasksetIndex);
+                                    determineActiveMasksetIndex(buffer, beginPos, activeMasksetIndex, isRTL);
                                     writeBuffer(input, buffer, beginPos);
                                     writeBuffer(input, buffer, beginPos);
                                 } else if (activeMasksetIndex > 0) { //retry other masks
                                 } else if (activeMasksetIndex > 0) { //retry other masks
                                     activeMasksetIndex = 0; //reset
                                     activeMasksetIndex = 0; //reset