Skip to content

Commit cf7d063

Browse files
committed
fix ctrlz
1 parent 8faec4b commit cf7d063

12 files changed

+1011
-971
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "inputmask",
3-
"version": "5.0.6-beta.51",
3+
"version": "5.0.6-beta.52",
44
"main": [
55
"./index.js",
66
"./css/inputmask.css"

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "robinherbots/inputmask",
33
"description": "Inputmask is a javascript library which creates an input mask. Inputmask can run against vanilla javascript, jQuery and jqlite.",
4-
"version": "5.0.6-beta.51",
4+
"version": "5.0.6-beta.52",
55
"type": "library",
66
"keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
77
"homepage": "http://robinherbots.github.io/Inputmask",

dist/inputmask.js

+894-892
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/inputmask.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.inputmask.js

+62-60
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery.inputmask.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/defaults.js

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import keyCode from "./keycode.json";
2+
13
export default {
24
_maxTestPos: 500,
35
placeholder: "_",
@@ -49,7 +51,37 @@ export default {
4951
tabThrough: false, //allows for tabbing through the different parts of the masked field
5052
supportsInputType: ["text", "tel", "url", "password", "search"], //list with the supported input types
5153
//specify keyCodes which should not be considered in the keypress event, otherwise the preventDefault will stop their default behavior especially in FF
52-
ignorables: [8, 9, 19, 27, 33, 34, 35, 36, 37, 38, 39, 40, 45, 46, 93, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 0, 229],
54+
ignorables: [
55+
keyCode.BACKSPACE,
56+
keyCode.TAB,
57+
keyCode["PAUSE/BREAK"],
58+
keyCode.ESCAPE,
59+
keyCode.PAGE_UP,
60+
keyCode.PAGE_DOWN,
61+
keyCode.END,
62+
keyCode.HOME,
63+
keyCode.LEFT,
64+
keyCode.UP,
65+
keyCode.RIGHT,
66+
keyCode.DOWN,
67+
keyCode.INSERT,
68+
keyCode.DELETE,
69+
93,
70+
112,
71+
113,
72+
114,
73+
115,
74+
116,
75+
117,
76+
118,
77+
119,
78+
120,
79+
121,
80+
122,
81+
123,
82+
0,
83+
229
84+
],
5385
isComplete: null, //override for isComplete - args => buffer, opts - return true || false
5486
preValidation: null, //hook to preValidate the input. Usefull for validating regardless the definition. args => buffer, pos, char, isSelection, opts, maskset, caretPos, strict => return true/false/command object
5587
postValidation: null, //hook to postValidate the result from isValid. Usefull for validating the entry as a whole. args => buffer, pos, c, currentResult, opts, maskset, strict, fromCheckval => return true/false/json

lib/eventhandlers.js

+7-8
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ var EventHandlers = {
100100
k = e.which || e.charCode || e.keyCode;
101101

102102
if (checkval !== true && (!(e.ctrlKey && e.altKey) && (e.ctrlKey || e.metaKey || inputmask.ignorable))) {
103-
if (k === keyCode.ENTER && inputmask.undoValue !== getBuffer.call(inputmask).join("")) {
104-
inputmask.undoValue = getBuffer.call(inputmask).join("");
103+
if (k === keyCode.ENTER && inputmask.undoValue !== inputmask._valueGet(true)) {
104+
inputmask.undoValue = inputmask._valueGet(true);
105105
// e.preventDefault();
106106
setTimeout(function () {
107107
$input.trigger("change");
@@ -192,7 +192,6 @@ var EventHandlers = {
192192
}
193193
}
194194
checkVal(input, true, false, pasteValue.toString().split(""), e);
195-
// writeBuffer(input, getBuffer(), seekNext(getLastValidPosition()), e, inputmask.undoValue !== getBuffer().join(""));
196195

197196
return e.preventDefault();
198197
},
@@ -373,7 +372,7 @@ var EventHandlers = {
373372
if (opts.positionCaretOnTab === true && inputmask.mouseEnter === false && (!isComplete.call(inputmask, getBuffer.call(inputmask)) || getLastValidPosition.call(inputmask) === -1)) {
374373
EventHandlers.clickEvent.apply(input, [e, true]);
375374
}
376-
inputmask.undoValue = getBuffer.call(inputmask).join("");
375+
inputmask.undoValue = inputmask._valueGet(true);
377376
},
378377
invalidEvent: function (e) {
379378
this.inputmask.validationEvent = true;
@@ -411,7 +410,7 @@ var EventHandlers = {
411410
if (document.execCommand) document.execCommand("copy"); // copy selected content to system clipbaord
412411

413412
handleRemove.call(inputmask, input, keyCode.DELETE, pos);
414-
writeBuffer(input, getBuffer.call(inputmask), maskset.p, e, inputmask.undoValue !== getBuffer.call(inputmask).join(""));
413+
writeBuffer(input, getBuffer.call(inputmask), maskset.p, e, inputmask.undoValue !== inputmask._valueGet(true));
415414
}
416415
,
417416
blurEvent: function (e) {
@@ -450,8 +449,8 @@ var EventHandlers = {
450449
writeBuffer(input, buffer, undefined, e);
451450
}
452451

453-
if (inputmask.undoValue !== getBuffer.call(inputmask).join("")) {
454-
inputmask.undoValue = getBuffer.call(inputmask).join("");
452+
if (inputmask.undoValue !== inputmask._valueGet(true)) {
453+
inputmask.undoValue = inputmask._valueGet(true);
455454
$input.trigger("change");
456455
}
457456
}
@@ -476,7 +475,7 @@ var EventHandlers = {
476475
submitEvent: function () { //trigger change on submit if any
477476
const inputmask = this.inputmask, opts = inputmask.opts;
478477

479-
if (inputmask.undoValue !== getBuffer.call(inputmask).join("")) {
478+
if (inputmask.undoValue !== inputmask._valueGet(true)) {
480479
inputmask.$el.trigger("change");
481480
}
482481
if (opts.clearMaskOnLostFocus && getLastValidPosition.call(inputmask) === -1 && inputmask._valueGet && inputmask._valueGet() === getBufferTemplate.call(inputmask).join("")) {

lib/inputHandling.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function applyInputValue(input, value) {
2323
if (typeof opts.onBeforeMask === "function") value = opts.onBeforeMask.call(inputmask, value, opts) || value;
2424
value = value.toString().split("");
2525
checkVal(input, true, false, value);
26-
inputmask.undoValue = getBuffer.call(inputmask).join("");
26+
inputmask.undoValue = inputmask._valueGet(true);
2727
if ((opts.clearMaskOnLostFocus || opts.clearIncomplete) && input.inputmask._valueGet() === getBufferTemplate.call(inputmask).join("") && getLastValidPosition.call(inputmask) === -1) {
2828
input.inputmask._valueSet("");
2929
}
@@ -146,7 +146,7 @@ function checkVal(input, writeOut, strict, nptvl, initiatingEvent) {
146146
}
147147
}
148148
if (writeOut) {
149-
writeBuffer.call(inputmask, input, getBuffer.call(inputmask), result ? result.forwardPosition : inputmask.caretPos.begin, initiatingEvent || new $.Event("checkval"), initiatingEvent && initiatingEvent.type === "input" && inputmask.undoValue !== getBuffer.call(inputmask).join(""));
149+
writeBuffer.call(inputmask, input, getBuffer.call(inputmask), result ? result.forwardPosition : inputmask.caretPos.begin, initiatingEvent || new $.Event("checkval"), initiatingEvent && initiatingEvent.type === "input" && inputmask.undoValue !== inputmask._valueGet(true));
150150
// for (var vndx in maskset.validPositions) {
151151
// if (maskset.validPositions[vndx].match.generated !== true) { //only remove non forced generated
152152
// delete maskset.validPositions[vndx].generatedInput; //clear generated markings ~ consider initializing with a value as fully typed

lib/keycode.json

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
"TAB": 9,
1717
"UP": 38,
1818
"X": 88,
19+
"Z": 90,
1920
"CONTROL": 17,
21+
"PAUSE/BREAK": 19,
22+
"WINDOWS_LEFT": 91,
23+
"WINDOWS_RIGHT": 92,
2024
"KEY_229": 229
2125
}

lib/mask.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ function mask() {
215215
EventRuler.on(el, "setvalue", EventHandlers.setValueEvent);
216216

217217
//apply mask
218-
inputmask.undoValue = getBufferTemplate.call(inputmask).join(""); //initialize the buffer and getmasklength
218+
getBufferTemplate.call(inputmask).join(""); //initialize the buffer and getmasklength
219+
inputmask.undoValue = inputmask._valueGet(true);
219220
var activeElement = (el.inputmask.shadowRoot || el.ownerDocument).activeElement;
220221
if (el.inputmask._valueGet(true) !== "" || opts.clearMaskOnLostFocus === false || activeElement === el) {
221222
applyInputValue(el, el.inputmask._valueGet(true), opts);

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "inputmask",
3-
"version": "5.0.6-beta.51",
3+
"version": "5.0.6-beta.52",
44
"description": "Inputmask is a javascript library which creates an input mask. Inputmask can run against vanilla javascript, jQuery and jqlite.",
55
"main": "dist/inputmask.js",
66
"files": [

0 commit comments

Comments
 (0)