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
@@ -6,129 +6,93 @@
|
|
6
6
|
**/
|
7
7
|
|
8
8
|
// Dependencies
|
9
|
-
var
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
var toolbox = require( 'compose-toolbox' ),
|
10
|
+
Event = toolbox.event,
|
11
|
+
matches = toolbox.matches,
|
12
|
+
fromTop = toolbox.fromTop,
|
13
|
+
scrollTo = toolbox.scrollTo,
|
14
|
+
getClosest = toolbox.getClosest,
|
15
|
+
callback = Event.callback;
|
14
16
|
|
15
17
|
// Public API function
|
16
|
-
var waypoints = function(
|
18
|
+
var waypoints = function( settings ) {
|
17
19
|
|
18
20
|
// Overridable defaults
|
19
21
|
var defaults = {
|
20
|
-
initWidth : '
|
21
|
-
|
22
|
-
|
23
|
-
showLandmarks : false,
|
24
|
-
landmarkSelector : '.landmark',
|
25
|
-
activeLandmark : 'pinned',
|
26
|
-
};
|
27
|
-
|
28
|
-
// Scoped variables
|
29
|
-
var options = Object.assign( {}, defaults, settings ),
|
30
|
-
selectors = document.querySelectorAll( elements );
|
31
|
-
|
32
|
-
// If selectors are not present
|
33
|
-
if ( !selectors.length ) {
|
34
|
-
|
35
|
-
// Abort
|
36
|
-
return false;
|
37
|
-
|
38
|
-
// Otherwise attach listeners
|
39
|
-
} else {
|
22
|
+
initWidth : '0px',
|
23
|
+
elemOffset : 0
|
24
|
+
}
|
40
25
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
docBody = document.body,
|
45
|
-
coordinates = [],
|
46
|
-
oldActiveItem,
|
47
|
-
windowHash,
|
48
|
-
docHeight,
|
49
|
-
winHeight;
|
26
|
+
function slice( obj, count ) {
|
27
|
+
return Array.prototype.slice.call( obj, count )
|
28
|
+
}
|
50
29
|
|
51
|
-
|
52
|
-
|
30
|
+
// Scoped variables
|
31
|
+
var options = toolbox.merge( defaults, settings ),
|
32
|
+
activeAnchor = 'active',
|
33
|
+
landmarkSelector = 'dl',
|
34
|
+
activeLandmark = 'pinned',
|
35
|
+
nav = document.querySelector('.waypoint-nav'),
|
36
|
+
elements = [];
|
53
37
|
|
54
|
-
|
55
|
-
windowHash = window.location.hash.replace( '#', '' );
|
38
|
+
if ( nav ) slice( nav.querySelectorAll( "a[href^='#']" ) ).forEach( function( el ) {
|
56
39
|
|
57
|
-
|
58
|
-
|
40
|
+
// Find all elements matching links in the waypoints nav
|
41
|
+
var section = document.querySelector( el.getAttribute('href') )
|
59
42
|
|
60
|
-
|
61
|
-
|
43
|
+
// If found, add them to the elements list
|
44
|
+
if ( section ) elements.push( section )
|
62
45
|
|
63
|
-
|
46
|
+
})
|
64
47
|
|
65
|
-
|
66
|
-
throttle( 'resize', 'optimizedResize' );
|
48
|
+
if ( !nav || elements.length < 1 ) { return false }
|
67
49
|
|
68
|
-
|
69
|
-
|
50
|
+
// Scoped variables
|
51
|
+
var docBody = document.body,
|
52
|
+
coordinates = [],
|
53
|
+
oldActiveItem,
|
54
|
+
windowHash,
|
55
|
+
docHeight,
|
56
|
+
winHeight;
|
70
57
|
|
71
|
-
|
72
|
-
|
58
|
+
// If hash is present
|
59
|
+
if ( window.location.hash ) {
|
73
60
|
|
74
|
-
|
75
|
-
|
61
|
+
// Cache it
|
62
|
+
windowHash = window.location.hash.replace( '#', '' );
|
76
63
|
|
77
|
-
|
78
|
-
|
64
|
+
// Then delete it to prevent default page scroll
|
65
|
+
window.location.hash = '';
|
79
66
|
|
80
|
-
|
67
|
+
// And replace it
|
68
|
+
history.replaceState( null, '', '#' + windowHash );
|
81
69
|
|
82
70
|
}
|
83
71
|
|
84
|
-
//
|
85
|
-
|
86
|
-
|
87
|
-
// If media query matches
|
88
|
-
if ( condition.matches ) {
|
72
|
+
// Only run once the window is loaded
|
73
|
+
Event.on( window, 'load', function() {
|
89
74
|
|
90
|
-
|
91
|
-
|
75
|
+
// Media query handler function
|
76
|
+
Event.media.minWidth( options.initWidth, function( condition ) {
|
92
77
|
|
93
|
-
//
|
94
|
-
|
78
|
+
// Set up resize listener
|
79
|
+
resize.toggle( condition.matches )
|
80
|
+
resize()
|
95
81
|
|
96
|
-
//
|
97
|
-
|
82
|
+
// Set up scroll listener
|
83
|
+
scroll.toggle( condition.matches )
|
84
|
+
scroll()
|
85
|
+
|
86
|
+
// Set up hash change listener
|
87
|
+
hashChange.toggle( condition.matches )
|
88
|
+
hashChange()
|
98
89
|
|
99
|
-
|
100
|
-
window.addEventListener( 'optimizedScroll', scrollHandler, false );
|
90
|
+
})
|
101
91
|
|
102
|
-
|
103
|
-
docBody.addEventListener( 'click', clickHandler, false );
|
104
|
-
|
105
|
-
// Call hash change listener function explicitly at run time
|
106
|
-
hashHandler();
|
107
|
-
|
108
|
-
// Hash change function listener
|
109
|
-
window.addEventListener( 'hashchange', hashHandler, false );
|
110
|
-
|
111
|
-
// Otherwise…
|
112
|
-
} else {
|
113
|
-
|
114
|
-
// Remove resize listener
|
115
|
-
window.removeEventListener( 'optimizedResize', resizeHandler, false );
|
116
|
-
|
117
|
-
// Remove scroll listener
|
118
|
-
window.removeEventListener( 'optimizedScroll', scrollHandler, false );
|
119
|
-
|
120
|
-
// Remove click listener
|
121
|
-
docBody.removeEventListener( 'click', clickHandler, false );
|
122
|
-
|
123
|
-
// Remove hash change listener
|
124
|
-
window.removeEventListener( 'hashchange', hashHandler, false );
|
125
|
-
|
126
|
-
}
|
127
|
-
|
128
|
-
}
|
92
|
+
})
|
129
93
|
|
130
94
|
// Resize handler function
|
131
|
-
|
95
|
+
var resize = callback.new( function() {
|
132
96
|
|
133
97
|
// Update document height variable
|
134
98
|
docHeight = docBody.scrollHeight;
|
@@ -137,23 +101,22 @@ var waypoints = function( elements, settings ) {
|
|
137
101
|
winHeight = window.innerHeight;
|
138
102
|
|
139
103
|
// Loop through waypoints
|
140
|
-
|
141
|
-
|
142
|
-
// Construct coordinate object
|
143
|
-
var coordinate = {
|
144
|
-
elem : selectors[ i ],
|
145
|
-
offset : fromTop( selectors[ i ] )
|
146
|
-
};
|
104
|
+
setCoordinates()
|
147
105
|
|
148
|
-
|
149
|
-
coordinates[ i ] = coordinate;
|
150
|
-
|
151
|
-
}
|
106
|
+
})
|
152
107
|
|
108
|
+
// Store coordinates to elements
|
109
|
+
var setCoordinates = function() {
|
110
|
+
elements.forEach( function( element, i ) {
|
111
|
+
coordinates[ i ] = {
|
112
|
+
elem : elements[ i ],
|
113
|
+
offset : fromTop( elements[ i ] )
|
114
|
+
}
|
115
|
+
})
|
153
116
|
}
|
154
117
|
|
155
118
|
// Scroll handler function
|
156
|
-
|
119
|
+
var scroll = callback.new( function() {
|
157
120
|
|
158
121
|
// Scoped variables
|
159
122
|
var newScrollY = window.pageYOffset,
|
@@ -163,11 +126,10 @@ var waypoints = function( elements, settings ) {
|
|
163
126
|
landmark;
|
164
127
|
|
165
128
|
// Loop through coordinates
|
166
|
-
|
129
|
+
coordinates.forEach( function( currWaypoint, i ) {
|
167
130
|
|
168
131
|
// Scoped variables
|
169
132
|
var firstWaypoint = coordinates[ 0 ],
|
170
|
-
currWaypoint = coordinates[ i ],
|
171
133
|
nextWaypoint = coordinates[ i + 1 ],
|
172
134
|
lastWaypoint = coordinates[ coordinates.length - 1 ];
|
173
135
|
|
@@ -191,76 +153,65 @@ var waypoints = function( elements, settings ) {
|
|
191
153
|
|
192
154
|
}
|
193
155
|
|
194
|
-
}
|
156
|
+
})
|
195
157
|
|
196
158
|
// If active item exists
|
197
159
|
if ( newActiveItem ) {
|
198
160
|
|
199
161
|
// Only run when new active item is triggered
|
200
|
-
if ( newActiveItem === oldActiveItem ) return false
|
162
|
+
if ( newActiveItem === oldActiveItem ) return false
|
201
163
|
|
202
164
|
// Update active link
|
203
|
-
activeLink =
|
165
|
+
activeLink = nav.querySelector( 'a[href="#' + newActiveItem + '"]' )
|
204
166
|
|
205
167
|
// If no active link is found, abort
|
206
|
-
if ( !activeLink ) return false
|
168
|
+
if ( !activeLink ) return false
|
207
169
|
|
208
170
|
// And enable navigation item
|
209
|
-
|
210
|
-
|
211
|
-
// If landmarks are turned on
|
212
|
-
if ( options.showLandmarks === true ) {
|
213
|
-
|
214
|
-
// Set active landmark to active link’s parent
|
215
|
-
landmark = getClosest( activeLink, options.landmarkSelector );
|
216
|
-
|
217
|
-
// Enable active landmark
|
218
|
-
activate( landmark, options.activeLandmark );
|
219
|
-
|
220
|
-
}
|
171
|
+
activateLink( activeLink )
|
221
172
|
|
222
173
|
// Update old active item variable
|
223
|
-
oldActiveItem = newActiveItem
|
174
|
+
oldActiveItem = newActiveItem
|
224
175
|
|
225
176
|
}
|
226
177
|
|
227
|
-
}
|
178
|
+
})
|
228
179
|
|
229
180
|
// Click handler function
|
230
|
-
|
181
|
+
var click = callback.new( function( event ) {
|
231
182
|
|
232
183
|
// Matches selector function init
|
233
184
|
if ( matches( event.target, 'a[href^="#"]' ) ) {
|
234
185
|
|
235
186
|
// Prevent default behavior
|
236
|
-
event.preventDefault()
|
187
|
+
event.preventDefault()
|
237
188
|
|
238
189
|
// Travel to clicked target
|
239
|
-
travel( event.target,
|
190
|
+
travel( event.target, true )
|
240
191
|
|
241
192
|
}
|
242
|
-
}
|
193
|
+
})
|
243
194
|
|
244
195
|
// Hash change handler function
|
245
|
-
|
196
|
+
var hashChange = callback.new( function() {
|
246
197
|
|
247
198
|
// Only run when a hash is present
|
248
|
-
if ( !window.location.hash ) return false
|
199
|
+
if ( !window.location.hash ) return false
|
249
200
|
|
250
201
|
// Find the hash’s relevant navigation item
|
251
|
-
var hashAnchor = document.querySelector( 'a[href="' + window.location.hash + '"]' )
|
202
|
+
var hashAnchor = document.querySelector( 'a[href="' + window.location.hash + '"]' )
|
252
203
|
|
253
204
|
// And travel to its target
|
254
|
-
travel( hashAnchor
|
205
|
+
travel( hashAnchor )
|
255
206
|
|
256
|
-
}
|
207
|
+
})
|
257
208
|
|
258
209
|
// Window scroll travel function
|
259
|
-
|
210
|
+
var travel = function( destination, animateScroll ) {
|
260
211
|
|
261
212
|
// Define scoped variable(s)
|
262
|
-
var targetAnchor = destination.
|
263
|
-
targetElement = document.querySelector(
|
213
|
+
var targetAnchor = destination.getAttribute('href'),
|
214
|
+
targetElement = document.querySelector( targetAnchor ),
|
264
215
|
targetOffset,
|
265
216
|
travelTime;
|
266
217
|
|
@@ -268,10 +219,10 @@ var waypoints = function( elements, settings ) {
|
|
268
219
|
if ( targetElement ) {
|
269
220
|
|
270
221
|
// Enable new active navigation item
|
271
|
-
|
222
|
+
activateLink( destination, activeAnchor )
|
272
223
|
|
273
224
|
// Loop through coordinates
|
274
|
-
|
225
|
+
coordinates.forEach( function( current, i ) {
|
275
226
|
|
276
227
|
// If coordinate element matches target element
|
277
228
|
if ( coordinates[ i ].elem === targetElement ) {
|
@@ -279,49 +230,61 @@ var waypoints = function( elements, settings ) {
|
|
279
230
|
// Assign its coordinates to target offset variable
|
280
231
|
targetOffset = coordinates[ i ].offset;
|
281
232
|
}
|
282
|
-
}
|
233
|
+
})
|
283
234
|
|
284
235
|
// If trigger was a click
|
285
|
-
if (
|
236
|
+
if ( animateScroll ) {
|
286
237
|
|
287
238
|
// Temporarily remove scroll listener function
|
288
|
-
|
239
|
+
scroll.stop()
|
289
240
|
|
290
241
|
// Update the hash
|
291
|
-
history.pushState( null, '',
|
292
|
-
|
293
|
-
// Animate scroll to appropriate element
|
294
|
-
scrollTo( targetOffset - options.elemOffset + 1, function() {
|
295
|
-
|
296
|
-
// Once scroll is complete, enable scroll listener
|
297
|
-
window.addEventListener( 'optimizedScroll', scrollHandler, false );
|
242
|
+
history.pushState( null, '', targetAnchor );
|
298
243
|
|
299
|
-
|
244
|
+
// Animate scroll to appropriate element then renable scroll listener
|
245
|
+
scrollTo( targetElement, scroll.start )
|
300
246
|
|
301
|
-
|
302
|
-
} else if ( trigger === 'hash' ) {
|
247
|
+
} else {
|
303
248
|
|
304
249
|
// Skip the scroll animation
|
305
|
-
window.scrollTo( 0,
|
250
|
+
window.scrollTo( 0, fromTop( targetElement ) );
|
306
251
|
|
307
252
|
}
|
308
253
|
}
|
309
254
|
}
|
310
255
|
|
311
|
-
|
312
|
-
function activate( selector, cls ) {
|
256
|
+
function activate( el, classname ) {
|
313
257
|
|
314
258
|
// Find currently active link
|
315
|
-
var
|
259
|
+
var activeEl = nav.querySelector( '.' + classname )
|
260
|
+
|
261
|
+
if ( activeEl == el ) return
|
316
262
|
|
317
|
-
//
|
318
|
-
if (
|
263
|
+
// remove active class from existing element
|
264
|
+
if ( activeEl ) activeEl.classList.remove( classname )
|
319
265
|
|
320
266
|
// Then enable the passed selector
|
321
|
-
|
267
|
+
el.classList.add( classname )
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
// Link activation function
|
272
|
+
function activateLink( el ) {
|
273
|
+
activate( el, activeAnchor )
|
322
274
|
|
275
|
+
// Set active landmark to active link’s parent
|
276
|
+
activateLandmark( getClosest( el, landmarkSelector ) )
|
323
277
|
}
|
324
278
|
|
279
|
+
function activateLandmark( el ) {
|
280
|
+
if ( el ) activate( el, activeLandmark )
|
281
|
+
}
|
282
|
+
|
283
|
+
Event.resize.stop( resize )
|
284
|
+
Event.scroll( scroll )
|
285
|
+
Event.on( document, 'click', click )
|
286
|
+
Event.on( window, 'hashchange', hashChange )
|
287
|
+
|
325
288
|
};
|
326
289
|
|
327
290
|
// Public API
|
@@ -0,0 +1,94 @@
|
|
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
|
+
})();
|
@@ -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 loader = function( settings ) {
|
10
12
|
|
@@ -21,35 +23,40 @@ var loader = function( settings ) {
|
|
21
23
|
};
|
22
24
|
|
23
25
|
// Extend defaults
|
24
|
-
var options =
|
26
|
+
var options = toolbox.merge( defaults, settings );
|
27
|
+
|
28
|
+
// If it doesn’t already exist
|
29
|
+
if ( !document.querySelector( 'div.' + options.loaderClass ) ) {
|
30
|
+
|
31
|
+
// Create and prepend loader element
|
32
|
+
options.selector.insertAdjacentHTML( 'afterbegin', '<div class="' + options.loaderClass + '"></div>' );
|
25
33
|
|
26
|
-
|
27
|
-
options.selector.insertAdjacentHTML( 'afterbegin', '<div class="' + options.loaderClass + '"></div>' );
|
34
|
+
}
|
28
35
|
|
29
36
|
// Cache loader element
|
30
37
|
var element = document.querySelector( 'div.' + options.loaderClass );
|
31
38
|
|
32
39
|
// Show loader icon function
|
33
|
-
var show = function( state ) {
|
40
|
+
var show = function( state, message ) {
|
34
41
|
|
35
42
|
// Loader pending state
|
36
43
|
if ( state === 'pending' ) {
|
37
44
|
|
38
|
-
element.textContent = options.loadingMessage;
|
45
|
+
element.textContent = message || options.loadingMessage;
|
39
46
|
element.classList.remove( options.successClass, options.failureClass );
|
40
47
|
element.classList.add( options.loadingClass );
|
41
48
|
|
42
49
|
// Loader failure state
|
43
50
|
} else if ( state === 'failure' ) {
|
44
51
|
|
45
|
-
element.textContent = options.failureMessage;
|
52
|
+
element.textContent = message || options.failureMessage;
|
46
53
|
element.classList.remove( options.loadingClass );
|
47
54
|
element.classList.add( options.failureClass );
|
48
55
|
|
49
56
|
// Loader success state
|
50
57
|
} else if ( state === 'success' ) {
|
51
58
|
|
52
|
-
element.textContent = options.successMessage;
|
59
|
+
element.textContent = message || options.successMessage;
|
53
60
|
element.classList.remove( options.loadingClass );
|
54
61
|
element.classList.add( options.successClass );
|
55
62
|
|
@@ -74,4 +81,4 @@ var loader = function( settings ) {
|
|
74
81
|
};
|
75
82
|
|
76
83
|
// Public API
|
77
|
-
module.exports = loader;
|
84
|
+
module.exports = loader;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
// Utility modules
|
2
2
|
@import 'utility/global';
|
3
3
|
@import 'utility/grid';
|
4
|
+
@import 'utility/loader';
|
4
5
|
|
5
6
|
// Base modules
|
6
7
|
@import 'base/text';
|
@@ -8,13 +9,15 @@
|
|
8
9
|
@import 'base/button';
|
9
10
|
@import 'base/media';
|
10
11
|
@import 'base/form';
|
12
|
+
@import 'base/multistep-form';
|
11
13
|
@import 'base/table';
|
12
14
|
@import 'base/document';
|
13
15
|
|
14
16
|
// Enhancement modules
|
15
|
-
@import 'enhancement/loader';
|
16
17
|
@import 'enhancement/feature';
|
17
18
|
@import 'enhancement/sticky-sidebar';
|
18
19
|
@import 'enhancement/notice';
|
19
20
|
@import 'enhancement/hero';
|
20
21
|
@import 'enhancement/contrast-section';
|
22
|
+
@import 'enhancement/tooltip';
|
23
|
+
@import 'enhancement/lightbox';
|
@@ -42,7 +42,7 @@
|
|
42
42
|
} @else if $color == secondary {
|
43
43
|
$color: $flush;
|
44
44
|
} @else if $color == success {
|
45
|
-
$color: $
|
45
|
+
$color: $apple;
|
46
46
|
} @else if $color == failure {
|
47
47
|
$color: $punch;
|
48
48
|
}
|
@@ -54,9 +54,9 @@
|
|
54
54
|
$margin-top: 15px;
|
55
55
|
$margin-bottom: 20px;
|
56
56
|
} @else if $size == large {
|
57
|
-
$padding:
|
57
|
+
$padding: 12px 24px;
|
58
58
|
$margin-top: 15px;
|
59
|
-
$margin-bottom:
|
59
|
+
$margin-bottom: 19px;
|
60
60
|
} @else if $size == x-large {
|
61
61
|
$font-size: 17px;
|
62
62
|
$padding: 14px 26px;
|