forked from jondavidjohn/payform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
79 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,7 @@ payform = require(2); | |
URL: https://github.com/jondavidjohn/payform | ||
Author: Jonathan D. Johnson <[email protected]> | ||
License: MIT | ||
Version: 1.2.4 | ||
Version: 1.2.5 | ||
*/ | ||
var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
|
||
|
@@ -67,17 +67,28 @@ var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i | |
}; | ||
_eventNormalize = function(listener) { | ||
return function(e) { | ||
var newEvt; | ||
if (e == null) { | ||
e = window.event; | ||
} | ||
e.target = e.target || e.srcElement; | ||
e.which = e.which || e.keyCode; | ||
if (e.preventDefault == null) { | ||
e.preventDefault = function() { | ||
return this.returnValue = false; | ||
}; | ||
if (e.inputType === 'insertCompositionText' && !e.isComposing) { | ||
return; | ||
} | ||
return listener(e); | ||
newEvt = { | ||
target: e.target || e.srcElement, | ||
which: e.which || e.keyCode, | ||
type: e.type, | ||
metaKey: e.metaKey, | ||
ctrlKey: e.ctrlKey, | ||
preventDefault: function() { | ||
if (e.preventDefault) { | ||
e.preventDefault(); | ||
} else { | ||
e.returnValue = false; | ||
} | ||
} | ||
}; | ||
return listener(newEvt); | ||
}; | ||
}; | ||
_on = function(ele, event, listener) { | ||
|
@@ -250,6 +261,9 @@ var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i | |
return; | ||
} | ||
e.target.value = payform.formatCardNumber(e.target.value); | ||
if (document.dir === 'rtl' && e.target.value.indexOf('\u200e') === -1) { | ||
e.target.value = '\u200e'.concat(e.target.value); | ||
} | ||
cursor = _getCaretPos(e.target); | ||
if ((cursor != null) && e.type !== 'change') { | ||
return e.target.setSelectionRange(cursor, cursor); | ||
|
@@ -320,6 +334,9 @@ var indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i | |
return; | ||
} | ||
e.target.value = payform.formatCardExpiry(e.target.value); | ||
if (document.dir === 'rtl' && e.target.value.indexOf('\u200e') === -1) { | ||
e.target.value = '\u200e'.concat(e.target.value); | ||
} | ||
cursor = _getCaretPos(e.target); | ||
if ((cursor != null) && e.type !== 'change') { | ||
return e.target.setSelectionRange(cursor, cursor); | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
URL: https://github.com/jondavidjohn/payform | ||
Author: Jonathan D. Johnson <[email protected]> | ||
License: MIT | ||
Version: 1.2.4 | ||
Version: 1.2.5 | ||
*/ | ||
|
||
(function() { | ||
|
@@ -37,17 +37,28 @@ | |
}; | ||
_eventNormalize = function(listener) { | ||
return function(e) { | ||
var newEvt; | ||
if (e == null) { | ||
e = window.event; | ||
} | ||
e.target = e.target || e.srcElement; | ||
e.which = e.which || e.keyCode; | ||
if (e.preventDefault == null) { | ||
e.preventDefault = function() { | ||
return this.returnValue = false; | ||
}; | ||
if (e.inputType === 'insertCompositionText' && !e.isComposing) { | ||
return; | ||
} | ||
return listener(e); | ||
newEvt = { | ||
target: e.target || e.srcElement, | ||
which: e.which || e.keyCode, | ||
type: e.type, | ||
metaKey: e.metaKey, | ||
ctrlKey: e.ctrlKey, | ||
preventDefault: function() { | ||
if (e.preventDefault) { | ||
e.preventDefault(); | ||
} else { | ||
e.returnValue = false; | ||
} | ||
} | ||
}; | ||
return listener(newEvt); | ||
}; | ||
}; | ||
_on = function(ele, event, listener) { | ||
|
@@ -220,6 +231,9 @@ | |
return; | ||
} | ||
e.target.value = payform.formatCardNumber(e.target.value); | ||
if (document.dir === 'rtl' && e.target.value.indexOf('\u200e') === -1) { | ||
e.target.value = '\u200e'.concat(e.target.value); | ||
} | ||
cursor = _getCaretPos(e.target); | ||
if ((cursor != null) && e.type !== 'change') { | ||
return e.target.setSelectionRange(cursor, cursor); | ||
|
@@ -290,6 +304,9 @@ | |
return; | ||
} | ||
e.target.value = payform.formatCardExpiry(e.target.value); | ||
if (document.dir === 'rtl' && e.target.value.indexOf('\u200e') === -1) { | ||
e.target.value = '\u200e'.concat(e.target.value); | ||
} | ||
cursor = _getCaretPos(e.target); | ||
if ((cursor != null) && e.type !== 'change') { | ||
return e.target.setSelectionRange(cursor, cursor); | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
URL: https://github.com/jondavidjohn/payform | ||
Author: Jonathan D. Johnson <[email protected]> | ||
License: MIT | ||
Version: 1.2.4 | ||
Version: 1.2.5 | ||
### | ||
((name, definition) -> | ||
if module? | ||
|
@@ -29,11 +29,21 @@ | |
|
||
_eventNormalize = (listener) -> | ||
return (e = window.event) -> | ||
e.target = e.target or e.srcElement | ||
e.which = e.which or e.keyCode | ||
unless e.preventDefault? | ||
e.preventDefault = -> this.returnValue = false | ||
listener(e) | ||
if e.inputType == 'insertCompositionText' and !e.isComposing | ||
return | ||
newEvt = | ||
target: e.target or e.srcElement | ||
which: e.which or e.keyCode | ||
type: e.type | ||
metaKey: e.metaKey | ||
ctrlKey: e.ctrlKey | ||
preventDefault: -> | ||
if e.preventDefault | ||
e.preventDefault() | ||
else | ||
e.returnValue = false | ||
return | ||
listener(newEvt) | ||
|
||
_on = (ele, event, listener) -> | ||
listener = _eventNormalize(listener) | ||
|
@@ -200,6 +210,8 @@ | |
reFormatCardNumber = (e) -> | ||
return if e.target.value is "" | ||
e.target.value = payform.formatCardNumber(e.target.value) | ||
if document.dir == 'rtl' and e.target.value.indexOf('\u200e') == -1 | ||
e.target.value = '\u200e'.concat(e.target.value) | ||
cursor = _getCaretPos(e.target) | ||
if cursor? and e.type isnt 'change' | ||
e.target.setSelectionRange(cursor, cursor) | ||
|
@@ -261,6 +273,8 @@ | |
reFormatExpiry = (e) -> | ||
return if e.target.value is "" | ||
e.target.value = payform.formatCardExpiry(e.target.value) | ||
if document.dir == 'rtl' and e.target.value.indexOf('\u200e') == -1 | ||
e.target.value = '\u200e'.concat(e.target.value) | ||
cursor = _getCaretPos(e.target) | ||
if cursor? and e.type isnt 'change' | ||
e.target.setSelectionRange(cursor, cursor) | ||
|