Skip to content

Commit

Permalink
Fix issue jondavidjohn#17 - IE11 page hangs on empty input triggering
Browse files Browse the repository at this point in the history
  • Loading branch information
joe4mg authored and joe-campiondigital-mo committed Dec 20, 2017
1 parent ed2382e commit 882e606
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dist/payform.js: src/payform.coffee
$(BIN)coffee -c --no-header -o dist/ src/payform.coffee

dist/payform.min.js: dist/payform.js
$(BIN)uglify -s dist/payform.js -o dist/payform.min.js
$(BIN)uglifyjs dist/payform.js -o dist/payform.min.js

dist/jquery.payform.js: src/jquery.payform.coffee
$(BIN)browserify \
Expand All @@ -17,7 +17,7 @@ dist/jquery.payform.js: src/jquery.payform.coffee
src/jquery.payform.coffee > dist/jquery.payform.js

dist/jquery.payform.min.js: dist/jquery.payform.js
$(BIN)uglify -s dist/jquery.payform.js -o dist/jquery.payform.min.js
$(BIN)uglifyjs dist/jquery.payform.js -o dist/jquery.payform.min.js

watch: build
$(BIN)watch 'make build' src
Expand Down
9 changes: 9 additions & 0 deletions dist/jquery.payform.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i
};
reFormatCardNumber = function(e) {
var cursor;
if (e.target.value === "") {
return;
}
cursor = _getCaretPos(e.target);
e.target.value = payform.formatCardNumber(e.target.value);
if ((cursor != null) && e.type !== 'change') {
Expand Down Expand Up @@ -313,6 +316,9 @@ var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i
};
reFormatExpiry = function(e) {
var cursor;
if (e.target.value === "") {
return;
}
cursor = _getCaretPos(e.target);
e.target.value = payform.formatCardExpiry(e.target.value);
if ((cursor != null) && e.type !== 'change') {
Expand Down Expand Up @@ -379,6 +385,9 @@ var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i
};
reFormatCVC = function(e) {
var cursor;
if (e.target.value === "") {
return;
}
cursor = _getCaretPos(e.target);
e.target.value = replaceFullWidthChars(e.target.value).replace(/\D/g, '').slice(0, 4);
if ((cursor != null) && e.type !== 'change') {
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.payform.min.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions dist/payform.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@
};
reFormatCardNumber = function(e) {
var cursor;
if (e.target.value === "") {
return;
}
cursor = _getCaretPos(e.target);
e.target.value = payform.formatCardNumber(e.target.value);
if ((cursor != null) && e.type !== 'change') {
Expand Down Expand Up @@ -283,6 +286,9 @@
};
reFormatExpiry = function(e) {
var cursor;
if (e.target.value === "") {
return;
}
cursor = _getCaretPos(e.target);
e.target.value = payform.formatCardExpiry(e.target.value);
if ((cursor != null) && e.type !== 'change') {
Expand Down Expand Up @@ -349,6 +355,9 @@
};
reFormatCVC = function(e) {
var cursor;
if (e.target.value === "") {
return;
}
cursor = _getCaretPos(e.target);
e.target.value = replaceFullWidthChars(e.target.value).replace(/\D/g, '').slice(0, 4);
if ((cursor != null) && e.type !== 'change') {
Expand Down
2 changes: 1 addition & 1 deletion dist/payform.min.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
"watch": "make watch"
},
"devDependencies": {
"coffee-script": "~1.9.0",
"watch": "~0.13.0",
"uglify": "~0.1.1",
"mocha": "~2.1.0",
"browserify": "~8.1.3",
"bundle-collapser": "~1.1.1",
"coffee-script": "~1.9.0",
"coffeeify": "~1.0.0",
"bundle-collapser": "~1.1.1"
"mocha": "~2.1.0",
"uglify-js": "^3.2.2",
"watch": "~0.13.0"
}
}
3 changes: 3 additions & 0 deletions src/payform.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
# Format Card Number

reFormatCardNumber = (e) ->
return if e.target.value is ""
cursor = _getCaretPos(e.target)
e.target.value = payform.formatCardNumber(e.target.value)
if cursor? and e.type isnt 'change'
Expand Down Expand Up @@ -258,6 +259,7 @@
# Format Expiry

reFormatExpiry = (e) ->
return if e.target.value is ""
cursor = _getCaretPos(e.target)
e.target.value = payform.formatCardExpiry(e.target.value)
if cursor? and e.type isnt 'change'
Expand Down Expand Up @@ -310,6 +312,7 @@
# Format CVC

reFormatCVC = (e) ->
return if e.target.value is ""
cursor = _getCaretPos(e.target)
e.target.value = replaceFullWidthChars(e.target.value).replace(/\D/g, '')[0...4]
if cursor? and e.type isnt 'change'
Expand Down

0 comments on commit 882e606

Please sign in to comment.