Browse Source

space as groupseparator + data-options fix

Robin Herbots 11 years ago
parent
commit
5a4f350c63

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


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


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


+ 13 - 7
js/jquery.inputmask.js

@@ -1591,12 +1591,13 @@
                                     var clickPosition = isRTL ? TranslatePosition(selectedCaret.begin) : selectedCaret.begin,
                                         lvp = getLastValidPosition(clickPosition),
                                         lastPosition = seekNext(lvp);
-                                    if (clickPosition < lastPosition) {
+                                    if (clickPosition <= lastPosition) {
                                         if (isMask(clickPosition))
                                             caret(input, clickPosition);
-                                        else caret(input, seekNext(clickPosition));
-                                    } else
+                                        else caret(input, lvp == -1 && opts.radixPoint != "" ? $.inArray(opts.radixPoint, getBuffer()) : seekNext(clickPosition));
+                                    } else {
                                         caret(input, lastPosition);
+                                    }
                                 }
                             }, 0);
                         }
@@ -1894,13 +1895,14 @@
             if (typeof fn === "string") {
                 switch (fn) {
                     case "mask":
+                    	importAttributeOptions(this, opts);
                         //resolve possible aliases given by options
                         resolveAlias(opts.alias, options, opts);
                         maskset = generateMaskSet(opts, targetScope !== maskScope);
                         if (maskset.length == 0) { return this; }
 
                         return this.each(function () {
-                            targetScope({ "action": "mask", "el": this }, $.extend(true, {}, maskset), importAttributeOptions(this, opts));
+                            targetScope({ "action": "mask", "el": this }, $.extend(true, {}, maskset), opts);
                         });
                     case "unmaskedvalue":
                         var $input = $(this);
@@ -1940,6 +1942,7 @@
                         }
                         return $.isArray(opts.mask);
                     default:
+                        importAttributeOptions(this, opts);
                         resolveAlias(opts.alias, options, opts);
                         //check if the fn is an alias
                         if (!resolveAlias(fn, options, opts)) {
@@ -1950,17 +1953,17 @@
                         maskset = generateMaskSet(opts, targetScope !== maskScope);
                         if (maskset == undefined) { return this; }
                         return this.each(function () {
-                            targetScope({ "action": "mask", "el": this }, $.extend(true, {}, maskset), importAttributeOptions(this, opts));
+                            targetScope({ "action": "mask", "el": this }, $.extend(true, {}, maskset), opts);
                         });
                 }
             } else if (typeof fn == "object") {
                 opts = $.extend(true, {}, $.inputmask.defaults, fn);
-
+				importAttributeOptions(this, opts);
                 resolveAlias(opts.alias, fn, opts); //resolve aliases
                 maskset = generateMaskSet(opts, targetScope !== maskScope);
                 if (maskset == undefined) { return this; }
                 return this.each(function () {
-                    targetScope({ "action": "mask", "el": this }, $.extend(true, {}, maskset), importAttributeOptions(this, opts));
+                    targetScope({ "action": "mask", "el": this }, $.extend(true, {}, maskset), opts);
                 });
             } else if (fn == undefined) {
                 //look for data-inputmask atribute - the attribute should only contain optipns
@@ -1977,6 +1980,9 @@
                             $(this).inputmask("mask", opts, targetScope);
                         } catch (ex) { } //need a more relax parseJSON
                     }
+                    if ($(this).attr("data-inputmask-mask") || $(this).attr("data-inputmask-alias")) {
+                        $(this).inputmask("mask", {}, targetScope);
+                    }
                 });
             }
         };

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

@@ -23,6 +23,9 @@ Optional extensions on the jquery.inputmask base
                         opts.groupSeparator = ".";
                     else opts.groupSeparator = "";
                 }
+                if (opts.groupSeparator === " ") { //prevent conflict with default skipOptionalPartCharacter
+                    opts.skipOptionalPartCharacter = undefined;
+                }
                 opts.autoGroup = opts.autoGroup && opts.groupSeparator != "";
 
                 if (opts.autoGroup && isFinite(opts.integerDigits)) {