ratchet_design 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/images/ratchet/favicon.ico +0 -0
- data/app/assets/javascripts/ratchet/base/form.js +117 -8
- data/app/assets/javascripts/ratchet/base/mobilemenu.js +50 -12
- data/app/assets/javascripts/ratchet/base/validation.js +263 -0
- data/app/assets/javascripts/ratchet/core.js +78 -57
- data/app/assets/javascripts/ratchet/enhancement/_collapse.js +6 -3
- data/app/assets/javascripts/ratchet/enhancement/_lightbox.js +93 -0
- data/app/assets/javascripts/ratchet/enhancement/_swap.js +7 -3
- data/app/assets/javascripts/ratchet/{utility → enhancement}/loader.js +8 -15
- data/app/assets/javascripts/ratchet/enhancement/notice.js +3 -8
- data/app/assets/javascripts/ratchet/enhancement/sticky.js +35 -18
- data/app/assets/javascripts/ratchet/enhancement/waypoints.js +162 -125
- data/app/assets/javascripts/ratchet/shim/classlist.js +234 -0
- data/app/assets/javascripts/ratchet/shim/object.assign.js +30 -0
- data/app/assets/javascripts/ratchet/utility/ajax.js +122 -0
- data/app/assets/javascripts/ratchet/utility/compile_data.js +40 -0
- data/app/assets/javascripts/ratchet/utility/from_top.js +14 -0
- data/app/assets/javascripts/ratchet/utility/full_stop.js +55 -0
- data/app/assets/javascripts/ratchet/utility/get_closest.js +20 -0
- data/app/assets/javascripts/ratchet/utility/get_next.js +17 -0
- data/app/assets/javascripts/ratchet/utility/matches.js +15 -0
- data/app/assets/javascripts/ratchet/utility/scroll_to.js +74 -0
- data/app/assets/javascripts/ratchet/utility/throttle.js +25 -0
- data/app/assets/javascripts/ratchet/utility/timeout.js +45 -0
- data/app/assets/javascripts/ratchet/utility/unhover.js +56 -0
- data/app/assets/javascripts/ratchet/utility/word_count.js +15 -0
- data/app/assets/stylesheets/ratchet/_core.scss +2 -4
- data/app/assets/stylesheets/ratchet/base/_button.scss +1 -1
- data/app/assets/stylesheets/ratchet/base/_form.scss +50 -61
- data/app/assets/stylesheets/ratchet/base/_text.scss +8 -8
- data/app/assets/stylesheets/ratchet/{utility → enhancement}/_loader.scss +1 -1
- data/app/assets/stylesheets/ratchet/enhancement/_tooltip.scss +1 -6
- data/app/assets/stylesheets/ratchet/utility/_global.scss +12 -2
- data/app/helpers/ratchet/application_helper.rb +2 -28
- data/app/views/layouts/ratchet/default.html.slim +4 -5
- data/app/views/shared/ratchet/_footer.html.slim +2 -3
- data/app/views/shared/ratchet/_header.html.slim +1 -1
- data/lib/ratchet_design/version.rb +1 -1
- data/lib/ratchet_design.rb +0 -1
- data/public/assets/ratchet/core-0.1.6.js +105 -0
- data/public/assets/ratchet/core-0.1.6.js.gz +0 -0
- data/public/assets/ratchet/core-0.1.6.map.json +1 -0
- data/public/assets/ratchet/{fonts-woff-0.1.5.css → fonts-woff-0.1.6.css} +0 -0
- data/public/assets/ratchet/{fonts-woff-0.1.5.css.gz → fonts-woff-0.1.6.css.gz} +0 -0
- data/public/assets/ratchet/{fonts-woff2-0.1.5.css → fonts-woff2-0.1.6.css} +0 -0
- data/public/assets/ratchet/{fonts-woff2-0.1.5.css.gz → fonts-woff2-0.1.6.css.gz} +0 -0
- metadata +28 -47
- data/app/assets/images/ratchet/safari-pinned-tab.svg +0 -1
- data/app/assets/javascripts/ratchet/base/sync-input-value.js +0 -30
- data/app/assets/javascripts/ratchet/enhancement/lightbox.js +0 -165
- data/app/assets/javascripts/ratchet/shim/scope.js +0 -94
- data/app/assets/stylesheets/ratchet/base/_multistep-form.scss +0 -64
- data/app/assets/stylesheets/ratchet/enhancement/_lightbox.scss +0 -98
- data/app/helpers/ratchet/form_helper.rb +0 -140
- data/public/assets/ratchet/core-0.1.5.js +0 -133
- data/public/assets/ratchet/core-0.1.5.js.gz +0 -0
- data/public/assets/ratchet/core-0.1.5.map.json +0 -1
@@ -1,165 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Lightbox 0.0.1
|
3
|
-
* A simple lightbox module
|
4
|
-
* @author Kyle Foster (@hkfoster)
|
5
|
-
* @license MIT
|
6
|
-
**/
|
7
|
-
|
8
|
-
// Dependencies
|
9
|
-
var toolbox = require( 'compose-toolbox' ),
|
10
|
-
Event = toolbox.event,
|
11
|
-
delay = toolbox.delay,
|
12
|
-
loader = require( '../utility/loader' );
|
13
|
-
|
14
|
-
// Public API function
|
15
|
-
var lightbox = function( element, settings ) {
|
16
|
-
|
17
|
-
// Apply default element selector
|
18
|
-
element = element || 'a[href$=jpg] ,a[href$=png], a[href$=gif], a[href$=svg]';
|
19
|
-
|
20
|
-
// Overridable defaults
|
21
|
-
var defaults = {
|
22
|
-
initWidth : '700px'
|
23
|
-
},
|
24
|
-
|
25
|
-
// Main variables
|
26
|
-
options = toolbox.merge( defaults, settings ),
|
27
|
-
selector = document.querySelector( element ),
|
28
|
-
widthQuery = window.matchMedia( '(max-width: ' + options.initWidth + ')' ),
|
29
|
-
spinner = loader({ loadingMessage: 'Loading image', failureMessage : 'No image found' }),
|
30
|
-
docBody = document.body,
|
31
|
-
tempImg;
|
32
|
-
|
33
|
-
// Only run when selectors exist
|
34
|
-
if ( !selector ) return false;
|
35
|
-
|
36
|
-
// Attach open lightbox click listener
|
37
|
-
Event.on( document, 'click', 'a[href$=jpg], a[href$=png], a[href$=gif], a[href$=svg]', clickHandler );
|
38
|
-
|
39
|
-
// Attach close lightbox click listener
|
40
|
-
Event.on( document, 'click', '.lightbox', hideLightbox );
|
41
|
-
|
42
|
-
// Initialize lightbox function
|
43
|
-
function init() {
|
44
|
-
|
45
|
-
// Insert lightbox container into body
|
46
|
-
docBody.insertAdjacentHTML( 'afterbegin', '<aside class="lightbox"><figure><img src="" alt=""><button></button></figure></aside>' );
|
47
|
-
|
48
|
-
// Cache temporary placeholder image
|
49
|
-
tempImg = document.querySelector( '.lightbox img' );
|
50
|
-
|
51
|
-
}
|
52
|
-
|
53
|
-
// Hide lightbox function
|
54
|
-
function hideLightbox( event ) {
|
55
|
-
|
56
|
-
// Don’t apply when image is clicked
|
57
|
-
if ( event && event.target.tagName === 'IMG' ) return false;
|
58
|
-
|
59
|
-
// Hide the spinner
|
60
|
-
spinner.hide();
|
61
|
-
|
62
|
-
// Remove active lightbox class from body
|
63
|
-
docBody.classList.remove( 'lightbox-active' );
|
64
|
-
|
65
|
-
// Remove loaded class from lightbox image
|
66
|
-
tempImg.classList.remove( 'loaded' );
|
67
|
-
|
68
|
-
// Reset lightbox image source
|
69
|
-
tempImg.src = '';
|
70
|
-
|
71
|
-
}
|
72
|
-
|
73
|
-
// Image load pending function
|
74
|
-
function loadPending( target ) {
|
75
|
-
|
76
|
-
// Show loading icon
|
77
|
-
spinner.show( 'pending' );
|
78
|
-
|
79
|
-
// Set temp image source appropriately
|
80
|
-
tempImg.src = target.parentNode.href;
|
81
|
-
|
82
|
-
// Add `lightbox-active` class to body
|
83
|
-
docBody.classList.add( 'lightbox-active' );
|
84
|
-
|
85
|
-
}
|
86
|
-
|
87
|
-
// Image load success function
|
88
|
-
function loadSuccess() {
|
89
|
-
|
90
|
-
// Hide the spinner
|
91
|
-
spinner.hide();
|
92
|
-
|
93
|
-
// Bada bing, bada boom
|
94
|
-
tempImg.classList.add( 'loaded' );
|
95
|
-
|
96
|
-
}
|
97
|
-
|
98
|
-
// Image load failure function
|
99
|
-
function loadFailure( event ) {
|
100
|
-
|
101
|
-
// Wait a second…
|
102
|
-
delay( function() {
|
103
|
-
|
104
|
-
// Show spinner failure state
|
105
|
-
spinner.show( 'failure' );
|
106
|
-
|
107
|
-
}, 1000 );
|
108
|
-
|
109
|
-
// Wait a couple more seconds…
|
110
|
-
delay( function() {
|
111
|
-
|
112
|
-
// Hide the lightbox
|
113
|
-
hideLightbox();
|
114
|
-
|
115
|
-
}, 2500 );
|
116
|
-
|
117
|
-
// Remove image load event listener
|
118
|
-
Event.off( tempImg, 'load', loadSuccess );
|
119
|
-
|
120
|
-
// Remove image error event listener
|
121
|
-
Event.off( tempImg, 'error', loadFailure );
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
// Click handler function
|
126
|
-
function clickHandler( event ) {
|
127
|
-
|
128
|
-
// Prevent default behavior
|
129
|
-
event.preventDefault();
|
130
|
-
|
131
|
-
// If viewport is smaller than <initWidth>, abort
|
132
|
-
if ( widthQuery.matches ) return false;
|
133
|
-
|
134
|
-
// If lightbox hasn’t already been instantiated, :doit:
|
135
|
-
if ( !document.querySelector( '.lightbox' ) ) init();
|
136
|
-
|
137
|
-
// Allow escape to close lightbox
|
138
|
-
Event.keyOne( 'esc', hideLightbox );
|
139
|
-
|
140
|
-
// Load lightbox image
|
141
|
-
loadPending( event.target );
|
142
|
-
|
143
|
-
// If it has loaded successfully
|
144
|
-
if ( tempImg.complete ) {
|
145
|
-
|
146
|
-
// Kick off image load success function
|
147
|
-
loadSuccess();
|
148
|
-
|
149
|
-
// Otherwise
|
150
|
-
} else {
|
151
|
-
|
152
|
-
// Listen for image load event
|
153
|
-
Event.on( tempImg, 'load', loadSuccess );
|
154
|
-
|
155
|
-
// Listen for image error event
|
156
|
-
Event.on( tempImg, 'error', loadFailure );
|
157
|
-
|
158
|
-
}
|
159
|
-
|
160
|
-
}
|
161
|
-
|
162
|
-
};
|
163
|
-
|
164
|
-
// Public API
|
165
|
-
module.exports = lightbox;
|
@@ -1,94 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Scoped QuerySelector polyfill
|
3
|
-
* @source https://github.com/lazd/scopedQuerySelectorShim
|
4
|
-
* @author Larry Davis ( @lazd )
|
5
|
-
* @license BSD
|
6
|
-
*/
|
7
|
-
( function() {
|
8
|
-
|
9
|
-
// Throw error on super old browsers
|
10
|
-
if ( !HTMLElement.prototype.querySelectorAll ) {
|
11
|
-
throw new Error( 'rootedQuerySelectorAll: This polyfill can only be used with browsers that support querySelectorAll' );
|
12
|
-
}
|
13
|
-
|
14
|
-
// Create temporary element to query against and test for :scope support
|
15
|
-
var container = document.createElement( 'div' );
|
16
|
-
|
17
|
-
// Check if the browser supports :scope
|
18
|
-
try {
|
19
|
-
|
20
|
-
// Browser supports :scope, do nothing
|
21
|
-
container.querySelectorAll( ':scope *' );
|
22
|
-
|
23
|
-
// Otherwise
|
24
|
-
} catch ( e ) {
|
25
|
-
|
26
|
-
// Match usage of scope
|
27
|
-
var scopeRE = /^\s*:scope/gi;
|
28
|
-
|
29
|
-
// Overrides
|
30
|
-
function overrideNodeMethod( prototype, methodName ) {
|
31
|
-
|
32
|
-
// Store the old method for use later
|
33
|
-
var oldMethod = prototype[ methodName ];
|
34
|
-
|
35
|
-
// Override the method
|
36
|
-
prototype[ methodName ] = function( query ) {
|
37
|
-
|
38
|
-
var gaveContainer = false,
|
39
|
-
gaveId = false,
|
40
|
-
nodeList;
|
41
|
-
|
42
|
-
if ( query.match( scopeRE ) ) {
|
43
|
-
|
44
|
-
// Remove :scope
|
45
|
-
query = query.replace( scopeRE, '' );
|
46
|
-
|
47
|
-
if ( !this.parentNode ) {
|
48
|
-
|
49
|
-
// Add to temporary container
|
50
|
-
container.appendChild( this );
|
51
|
-
gaveContainer = true;
|
52
|
-
|
53
|
-
}
|
54
|
-
|
55
|
-
parentNode = this.parentNode;
|
56
|
-
|
57
|
-
if ( !this.id ) {
|
58
|
-
|
59
|
-
// Give temporary ID
|
60
|
-
this.id = 'rootedQuerySelector_id_' + new Date().getTime();
|
61
|
-
gaveId = true;
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
// Find elements against parent node
|
66
|
-
nodeList = oldMethod.call( parentNode, '#' + this.id + ' ' + query );
|
67
|
-
|
68
|
-
// Reset the ID
|
69
|
-
if ( gaveId ) {
|
70
|
-
this.id = '';
|
71
|
-
}
|
72
|
-
|
73
|
-
// Remove from temporary container
|
74
|
-
if ( gaveContainer ) {
|
75
|
-
container.removeChild( this );
|
76
|
-
}
|
77
|
-
|
78
|
-
return nodeList;
|
79
|
-
|
80
|
-
} else {
|
81
|
-
|
82
|
-
// No immediate child selector used
|
83
|
-
return oldMethod.call( this, query );
|
84
|
-
|
85
|
-
}
|
86
|
-
};
|
87
|
-
}
|
88
|
-
|
89
|
-
// Browser doesnt support :scope, add polyfill
|
90
|
-
overrideNodeMethod( HTMLElement.prototype, 'querySelector' );
|
91
|
-
overrideNodeMethod( HTMLElement.prototype, 'querySelectorAll' );
|
92
|
-
|
93
|
-
}
|
94
|
-
})();
|
@@ -1,64 +0,0 @@
|
|
1
|
-
fieldset.form-step {
|
2
|
-
left: 0;
|
3
|
-
right: 0;
|
4
|
-
|
5
|
-
&[disabled] {
|
6
|
-
position: absolute;
|
7
|
-
left: -9999px;
|
8
|
-
opacity: 0;
|
9
|
-
}
|
10
|
-
|
11
|
-
|
12
|
-
// Transition to form step
|
13
|
-
&.arrived { animation: fade-in-right .5s forwards; }
|
14
|
-
|
15
|
-
// Revisit form step
|
16
|
-
&.revisted, &.step-visited.arrived { animation: .5s fade-in-left forwards; }
|
17
|
-
|
18
|
-
// Transition away from form step
|
19
|
-
&.departed { animation: fade-out-left .5s forwards; }
|
20
|
-
}
|
21
|
-
|
22
|
-
// Transition to form step
|
23
|
-
@keyframes fade-in-right {
|
24
|
-
0% {
|
25
|
-
opacity: 0;
|
26
|
-
transform: perspective(1px) translate3d(200px, 0, 0);
|
27
|
-
}
|
28
|
-
|
29
|
-
100% {
|
30
|
-
opacity: 1;
|
31
|
-
transform: perspective(1px) translate3d(0, 0, 0);
|
32
|
-
}
|
33
|
-
}
|
34
|
-
|
35
|
-
// Transition away from form step
|
36
|
-
@keyframes fade-out-left {
|
37
|
-
0% {
|
38
|
-
opacity: 1;
|
39
|
-
transform: perspective(1px) translate3d(0, 0, 0);
|
40
|
-
}
|
41
|
-
|
42
|
-
99% {
|
43
|
-
opacity: 0;
|
44
|
-
transform: perspective(1px) translate3d(-200px, 0, 0);
|
45
|
-
}
|
46
|
-
|
47
|
-
100% {
|
48
|
-
opacity: 0;
|
49
|
-
transform: perspective(1px) translate3d(-9999px, 0, 0);
|
50
|
-
}
|
51
|
-
}
|
52
|
-
|
53
|
-
// Return to previous form step
|
54
|
-
@keyframes fade-in-left {
|
55
|
-
0% {
|
56
|
-
opacity: 0;
|
57
|
-
transform: perspective(1px) translate3d(-200px, 0, 0);
|
58
|
-
}
|
59
|
-
|
60
|
-
100% {
|
61
|
-
opacity: 1;
|
62
|
-
transform: perspective(1px) translate3d(0, 0, 0);
|
63
|
-
}
|
64
|
-
}
|
@@ -1,98 +0,0 @@
|
|
1
|
-
/* ========================================================================== *
|
2
|
-
* Lightbox module
|
3
|
-
* -------------------------------------------------------------------------- */
|
4
|
-
|
5
|
-
/* ===================================== *
|
6
|
-
* a. Common
|
7
|
-
* ------------------------------------- */
|
8
|
-
|
9
|
-
// Main lightbox element
|
10
|
-
.lightbox {
|
11
|
-
@extend %hidden;
|
12
|
-
display: flex;
|
13
|
-
width: 100%;
|
14
|
-
height: 100%;
|
15
|
-
margin: 0;
|
16
|
-
align-items: center;
|
17
|
-
justify-content: center;
|
18
|
-
background: rgba(0, 0, 0, .9);
|
19
|
-
visibility: hidden; // Hidden by default
|
20
|
-
cursor: pointer;
|
21
|
-
|
22
|
-
// Container figure
|
23
|
-
figure {
|
24
|
-
position: relative;
|
25
|
-
margin: 0;
|
26
|
-
}
|
27
|
-
|
28
|
-
// Main image
|
29
|
-
img {
|
30
|
-
max-width: 90vw;
|
31
|
-
max-height: 90vh;
|
32
|
-
cursor: default;
|
33
|
-
visibility: hidden; // Hidden by default
|
34
|
-
|
35
|
-
// Make visible once loaded
|
36
|
-
&.loaded,
|
37
|
-
&.loaded + button {
|
38
|
-
visibility: visible;
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
// Close button
|
43
|
-
button {
|
44
|
-
position: absolute;
|
45
|
-
margin: 10px 0 0 10px;
|
46
|
-
width: 20px;
|
47
|
-
height: 20px;
|
48
|
-
appearance: none;
|
49
|
-
outline: none;
|
50
|
-
border: 0;
|
51
|
-
visibility: hidden; // Hidden by default
|
52
|
-
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg' fill='#FFF'%3E%3Cpath d='M2.663.005c.176.021.349.045.519.095.316.091.613.249.868.455l.184.166 10.765 10.765 10.768-10.768.187-.164c.262-.21.559-.368.882-.46.279-.079.567-.106.856-.089.228.014.456.065.671.143.257.094.498.23.712.401.578.467.922 1.186.925 1.928.001.239-.033.478-.1.707-.093.316-.249.611-.456.867l-.165.184-10.766 10.765 10.768 10.768.165.187c.224.279.388.599.477.947.078.308.097.631.055.946-.041.301-.136.593-.282.859-.113.208-.256.399-.424.566-.152.153-.324.285-.511.393-.584.337-1.296.423-1.945.235-.316-.092-.612-.25-.868-.456l-.183-.166-10.766-10.765-10.768 10.768-.186.165c-.28.224-.599.388-.947.477-.316.08-.646.098-.968.052-.293-.042-.578-.137-.838-.279-.242-.132-.462-.306-.648-.511-.16-.177-.294-.377-.398-.592-.307-.636-.328-1.387-.054-2.039.091-.218.214-.422.362-.606l.166-.183 10.765-10.766-10.765-10.765-.111-.119c-.208-.245-.372-.521-.476-.826-.204-.594-.172-1.259.087-1.832.098-.217.229-.42.385-.601.174-.201.381-.374.61-.51.279-.166.594-.278.916-.323l.353-.025.179.006z'/%3E%3C/svg%3E") 0 0 / 16px 16px no-repeat;
|
53
|
-
}
|
54
|
-
}
|
55
|
-
|
56
|
-
// Active state
|
57
|
-
.lightbox-active {
|
58
|
-
|
59
|
-
// Prevent scrolling
|
60
|
-
overflow: hidden;
|
61
|
-
|
62
|
-
// Reposition lightbox
|
63
|
-
.lightbox {
|
64
|
-
position: fixed;
|
65
|
-
left: 0;
|
66
|
-
top: 0;
|
67
|
-
z-index: 13;
|
68
|
-
visibility: visible; // Shown while active
|
69
|
-
}
|
70
|
-
|
71
|
-
// Default loader state
|
72
|
-
.loader {
|
73
|
-
z-index: 14;
|
74
|
-
}
|
75
|
-
|
76
|
-
// Loader failure state
|
77
|
-
.loader.failure {
|
78
|
-
&:before {
|
79
|
-
border-color: transparent;
|
80
|
-
background: rgba($white, .2)
|
81
|
-
}
|
82
|
-
|
83
|
-
&:after {
|
84
|
-
content: '';
|
85
|
-
background: url("data:image/svg+xml,%3Csvg viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='#FFF' d='M30.51 6.423l5.099-5.099.202-.16c.146-.09.313-.145.485-.16l.129-.004.128.011.126.026c.125.034.243.089.349.163.106.074.198.166.272.272.2.285.254.655.145.984-.041.123-.103.238-.183.339l-.086.096-35.284 35.285-.202.159c-.183.113-.398.171-.614.165-.347-.01-.676-.188-.876-.472l-.122-.227c-.047-.12-.074-.248-.078-.377-.003-.129.016-.258.056-.381.041-.122.103-.237.183-.339l.086-.096 3.989-3.989c-.337-.385-.538-.887-.538-1.424v-22.611c0-1.219.998-2.161 2.161-2.161h24.573zm3.857 26.933h-24.573l1.774-1.773h22.799c.222 0 .388-.166.333-.388v-1.884l-.166-.222-6.429-6.429c-.111-.11-.332-.11-.499 0l-2.937 2.439c-.831.72-2.106.665-2.882-.111l-1.832-1.792 1.295-1.295 1.867 1.812c.111.111.333.111.499 0l2.937-2.383c.832-.72 2.106-.665 2.882.111l5.32 5.32v-18.177l-.031-.158 1.267-1.266c.337.384.538.886.538 1.424v22.611c0 1.219-.998 2.161-2.162 2.161zm-17.556-13.234l-2.561-2.505c-.11-.111-.332-.111-.498 0l-8.202 7.703v5.875l.03.157 11.231-11.23zm1.284-1.284l10.642-10.642h-22.8c-.166 0-.332.166-.332.388v14.243l6.927-6.54c.832-.776 2.162-.776 2.993.056l2.57 2.495zm-8.089-8.465c1.101 0 1.995.894 1.995 1.996 0 1.101-.894 1.995-1.995 1.995s-1.995-.894-1.995-1.995c0-1.102.894-1.996 1.995-1.996z' /%3E%3C/svg%3E") 50% 50% / 28px 28px no-repeat;
|
86
|
-
}
|
87
|
-
}
|
88
|
-
}
|
89
|
-
|
90
|
-
// Deactivate anchor links under 700px
|
91
|
-
@media (max-width: 700px) {
|
92
|
-
a[href$=jpg],
|
93
|
-
a[href$=png],
|
94
|
-
a[href$=gif],
|
95
|
-
a[href$=svg] {
|
96
|
-
cursor: default;
|
97
|
-
}
|
98
|
-
}
|
@@ -1,140 +0,0 @@
|
|
1
|
-
module Ratchet
|
2
|
-
module FormHelper
|
3
|
-
|
4
|
-
INPUT_OPTIONS = {
|
5
|
-
email: {
|
6
|
-
type: "email",
|
7
|
-
placeholder: "Email address",
|
8
|
-
pattern: "[^@]+@[^@]+\\.[a-zA-Z]{2,}",
|
9
|
-
data: { message: "Please enter a valid email address." }
|
10
|
-
},
|
11
|
-
|
12
|
-
password: {
|
13
|
-
type: "password",
|
14
|
-
placeholder: "Password"
|
15
|
-
},
|
16
|
-
|
17
|
-
text: {
|
18
|
-
type: "text"
|
19
|
-
},
|
20
|
-
|
21
|
-
card_number: {
|
22
|
-
type: "text",
|
23
|
-
required: true,
|
24
|
-
pattern: "[0-9 -]{13,20}",
|
25
|
-
placeholder: "Credit Card Number",
|
26
|
-
data: {
|
27
|
-
stripe: "number",
|
28
|
-
message: "Please enter a valid credit card number."
|
29
|
-
}
|
30
|
-
},
|
31
|
-
|
32
|
-
card_month: {
|
33
|
-
type: "text",
|
34
|
-
required: true,
|
35
|
-
pattern: "0[1-9]|1[012]",
|
36
|
-
placeholder: "MM",
|
37
|
-
data: {
|
38
|
-
stripe: "exp_month",
|
39
|
-
message: "Please enter a valid expiration month."
|
40
|
-
}
|
41
|
-
},
|
42
|
-
|
43
|
-
card_year: {
|
44
|
-
type: "text",
|
45
|
-
required: true,
|
46
|
-
pattern: "[0-9]{4}",
|
47
|
-
placeholder: "YYYY",
|
48
|
-
data: {
|
49
|
-
stripe: "exp_year",
|
50
|
-
message: "Please enter a valid expiration year."
|
51
|
-
}
|
52
|
-
},
|
53
|
-
|
54
|
-
card_cvc: {
|
55
|
-
type: "text",
|
56
|
-
required: true,
|
57
|
-
pattern: "[0-9]{3,4}",
|
58
|
-
data: {
|
59
|
-
stripe: "cvc",
|
60
|
-
message: "Please enter a valid security code."
|
61
|
-
}
|
62
|
-
},
|
63
|
-
|
64
|
-
select_country: {
|
65
|
-
country_options: {
|
66
|
-
include_blank: "Select a country",
|
67
|
-
priority_countries: ["US", "GB", "CA"],
|
68
|
-
},
|
69
|
-
|
70
|
-
html_options: {}
|
71
|
-
}
|
72
|
-
}
|
73
|
-
|
74
|
-
# Country select
|
75
|
-
def select_country_tag(name, options = {}, country_options = {})
|
76
|
-
country_options.reverse_merge! INPUT_OPTIONS[:select_country][:country_options]
|
77
|
-
|
78
|
-
options = INPUT_OPTIONS[:select_country][:html_options].deep_merge options
|
79
|
-
|
80
|
-
content_tag(:label) do
|
81
|
-
country_select :user, :country, country_options, options
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# Email inputs
|
86
|
-
def email_input_tag(name, value = nil, options = {})
|
87
|
-
base_input_tag(name, value, options, :email)
|
88
|
-
end
|
89
|
-
|
90
|
-
# Passowrd inputs
|
91
|
-
def password_input_tag(name, value = nil, options = {})
|
92
|
-
base_input_tag(name, value, options, :password)
|
93
|
-
end
|
94
|
-
|
95
|
-
def text_input_tag(name, value = nil, options = {})
|
96
|
-
base_input_tag(name, value, options, :text)
|
97
|
-
end
|
98
|
-
|
99
|
-
def card_number_tag(name, value=nil, options={})
|
100
|
-
base_input_tag(name, value, options, :card_number)
|
101
|
-
end
|
102
|
-
|
103
|
-
def card_month_tag(name, value=nil, options={})
|
104
|
-
base_input_tag(name, value, options, :card_month)
|
105
|
-
end
|
106
|
-
|
107
|
-
def card_year_tag(name, value=nil, options={})
|
108
|
-
base_input_tag(name, value, options, :card_year)
|
109
|
-
end
|
110
|
-
|
111
|
-
def card_cvc_tag(name, value=nil, options={})
|
112
|
-
base_input_tag(name, value, options, :card_cvc)
|
113
|
-
end
|
114
|
-
|
115
|
-
private
|
116
|
-
|
117
|
-
def base_input_tag(name, value, options, type)
|
118
|
-
if value.is_a? Hash
|
119
|
-
options = value
|
120
|
-
value = nil
|
121
|
-
end
|
122
|
-
|
123
|
-
options = (INPUT_OPTIONS[type]||{}).deep_merge options
|
124
|
-
|
125
|
-
label = options.delete(:label)
|
126
|
-
tag = text_field_tag(name, value, options)
|
127
|
-
|
128
|
-
if label
|
129
|
-
options[:placeholder] = label
|
130
|
-
|
131
|
-
content_tag(:label) do
|
132
|
-
tag + content_tag(:span) { label }
|
133
|
-
end
|
134
|
-
else
|
135
|
-
tag
|
136
|
-
end
|
137
|
-
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|