Comparing version 0.0.6 to 0.1.2
{ | ||
"name": "card", | ||
"version": "0.0.6", | ||
"version": "0.1.2", | ||
"homepage": "https://github.com/jessepollak/card", | ||
@@ -27,3 +27,2 @@ "authors": [ | ||
"example", | ||
"src", | ||
"test", | ||
@@ -30,0 +29,0 @@ "tests" |
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.card=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ | ||
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
var $, cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlash, hasTextSelected, luhnCheck, reFormatCardNumber, restrictCVC, restrictCardNumber, restrictExpiry, restrictNumeric, setCardType, | ||
var $, cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlashAndSpace, hasTextSelected, luhnCheck, reFormatCardNumber, reFormatExpiry, restrictCVC, restrictCardNumber, restrictExpiry, restrictNumeric, setCardType, | ||
__slice = [].slice, | ||
@@ -24,25 +24,25 @@ __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; }; | ||
{ | ||
type: 'maestro', | ||
pattern: /^(5018|5020|5038|6304|6759|676[1-3])/, | ||
type: 'visaelectron', | ||
pattern: /^4(026|17500|405|508|844|91[37])/, | ||
format: defaultFormat, | ||
length: [12, 13, 14, 15, 16, 17, 18, 19], | ||
length: [16], | ||
cvcLength: [3], | ||
luhn: true | ||
}, { | ||
type: 'dinersclub', | ||
pattern: /^(36|38|30[0-5])/, | ||
type: 'maestro', | ||
pattern: /^(5(018|0[23]|[68])|6(39|7))/, | ||
format: defaultFormat, | ||
length: [14], | ||
length: [12, 13, 14, 15, 16, 17, 18, 19], | ||
cvcLength: [3], | ||
luhn: true | ||
}, { | ||
type: 'laser', | ||
pattern: /^(6706|6771|6709)/, | ||
type: 'forbrugsforeningen', | ||
pattern: /^600/, | ||
format: defaultFormat, | ||
length: [16, 17, 18, 19], | ||
length: [16], | ||
cvcLength: [3], | ||
luhn: true | ||
}, { | ||
type: 'jcb', | ||
pattern: /^35/, | ||
type: 'dankort', | ||
pattern: /^5019/, | ||
format: defaultFormat, | ||
@@ -53,18 +53,11 @@ length: [16], | ||
}, { | ||
type: 'unionpay', | ||
pattern: /^62/, | ||
type: 'visa', | ||
pattern: /^4/, | ||
format: defaultFormat, | ||
length: [16, 17, 18, 19], | ||
length: [13, 16], | ||
cvcLength: [3], | ||
luhn: false | ||
}, { | ||
type: 'discover', | ||
pattern: /^(6011|65|64[4-9]|622)/, | ||
format: defaultFormat, | ||
length: [16], | ||
cvcLength: [3], | ||
luhn: true | ||
}, { | ||
type: 'mastercard', | ||
pattern: /^5[1-5]/, | ||
pattern: /^5[0-5]/, | ||
format: defaultFormat, | ||
@@ -82,8 +75,29 @@ length: [16], | ||
}, { | ||
type: 'visa', | ||
pattern: /^4/, | ||
type: 'dinersclub', | ||
pattern: /^3[0689]/, | ||
format: defaultFormat, | ||
length: [13, 16], | ||
length: [14], | ||
cvcLength: [3], | ||
luhn: true | ||
}, { | ||
type: 'discover', | ||
pattern: /^6([045]|22)/, | ||
format: defaultFormat, | ||
length: [16], | ||
cvcLength: [3], | ||
luhn: true | ||
}, { | ||
type: 'unionpay', | ||
pattern: /^(62|88)/, | ||
format: defaultFormat, | ||
length: [16, 17, 18, 19], | ||
cvcLength: [3], | ||
luhn: false | ||
}, { | ||
type: 'jcb', | ||
pattern: /^35/, | ||
format: defaultFormat, | ||
length: [16], | ||
cvcLength: [3], | ||
luhn: true | ||
} | ||
@@ -144,11 +158,9 @@ ]; | ||
reFormatCardNumber = function(e) { | ||
return setTimeout((function(_this) { | ||
return function() { | ||
var $target, value; | ||
$target = $(e.currentTarget); | ||
value = $target.val(); | ||
value = $.payment.formatCardNumber(value); | ||
return $target.val(value); | ||
}; | ||
})(this)); | ||
return setTimeout(function() { | ||
var $target, value; | ||
$target = $(e.currentTarget); | ||
value = $target.val(); | ||
value = $.payment.formatCardNumber(value); | ||
return $target.val(value); | ||
}); | ||
}; | ||
@@ -183,6 +195,10 @@ | ||
e.preventDefault(); | ||
return $target.val(value + ' ' + digit); | ||
return setTimeout(function() { | ||
return $target.val(value + ' ' + digit); | ||
}); | ||
} else if (re.test(value + digit)) { | ||
e.preventDefault(); | ||
return $target.val(value + digit + ' '); | ||
return setTimeout(function() { | ||
return $target.val(value + digit + ' '); | ||
}); | ||
} | ||
@@ -195,5 +211,2 @@ }; | ||
value = $target.val(); | ||
if (e.meta) { | ||
return; | ||
} | ||
if (e.which !== 8) { | ||
@@ -207,9 +220,23 @@ return; | ||
e.preventDefault(); | ||
return $target.val(value.replace(/\d\s$/, '')); | ||
return setTimeout(function() { | ||
return $target.val(value.replace(/\d\s$/, '')); | ||
}); | ||
} else if (/\s\d?$/.test(value)) { | ||
e.preventDefault(); | ||
return $target.val(value.replace(/\s\d?$/, '')); | ||
return setTimeout(function() { | ||
return $target.val(value.replace(/\s\d?$/, '')); | ||
}); | ||
} | ||
}; | ||
reFormatExpiry = function(e) { | ||
return setTimeout(function() { | ||
var $target, value; | ||
$target = $(e.currentTarget); | ||
value = $target.val(); | ||
value = $.payment.formatExpiry(value); | ||
return $target.val(value); | ||
}); | ||
}; | ||
formatExpiry = function(e) { | ||
@@ -225,6 +252,10 @@ var $target, digit, val; | ||
e.preventDefault(); | ||
return $target.val("0" + val + " / "); | ||
return setTimeout(function() { | ||
return $target.val("0" + val + " / "); | ||
}); | ||
} else if (/^\d\d$/.test(val)) { | ||
e.preventDefault(); | ||
return $target.val("" + val + " / "); | ||
return setTimeout(function() { | ||
return $target.val("" + val + " / "); | ||
}); | ||
} | ||
@@ -246,6 +277,6 @@ }; | ||
formatForwardSlash = function(e) { | ||
var $target, slash, val; | ||
slash = String.fromCharCode(e.which); | ||
if (slash !== '/') { | ||
formatForwardSlashAndSpace = function(e) { | ||
var $target, val, which; | ||
which = String.fromCharCode(e.which); | ||
if (!(which === '/' || which === ' ')) { | ||
return; | ||
@@ -262,5 +293,2 @@ } | ||
var $target, value; | ||
if (e.meta) { | ||
return; | ||
} | ||
$target = $(e.currentTarget); | ||
@@ -274,8 +302,7 @@ value = $target.val(); | ||
} | ||
if (/\d(\s|\/)+$/.test(value)) { | ||
if (/\s\/\s\d?$/.test(value)) { | ||
e.preventDefault(); | ||
return $target.val(value.replace(/\d(\s|\/)*$/, '')); | ||
} else if (/\s\/\s?\d?$/.test(value)) { | ||
e.preventDefault(); | ||
return $target.val(value.replace(/\s\/\s?\d?$/, '')); | ||
return setTimeout(function() { | ||
return $target.val(value.replace(/\s\/\s\d?$/, '')); | ||
}); | ||
} | ||
@@ -385,5 +412,7 @@ }; | ||
this.on('keypress', formatExpiry); | ||
this.on('keypress', formatForwardSlash); | ||
this.on('keypress', formatForwardSlashAndSpace); | ||
this.on('keypress', formatForwardExpiry); | ||
this.on('keydown', formatBackExpiry); | ||
this.on('change', reFormatExpiry); | ||
this.on('input', reFormatExpiry); | ||
return this; | ||
@@ -399,2 +428,5 @@ }; | ||
this.on('paste', reFormatCardNumber); | ||
this.on('change', reFormatCardNumber); | ||
this.on('input', reFormatCardNumber); | ||
this.on('input', setCardType); | ||
return this; | ||
@@ -442,37 +474,40 @@ }; | ||
$.payment.validateCardExpiry = (function(_this) { | ||
return function(month, year) { | ||
var currentTime, expiry, prefix, _ref; | ||
if (typeof month === 'object' && 'month' in month) { | ||
_ref = month, month = _ref.month, year = _ref.year; | ||
$.payment.validateCardExpiry = function(month, year) { | ||
var currentTime, expiry, _ref; | ||
if (typeof month === 'object' && 'month' in month) { | ||
_ref = month, month = _ref.month, year = _ref.year; | ||
} | ||
if (!(month && year)) { | ||
return false; | ||
} | ||
month = $.trim(month); | ||
year = $.trim(year); | ||
if (!/^\d+$/.test(month)) { | ||
return false; | ||
} | ||
if (!/^\d+$/.test(year)) { | ||
return false; | ||
} | ||
if (!((1 <= month && month <= 12))) { | ||
return false; | ||
} | ||
if (year.length === 2) { | ||
if (year < 70) { | ||
year = "20" + year; | ||
} else { | ||
year = "19" + year; | ||
} | ||
if (!(month && year)) { | ||
return false; | ||
} | ||
month = $.trim(month); | ||
year = $.trim(year); | ||
if (!/^\d+$/.test(month)) { | ||
return false; | ||
} | ||
if (!/^\d+$/.test(year)) { | ||
return false; | ||
} | ||
if (!(parseInt(month, 10) <= 12)) { | ||
return false; | ||
} | ||
if (year.length === 2) { | ||
prefix = (new Date).getFullYear(); | ||
prefix = prefix.toString().slice(0, 2); | ||
year = prefix + year; | ||
} | ||
expiry = new Date(year, month); | ||
currentTime = new Date; | ||
expiry.setMonth(expiry.getMonth() - 1); | ||
expiry.setMonth(expiry.getMonth() + 1, 1); | ||
return expiry > currentTime; | ||
}; | ||
})(this); | ||
} | ||
if (year.length !== 4) { | ||
return false; | ||
} | ||
expiry = new Date(year, month); | ||
currentTime = new Date; | ||
expiry.setMonth(expiry.getMonth() - 1); | ||
expiry.setMonth(expiry.getMonth() + 1, 1); | ||
return expiry > currentTime; | ||
}; | ||
$.payment.validateCardCVC = function(cvc, type) { | ||
var _ref, _ref1; | ||
var card, _ref; | ||
cvc = $.trim(cvc); | ||
@@ -482,4 +517,5 @@ if (!/^\d+$/.test(cvc)) { | ||
} | ||
if (type) { | ||
return _ref = cvc.length, __indexOf.call((_ref1 = cardFromType(type)) != null ? _ref1.cvcLength : void 0, _ref) >= 0; | ||
card = cardFromType(type); | ||
if (card != null) { | ||
return _ref = cvc.length, __indexOf.call(card.cvcLength, _ref) >= 0; | ||
} else { | ||
@@ -506,3 +542,3 @@ return cvc.length >= 3 && cvc.length <= 4; | ||
num = num.replace(/\D/g, ''); | ||
num = num.slice(0, +upperLength + 1 || 9e9); | ||
num = num.slice(0, upperLength); | ||
if (card.format.global) { | ||
@@ -512,9 +548,32 @@ return (_ref = num.match(card.format)) != null ? _ref.join(' ') : void 0; | ||
groups = card.format.exec(num); | ||
if (groups != null) { | ||
groups.shift(); | ||
if (groups == null) { | ||
return; | ||
} | ||
return groups != null ? groups.join(' ') : void 0; | ||
groups.shift(); | ||
groups = $.grep(groups, function(n) { | ||
return n; | ||
}); | ||
return groups.join(' '); | ||
} | ||
}; | ||
$.payment.formatExpiry = function(expiry) { | ||
var mon, parts, sep, year; | ||
parts = expiry.match(/^\D*(\d{1,2})(\D+)?(\d{1,4})?/); | ||
if (!parts) { | ||
return ''; | ||
} | ||
mon = parts[1] || ''; | ||
sep = parts[2] || ''; | ||
year = parts[3] || ''; | ||
if (year.length > 0 || (sep.length > 0 && !(/\ \/?\ ?/.test(sep)))) { | ||
sep = ' / '; | ||
} | ||
if (mon.length === 1 && (mon !== '0' && mon !== '1')) { | ||
mon = "0" + mon; | ||
sep = ' / '; | ||
} | ||
return mon + sep + year; | ||
}; | ||
}).call(this); | ||
@@ -524,2 +583,3 @@ | ||
var $, Card, | ||
__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; }, | ||
__slice = [].slice; | ||
@@ -637,4 +697,7 @@ | ||
if (new Function("/*@cc_on return @_jscript_version; @*/")()) { | ||
return this.$card.addClass('ie-10'); | ||
this.$card.addClass('ie-10'); | ||
} | ||
if (/rv:11.0/i.test(navigator.userAgent)) { | ||
return this.$card.addClass('ie-11'); | ||
} | ||
}; | ||
@@ -655,3 +718,2 @@ | ||
expiryFilters.push(this.validToggler('cardExpiry')); | ||
this.$expiryInput.on('keydown', this.handle('captureTab')); | ||
} | ||
@@ -757,20 +819,8 @@ this.$expiryInput.bindVal(this.$expiryDisplay, { | ||
}, | ||
captureTab: function($el, e) { | ||
var keyCode, val; | ||
keyCode = e.keyCode || e.which; | ||
if (keyCode !== 9 || e.shiftKey) { | ||
return; | ||
} | ||
val = $el.payment('cardExpiryVal'); | ||
if (!(val.month || val.year)) { | ||
return; | ||
} | ||
if (!$.payment.validateCardExpiry(val.month, val.year)) { | ||
return e.preventDefault(); | ||
} | ||
}, | ||
captureName: function($el, e) { | ||
var banKeyCodes; | ||
var allowedSymbols, banKeyCodes, keyCode; | ||
keyCode = e.which || e.keyCode; | ||
banKeyCodes = [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 106, 107, 109, 110, 111, 186, 187, 188, 189, 190, 191, 192, 219, 220, 221, 222]; | ||
if (banKeyCodes.indexOf(e.which || e.keyCode) !== -1) { | ||
allowedSymbols = [189, 109, 190, 110, 222]; | ||
if (banKeyCodes.indexOf(keyCode) !== -1 && !(!e.shiftKey && __indexOf.call(allowedSymbols, keyCode) >= 0)) { | ||
return e.preventDefault(); | ||
@@ -777,0 +827,0 @@ } |
{ | ||
"name": "card", | ||
"version": "0.0.6", | ||
"version": "0.1.2", | ||
"author": "Jesse Pollak <jpollak92@gmail.com>", | ||
@@ -35,4 +35,4 @@ "description": "Card let's you add an interactive, CSS3 credit card animation to your credit card form to help your users through the process.", | ||
"jquery": "~2.1.1", | ||
"jquery.payment": "~1.0.3" | ||
"jquery.payment": "~1.1.3" | ||
} | ||
} |
@@ -162,3 +162,13 @@ # Card - check out the **[demo](https://jessepollak.github.io/card)** | ||
* [MakeSpace – Your Closet in the Cloud](https://www.makespace.com/) | ||
* [Blumpa](http://www.blumpa.com/) | ||
* [CourseLoads – Clean Clothes, Delivered to your Door.](http://www.courseloads.com/) | ||
Are you using Card in production? If so, we'd love to link to you from this page. Open a PR or drop [@jessepollak](http://twitter.com/jessepollak) a line on [Twitter](http://twitter.com/jessepollak) and we'll add you right away! | ||
## Acknowledgements | ||
This library depends on, and bundles, [Stripe's jquery.payment library](https://github.com/stripe/jquery.payment) — thanks [Stripe](https://stripe.com)! | ||
## Donations | ||
If you'd like to donate to help support development of Card, send Bitcoin directly to `17NUKd3v7GWben18kGhmFafa4ZpWrXpQSC` or through Coinbase [here](https://coinbase.com/jessepollak). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1546120
1324
174
+ Addedjquery.payment@1.1.4(transitive)
- Removedjquery.payment@1.0.3(transitive)
Updatedjquery.payment@~1.1.3