Browse Source

fix unmaskedvalue + remove option

Robin Herbots 12 years ago
parent
commit
91994846a0

+ 1 - 1
build.properties

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

+ 1 - 1
component.json

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

BIN
dist/jQuery.InputMask.2.2.54.nupkg


BIN
dist/jQuery.InputMask.2.2.55.nupkg


+ 22 - 19
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2013 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 2.2.54
+* Version: 2.2.55
 */
 
 (function ($) {
@@ -104,11 +104,13 @@
                         });
                     case "unmaskedvalue":
                         var $input = $(this), input = this;
-                        masksets = $input.data('_inputmask')['masksets'];
-                        activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
-                        opts = $input.data('_inputmask')['opts'];
-                        return maskScope(masksets, activeMasksetIndex).unmaskedvalue(this);
-                    case "remove":
+                        if ($input.data('_inputmask')) {
+                            masksets = $input.data('_inputmask')['masksets'];
+                            activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
+                            opts = $input.data('_inputmask')['opts'];
+                            return maskScope(masksets, activeMasksetIndex).unmaskedvalue($input);
+                        } else return $input.val();
+                case "remove":
                         return this.each(function () {
                             var $input = $(this), input = this;
                             setTimeout(function () {
@@ -119,7 +121,7 @@
                                     //writeout the unmaskedvalue
                                     input._valueSet(maskScope(masksets, activeMasksetIndex).unmaskedvalue($input, true));
                                     //clear data
-                                    $input.removedata('_inputmask');
+                                    $input.removeData('_inputmask');
                                     //unbind all events
                                     $input.unbind(".inputmask");
                                     $input.removeClass('focus.inputmask');
@@ -642,7 +644,7 @@
                         var index = isRTL ? (opts.numericInput ? ml : ml - ndx) : ndx;
                         if (isMask(isRTL ? index - 1 : index)
                         || (strict !== true && charCode != getBufferElement(getActiveBufferTemplate(), isRTL ? index - 1 : index, true))) {
-                            $(input).trigger("keypress", [true, charCode.charCodeAt(0), writeOut, strict, index]);
+                            $(input).trigger("keypress", [true, charCode.charCodeAt(0), writeOut, strict, index, isRTL]);
                         }
                     });
                     if (strict === true) {
@@ -687,14 +689,13 @@
                     return unmaskedvalue($input, skipDatepickerCheck);
                 };
                 function unmaskedvalue($input, skipDatepickerCheck) {
-                    var input = $input[0];
                     if (getActiveTests() && (skipDatepickerCheck === true || !$input.hasClass('hasDatepicker'))) {
-                        checkVal(input, false, true);
+                        //checkVal(input, false, true);
                         return $.map(getActiveBuffer(), function (element, index) {
                             return isMask(index) && isValid(index, element, true) ? element : null;
                         }).join('');
                     } else {
-                        return input._valueGet();
+                        return $input[0]._valueGet();
                     }
                 }
 
@@ -1087,7 +1088,7 @@
                         var buffer = getActiveBuffer();
                         for (var i = start; i <= end && i < getMaskLength() ; i++) {
                             if (isMask(i)) {
-                                var t = getBufferElement(buffer, i);
+                                var t = getBufferElement(buffer, i, true);
                                 setBufferElement(buffer, i, c, true, isRTL);
                                 if (t != getPlaceHolder(i)) {
                                     var j = seekNext(i);
@@ -1264,7 +1265,9 @@
                         ignorable = $.inArray(k, opts.ignorables) != -1;
                     }
 
-                    function keypressEvent(e, checkval, k, writeOut, strict, ndx) {
+                    function keypressEvent(e, checkval, k, writeOut, strict, ndx, rtl) {
+                        isRTL = rtl == undefined ? isRTL : rtl;
+
                         //Safari 5.1.x - modal dialog fires keypress twice workaround
                         if (k == undefined && skipKeyPressEvent) return false;
                         skipKeyPressEvent = true;
@@ -1322,7 +1325,7 @@
                                     activeMasksetIndex = initialIndex;
                                     checkVal(input, false, true, getActiveBuffer());
                                     if (!opts.insertMode) { //preserve some space
-                                        $.each(masksets, function(ndx, lmnt) {
+                                        $.each(masksets, function (ndx, lmnt) {
                                             activeMasksetIndex = ndx;
                                             isRTL ? shiftL(0, posend) : shiftR(pos.begin, ml, getPlaceHolder(pos.begin), true);
                                             getActiveMaskSet()["lastValidPosition"] = isRTL ? seekPrevious(getActiveMaskSet()["lastValidPosition"]) : seekNext(getActiveMaskSet()["lastValidPosition"]);
@@ -1401,7 +1404,6 @@
                                     });
                                 }
 
-                                console.log(getActiveMaskSet()["p"]);
                                 if (strict !== true) determineActiveMasksetIndex(isRTL);
                                 if (writeOut !== false) {
                                     $.each(results, function (ndx, rslt) {
@@ -1456,7 +1458,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.54
+Version: 2.2.55
 
 Optional extensions on the jquery.inputmask base
 */
@@ -1558,7 +1560,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2012 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.54
+Version: 2.2.55
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2027,7 +2029,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.54
+Version: 2.2.55
 
 Optional extensions on the jquery.inputmask base
 */
@@ -2163,6 +2165,7 @@ Optional extensions on the jquery.inputmask base
                             var newPos = opts.postFormat(buffer, pos, false, opts);
                             return { "pos": newPos };
                         }
+
                         return isValid;
                     },
                     cardinality: 1,
@@ -2189,7 +2192,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2013 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.2.54
+Version: 2.2.55
 
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask

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


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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 16 - 14
js/jquery.inputmask.js

@@ -104,11 +104,13 @@
                         });
                     case "unmaskedvalue":
                         var $input = $(this), input = this;
-                        masksets = $input.data('_inputmask')['masksets'];
-                        activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
-                        opts = $input.data('_inputmask')['opts'];
-                        return maskScope(masksets, activeMasksetIndex).unmaskedvalue(this);
-                    case "remove":
+                        if ($input.data('_inputmask')) {
+                            masksets = $input.data('_inputmask')['masksets'];
+                            activeMasksetIndex = $input.data('_inputmask')['activeMasksetIndex'];
+                            opts = $input.data('_inputmask')['opts'];
+                            return maskScope(masksets, activeMasksetIndex).unmaskedvalue($input);
+                        } else return $input.val();
+                case "remove":
                         return this.each(function () {
                             var $input = $(this), input = this;
                             setTimeout(function () {
@@ -119,7 +121,7 @@
                                     //writeout the unmaskedvalue
                                     input._valueSet(maskScope(masksets, activeMasksetIndex).unmaskedvalue($input, true));
                                     //clear data
-                                    $input.removedata('_inputmask');
+                                    $input.removeData('_inputmask');
                                     //unbind all events
                                     $input.unbind(".inputmask");
                                     $input.removeClass('focus.inputmask');
@@ -642,7 +644,7 @@
                         var index = isRTL ? (opts.numericInput ? ml : ml - ndx) : ndx;
                         if (isMask(isRTL ? index - 1 : index)
                         || (strict !== true && charCode != getBufferElement(getActiveBufferTemplate(), isRTL ? index - 1 : index, true))) {
-                            $(input).trigger("keypress", [true, charCode.charCodeAt(0), writeOut, strict, index]);
+                            $(input).trigger("keypress", [true, charCode.charCodeAt(0), writeOut, strict, index, isRTL]);
                         }
                     });
                     if (strict === true) {
@@ -687,14 +689,13 @@
                     return unmaskedvalue($input, skipDatepickerCheck);
                 };
                 function unmaskedvalue($input, skipDatepickerCheck) {
-                    var input = $input[0];
                     if (getActiveTests() && (skipDatepickerCheck === true || !$input.hasClass('hasDatepicker'))) {
-                        checkVal(input, false, true);
+                        //checkVal(input, false, true);
                         return $.map(getActiveBuffer(), function (element, index) {
                             return isMask(index) && isValid(index, element, true) ? element : null;
                         }).join('');
                     } else {
-                        return input._valueGet();
+                        return $input[0]._valueGet();
                     }
                 }
 
@@ -1087,7 +1088,7 @@
                         var buffer = getActiveBuffer();
                         for (var i = start; i <= end && i < getMaskLength() ; i++) {
                             if (isMask(i)) {
-                                var t = getBufferElement(buffer, i);
+                                var t = getBufferElement(buffer, i, true);
                                 setBufferElement(buffer, i, c, true, isRTL);
                                 if (t != getPlaceHolder(i)) {
                                     var j = seekNext(i);
@@ -1264,7 +1265,9 @@
                         ignorable = $.inArray(k, opts.ignorables) != -1;
                     }
 
-                    function keypressEvent(e, checkval, k, writeOut, strict, ndx) {
+                    function keypressEvent(e, checkval, k, writeOut, strict, ndx, rtl) {
+                        isRTL = rtl == undefined ? isRTL : rtl;
+
                         //Safari 5.1.x - modal dialog fires keypress twice workaround
                         if (k == undefined && skipKeyPressEvent) return false;
                         skipKeyPressEvent = true;
@@ -1322,7 +1325,7 @@
                                     activeMasksetIndex = initialIndex;
                                     checkVal(input, false, true, getActiveBuffer());
                                     if (!opts.insertMode) { //preserve some space
-                                        $.each(masksets, function(ndx, lmnt) {
+                                        $.each(masksets, function (ndx, lmnt) {
                                             activeMasksetIndex = ndx;
                                             isRTL ? shiftL(0, posend) : shiftR(pos.begin, ml, getPlaceHolder(pos.begin), true);
                                             getActiveMaskSet()["lastValidPosition"] = isRTL ? seekPrevious(getActiveMaskSet()["lastValidPosition"]) : seekNext(getActiveMaskSet()["lastValidPosition"]);
@@ -1401,7 +1404,6 @@
                                     });
                                 }
 
-                                console.log(getActiveMaskSet()["p"]);
                                 if (strict !== true) determineActiveMasksetIndex(isRTL);
                                 if (writeOut !== false) {
                                     $.each(results, function (ndx, rslt) {

+ 1 - 0
js/jquery.inputmask.numeric.extensions.js

@@ -139,6 +139,7 @@ Optional extensions on the jquery.inputmask base
                             var newPos = opts.postFormat(buffer, pos, false, opts);
                             return { "pos": newPos };
                         }
+
                         return isValid;
                     },
                     cardinality: 1,