Comparing version 0.0.10 to 0.0.11
{ | ||
"name": "payment", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"main": "lib/payment.js" | ||
} |
@@ -235,3 +235,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.payment || (g.payment = {})).js = f()}})(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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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(require,module,exports){ | ||
(function (global){ | ||
var Payment, QJ, cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlash, hasTextSelected, luhnCheck, reFormatCardNumber, restrictCVC, restrictCardNumber, restrictExpiry, restrictNumeric, setCardType, | ||
var Payment, QJ, cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlash, formatMonthExpiry, hasTextSelected, luhnCheck, reFormatCardNumber, restrictCVC, restrictCardNumber, restrictCombinedExpiry, restrictExpiry, restrictMonthExpiry, restrictNumeric, restrictYearExpiry, setCardType, | ||
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; }; | ||
@@ -321,2 +321,9 @@ | ||
luhn: true | ||
}, { | ||
type: 'elo', | ||
pattern: /^4011|438935|45(1416|76)|50(4175|6699|67|90[4-7])|63(6297|6368)/, | ||
format: defaultFormat, | ||
length: [16], | ||
cvcLength: [3], | ||
luhn: true | ||
} | ||
@@ -463,2 +470,19 @@ ]; | ||
formatMonthExpiry = function(e) { | ||
var digit, target, val; | ||
digit = String.fromCharCode(e.which); | ||
if (!/^\d+$/.test(digit)) { | ||
return; | ||
} | ||
target = e.target; | ||
val = QJ.val(target) + digit; | ||
if (/^\d$/.test(val) && (val !== '0' && val !== '1')) { | ||
e.preventDefault(); | ||
return QJ.val(target, "0" + val); | ||
} else if (/^\d\d$/.test(val)) { | ||
e.preventDefault(); | ||
return QJ.val(target, "" + val); | ||
} | ||
}; | ||
formatForwardExpiry = function(e) { | ||
@@ -555,3 +579,3 @@ var digit, target, val; | ||
restrictExpiry = function(e) { | ||
restrictExpiry = function(e, length) { | ||
var digit, target, value; | ||
@@ -568,3 +592,3 @@ target = e.target; | ||
value = value.replace(/\D/g, ''); | ||
if (value.length > 6) { | ||
if (value.length > length) { | ||
return e.preventDefault(); | ||
@@ -574,2 +598,14 @@ } | ||
restrictCombinedExpiry = function(e) { | ||
return restrictExpiry(e, 6); | ||
}; | ||
restrictMonthExpiry = function(e) { | ||
return restrictExpiry(e, 2); | ||
}; | ||
restrictYearExpiry = function(e) { | ||
return restrictExpiry(e, 4); | ||
}; | ||
restrictCVC = function(e) { | ||
@@ -582,2 +618,5 @@ var digit, target, val; | ||
} | ||
if (hasTextSelected(target)) { | ||
return; | ||
} | ||
val = QJ.val(target) + digit; | ||
@@ -729,11 +768,23 @@ if (!(val.length <= 4)) { | ||
Payment.formatCardExpiry = function(el) { | ||
var month, year; | ||
Payment.restrictNumeric(el); | ||
QJ.on(el, 'keypress', restrictExpiry); | ||
QJ.on(el, 'keypress', formatExpiry); | ||
QJ.on(el, 'keypress', formatForwardSlash); | ||
QJ.on(el, 'keypress', formatForwardExpiry); | ||
QJ.on(el, 'keydown', formatBackExpiry); | ||
if (el.length && el.length === 2) { | ||
month = el[0], year = el[1]; | ||
this.formatCardExpiryMultiple(month, year); | ||
} else { | ||
QJ.on(el, 'keypress', restrictCombinedExpiry); | ||
QJ.on(el, 'keypress', formatExpiry); | ||
QJ.on(el, 'keypress', formatForwardSlash); | ||
QJ.on(el, 'keypress', formatForwardExpiry); | ||
QJ.on(el, 'keydown', formatBackExpiry); | ||
} | ||
return el; | ||
}; | ||
Payment.formatCardExpiryMultiple = function(month, year) { | ||
QJ.on(month, 'keypress', restrictMonthExpiry); | ||
QJ.on(month, 'keypress', formatMonthExpiry); | ||
return QJ.on(year, 'keypress', restrictYearExpiry); | ||
}; | ||
Payment.formatCardNumber = function(el) { | ||
@@ -740,0 +791,0 @@ Payment.restrictNumeric(el); |
{ | ||
"name": "payment", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "A general purpose library for building credit card forms, validating inputs and formatting numbers. Base on jquery.payment by @stripe, but without the jQuery.", | ||
@@ -26,24 +26,24 @@ "keywords": [ | ||
"devDependencies": { | ||
"browserify": "~11.2.0", | ||
"coffee-script": "~1.10", | ||
"jsdom": "~6.5", | ||
"mocha": "~2.3", | ||
"gulp": "~3.9.0", | ||
"gulp-autoprefixer": "3.0.2", | ||
"tiny-lr": "0.2.0", | ||
"gulp-changed": "~1.3.0", | ||
"gulp-connect": "~2.2.0", | ||
"gulp-livereload": "~3.8.1", | ||
"nodemon": "~1.7.1", | ||
"coffeeify": "~1.1.0", | ||
"gulp-mocha": "~2.1.3", | ||
"gulp-open": "~1.0.0", | ||
"gulp-rename": "~1.2.0", | ||
"gulp-changed": "~1.3.0", | ||
"gulp-rimraf": "~0.2.0", | ||
"gulp-connect": "~2.2.0", | ||
"gulp-open": "~1.0.0", | ||
"jsdom": "~6.5", | ||
"mocha": "~2.3", | ||
"nodemon": "~1.7.1", | ||
"run-sequence": "~1.1.4", | ||
"gulp-mocha": "~2.1.3", | ||
"browserify": "~11.2.0", | ||
"tiny-lr": "0.2.0", | ||
"vinyl-source-stream": "~1.1.0" | ||
}, | ||
"dependencies": { | ||
"qj": "0.0.8" | ||
"qj": "0.0.8", | ||
"coffeeify": "^1.1.0" | ||
} | ||
} |
{ | ||
"name": "payment", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"title": "payment", | ||
@@ -5,0 +5,0 @@ "description": "A general purpose library for building credit card forms, validating inputs and formatting numbers. Base on jquery.payment by @stripe, but without the jQuery.", |
@@ -35,2 +35,3 @@ # Payment [![Build Status](https://travis-ci.org/jessepollak/payment.svg?branch=master)](https://travis-ci.org/jessepollak/payment) | ||
* UnionPay | ||
* Elo | ||
@@ -54,3 +55,3 @@ ## API | ||
### Payment.formatCardExpiry | ||
### Payment.formatCardExpiry | ||
@@ -150,2 +151,3 @@ Formats card expiry: | ||
* `unionpay` | ||
* `elo` | ||
@@ -152,0 +154,0 @@ The function will return `null` if the card type can't be determined. |
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
144402
17
801
231
2
+ Addedcoffeeify@^1.1.0
+ Addedcoffee-script@1.12.7(transitive)
+ Addedcoffeeify@1.2.0(transitive)
+ Addedconvert-source-map@1.9.0(transitive)
+ Addedthrough@2.3.8(transitive)