Skip to content

Commit

Permalink
Merge branch 'release/1.2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
jondavidjohn committed Aug 1, 2018
2 parents d70c4c6 + 9db1075 commit 3a398c7
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
= 1.2.5
* Fixes #37, allowing for vendoring and fix event normalization (PR #39)
* Fixes #38, full width character fixes for Safari
* Fixes #41, improve RTL support

= 1.2.4
* Fix issue with cutting off last 2 digits of some cards (see #34 and #25)
* Update Mocha to 3.5.3 (CVE)
Expand Down
33 changes: 25 additions & 8 deletions dist/jquery.payform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; };

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion dist/jquery.payform.min.js

Large diffs are not rendered by default.

33 changes: 25 additions & 8 deletions dist/payform.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion dist/payform.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "payform",
"version": "1.2.4",
"version": "1.2.5",
"description": "A general purpose library for building credit card forms, validating inputs, and formatting numbers.",
"keywords": [
"payment",
Expand Down
26 changes: 20 additions & 6 deletions src/payform.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3a398c7

Please sign in to comment.