Skip to content

Commit bcad79f

Browse files
committed
more proper makefile and updated jquery docs
1 parent 1c06272 commit bcad79f

File tree

2 files changed

+76
-8
lines changed

2 files changed

+76
-8
lines changed

Makefile

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
11
SHELL := /bin/bash
2-
BIN := ./node_modules/.bin/
2+
BIN := node_modules/.bin/
33

4-
build:
5-
$(BIN)coffee -c --no-header -o ./dist/ ./src/payform.coffee
6-
$(BIN)uglify -s ./dist/payform.js -o ./dist/payform.min.js
7-
$(BIN)browserify -p bundle-collapser/plugin -t coffeeify --extension='.coffee' ./src/jquery.payform.coffee > ./dist/jquery.payform.js
8-
$(BIN)uglify -s ./dist/jquery.payform.js -o ./dist/jquery.payform.min.js
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
921

1022
watch: build
11-
$(BIN)watch 'make build' ./src
23+
$(BIN)watch 'make build' src
1224

1325
test:
14-
$(BIN)mocha ./test/**_spec.coffee
26+
$(BIN)mocha test/**_spec.coffee
27+
28+
clean:
29+
rm -rf dist/*.js
1530

1631
.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
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

0 commit comments

Comments
 (0)