ソースを参照

Minor fixes - reset the placeholder when used in optional masks. Still needs some rework.
fix getmasklength when repeat: 0

Robin 15 年 前
コミット
248141fbb3
1 ファイル変更6 行追加3 行削除
  1. 6 3
      jquery.inputmask.js

+ 6 - 3
jquery.inputmask.js

@@ -3,7 +3,7 @@ Input Mask plugin for jquery
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 0.2.6
+Version: 0.2.6c
    
 This plugin is based on the masked input plugin written by Josh Bush (digitalbush.com)
 */
@@ -277,7 +277,7 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
 
         function getMaskLength() {
             var calculatedLength = _buffer.length;
-            if (!opts.greedy) {
+            if (!opts.greedy && opts.repeat > 1) {
                 calculatedLength += (_buffer.length * (opts.repeat - 1))
             }
             return calculatedLength - _numberOfRemovedElementsFromMask;
@@ -326,10 +326,13 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
             var test = tests[testPos];
             if (test != undefined) {
                 if (test.optionality && test.offset > 0) {
-                    var firstMaskPosition = isFirstMaskOfBlock(testPos);
+                    var firstMaskPosition = isFirstMaskOfBlock(testPos); //FIXME should be testPos + test.offset
                     if (firstMaskPosition !== false && _numberOfRemovedElementsFromMask >= test.offset) {  //needs fixing does not take multiple optional masks into account
                         if (clearOptionalElement)
                             setBufferElement(buffer, pos, getBufferElement(_buffer, testPos));
+                        for(var i = firstMaskPosition; i < testPos;i++) { //reset placeholders
+                        	setBufferElement(buffer, i, getBufferElement(_buffer, i));
+                        }
                         $.each(_buffer.slice(testPos, testPos + test.offset), function() {
                             buffer.splice(pos++, 0, this.toString());
                         });