weaver 0.8.2 → 0.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/bin/console +1 -0
  4. data/data/weaver/js/plugins/skeuocard/Gruntfile.coffee +74 -0
  5. data/{LICENSE.txt → data/weaver/js/plugins/skeuocard/LICENSE} +2 -2
  6. data/data/weaver/js/plugins/skeuocard/README.md +388 -0
  7. data/data/weaver/js/plugins/skeuocard/bower.json +40 -0
  8. data/data/weaver/js/plugins/skeuocard/fonts/ocra-webfont.eot +0 -0
  9. data/data/weaver/js/plugins/skeuocard/fonts/ocra-webfont.svg +138 -0
  10. data/data/weaver/js/plugins/skeuocard/fonts/ocra-webfont.ttf +0 -0
  11. data/data/weaver/js/plugins/skeuocard/fonts/ocra-webfont.woff +0 -0
  12. data/data/weaver/js/plugins/skeuocard/images/card-flip-arrow.png +0 -0
  13. data/data/weaver/js/plugins/skeuocard/images/card-front-background.png +0 -0
  14. data/data/weaver/js/plugins/skeuocard/images/card-invalid-indicator.png +0 -0
  15. data/data/weaver/js/plugins/skeuocard/images/card-valid-anim.gif +0 -0
  16. data/data/weaver/js/plugins/skeuocard/images/card-valid-indicator.png +0 -0
  17. data/data/weaver/js/plugins/skeuocard/images/error-pointer.png +0 -0
  18. data/data/weaver/js/plugins/skeuocard/images/issuers/visa-chase-sapphire.png +0 -0
  19. data/data/weaver/js/plugins/skeuocard/images/issuers/visa-simple-front.png +0 -0
  20. data/data/weaver/js/plugins/skeuocard/images/products/amex-front.png +0 -0
  21. data/data/weaver/js/plugins/skeuocard/images/products/dinersclubintl-front.png +0 -0
  22. data/data/weaver/js/plugins/skeuocard/images/products/discover-front.png +0 -0
  23. data/data/weaver/js/plugins/skeuocard/images/products/generic-back.png +0 -0
  24. data/data/weaver/js/plugins/skeuocard/images/products/generic-front.png +0 -0
  25. data/data/weaver/js/plugins/skeuocard/images/products/jcb-front.png +0 -0
  26. data/data/weaver/js/plugins/skeuocard/images/products/maestro-front.png +0 -0
  27. data/data/weaver/js/plugins/skeuocard/images/products/mastercard-front.png +0 -0
  28. data/data/weaver/js/plugins/skeuocard/images/products/unionpay-front.png +0 -0
  29. data/data/weaver/js/plugins/skeuocard/images/products/visa-back.png +0 -0
  30. data/data/weaver/js/plugins/skeuocard/images/products/visa-front.png +0 -0
  31. data/data/weaver/js/plugins/skeuocard/images/src/card-front-background.fw.png +0 -0
  32. data/data/weaver/js/plugins/skeuocard/images/src/error-pointer.png +0 -0
  33. data/data/weaver/js/plugins/skeuocard/images/src/product-amex-front.fw.png +0 -0
  34. data/data/weaver/js/plugins/skeuocard/images/src/product-dinersclub-front.fw.png +0 -0
  35. data/data/weaver/js/plugins/skeuocard/images/src/product-discover-front.fw.png +0 -0
  36. data/data/weaver/js/plugins/skeuocard/images/src/product-generic-front.fw.png +0 -0
  37. data/data/weaver/js/plugins/skeuocard/images/src/product-jcb-front.fw.png +0 -0
  38. data/data/weaver/js/plugins/skeuocard/images/src/product-maestro-front.fw.png +0 -0
  39. data/data/weaver/js/plugins/skeuocard/images/src/product-mastercard-front.fw.png +0 -0
  40. data/data/weaver/js/plugins/skeuocard/images/src/product-unionpay-front.fw.png +0 -0
  41. data/data/weaver/js/plugins/skeuocard/images/src/product-visa-front.fw.png +0 -0
  42. data/data/weaver/js/plugins/skeuocard/index.html +124 -0
  43. data/data/weaver/js/plugins/skeuocard/javascripts/skeuocard.js +1748 -0
  44. data/data/weaver/js/plugins/skeuocard/javascripts/skeuocard.min.js +2 -0
  45. data/data/weaver/js/plugins/skeuocard/javascripts/src/CardProduct.coffee +284 -0
  46. data/data/weaver/js/plugins/skeuocard/javascripts/src/ExpirationInputView.coffee +206 -0
  47. data/data/weaver/js/plugins/skeuocard/javascripts/src/FlipTabView.coffee +67 -0
  48. data/data/weaver/js/plugins/skeuocard/javascripts/src/SegmentedCardNumberInputView.coffee +284 -0
  49. data/data/weaver/js/plugins/skeuocard/javascripts/src/Skeuocard.coffee +439 -0
  50. data/data/weaver/js/plugins/skeuocard/javascripts/src/TextInputView.coffee +42 -0
  51. data/data/weaver/js/plugins/skeuocard/javascripts/vendor/cssua.min.js +7 -0
  52. data/data/weaver/js/plugins/skeuocard/javascripts/vendor/demo.fix.js +17 -0
  53. data/data/weaver/js/plugins/skeuocard/javascripts/vendor/jquery-2.0.3.min.js +5 -0
  54. data/data/weaver/js/plugins/skeuocard/package-lock.json +760 -0
  55. data/data/weaver/js/plugins/skeuocard/package.json +19 -0
  56. data/data/weaver/js/plugins/skeuocard/screenshot.png +0 -0
  57. data/data/weaver/js/plugins/skeuocard/styles/demo.css +2 -0
  58. data/data/weaver/js/plugins/skeuocard/styles/demo.css.map +7 -0
  59. data/data/weaver/js/plugins/skeuocard/styles/skeuocard.css +2 -0
  60. data/data/weaver/js/plugins/skeuocard/styles/skeuocard.css.map +7 -0
  61. data/data/weaver/js/plugins/skeuocard/styles/skeuocard.reset.css +2 -0
  62. data/data/weaver/js/plugins/skeuocard/styles/skeuocard.reset.css.map +7 -0
  63. data/data/weaver/js/plugins/skeuocard/styles/src/_browser_hacks.scss +52 -0
  64. data/data/weaver/js/plugins/skeuocard/styles/src/_cards.scss +502 -0
  65. data/data/weaver/js/plugins/skeuocard/styles/src/_util.scss +15 -0
  66. data/data/weaver/js/plugins/skeuocard/styles/src/demo.scss +265 -0
  67. data/data/weaver/js/plugins/skeuocard/styles/src/skeuocard.reset.scss +60 -0
  68. data/data/weaver/js/plugins/skeuocard/styles/src/skeuocard.scss +178 -0
  69. data/exe/weaver +25 -24
  70. data/lib/weaver.rb +2 -0
  71. data/lib/weaver/element_types/accordion.rb +2 -0
  72. data/lib/weaver/element_types/action.rb +6 -4
  73. data/lib/weaver/element_types/code.rb +2 -0
  74. data/lib/weaver/element_types/credit_card_form.rb +117 -0
  75. data/lib/weaver/element_types/dynamic_table.rb +7 -5
  76. data/lib/weaver/element_types/dynamic_table_cell.rb +2 -0
  77. data/lib/weaver/element_types/form.rb +9 -7
  78. data/lib/weaver/element_types/form_elements.rb +16 -73
  79. data/lib/weaver/element_types/javascript_object.rb +2 -0
  80. data/lib/weaver/element_types/modal_dialog.rb +2 -0
  81. data/lib/weaver/element_types/panel.rb +2 -0
  82. data/lib/weaver/element_types/row.rb +2 -0
  83. data/lib/weaver/element_types/tabs.rb +2 -0
  84. data/lib/weaver/element_types/textfield_javascript.rb +37 -35
  85. data/lib/weaver/elements.rb +2 -0
  86. data/lib/weaver/page_types/center_page.rb +2 -0
  87. data/lib/weaver/page_types/empty_page.rb +10 -8
  88. data/lib/weaver/page_types/nav_page.rb +2 -0
  89. data/lib/weaver/page_types/nonnav_page.rb +14 -12
  90. data/lib/weaver/page_types/page.rb +67 -65
  91. data/lib/weaver/page_types/raw_page.rb +2 -0
  92. data/lib/weaver/page_types/sidenav_page.rb +33 -31
  93. data/lib/weaver/page_types/structured_page.rb +2 -0
  94. data/lib/weaver/page_types/topnav_page.rb +35 -35
  95. data/lib/weaver/version.rb +3 -1
  96. data/lib/weaver/weave.rb +2 -0
  97. data/spec/spec_helper.rb +4 -0
  98. data/spec/weaver_spec.rb +13 -0
  99. data/weaver.gemspec +4 -3
  100. metadata +73 -12
  101. data/.gitignore +0 -10
  102. data/.gitmodules +0 -3
  103. data/.rspec +0 -2
  104. data/.travis.yml +0 -3
  105. data/CODE_OF_CONDUCT.md +0 -13
  106. data/README.md +0 -39
  107. data/Rakefile +0 -1
  108. data/data/weaver/js/MathJax/extensions/a11y/mathmaps/.htaccess +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 220a671a0bed8931b6c2e47d2d6a804a96d1894c7867f0fb253e2b037783e1ac
4
- data.tar.gz: 23c020aad09cfd09d9495d21ad5101f4f39b8e102704753b36c030d202aae60a
3
+ metadata.gz: abfaf130015f2ffc43c2e607610b5aeb84b17dbf83924f0fc54bd24660a01478
4
+ data.tar.gz: d40fc5cab70c1b319dc829903999a4815dcd1569a2fc30bb3af597e9066bbdad
5
5
  SHA512:
6
- metadata.gz: d1376013058319efd0a7a922f0adfc7a9ef943f67db9fc632fb98edcd6a0b73f544274a6cc201cc6ccc729450a426076bd544c5630230ec5ebae609d38f66601
7
- data.tar.gz: e47239b8695dacd72312768679c77addc1d3e7de916d02f6cfaff5cbf34fb7a1b6c35d903bac74e004d36875789cb4330771919555e24fb2117352e2ffbfd1ed
6
+ metadata.gz: b408b1ac91f798b9eb717a37435f44c5c1e83fd337722dd0255e87282d4d9bf81b60cb18b7c40346b22f4427b5a22559fc093f4d91027669f7f2a6679b049aaf
7
+ data.tar.gz: 537edf229320c647597351e76177a5ca8f44e25dd43732f55a902c3535f70b106ab619dfb9d17b652214c10cab25ab5d99d9f0e3fbbd821a9517a5343386af81
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in weaver.gemspec
data/bin/console CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'weaver'
@@ -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
+ ]
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 David Siaw
3
+ Copyright (c) 2013 Ken Keiter <ken@kenkeiter.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
21
+ THE SOFTWARE.
@@ -0,0 +1,388 @@
1
+ # Looking for a new maintainer!
2
+
3
+ Unfortunately, I haven't been able to find the time that I would like to dedicate to this project. Although it is still widely stable on most browsers, the internet is an inherently unstable place, and the usability of Skeuocard will deteriorate over time if not maintained and improved. To further the use of Skeuocard, **I'm looking for a new maintainer for the Skeuocard project.**
4
+
5
+ To those of you that have submitted issues and pull requests: thank you so much for your time, attention to detail, and effort. I'm sorry that I haven't been able to return that. This was always meant to be at worst an experiment, and at best, a gift. I hope you enjoy Skeuocard, and I hope that we find a maintainer who can give this the attention your interest has demonstrated that it deserves.
6
+
7
+ If you believe yourself or someone you know to be qualified, please reach out to me via email: [ken+skeuocard@kenkeiter.com](mailto:ken+skeuocard@kenkeiter.com).
8
+
9
+ # Skeuocard (v1.0.3)
10
+
11
+ _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.
12
+
13
+ You can try it out at [http://kenkeiter.com/skeuocard](http://kenkeiter.com/skeuocard).
14
+
15
+ For more on the theory behind Skeuocard, check out the blog post that started it all: [_"Redesigning Credit Card Inputs"_](http://kenkeiter.com/2013/07/21/redesigning-credit-card-inputs/) by [me (Ken Keiter)](http://kenkeiter.com/).
16
+
17
+ ![Skeuocard at its finest.](https://raw.github.com/kenkeiter/skeuocard/master/screenshot.png)
18
+
19
+ ## Usage
20
+
21
+ 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.
22
+
23
+ ### Bower
24
+
25
+ If you have [Bower](http://bower.io) then you can simply:
26
+
27
+ ```bash
28
+ $ bower install skeuocard
29
+ ```
30
+
31
+ ### Manually
32
+
33
+ Or you can link the necessary style sheets and scripts, and make sure any asset dependencies are at the right paths.
34
+
35
+ ```html
36
+ <head>
37
+ <!-- ... your CSS includes ... -->
38
+ <link rel="stylesheet" href="styles/skeuocard.reset.css" />
39
+ <link rel="stylesheet" href="styles/skeuocard.css" />
40
+ <link rel="stylesheet" href="styles/demo.css">
41
+ <script src="javascripts/vendor/cssua.min.js"></script>
42
+ <!-- ... -->
43
+ </head>
44
+ ```
45
+
46
+ 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.
47
+
48
+ 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.
49
+
50
+ ```html
51
+ <div class="credit-card-input no-js" id="skeuocard">
52
+ <p class="no-support-warning">
53
+ 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...
54
+ </p>
55
+ <label for="cc_type">Card Type</label>
56
+ <select name="cc_type">
57
+ <option value="">...</option>
58
+ <option value="visa">Visa</option>
59
+ <option value="discover">Discover</option>
60
+ <option value="mastercard">MasterCard</option>
61
+ <option value="maestro">Maestro</option>
62
+ <option value="jcb">JCB</option>
63
+ <option value="unionpay">China UnionPay</option>
64
+ <option value="amex">American Express</option>
65
+ <option value="dinersclubintl">Diners Club</option>
66
+ </select>
67
+ <label for="cc_number">Card Number</label>
68
+ <input type="text" name="cc_number" id="cc_number" placeholder="XXXX XXXX XXXX XXXX" maxlength="19" size="19">
69
+ <label for="cc_exp_month">Expiration Month</label>
70
+ <input type="text" name="cc_exp_month" id="cc_exp_month" placeholder="00">
71
+ <label for="cc_exp_year">Expiration Year</label>
72
+ <input type="text" name="cc_exp_year" id="cc_exp_year" placeholder="00">
73
+ <label for="cc_name">Cardholder's Name</label>
74
+ <input type="text" name="cc_name" id="cc_name" placeholder="John Doe">
75
+ <label for="cc_cvc">Card Validation Code</label>
76
+ <input type="text" name="cc_cvc" id="cc_cvc" placeholder="123" maxlength="3" size="3">
77
+ </div>
78
+ ```
79
+
80
+ 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.
81
+
82
+ Causing a Skeuocard to appear instead is as simple as:
83
+
84
+ ```javascript
85
+ $(document).ready(function(){
86
+ card = new Skeuocard($("#skeuocard"));
87
+ });
88
+ ```
89
+
90
+ That's it! You've got a skeuomorphic credit card input, instead of your normal, confusing form.
91
+
92
+ ### Beyond the Basics
93
+
94
+ #### Enabling Debugging Output
95
+
96
+ 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]`.
97
+
98
+ ```javascript
99
+ new Skeuocard($("#skeuocard"), {
100
+ debug: true
101
+ });
102
+ ```
103
+
104
+ #### Turn off Focusing the Input by Default
105
+
106
+ 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.
107
+
108
+ ```javascript
109
+ new Skeuocard($("#skeuocard"), {
110
+ dontFocus: true
111
+ });
112
+
113
+ ```
114
+
115
+ #### Providing Initial Values
116
+
117
+ 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.
118
+
119
+ Alternately, you can instantiate your Skeuocard instance with an `initialValues` object, which will override any existing values provided in the form, like so:
120
+
121
+ ```javascript
122
+ new Skeuocard($("#skeuocard"), {
123
+ initialValues: {
124
+ number: "4111111111111111",
125
+ expMonth: "1",
126
+ expYear: "2016",
127
+ name: "James Doe",
128
+ cvc: "123"
129
+ }
130
+ });
131
+ ```
132
+
133
+ #### Changing Values on the Fly
134
+
135
+ You can also change Skeuocard values manually by changing the underlying form element's value, and triggering a `change` event.
136
+
137
+ ```javascript
138
+ $('[name="cc_number"]').val('4111111111111111').trigger('change')
139
+ ```
140
+
141
+ #### Changing Placeholder Strings
142
+
143
+ 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`.
144
+
145
+ `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`.
146
+
147
+ ```javascript
148
+ new Skeuocard($("#skeuocard"), {
149
+ cardNumberPlaceholderChar: '*',
150
+ genericPlaceholder: '**** **** **** ****'
151
+ });
152
+ ```
153
+
154
+ #### Changing Underlying Value Selectors
155
+
156
+ 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.
157
+
158
+ By default, Skeuocard sets the following default selectors to match the underlying form fields within the container element, and use them to store values:
159
+
160
+ * `typeInputSelector: [name="cc_type"]`
161
+ * `numberInputSelector: [name="cc_number"]`
162
+ * `expMonthInputSelector: [name="cc_exp_month"]`
163
+ * `expYearInputSelector: [name="cc_exp_year"]`
164
+ * `nameInputSelector: [name="cc_name"]`
165
+ * `cvcInputSelector: [name="cc_cvc"]`
166
+
167
+ 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:
168
+
169
+ ```javascript
170
+ new Skeuocard($("#skeuocard"), {
171
+ numberInputSelector: '[name="credit_card_number"]'
172
+ });
173
+ ```
174
+
175
+ #### Using the Server's Current Date
176
+
177
+ 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:
178
+
179
+ ```javascript
180
+ Skeuocard.currentDate = new Date(year, month, day);
181
+ ```
182
+
183
+ Note that month is an integer from 0 - 11.
184
+
185
+ By default, Skeuocard will automatically use the client's local Date.
186
+
187
+ #### Specifying Accepted Card Products
188
+
189
+ 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.
190
+
191
+ 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).
192
+
193
+ ```html
194
+ <select name="cc_type">
195
+ <option value="">...</option>
196
+ <option value="visa">Visa</option>
197
+ <option value="mastercard">MasterCard</option>
198
+ <option value="maestro">Maestro</option>
199
+ <option value="amex">American Express</option>
200
+ <option value="diners" data-sc-type="dinersclubintl">Diners Club</option>
201
+ </select>
202
+ ```
203
+
204
+ You can also optionally override this list by providing an array of accepted card product shortnames at instantiation, like so:
205
+
206
+ ```javascript
207
+ new Skeuocard($("#skeuocard"), {
208
+ acceptedCardProducts: ['visa', 'amex']
209
+ });
210
+ ```
211
+
212
+ #### jQuery's noConflict Mode
213
+
214
+ If you are using jQuery's `noConflict` mode, you'll need to instantiate your Skeuocard instance slightly differently than above:
215
+
216
+ ```javascript
217
+ jQuery(document).ready(function(){
218
+ card = new Skeuocard(jQuery("#skeuocard"));
219
+ });
220
+ ```
221
+
222
+ #### Progressive Enhancement
223
+
224
+ 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.
225
+
226
+ 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.
227
+
228
+ #### Checking Validity
229
+
230
+ 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:
231
+
232
+ ```javascript
233
+ card.isValid() // => Boolean
234
+ ```
235
+
236
+ #### Showing Errors at Instantiation
237
+
238
+ 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.
239
+
240
+ Applying the `invalid` class to the invalid field:
241
+
242
+ ```html
243
+ ...
244
+ <input type="text" name="cc_number" id="cc_number" placeholder="XXXX XXXX XXXX XXXX" maxlength="19" size="19" class="invalid">
245
+ ...
246
+ ```
247
+
248
+ Providing a list of invalid fields at instantiation:
249
+
250
+ ```javascript
251
+ new Skeuocard($("#skeuocard"), {
252
+ validationState: {
253
+ number: false,
254
+ exp: true,
255
+ name: true,
256
+ cvc: true
257
+ }
258
+ });
259
+ ```
260
+
261
+ 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.
262
+
263
+ #### Registering Custom Card Layouts
264
+
265
+ 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.
266
+
267
+ 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/`.
268
+
269
+ For an example of how to style a card, see `styles/_cards.scss`.
270
+
271
+ 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:
272
+
273
+ ```javascript
274
+ // Create a new CardProduct instance, and register it with Skeuocard.
275
+ Skeuocard.CardProduct.create({
276
+ pattern: /^9123/, // match all cards starting with 9123
277
+ companyName: "Fancy Gift Card Inc.",
278
+ companyShortname: "fancycard", // this will be the card type
279
+ cardNumberGrouping: [4,4,4,4], // how the number input should group
280
+ cardNumberLength: [14], // array of valid card number lengths
281
+ expirationFormat: "MM/YY", // format of the date field
282
+ cvcLength: 3, // the length of the CVC
283
+ validateLuhn: true, // validate using the Luhn algorithm?
284
+ layout: {
285
+ number: 'front',
286
+ exp: 'front',
287
+ name: 'front',
288
+ cvc: 'back'
289
+ }
290
+ });
291
+ ```
292
+
293
+ 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:
294
+
295
+ ```javascript
296
+ // find the existing Visa product
297
+ var visaProduct = Skeuocard.CardProduct.firstMatchingShortname('visa');
298
+ // register a new variation of the Visa product
299
+ visaProduct.createVariation({
300
+ pattern: /^414720/,
301
+ issuingAuthority: "Chase",
302
+ issuerName: "Chase Sapphire Card",
303
+ issuerShortname: "chase-sapphire",
304
+ layout:
305
+ number: 'front',
306
+ exp: 'front',
307
+ name: 'front',
308
+ cvc: 'front'
309
+ });
310
+ ```
311
+
312
+ #### Design Customization
313
+
314
+ 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.
315
+
316
+ ## Browser Compatibility
317
+
318
+ Skeuocard aims to gain better compatibility with older browsers, but for the time being, it looks good and works well in the following browsers:
319
+
320
+ * Chrome (Mac, Win)
321
+ * Safari (Mac)
322
+ * Firefox > 18 (Mac, Win)
323
+ * Mobile Safari (iOS)
324
+ * Mobile Chrome (iOS/Android)
325
+ * IE 10+ (Win)
326
+
327
+ 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!
328
+
329
+ ## Integration
330
+
331
+ * The [skeuocard-rails](https://github.com/rougecardinal/skeuocard-rails) gem provides integration with the Rails asset pipeline.
332
+
333
+ ## Development
334
+
335
+ Contributing to Skeuocard is pretty simple. Simply fork the project, make your changes in a branch, and submit a pull request.
336
+
337
+ 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.
338
+
339
+ #### Getting Up and Running
340
+
341
+ Ensure that you have the following tools installed before continuing:
342
+
343
+ * [NodeJS/NPM](http://nodejs.org/download/)
344
+ * [SASS](http://sass-lang.com/)
345
+ * [CoffeeScript](http://coffeescript.org/)
346
+
347
+ To begin working on Skeuocard, fork the repository to your Github account, and clone it to your machine.
348
+
349
+ Once you have `cd`ed to your cloned `skeuocard` repository, you'll need to install the required Node packages:
350
+
351
+ $ npm install
352
+
353
+ Once that's completed, simply run:
354
+
355
+ $ grunt
356
+
357
+ Upon starting `grunt`, the following things will happen:
358
+
359
+ * a development server will be started on `0.0.0.0:8000`;
360
+ * `index.html` will be opened automatically in your browser;
361
+ * grunt will begin watching for changes to source files, and setup live-reload
362
+ * source files will be recompiled automatically when changes are made.
363
+
364
+ 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!
365
+
366
+ #### New Card Layouts & Graphics
367
+
368
+ 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.
369
+
370
+ 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.
371
+
372
+ 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.
373
+
374
+ ## Licensing
375
+
376
+ Skeuocard is licensed under the [MIT license](http://opensource.org/licenses/MIT). Share and enjoy :)
377
+
378
+ * 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).
379
+ * [*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).
380
+ * [*jQuery*](http://jquery.com/) 2.0.3 is included under its [MIT license](https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt).
381
+
382
+ 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.
383
+
384
+ Any complaints should be sent to me at: ken+skeuocard-complaints@kenkeiter.com and I will address them promptly.
385
+
386
+ ### Special Thanks
387
+
388
+ 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.