Skip to content

Commit fe33ffe

Browse files
committed
Merge branch 'release/1.1.0'
2 parents 995eca8 + 7ff69ab commit fe33ffe

15 files changed

+796
-9
lines changed

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
bower.json
22
.npmignore
33
CONTRIBUTING.md
4+
Makefile
5+
index.html
6+
jquery.html
47
.travis.yml
58
test/*
69
src/*

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
= 1.1.0
2+
* Add jQuery Plugin shim
3+
* Add numeric input formatter `numericInput`
4+
* Move build process to makefile
5+
16
= 1.0.2
27
* Fix bug with 1 or 0 in expiry formatting
38
* Fix strange behavior with cursor position on 'change' events

Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
SHELL := /bin/bash
2+
BIN := node_modules/.bin/
3+
4+
build: dist/payform.js dist/payform.min.js dist/jquery.payform.js dist/jquery.payform.min.js
5+
6+
dist/payform.js: src/payform.coffee
7+
$(BIN)coffee -c --no-header -o dist/ src/payform.coffee
8+
9+
dist/payform.min.js: dist/payform.js
10+
$(BIN)uglify -s dist/payform.js -o dist/payform.min.js
11+
12+
dist/jquery.payform.js: src/jquery.payform.coffee
13+
$(BIN)browserify \
14+
-p bundle-collapser/plugin \
15+
-t coffeeify \
16+
--extension='.coffee' \
17+
src/jquery.payform.coffee > dist/jquery.payform.js
18+
19+
dist/jquery.payform.min.js: dist/jquery.payform.js
20+
$(BIN)uglify -s dist/jquery.payform.js -o dist/jquery.payform.min.js
21+
22+
watch: build
23+
$(BIN)watch 'make build' src
24+
25+
test:
26+
$(BIN)mocha test/**_spec.coffee
27+
28+
clean:
29+
rm -rf dist/*.js
30+
31+
.PHONY: build test watch

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ npm install payform --save
3838
```javascript
3939
var payform = require('payform');
4040

41+
// Format input for card number entry
42+
var input = document.getElementById('ccnum');
43+
payform.cardNumberInput(input)
44+
4145
// Validate a credit card number
4246
payform.validateCardNumber('4242 4242 4242 4242'); //=> true
4347

@@ -53,6 +57,10 @@ require.config({
5357
});
5458

5559
require(["payform"], function (payform) {
60+
// Format input for card number entry
61+
var input = document.getElementById('ccnum');
62+
payform.cardNumberInput(input)
63+
5664
// Validate a credit card number
5765
payform.validateCardNumber('4242 4242 4242 4242'); //=> true
5866

@@ -71,6 +79,10 @@ bower install payform --save
7179
```html
7280
<script src="path/to/payform/dist/payform.js"></script>
7381
<script>
82+
// Format input for card number entry
83+
var input = document.getElementById('ccnum');
84+
payform.cardNumberInput(input)
85+
7486
// Validate a credit card number
7587
payform.validateCardNumber('4242 4242 4242 4242'); //=> true
7688
@@ -79,6 +91,26 @@ bower install payform --save
7991
</script>
8092
```
8193

94+
### jQuery Plugin (also supports Zepto)
95+
96+
This library also includes a jquery plugin. The primary `payform` object
97+
can be found at `$.payform`, and there are jquery centric ways to utilize the [browser
98+
input formatters.](#browser-input-formatting-helpers)
99+
100+
```html
101+
<script src="path/to/payform/dist/jquery.payform.js"></script>
102+
<script>
103+
// Format input for card number entry
104+
$('input.ccnum').payform('formatCardNumber');
105+
106+
// Validate a credit card number
107+
$.payform.validateCardNumber('4242 4242 4242 4242'); //=> true
108+
109+
// Get card type from number
110+
$.payform.parseCardType('4242 4242 4242 4242'); //=> 'visa'
111+
</script>
112+
```
113+
82114
## API
83115

84116
### General Formatting and Validation
@@ -169,8 +201,12 @@ This function doesn't perform any validation of the month or year; use `payform.
169201

170202
These methods are specifically for use in the browser to attach `<input>` formatters.
171203

204+
(alternate [jQuery Plugin](#jquery-plugin) syntax is also provided)
205+
172206
#### payform.cardNumberInput(input)
173207

208+
_jQuery plugin:_ `$(...).payform('formatCardNumber')`
209+
174210
Formats card numbers:
175211

176212
* Includes a space between every 4 digits
@@ -187,6 +223,8 @@ payform.cardNumberInput(input);
187223

188224
#### payform.expiryInput(input)
189225

226+
_jQuery plugin:_ `$(...).payform('formatCardExpiry')`
227+
190228
Formats card expiry:
191229

192230
* Includes a `/` between the month and year
@@ -202,6 +240,8 @@ payform.expiryInput(input);
202240

203241
#### payform.cvcInput(input)
204242

243+
_jQuery plugin:_ `$(...).payform('formatCardCVC')`
244+
205245
Formats card CVC:
206246

207247
* Restricts length to 4 numbers
@@ -214,6 +254,19 @@ var input = document.getElementById('cvc');
214254
payform.cvcInput(input);
215255
```
216256

257+
#### payform.numericInput(input)
258+
259+
_jQuery plugin:_ `$(...).payform('formatNumeric')`
260+
261+
General numeric input restriction.
262+
263+
Example:
264+
265+
``` javascript
266+
var input = document.getElementById('numeric');
267+
payform.numericInput(input);
268+
```
269+
217270
### Custom Cards
218271

219272
#### payform.cards

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"name": "payform",
3-
"version": "1.0.2",
3+
"version": "1.1.0",
44
"main": "dist/payform.js"
55
}

0 commit comments

Comments
 (0)