ratchet_design 0.1.1 → 0.1.2
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/app/assets/images/ratchet/favicon.ico +0 -0
- data/app/assets/images/ratchet/safari-pinned-tab.svg +1 -0
- data/app/assets/javascripts/ratchet/base/form.js +9 -118
- data/app/assets/javascripts/ratchet/base/mobilemenu.js +12 -50
- data/app/assets/javascripts/ratchet/base/sync-input-value.js +30 -0
- data/app/assets/javascripts/ratchet/core.js +58 -77
- data/app/assets/javascripts/ratchet/enhancement/_collapse.js +3 -6
- data/app/assets/javascripts/ratchet/enhancement/_swap.js +3 -7
- data/app/assets/javascripts/ratchet/enhancement/lightbox.js +165 -0
- data/app/assets/javascripts/ratchet/enhancement/notice.js +8 -3
- data/app/assets/javascripts/ratchet/enhancement/sticky.js +18 -35
- data/app/assets/javascripts/ratchet/enhancement/waypoints.js +125 -162
- data/app/assets/javascripts/ratchet/shim/scope.js +94 -0
- data/app/assets/javascripts/ratchet/{enhancement → utility}/loader.js +15 -8
- data/app/assets/stylesheets/ratchet/_core.scss +4 -1
- data/app/assets/stylesheets/ratchet/base/_button.scss +3 -3
- data/app/assets/stylesheets/ratchet/base/_form.scss +63 -47
- data/app/assets/stylesheets/ratchet/base/_multistep-form.scss +64 -0
- data/app/assets/stylesheets/ratchet/base/_text.scss +15 -15
- data/app/assets/stylesheets/ratchet/enhancement/_lightbox.scss +98 -0
- data/app/assets/stylesheets/ratchet/enhancement/_tooltip.scss +142 -0
- data/app/assets/stylesheets/ratchet/fonts-woff.css +4 -4
- data/app/assets/stylesheets/ratchet/fonts-woff2.css +4 -4
- data/app/assets/stylesheets/ratchet/utility/_global.scss +3 -13
- data/app/assets/stylesheets/ratchet/{enhancement → utility}/_loader.scss +1 -1
- data/app/helpers/ratchet/application_helper.rb +6 -12
- data/app/helpers/ratchet/form_helper.rb +140 -0
- data/app/views/layouts/ratchet/default.html.slim +3 -2
- data/app/views/shared/ratchet/_footer.html.slim +1 -1
- data/app/views/shared/ratchet/_header.html.slim +1 -1
- data/lib/ratchet_design/version.rb +1 -1
- data/lib/ratchet_design.rb +24 -4
- data/public/assets/ratchet/core-0.1.2.js +133 -0
- data/public/assets/ratchet/core-0.1.2.js.gz +0 -0
- data/public/assets/ratchet/core-0.1.2.map.json +1 -0
- data/public/assets/ratchet/core-0.1.20.js +20472 -0
- data/public/assets/ratchet/{fonts-woff-0.1.1.css → fonts-woff-0.1.2.css} +4 -4
- data/public/assets/ratchet/{fonts-woff-0.1.1.css.gz → fonts-woff-0.1.2.css.gz} +0 -0
- data/public/assets/ratchet/{fonts-woff2-0.1.1.css → fonts-woff2-0.1.2.css} +4 -4
- data/public/assets/ratchet/{fonts-woff2-0.1.1.css.gz → fonts-woff2-0.1.2.css.gz} +0 -0
- metadata +48 -27
- data/app/assets/javascripts/ratchet/base/validation.js +0 -263
- data/app/assets/javascripts/ratchet/enhancement/_lightbox.js +0 -93
- data/app/assets/javascripts/ratchet/shim/classlist.js +0 -234
- data/app/assets/javascripts/ratchet/shim/object.assign.js +0 -30
- data/app/assets/javascripts/ratchet/utility/compile_data.js +0 -32
- data/app/assets/javascripts/ratchet/utility/from_top.js +0 -14
- data/app/assets/javascripts/ratchet/utility/full_stop.js +0 -55
- data/app/assets/javascripts/ratchet/utility/get_closest.js +0 -20
- data/app/assets/javascripts/ratchet/utility/get_next.js +0 -17
- data/app/assets/javascripts/ratchet/utility/matches.js +0 -15
- data/app/assets/javascripts/ratchet/utility/scroll_to.js +0 -74
- data/app/assets/javascripts/ratchet/utility/throttle.js +0 -25
- data/app/assets/javascripts/ratchet/utility/timeout.js +0 -45
- data/app/assets/javascripts/ratchet/utility/unhover.js +0 -56
- data/app/assets/javascripts/ratchet/utility/word_count.js +0 -15
- data/app/assets/stylesheets/ratchet/enhancement/_signup.scss +0 -206
- data/public/assets/ratchet/core-0.1.1.js +0 -103
- data/public/assets/ratchet/core-0.1.1.js.gz +0 -0
- data/public/assets/ratchet/core-0.1.1.map.json +0 -1
@@ -0,0 +1,165 @@
|
|
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;
|
@@ -5,6 +5,8 @@
|
|
5
5
|
* @license MIT
|
6
6
|
**/
|
7
7
|
|
8
|
+
var toolbox = require( 'compose-toolbox' )
|
9
|
+
|
8
10
|
// Public API function
|
9
11
|
var notice = function( element, settings ) {
|
10
12
|
|
@@ -16,9 +18,10 @@ var notice = function( element, settings ) {
|
|
16
18
|
};
|
17
19
|
|
18
20
|
// Scoped variables
|
19
|
-
var options =
|
21
|
+
var options = toolbox.merge( defaults, settings ),
|
20
22
|
selector = document.querySelector( element ),
|
21
|
-
cookieName = 'dismiss-' + options.noticeName
|
23
|
+
cookieName = 'dismiss-' + options.noticeName,
|
24
|
+
button = selector.querySelector( '.' + options.noticeClass + ' .close-btn' );
|
22
25
|
|
23
26
|
// Only run if selector exists & no dismiss cookie is found
|
24
27
|
if ( !selector || getCookie( cookieName ) ) return false;
|
@@ -31,7 +34,7 @@ var notice = function( element, settings ) {
|
|
31
34
|
document.querySelector( 'main' ).insertAdjacentHTML( 'afterbegin', html );
|
32
35
|
|
33
36
|
// Listen for close button click
|
34
|
-
|
37
|
+
toolbox.event.on( button , 'click', dismissNotice )
|
35
38
|
|
36
39
|
// Dismiss notice on close
|
37
40
|
function dismissNotice( event ) {
|
@@ -47,6 +50,8 @@ var notice = function( element, settings ) {
|
|
47
50
|
|
48
51
|
// Set cookie to prevent it from returning
|
49
52
|
document.cookie = cookieName + '=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/';
|
53
|
+
|
54
|
+
toolbox.event.off( button )
|
50
55
|
|
51
56
|
}
|
52
57
|
|
@@ -6,8 +6,8 @@
|
|
6
6
|
**/
|
7
7
|
|
8
8
|
// Dependencies
|
9
|
-
var
|
10
|
-
fromTop =
|
9
|
+
var toolbox = require( 'compose-toolbox' ),
|
10
|
+
fromTop = toolbox.fromTop
|
11
11
|
|
12
12
|
// Public API function
|
13
13
|
var sticky = function( element, settings ) {
|
@@ -21,7 +21,7 @@ var sticky = function( element, settings ) {
|
|
21
21
|
};
|
22
22
|
|
23
23
|
// Scoped variables
|
24
|
-
var options =
|
24
|
+
var options = toolbox.merge( defaults, settings ),
|
25
25
|
selector = document.querySelector( element );
|
26
26
|
|
27
27
|
// If selector is not present
|
@@ -40,15 +40,11 @@ var sticky = function( element, settings ) {
|
|
40
40
|
elemHeight = selector.offsetHeight,
|
41
41
|
anchorInit = options.anchorPoint,
|
42
42
|
docBody = document.body,
|
43
|
+
resizeHandler = toolbox.event.resize( resized ),
|
44
|
+
scrollHandler = toolbox.event.scroll( scrolled ),
|
43
45
|
docHeight,
|
44
46
|
winHeight;
|
45
47
|
|
46
|
-
// Resize throttle function init
|
47
|
-
throttle( 'resize', 'optimizedResize' );
|
48
|
-
|
49
|
-
// Scroll throttle function init
|
50
|
-
throttle( 'scroll', 'optimizedScroll' );
|
51
|
-
|
52
48
|
// Call listener function explicitly at run time
|
53
49
|
queryHandler( widthQuery );
|
54
50
|
|
@@ -60,38 +56,25 @@ var sticky = function( element, settings ) {
|
|
60
56
|
// Media query handler function
|
61
57
|
function queryHandler( condition ) {
|
62
58
|
|
63
|
-
//
|
64
|
-
|
65
|
-
|
66
|
-
// Call resize listener function explicitly at run time
|
67
|
-
resizeHandler();
|
59
|
+
// Call resize listener function explicitly at run time
|
60
|
+
resized()
|
68
61
|
|
69
|
-
|
70
|
-
|
62
|
+
// Call scroll listener function explicitly at run time
|
63
|
+
scrolled();
|
64
|
+
|
65
|
+
// Reset styles
|
66
|
+
if ( !condition.matches ) docBody.classList.remove( 'sticky' )
|
71
67
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
// Scroll function listener
|
76
|
-
window.addEventListener( 'optimizedScroll', scrollHandler, false );
|
77
|
-
|
78
|
-
} else {
|
68
|
+
// Remove resize listener
|
69
|
+
resizeHandler.toggle( condition.matches )
|
79
70
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
// Remove resize listener
|
84
|
-
window.removeEventListener( 'optimizedResize', resizeHandler, false );
|
85
|
-
|
86
|
-
// Remove scroll listener
|
87
|
-
window.removeEventListener( 'optimizedScroll', scrollHandler, false );
|
88
|
-
|
89
|
-
}
|
71
|
+
// Remove scroll listener
|
72
|
+
scrollHandler.toggle( condition.matches )
|
90
73
|
|
91
74
|
}
|
92
75
|
|
93
76
|
// Resize handler function
|
94
|
-
function
|
77
|
+
function resized() {
|
95
78
|
|
96
79
|
// Update document height variable
|
97
80
|
docHeight = document.body.scrollHeight;
|
@@ -102,7 +85,7 @@ var sticky = function( element, settings ) {
|
|
102
85
|
}
|
103
86
|
|
104
87
|
// Scroll handler function
|
105
|
-
function
|
88
|
+
function scrolled() {
|
106
89
|
|
107
90
|
// Scoped variables
|
108
91
|
var newScrollY = window.pageYOffset,
|