Skip to content

Commit

Permalink
[WIP] jondavidjohn#63 refine code
Browse files Browse the repository at this point in the history
  • Loading branch information
andygi committed Mar 19, 2019
1 parent a1ae395 commit 1f03a30
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions dist/jquery.payform.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,15 @@ var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i
e.target.value = payform.formatCardNumber(e.target.value);
if (getDirectionality(e.target) === 'ltr' && cursor !== e.target.selectionStart && isCardNumberPaste === true) {
cursor = _getCaretPos(e.target);
isCardNumberPaste = false;
}
if (getDirectionality(e.target) === 'rtl' && e.target.value.indexOf('‎\u200e') === -1) {
e.target.value = '‎\u200e'.concat(e.target.value);
cursor = _getCaretPos(e.target);
}
if ((cursor != null) && cursor !== 0 && e.type !== 'change') {
e.target.setSelectionRange(cursor, cursor);
return e.target.setSelectionRange(cursor, cursor);
}
return isCardNumberPaste = false;
};
formatCardNumber = function(e) {
var card, cursor, digit, length, re, upperLength, value;
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.payform.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/payform.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@
e.target.value = payform.formatCardNumber(e.target.value);
if (getDirectionality(e.target) === 'ltr' && cursor !== e.target.selectionStart && isCardNumberPaste === true) {
cursor = _getCaretPos(e.target);
isCardNumberPaste = false;
}
if (getDirectionality(e.target) === 'rtl' && e.target.value.indexOf('‎\u200e') === -1) {
e.target.value = '‎\u200e'.concat(e.target.value);
cursor = _getCaretPos(e.target);
}
if ((cursor != null) && cursor !== 0 && e.type !== 'change') {
e.target.setSelectionRange(cursor, cursor);
return e.target.setSelectionRange(cursor, cursor);
}
return isCardNumberPaste = false;
};
formatCardNumber = function(e) {
var card, cursor, digit, length, re, upperLength, value;
Expand Down
2 changes: 1 addition & 1 deletion dist/payform.min.js

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions src/payform.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@

if getDirectionality(e.target) == 'ltr' and cursor isnt e.target.selectionStart and isCardNumberPaste is true
cursor = _getCaretPos(e.target)
isCardNumberPaste = false

if getDirectionality(e.target) == 'rtl' and e.target.value.indexOf('\u200e') == -1
e.target.value = '\u200e'.concat(e.target.value)
Expand All @@ -270,8 +271,6 @@
if cursor? and cursor isnt 0 and e.type isnt 'change'
e.target.setSelectionRange(cursor, cursor)

isCardNumberPaste = false

formatCardNumber = (e) ->
# Only format if input is a number
digit = String.fromCharCode(e.which)
Expand Down

0 comments on commit 1f03a30

Please sign in to comment.