weaver 0.8.14 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/data/weaver/css/plugins/codemirror/codemirror.css +97 -96
- data/data/weaver/css/style-dark.css +8628 -0
- data/data/weaver/css/style.css +37 -0
- data/data/weaver/js/plugins/codemirror/codemirror.js +8817 -6763
- data/data/weaver/js/plugins/skeuocard/Gruntfile.coffee +74 -0
- data/data/weaver/js/plugins/skeuocard/LICENSE +21 -0
- data/data/weaver/js/plugins/skeuocard/README.md +393 -0
- data/data/weaver/js/plugins/skeuocard/bower.json +40 -0
- data/data/weaver/js/plugins/skeuocard/fonts/ocra-webfont.eot +0 -0
- data/data/weaver/js/plugins/skeuocard/fonts/ocra-webfont.svg +138 -0
- data/data/weaver/js/plugins/skeuocard/fonts/ocra-webfont.ttf +0 -0
- data/data/weaver/js/plugins/skeuocard/fonts/ocra-webfont.woff +0 -0
- data/data/weaver/js/plugins/skeuocard/images/card-flip-arrow.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/card-front-background.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/card-invalid-indicator.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/card-valid-anim.gif +0 -0
- data/data/weaver/js/plugins/skeuocard/images/card-valid-indicator.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/error-pointer.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/issuers/visa-chase-sapphire.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/issuers/visa-simple-front.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/products/amex-front.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/products/dinersclubintl-front.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/products/discover-front.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/products/generic-back.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/products/generic-front.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/products/jcb-front.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/products/maestro-front.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/products/mastercard-front.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/products/unionpay-front.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/products/visa-back.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/products/visa-front.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/src/card-front-background.fw.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/src/error-pointer.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/src/product-amex-front.fw.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/src/product-dinersclub-front.fw.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/src/product-discover-front.fw.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/src/product-generic-front.fw.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/src/product-jcb-front.fw.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/src/product-maestro-front.fw.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/src/product-mastercard-front.fw.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/src/product-unionpay-front.fw.png +0 -0
- data/data/weaver/js/plugins/skeuocard/images/src/product-visa-front.fw.png +0 -0
- data/data/weaver/js/plugins/skeuocard/index.html +124 -0
- data/data/weaver/js/plugins/skeuocard/javascripts/skeuocard.js +1748 -0
- data/data/weaver/js/plugins/skeuocard/javascripts/skeuocard.min.js +2 -0
- data/data/weaver/js/plugins/skeuocard/javascripts/src/CardProduct.coffee +284 -0
- data/data/weaver/js/plugins/skeuocard/javascripts/src/ExpirationInputView.coffee +206 -0
- data/data/weaver/js/plugins/skeuocard/javascripts/src/FlipTabView.coffee +67 -0
- data/data/weaver/js/plugins/skeuocard/javascripts/src/SegmentedCardNumberInputView.coffee +284 -0
- data/data/weaver/js/plugins/skeuocard/javascripts/src/Skeuocard.coffee +439 -0
- data/data/weaver/js/plugins/skeuocard/javascripts/src/TextInputView.coffee +42 -0
- data/data/weaver/js/plugins/skeuocard/javascripts/vendor/cssua.min.js +7 -0
- data/data/weaver/js/plugins/skeuocard/javascripts/vendor/demo.fix.js +17 -0
- data/data/weaver/js/plugins/skeuocard/javascripts/vendor/jquery-2.0.3.min.js +5 -0
- data/data/weaver/js/plugins/skeuocard/package-lock.json +760 -0
- data/data/weaver/js/plugins/skeuocard/package.json +19 -0
- data/data/weaver/js/plugins/skeuocard/screenshot.png +0 -0
- data/data/weaver/js/plugins/skeuocard/styles/demo.css +2 -0
- data/data/weaver/js/plugins/skeuocard/styles/skeuocard.css +2 -0
- data/data/weaver/js/plugins/skeuocard/styles/skeuocard.reset.css +2 -0
- data/data/weaver/js/plugins/skeuocard/styles/src/_browser_hacks.scss +52 -0
- data/data/weaver/js/plugins/skeuocard/styles/src/_cards.scss +516 -0
- data/data/weaver/js/plugins/skeuocard/styles/src/_util.scss +15 -0
- data/data/weaver/js/plugins/skeuocard/styles/src/demo.scss +265 -0
- data/data/weaver/js/plugins/skeuocard/styles/src/skeuocard.reset.scss +60 -0
- data/data/weaver/js/plugins/skeuocard/styles/src/skeuocard.scss +190 -0
- data/lib/weaver/page_types/page.rb +5 -0
- data/lib/weaver/page_types/structured_page.rb +1 -1
- data/lib/weaver/version.rb +1 -1
- metadata +69 -6
@@ -0,0 +1,74 @@
|
|
1
|
+
# Thanks to Jackson Gariety (https://github.com/jacksongariety/) for
|
2
|
+
# contributing the initial version of this Gruntfile.
|
3
|
+
|
4
|
+
module.exports = (grunt) ->
|
5
|
+
path = require('path')
|
6
|
+
# Configure plugins
|
7
|
+
grunt.initConfig
|
8
|
+
|
9
|
+
express:
|
10
|
+
all:
|
11
|
+
options:
|
12
|
+
port: 8000
|
13
|
+
hostname: "0.0.0.0"
|
14
|
+
bases: [path.resolve(__dirname, '.')]
|
15
|
+
|
16
|
+
open:
|
17
|
+
all:
|
18
|
+
path: 'http://localhost:<%= express.all.options.port%>'
|
19
|
+
|
20
|
+
coffee:
|
21
|
+
all:
|
22
|
+
options:
|
23
|
+
join: true
|
24
|
+
files:
|
25
|
+
"./javascripts/skeuocard.js": [
|
26
|
+
"./javascripts/src/Skeuocard.coffee",
|
27
|
+
"./javascripts/src/FlipTabView.coffee",
|
28
|
+
"./javascripts/src/SegmentedCardNumberInputView.coffee",
|
29
|
+
"./javascripts/src/ExpirationInputView.coffee",
|
30
|
+
"./javascripts/src/TextInputView.coffee",
|
31
|
+
"./javascripts/src/CardProduct.coffee"
|
32
|
+
]
|
33
|
+
|
34
|
+
sass:
|
35
|
+
all:
|
36
|
+
options:
|
37
|
+
style: 'compressed'
|
38
|
+
files:
|
39
|
+
"./styles/skeuocard.reset.css": "./styles/src/skeuocard.reset.scss"
|
40
|
+
"./styles/skeuocard.css": "./styles/src/skeuocard.scss"
|
41
|
+
"./styles/demo.css": "./styles/src/demo.scss"
|
42
|
+
|
43
|
+
uglify:
|
44
|
+
all:
|
45
|
+
options:
|
46
|
+
mangle: false # don't change function names
|
47
|
+
files:
|
48
|
+
"./javascripts/skeuocard.min.js": "./javascripts/skeuocard.js"
|
49
|
+
|
50
|
+
watch:
|
51
|
+
all:
|
52
|
+
files: [
|
53
|
+
"./javascripts/src/*.coffee"
|
54
|
+
"./styles/src/*.scss"
|
55
|
+
]
|
56
|
+
tasks: ["coffee", "sass", "uglify"]
|
57
|
+
options:
|
58
|
+
livereload: true
|
59
|
+
|
60
|
+
|
61
|
+
# Load plugins
|
62
|
+
grunt.loadNpmTasks "grunt-contrib-watch"
|
63
|
+
grunt.loadNpmTasks "grunt-contrib-coffee"
|
64
|
+
grunt.loadNpmTasks "grunt-contrib-sass"
|
65
|
+
grunt.loadNpmTasks "grunt-contrib-uglify"
|
66
|
+
grunt.loadNpmTasks "grunt-open"
|
67
|
+
grunt.loadNpmTasks "grunt-express"
|
68
|
+
|
69
|
+
# Default task
|
70
|
+
grunt.registerTask "default", [
|
71
|
+
"express",
|
72
|
+
"open",
|
73
|
+
"watch"
|
74
|
+
]
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Ken Keiter <ken@kenkeiter.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,393 @@
|
|
1
|
+
## This is a fork of Skeuocard
|
2
|
+
|
3
|
+
I am not the original maintainer, but this piece of software has sat in rot for a while so I made a lot of trivial fixes to make it work for [my website generator DSL](https://davidsiaw.github.io/weaver-docs/dynamic/).
|
4
|
+
|
5
|
+
No guarantees are made whatsoever that it will work or be compatible with your website's framework cocktail.
|
6
|
+
|
7
|
+
No effort has been made whatsoever to make it responsive.
|
8
|
+
|
9
|
+
### Differences from the original Skeuocard
|
10
|
+
|
11
|
+
- MasterCard numbers are shown so they don't overlap the massive logo
|
12
|
+
- Supports MasterCard 2-series BINs
|
13
|
+
- Flip tab does not appear unless it needs to
|
14
|
+
- Variety of fixes for validations, and unneccessary errors
|
15
|
+
|
16
|
+
# Skeuocard (v1.2)
|
17
|
+
|
18
|
+

|
19
|
+
|
20
|
+
_Skeuocard_ is a re-think of the way we handle credit card input on the web. It progressively enhances credit card input forms so that the card inputs become skeuomorphic, facilitating accurate and fast card entry, and removing barriers to purchase.
|
21
|
+
|
22
|
+
You can try it out at [http://kenkeiter.com/skeuocard](http://kenkeiter.com/skeuocard).
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Skeuocard takes a standard credit card input form and partially transforms its DOM, removing non-essential elements, while leaving the underlying inputs alone. In order to use Skeuocard in your checkout page, you'll need to do one of two things.
|
27
|
+
|
28
|
+
### Bower
|
29
|
+
|
30
|
+
If you have [Bower](http://bower.io) then you can simply:
|
31
|
+
|
32
|
+
```bash
|
33
|
+
$ bower install skeuocard
|
34
|
+
```
|
35
|
+
|
36
|
+
### Manually
|
37
|
+
|
38
|
+
Or you can link the necessary style sheets and scripts, and make sure any asset dependencies are at the right paths.
|
39
|
+
|
40
|
+
```html
|
41
|
+
<head>
|
42
|
+
<!-- ... your CSS includes ... -->
|
43
|
+
<link rel="stylesheet" href="styles/skeuocard.reset.css" />
|
44
|
+
<link rel="stylesheet" href="styles/skeuocard.css" />
|
45
|
+
<link rel="stylesheet" href="styles/demo.css">
|
46
|
+
<script src="javascripts/vendor/cssua.min.js"></script>
|
47
|
+
<!-- ... -->
|
48
|
+
</head>
|
49
|
+
```
|
50
|
+
|
51
|
+
Make sure your credit card inputs are within their own containing element (most likely a `<div>`). In the example below, the `name` attribute of the inputs is significant because Skeuocard needs to determine which inputs should remain intact and be used to store the underlying card values.
|
52
|
+
|
53
|
+
Side note: If you'd like to use different input `name`s or selectors, you can specify those at instantiation. See the "Changing Underlying Value Selectors" section, below.
|
54
|
+
|
55
|
+
```html
|
56
|
+
<div class="credit-card-input no-js" id="skeuocard">
|
57
|
+
<p class="no-support-warning">
|
58
|
+
Either you have Javascript disabled, or you're using an unsupported browser, amigo! That's why you're seeing this old-school credit card input form instead of a fancy new Skeuocard. On the other hand, at least you know it gracefully degrades...
|
59
|
+
</p>
|
60
|
+
<label for="cc_type">Card Type</label>
|
61
|
+
<select name="cc_type">
|
62
|
+
<option value="">...</option>
|
63
|
+
<option value="visa">Visa</option>
|
64
|
+
<option value="discover">Discover</option>
|
65
|
+
<option value="mastercard">MasterCard</option>
|
66
|
+
<option value="maestro">Maestro</option>
|
67
|
+
<option value="jcb">JCB</option>
|
68
|
+
<option value="unionpay">China UnionPay</option>
|
69
|
+
<option value="amex">American Express</option>
|
70
|
+
<option value="dinersclubintl">Diners Club</option>
|
71
|
+
</select>
|
72
|
+
<label for="cc_number">Card Number</label>
|
73
|
+
<input type="text" name="cc_number" id="cc_number" placeholder="XXXX XXXX XXXX XXXX" maxlength="19" size="19">
|
74
|
+
<label for="cc_exp_month">Expiration Month</label>
|
75
|
+
<input type="text" name="cc_exp_month" id="cc_exp_month" placeholder="00">
|
76
|
+
<label for="cc_exp_year">Expiration Year</label>
|
77
|
+
<input type="text" name="cc_exp_year" id="cc_exp_year" placeholder="00">
|
78
|
+
<label for="cc_name">Cardholder's Name</label>
|
79
|
+
<input type="text" name="cc_name" id="cc_name" placeholder="John Doe">
|
80
|
+
<label for="cc_cvc">Card Validation Code</label>
|
81
|
+
<input type="text" name="cc_cvc" id="cc_cvc" placeholder="123" maxlength="3" size="3">
|
82
|
+
</div>
|
83
|
+
```
|
84
|
+
|
85
|
+
When the Skeuocard is instantiated for the containing element above, all children of the containing element will be removed except for the underlying form fields.
|
86
|
+
|
87
|
+
Causing a Skeuocard to appear instead is as simple as:
|
88
|
+
|
89
|
+
```javascript
|
90
|
+
$(document).ready(function(){
|
91
|
+
card = new Skeuocard($("#skeuocard"));
|
92
|
+
});
|
93
|
+
```
|
94
|
+
|
95
|
+
That's it! You've got a skeuomorphic credit card input, instead of your normal, confusing form.
|
96
|
+
|
97
|
+
### Beyond the Basics
|
98
|
+
|
99
|
+
#### Enabling Debugging Output
|
100
|
+
|
101
|
+
Skeuocard occasionally provides useful debugging output. By instantiating Skeuocard with the `debug` option set to true, those messages will be sent to `console.log` and prefixed with `[skeuocard]`.
|
102
|
+
|
103
|
+
```javascript
|
104
|
+
new Skeuocard($("#skeuocard"), {
|
105
|
+
debug: true
|
106
|
+
});
|
107
|
+
```
|
108
|
+
|
109
|
+
#### Turn off Focusing the Input by Default
|
110
|
+
|
111
|
+
By default, when Skeuocard is initialized, the input field will be focused. If you don't want this to happen (for example, if the skeuocard element is positioned below the fold and you want to prevent the browser from scrolling there), then pass `dontFocus: true` as an initialization option.
|
112
|
+
|
113
|
+
```javascript
|
114
|
+
new Skeuocard($("#skeuocard"), {
|
115
|
+
dontFocus: true
|
116
|
+
});
|
117
|
+
|
118
|
+
```
|
119
|
+
|
120
|
+
#### Providing Initial Values
|
121
|
+
|
122
|
+
Sometimes you'll need to pre-fill credit card information when you load the page. To do so, you can simply provide a `value` attribute for your form fields (or `<option selected ...>`, in the case of a `<select>`), and Skeuocard will pick up your initial values when instantiated.
|
123
|
+
|
124
|
+
Alternately, you can instantiate your Skeuocard instance with an `initialValues` object, which will override any existing values provided in the form, like so:
|
125
|
+
|
126
|
+
```javascript
|
127
|
+
new Skeuocard($("#skeuocard"), {
|
128
|
+
initialValues: {
|
129
|
+
number: "4111111111111111",
|
130
|
+
expMonth: "1",
|
131
|
+
expYear: "2016",
|
132
|
+
name: "James Doe",
|
133
|
+
cvc: "123"
|
134
|
+
}
|
135
|
+
});
|
136
|
+
```
|
137
|
+
|
138
|
+
#### Changing Values on the Fly
|
139
|
+
|
140
|
+
You can also change Skeuocard values manually by changing the underlying form element's value, and triggering a `change` event.
|
141
|
+
|
142
|
+
```javascript
|
143
|
+
$('[name="cc_number"]').val('4111111111111111').trigger('change')
|
144
|
+
```
|
145
|
+
|
146
|
+
#### Changing Placeholder Strings
|
147
|
+
|
148
|
+
You can change the character which Skeuocard uses as a placeholder for segmented card inputs, as well as the placeholder on the generic card view (visible when a card type has not been determined) by providing either of the following options at instantiation: `cardNumberPlaceholderChar` and `genericPlaceholder`.
|
149
|
+
|
150
|
+
`cardNumberPlaceholderChar` is used for filling only segmented inputs (i.e. "[XXXX] [XXXX] [XXXX] [XXXX]") and is by default set to `X`. The `genericPlaceholder` value is used when the card type has not yet been determined, and is by default set to `XXXX XXXX XXXX XXXX`.
|
151
|
+
|
152
|
+
```javascript
|
153
|
+
new Skeuocard($("#skeuocard"), {
|
154
|
+
cardNumberPlaceholderChar: '*',
|
155
|
+
genericPlaceholder: '**** **** **** ****'
|
156
|
+
});
|
157
|
+
```
|
158
|
+
|
159
|
+
#### Changing Underlying Value Selectors
|
160
|
+
|
161
|
+
When a Skeuocard is instantiated, it attaches itself to a container element and removes any unneeded children, before adding its own; *however,* Skeuocard stores its values in pre-existing input fields, which aren't selected for removal.
|
162
|
+
|
163
|
+
By default, Skeuocard sets the following default selectors to match the underlying form fields within the container element, and use them to store values:
|
164
|
+
|
165
|
+
* `typeInputSelector: [name="cc_type"]`
|
166
|
+
* `numberInputSelector: [name="cc_number"]`
|
167
|
+
* `expMonthInputSelector: [name="cc_exp_month"]`
|
168
|
+
* `expYearInputSelector: [name="cc_exp_year"]`
|
169
|
+
* `nameInputSelector: [name="cc_name"]`
|
170
|
+
* `cvcInputSelector: [name="cc_cvc"]`
|
171
|
+
|
172
|
+
Providing any of those options with different values at instantiation will cause Skeuocard to use your supplied selector, instead! For example, if our credit card number field had a `name` of `credit_card_number` (instead of the default `cc_number`), we could change it at instantiation like so:
|
173
|
+
|
174
|
+
```javascript
|
175
|
+
new Skeuocard($("#skeuocard"), {
|
176
|
+
numberInputSelector: '[name="credit_card_number"]'
|
177
|
+
});
|
178
|
+
```
|
179
|
+
|
180
|
+
#### Using the Server's Current Date
|
181
|
+
|
182
|
+
If you're smart, you probably won't want to use the client's local `Date` to validate against when checking expiration. You can specify a `Date` to check against at instantiation by setting `currentDate` on the Skeuocard class like so:
|
183
|
+
|
184
|
+
```javascript
|
185
|
+
Skeuocard.currentDate = new Date(year, month, day);
|
186
|
+
```
|
187
|
+
|
188
|
+
Note that month is an integer from 0 - 11.
|
189
|
+
|
190
|
+
By default, Skeuocard will automatically use the client's local Date.
|
191
|
+
|
192
|
+
#### Specifying Accepted Card Products
|
193
|
+
|
194
|
+
Only accept Visa and AmEx? No worries. Skeuocard has you covered. You can specify accepted card types with an options argument, or in the underlying form itself.
|
195
|
+
|
196
|
+
To limit your accepted card products, simply add or remove `<option>`s from your type `<select>` where either the `value` attribute matches the shortname of the product (see the example below), or the `data-sc-type` attribute is set to the shortname of the product (if your `value` needs to be different for legacy purposes).
|
197
|
+
|
198
|
+
```html
|
199
|
+
<select name="cc_type">
|
200
|
+
<option value="">...</option>
|
201
|
+
<option value="visa">Visa</option>
|
202
|
+
<option value="mastercard">MasterCard</option>
|
203
|
+
<option value="maestro">Maestro</option>
|
204
|
+
<option value="amex">American Express</option>
|
205
|
+
<option value="diners" data-sc-type="dinersclubintl">Diners Club</option>
|
206
|
+
</select>
|
207
|
+
```
|
208
|
+
|
209
|
+
You can also optionally override this list by providing an array of accepted card product shortnames at instantiation, like so:
|
210
|
+
|
211
|
+
```javascript
|
212
|
+
new Skeuocard($("#skeuocard"), {
|
213
|
+
acceptedCardProducts: ['visa', 'amex']
|
214
|
+
});
|
215
|
+
```
|
216
|
+
|
217
|
+
#### jQuery's noConflict Mode
|
218
|
+
|
219
|
+
If you are using jQuery's `noConflict` mode, you'll need to instantiate your Skeuocard instance slightly differently than above:
|
220
|
+
|
221
|
+
```javascript
|
222
|
+
jQuery(document).ready(function(){
|
223
|
+
card = new Skeuocard(jQuery("#skeuocard"));
|
224
|
+
});
|
225
|
+
```
|
226
|
+
|
227
|
+
#### Progressive Enhancement
|
228
|
+
|
229
|
+
Progressive enhancement was really important to me when creating this plugin. I wanted to make sure that a potential purchase opportunity would never be denied by a failure in Skeuocard, so I chose to take an approach which would leave the users with a functional, styled form in the event that Skeuocard fails.
|
230
|
+
|
231
|
+
You can style your un-enhanced form elements in whichever way you wish. When Skeuocard is instantiated, it will automatically add both the `skeuocard` and `js` classes to the container, which will match the selectors necessary to style the card input properly.
|
232
|
+
|
233
|
+
#### Checking Validity
|
234
|
+
|
235
|
+
At some point or another, you're going to want your user to submit your purchase form -- so how do you determine if the credit card input they provided is valid? While there are several ways of doing this, there's one recommended way:
|
236
|
+
|
237
|
+
```javascript
|
238
|
+
card.isValid() // => Boolean
|
239
|
+
```
|
240
|
+
|
241
|
+
#### Showing Errors at Instantiation
|
242
|
+
|
243
|
+
Sometimes you'll want to indicate a problem with the card to the user at instantiation -- for example, if the card number (after having been submitted to your payment processor) is determined to be incorrect. You can do this one of two ways: by adding the `invalid` class to your underlying `number` form field at instantiation, or by passing an initial `validationState` argument with your options.
|
244
|
+
|
245
|
+
Applying the `invalid` class to the invalid field:
|
246
|
+
|
247
|
+
```html
|
248
|
+
...
|
249
|
+
<input type="text" name="cc_number" id="cc_number" placeholder="XXXX XXXX XXXX XXXX" maxlength="19" size="19" class="invalid">
|
250
|
+
...
|
251
|
+
```
|
252
|
+
|
253
|
+
Providing a list of invalid fields at instantiation:
|
254
|
+
|
255
|
+
```javascript
|
256
|
+
new Skeuocard($("#skeuocard"), {
|
257
|
+
validationState: {
|
258
|
+
number: false,
|
259
|
+
exp: true,
|
260
|
+
name: true,
|
261
|
+
cvc: true
|
262
|
+
}
|
263
|
+
});
|
264
|
+
```
|
265
|
+
|
266
|
+
Note that, if the CVC is on the back of the card for the matching card product, the card will automatically flip to show the invalid field.
|
267
|
+
|
268
|
+
#### Registering Custom Card Layouts
|
269
|
+
|
270
|
+
You may wish to add a custom layout to support a card (BIN) specific to your locale, or for promotional reasons. You can do so easily.
|
271
|
+
|
272
|
+
You'll need to create a set of transparent PNG file containing any elements you wish to appear on the card faces. For an example, see any of the images in the `images/products/` folder. If you have Adobe Fireworks installed, the editable images are also included in `images/src/`.
|
273
|
+
|
274
|
+
For an example of how to style a card, see `styles/_cards.scss`.
|
275
|
+
|
276
|
+
Once you have created your images and the appropriate CSS styling, you will need to create a new CardProduct or variation of an existing card product. Lets say that we're matching a new type of gift card with a BIN (9123) that doesn't match any of the pre-defined credit card providers:
|
277
|
+
|
278
|
+
```javascript
|
279
|
+
// Create a new CardProduct instance, and register it with Skeuocard.
|
280
|
+
Skeuocard.CardProduct.create({
|
281
|
+
pattern: /^9123/, // match all cards starting with 9123
|
282
|
+
companyName: "Fancy Gift Card Inc.",
|
283
|
+
companyShortname: "fancycard", // this will be the card type
|
284
|
+
cardNumberGrouping: [4,4,4,4], // how the number input should group
|
285
|
+
cardNumberLength: [14], // array of valid card number lengths
|
286
|
+
expirationFormat: "MM/YY", // format of the date field
|
287
|
+
cvcLength: 3, // the length of the CVC
|
288
|
+
validateLuhn: true, // validate using the Luhn algorithm?
|
289
|
+
layout: {
|
290
|
+
number: 'front',
|
291
|
+
exp: 'front',
|
292
|
+
name: 'front',
|
293
|
+
cvc: 'back'
|
294
|
+
}
|
295
|
+
});
|
296
|
+
```
|
297
|
+
|
298
|
+
Now, lets say that we'd like to recognize and apply a layout for a Visa card with a specific BIN. First, we'd select the matching card product, and then add a variant, which will extend it:
|
299
|
+
|
300
|
+
```javascript
|
301
|
+
// find the existing Visa product
|
302
|
+
var visaProduct = Skeuocard.CardProduct.firstMatchingShortname('visa');
|
303
|
+
// register a new variation of the Visa product
|
304
|
+
visaProduct.createVariation({
|
305
|
+
pattern: /^414720/,
|
306
|
+
issuingAuthority: "Chase",
|
307
|
+
issuerName: "Chase Sapphire Card",
|
308
|
+
issuerShortname: "chase-sapphire",
|
309
|
+
layout:
|
310
|
+
number: 'front',
|
311
|
+
exp: 'front',
|
312
|
+
name: 'front',
|
313
|
+
cvc: 'front'
|
314
|
+
});
|
315
|
+
```
|
316
|
+
|
317
|
+
#### Design Customization
|
318
|
+
|
319
|
+
You might not like the way Skeuocard looks. That's easy to fix; CSS is used to style and position most elements in Skeuocard, with the exception of the card faces.
|
320
|
+
|
321
|
+
## Browser Compatibility
|
322
|
+
|
323
|
+
Skeuocard aims to gain better compatibility with older browsers, but for the time being, it looks good and works well in the following browsers:
|
324
|
+
|
325
|
+
* Chrome (Mac, Win)
|
326
|
+
* Safari (Mac)
|
327
|
+
* Firefox > 18 (Mac, Win)
|
328
|
+
* Mobile Safari (iOS)
|
329
|
+
* Mobile Chrome (iOS/Android)
|
330
|
+
* IE 10+ (Win)
|
331
|
+
|
332
|
+
It's recommended that you selectively disable Skeuocard based upon browser version, to retain maximum compatibility. If you have an odd or obscure browser, and wish to submit a patch, that's always appreciated!
|
333
|
+
|
334
|
+
## Integration
|
335
|
+
|
336
|
+
* The [skeuocard-rails](https://github.com/rougecardinal/skeuocard-rails) gem provides integration with the Rails asset pipeline.
|
337
|
+
|
338
|
+
## Development
|
339
|
+
|
340
|
+
Contributing to Skeuocard is pretty simple. Simply fork the project, make your changes in a branch, and submit a pull request.
|
341
|
+
|
342
|
+
I'll do my best to keep an eye out for pull requests and triage any submitted issues. Please note that you MUST make changes on the src (.coffee, .scss) files, compile the changes with Grunt, and include any compiled changes in any pull requests you submit.
|
343
|
+
|
344
|
+
#### Getting Up and Running
|
345
|
+
|
346
|
+
Ensure that you have the following tools installed before continuing:
|
347
|
+
|
348
|
+
* [NodeJS/NPM](http://nodejs.org/download/)
|
349
|
+
* [SASS](http://sass-lang.com/)
|
350
|
+
* [CoffeeScript](http://coffeescript.org/)
|
351
|
+
|
352
|
+
To begin working on Skeuocard, fork the repository to your Github account, and clone it to your machine.
|
353
|
+
|
354
|
+
Once you have `cd`ed to your cloned `skeuocard` repository, you'll need to install the required Node packages:
|
355
|
+
|
356
|
+
$ npm install
|
357
|
+
|
358
|
+
Once that's completed, simply run:
|
359
|
+
|
360
|
+
$ grunt
|
361
|
+
|
362
|
+
Upon starting `grunt`, the following things will happen:
|
363
|
+
|
364
|
+
* a development server will be started on `0.0.0.0:8000`;
|
365
|
+
* `index.html` will be opened automatically in your browser;
|
366
|
+
* grunt will begin watching for changes to source files, and setup live-reload
|
367
|
+
* source files will be recompiled automatically when changes are made.
|
368
|
+
|
369
|
+
Simply make your changes to the necessary source files (typically under the `src` directory of each directory in the project), commit the changes (including the compiled changes), and submit a pull request!
|
370
|
+
|
371
|
+
#### New Card Layouts & Graphics
|
372
|
+
|
373
|
+
I've done my best to include layouts for all major card products (Visa, MasterCard, Amex, etc.) in the project. It is entirely possible that I've missed some products, and that the addition of a product is justified; however, I'm not accepting issuer-specific layouts (for things like Visa-branded products) at this time. There are literally thousands of them, and doing so could be seen as discriminatory.
|
374
|
+
|
375
|
+
For the time being, the only reason I'll make an exception is for cards like the Chase Sapphire, which is a Visa product, but has been granted an allowance by Visa to drastically alter the appearance and field layout of the card.
|
376
|
+
|
377
|
+
All of that said, I'm working on a standardized method of distributing issuer-specific layouts for users who wish to cater to popular cards in their locale, etc.
|
378
|
+
|
379
|
+
## Licensing
|
380
|
+
|
381
|
+
Skeuocard is licensed under the [MIT license](http://opensource.org/licenses/MIT). Share and enjoy :)
|
382
|
+
|
383
|
+
* The [*OCR-A font*](http://ansuz.sooke.bc.ca/page/fonts#ocra) included with this project was converted and released for free commercial and non-commercial use by [Matthew Skala](http://ansuz.sooke.bc.ca/page/about).
|
384
|
+
* [*CSS User Agent*](http://cssuseragent.org/) by [Stephen M. McKamey](http://stephen.mckamey.com/) is included under its [MIT license](https://bitbucket.org/mckamey/cssuseragent/raw/tip/LICENSE.txt).
|
385
|
+
* [*jQuery*](http://jquery.com/) 2.0.3 is included under its [MIT license](https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt).
|
386
|
+
|
387
|
+
The trademarks and branding assets of the credit card products used in this project have not been used with express consent of their owners; this project is intended for use only by those whom have the proper authorization to do so. The trademarks and branding included in this project are property of their respective owners.
|
388
|
+
|
389
|
+
Any complaints should be sent to me at: ken+skeuocard-complaints@kenkeiter.com and I will address them promptly.
|
390
|
+
|
391
|
+
### Special Thanks
|
392
|
+
|
393
|
+
I owe a special thanks to my guinea-pig users, and to the designers I met in coffee shops who took the time to critique this work.
|
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
"name": "skeuocard",
|
3
|
+
"keywords": [
|
4
|
+
"credit",
|
5
|
+
"card",
|
6
|
+
"skeuomorphism"
|
7
|
+
],
|
8
|
+
"description": "Skeuocard progressively enhances credit card inputs to provide a skeuomorphic interface.",
|
9
|
+
"version": "1.1.0",
|
10
|
+
"license": "The MIT License (MIT)",
|
11
|
+
"readmeFilename": "README.md",
|
12
|
+
"repository": {
|
13
|
+
"type": "git",
|
14
|
+
"url": "git://github.com:kenkeiter/skeuocard.git"
|
15
|
+
},
|
16
|
+
"main": [
|
17
|
+
"styles/skeuocard.reset.css",
|
18
|
+
"styles/skeuocard.css",
|
19
|
+
"javascripts/vendor/cssua.min.js",
|
20
|
+
"javascripts/vendor/demo.fix.js",
|
21
|
+
"javascripts/vendor/jquery-2.0.3.min.js",
|
22
|
+
"javascripts/skeuocard.js",
|
23
|
+
"javascripts/skeuocard.min.js"
|
24
|
+
],
|
25
|
+
"ignore": [
|
26
|
+
"Gruntfile.coffee",
|
27
|
+
"package.json",
|
28
|
+
"index.html",
|
29
|
+
"screenshot.png",
|
30
|
+
"**/.*",
|
31
|
+
"node_modules",
|
32
|
+
"bower_components",
|
33
|
+
"test",
|
34
|
+
"tests"
|
35
|
+
],
|
36
|
+
"homepage": "https://github.com/kenkeiter/skeuocard",
|
37
|
+
"authors": [
|
38
|
+
"Kenneth Keiter <ken@kenkeiter.com>"
|
39
|
+
]
|
40
|
+
}
|
Binary file
|