Browse Source

fix getmetadata

Robin Herbots 11 years ago
parent
commit
8364df6e36

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "jquery.inputmask",
   "name": "jquery.inputmask",
-  "version": "3.0.73",
+  "version": "3.0.74",
   "main": [
   "main": [
     "./dist/inputmask/jquery.inputmask.js",
     "./dist/inputmask/jquery.inputmask.js",
     "./dist/inputmask/jquery.inputmask.extensions.js",
     "./dist/inputmask/jquery.inputmask.extensions.js",

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 
 build.major = 3
 build.major = 3
 build.minor = 0
 build.minor = 0
-build.revision = 73
+build.revision = 74
 
 
 target = jquery.inputmask.bundle.js
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js
 target.min = jquery.inputmask.bundle.min.js

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


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


+ 31 - 14
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Copyright (c) 2010 - 2014 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: 3.0.73
+* Version: 3.0.74
 */
 */
 
 
 (function (factory) {
 (function (factory) {
@@ -272,7 +272,7 @@
                         }
                         }
                     });
                     });
                 } else {
                 } else {
-                    opts.keepStatic = opts.keepStatic == undefined ? true: opts.keepStatic; //enable by default when passing multiple masks when the option is not explicitly specified
+                    opts.keepStatic = opts.keepStatic == undefined ? true : opts.keepStatic; //enable by default when passing multiple masks when the option is not explicitly specified
                     var hasMetaData = false;
                     var hasMetaData = false;
                     var altMask = "(";
                     var altMask = "(";
                     $.each(opts.mask, function (ndx, msk) {
                     $.each(opts.mask, function (ndx, msk) {
@@ -907,8 +907,7 @@
                 if (writeOut) input._valueSet(""); //initial clear
                 if (writeOut) input._valueSet(""); //initial clear
                 $.each(inputValue, function (ndx, charCode) {
                 $.each(inputValue, function (ndx, charCode) {
                     if (intelliCheck === true) {
                     if (intelliCheck === true) {
-                        var p = getMaskSet()["p"],
-                            lvp = p == -1 ? p : seekPrevious(p),
+                        var lvp = getLastValidPosition(),
                             pos = lvp == -1 ? ndx : seekNext(lvp);
                             pos = lvp == -1 ? ndx : seekNext(lvp);
                         if ($.inArray(charCode, getBufferTemplate().slice(lvp + 1, pos)) == -1) {
                         if ($.inArray(charCode, getBufferTemplate().slice(lvp + 1, pos)) == -1) {
                             keypressEvent.call(input, undefined, true, charCode.charCodeAt(0), false, strict, ndx);
                             keypressEvent.call(input, undefined, true, charCode.charCodeAt(0), false, strict, ndx);
@@ -1753,9 +1752,28 @@
 
 
                         }
                         }
                         break;
                         break;
+                    case "getmetadata":
+                        $el = $(actionObj["el"]);
+                        maskset = $el.data('_inputmask')['maskset'];
+                        opts = $el.data('_inputmask')['opts'];
+                        if ($.isArray(maskset["metadata"])) {
+                            //find last alternation
+                            var alternation, lvp = getLastValidPosition();
+                            for (var firstAlt = lvp; firstAlt >= 0; firstAlt--) {
+                                if (getMaskSet()["validPositions"][firstAlt] && getMaskSet()["validPositions"][firstAlt].alternation != undefined) {
+                                    alternation = getMaskSet()["validPositions"][firstAlt].alternation;
+                                    break;
+                                }
+                            }
+                            if (alternation != undefined) {
+                                return maskset["metadata"][getMaskSet()["validPositions"][lvp].locator[alternation]];
+                            } else return maskset["metadata"][0];
+                        }
+
+                        return maskset["metadata"];
                 }
                 }
             }
             }
-        };
+        }
 
 
         $.inputmask = {
         $.inputmask = {
             //options default
             //options default
@@ -1890,8 +1908,7 @@
                         } else return true;
                         } else return true;
                     case "getmetadata": //return mask metadata if exists
                     case "getmetadata": //return mask metadata if exists
                         if (this.data(targetData)) {
                         if (this.data(targetData)) {
-                            maskset = this.data(targetData)['maskset'];
-                            return maskset['metadata'];
+                            return targetScope({ "action": "getmetadata", "el": this });
                         }
                         }
                         else return undefined;
                         else return undefined;
                     case "_detectScope":
                     case "_detectScope":
@@ -1952,7 +1969,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 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: 3.0.73
+Version: 3.0.74
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2080,7 +2097,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 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: 3.0.73
+Version: 3.0.74
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2576,7 +2593,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 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: 3.0.73
+Version: 3.0.74
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2836,7 +2853,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 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: 3.0.73
+Version: 3.0.74
 
 
 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
@@ -3030,7 +3047,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 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: 3.0.73
+Version: 3.0.74
 
 
 Phone extension.
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks
 When using this extension make sure you specify the correct url to get the masks
@@ -3075,7 +3092,7 @@ When using this extension make sure you specify the correct url to get the masks
                     }
                     }
                 });
                 });
 
 
-                maskList.splice(0, 0, "+pp-pppppppppp");
+                maskList.splice(0, 0, "+pp(pp)pppppppp");
                 return maskList;
                 return maskList;
             },
             },
             nojumps: true,
             nojumps: true,
@@ -3104,7 +3121,7 @@ When using this extension make sure you specify the correct url to get the masks
                     }
                     }
                 });
                 });
 
 
-                maskList.splice(0, 0, "+32-pppppppppp");
+                maskList.splice(0, 0, "+32(pp)pppppppp");
                 return maskList;
                 return maskList;
             },
             },
             nojumps: true,
             nojumps: true,

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


+ 1 - 1
jquery.inputmask.jquery.json

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

+ 23 - 6
js/jquery.inputmask.js

@@ -272,7 +272,7 @@
                         }
                         }
                     });
                     });
                 } else {
                 } else {
-                    opts.keepStatic = opts.keepStatic == undefined ? true: opts.keepStatic; //enable by default when passing multiple masks when the option is not explicitly specified
+                    opts.keepStatic = opts.keepStatic == undefined ? true : opts.keepStatic; //enable by default when passing multiple masks when the option is not explicitly specified
                     var hasMetaData = false;
                     var hasMetaData = false;
                     var altMask = "(";
                     var altMask = "(";
                     $.each(opts.mask, function (ndx, msk) {
                     $.each(opts.mask, function (ndx, msk) {
@@ -907,8 +907,7 @@
                 if (writeOut) input._valueSet(""); //initial clear
                 if (writeOut) input._valueSet(""); //initial clear
                 $.each(inputValue, function (ndx, charCode) {
                 $.each(inputValue, function (ndx, charCode) {
                     if (intelliCheck === true) {
                     if (intelliCheck === true) {
-                        var p = getMaskSet()["p"],
-                            lvp = p == -1 ? p : seekPrevious(p),
+                        var lvp = getLastValidPosition(),
                             pos = lvp == -1 ? ndx : seekNext(lvp);
                             pos = lvp == -1 ? ndx : seekNext(lvp);
                         if ($.inArray(charCode, getBufferTemplate().slice(lvp + 1, pos)) == -1) {
                         if ($.inArray(charCode, getBufferTemplate().slice(lvp + 1, pos)) == -1) {
                             keypressEvent.call(input, undefined, true, charCode.charCodeAt(0), false, strict, ndx);
                             keypressEvent.call(input, undefined, true, charCode.charCodeAt(0), false, strict, ndx);
@@ -1753,9 +1752,28 @@
 
 
                         }
                         }
                         break;
                         break;
+                    case "getmetadata":
+                        $el = $(actionObj["el"]);
+                        maskset = $el.data('_inputmask')['maskset'];
+                        opts = $el.data('_inputmask')['opts'];
+                        if ($.isArray(maskset["metadata"])) {
+                            //find last alternation
+                            var alternation, lvp = getLastValidPosition();
+                            for (var firstAlt = lvp; firstAlt >= 0; firstAlt--) {
+                                if (getMaskSet()["validPositions"][firstAlt] && getMaskSet()["validPositions"][firstAlt].alternation != undefined) {
+                                    alternation = getMaskSet()["validPositions"][firstAlt].alternation;
+                                    break;
+                                }
+                            }
+                            if (alternation != undefined) {
+                                return maskset["metadata"][getMaskSet()["validPositions"][lvp].locator[alternation]];
+                            } else return maskset["metadata"][0];
+                        }
+
+                        return maskset["metadata"];
                 }
                 }
             }
             }
-        };
+        }
 
 
         $.inputmask = {
         $.inputmask = {
             //options default
             //options default
@@ -1890,8 +1908,7 @@
                         } else return true;
                         } else return true;
                     case "getmetadata": //return mask metadata if exists
                     case "getmetadata": //return mask metadata if exists
                         if (this.data(targetData)) {
                         if (this.data(targetData)) {
-                            maskset = this.data(targetData)['maskset'];
-                            return maskset['metadata'];
+                            return targetScope({ "action": "getmetadata", "el": this });
                         }
                         }
                         else return undefined;
                         else return undefined;
                     case "_detectScope":
                     case "_detectScope":

+ 2 - 2
js/jquery.inputmask.phone.extensions.js

@@ -48,7 +48,7 @@ When using this extension make sure you specify the correct url to get the masks
                     }
                     }
                 });
                 });
 
 
-                maskList.splice(0, 0, "+pp-pppppppppp");
+                maskList.splice(0, 0, "+pp(pp)pppppppp");
                 return maskList;
                 return maskList;
             },
             },
             nojumps: true,
             nojumps: true,
@@ -77,7 +77,7 @@ When using this extension make sure you specify the correct url to get the masks
                     }
                     }
                 });
                 });
 
 
-                maskList.splice(0, 0, "+32-pppppppppp");
+                maskList.splice(0, 0, "+32(pp)pppppppp");
                 return maskList;
                 return maskList;
             },
             },
             nojumps: true,
             nojumps: true,

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "jquery.inputmask",
   "name": "jquery.inputmask",
-  "version": "3.0.73",
+  "version": "3.0.74",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "description": "jquery.inputmask is a jquery plugin which create an input mask.",
   "main": [
   "main": [
     "./dist/inputmask/jquery.inputmask.js",
     "./dist/inputmask/jquery.inputmask.js",