ratchet_design 0.1.7 → 0.1.8
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/core.js +2 -0
- data/app/assets/javascripts/ratchet/enhancement/_swap.js +71 -64
- data/app/assets/javascripts/ratchet/enhancement/lightbox.js +256 -0
- data/app/assets/javascripts/ratchet/enhancement/loader.js +4 -4
- data/app/assets/javascripts/ratchet/shim/classlist.js +1 -1
- data/app/assets/javascripts/ratchet/shim/scope.js +94 -0
- data/app/assets/stylesheets/ratchet/_core.scss +2 -1
- data/app/assets/stylesheets/ratchet/base/_button.scss +1 -1
- data/app/assets/stylesheets/ratchet/base/_form.scss +58 -38
- data/app/assets/stylesheets/ratchet/base/_text.scss +8 -8
- data/app/assets/stylesheets/ratchet/enhancement/_lightbox.scss +93 -0
- data/app/assets/stylesheets/ratchet/enhancement/_loader.scss +1 -1
- data/app/assets/stylesheets/ratchet/enhancement/_tooltip.scss +6 -1
- data/app/assets/stylesheets/ratchet/utility/_global.scss +1 -2
- data/app/helpers/ratchet/application_helper.rb +5 -0
- data/app/helpers/ratchet/form_helper.rb +140 -0
- data/app/views/layouts/ratchet/default.html.slim +2 -1
- data/app/views/shared/ratchet/_footer.html.slim +1 -1
- data/lib/ratchet_design/version.rb +1 -1
- data/lib/ratchet_design.rb +1 -0
- data/public/assets/ratchet/core-0.1.8.js +107 -0
- data/public/assets/ratchet/core-0.1.8.js.gz +0 -0
- data/public/assets/ratchet/core-0.1.8.map.json +1 -0
- data/public/assets/ratchet/{fonts-woff-0.1.7.css → fonts-woff-0.1.8.css} +0 -0
- data/public/assets/ratchet/{fonts-woff-0.1.7.css.gz → fonts-woff-0.1.8.css.gz} +0 -0
- data/public/assets/ratchet/{fonts-woff2-0.1.7.css → fonts-woff2-0.1.8.css} +0 -0
- data/public/assets/ratchet/{fonts-woff2-0.1.7.css.gz → fonts-woff2-0.1.8.css.gz} +0 -0
- metadata +42 -10
- data/app/assets/javascripts/ratchet/enhancement/_lightbox.js +0 -93
- data/public/assets/ratchet/core-0.1.7.js +0 -105
- data/public/assets/ratchet/core-0.1.7.js.gz +0 -0
- data/public/assets/ratchet/core-0.1.7.map.json +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c1131fa26386e461f0d5a3bea05a5438a954038
|
4
|
+
data.tar.gz: 8fa3b4cf22a717aefc7d9fb95c0bcadf4ae43ab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43ad5b3a613966848c28df7cd19cd20e09e0014a9fde5688cdf6cbb1b90e03b08a1127e3bef67de878990071d135c3383f5d276a10b2819b7340cf88a43f4757
|
7
|
+
data.tar.gz: faa591cf3997ebfed5d8026113b9ce8d21b1ed7fc2ffa86e787e722357623b4d9715af8617dbe770c612255ee186c47730c10198b03eaaec6f4275d93d75cb51
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path d="M11.251 24.382l-4.844-8.414 4.844-8.35h9.562l4.78 8.35-4.78 8.414h-9.562zM16.103 0c.781.008 1.56.067 2.331.185 1.431.218 2.83.633 4.149 1.23 1.698.768 3.258 1.836 4.592 3.139 1.263 1.233 2.321 2.674 3.117 4.25.664 1.315 1.144 2.722 1.421 4.169.326 1.698.374 3.449.145 5.162-.218 1.631-.69 3.226-1.396 4.712-.812 1.712-1.931 3.275-3.287 4.599-1.427 1.393-3.112 2.518-4.949 3.295-1.933.818-4.024 1.245-6.123 1.258-2.102.014-4.202-.387-6.149-1.183-1.847-.755-3.547-1.86-4.991-3.237-1.371-1.307-2.508-2.856-3.341-4.557-.722-1.475-1.214-3.062-1.452-4.687-.251-1.711-.224-3.463.08-5.165.266-1.484.744-2.929 1.415-4.279.786-1.581 1.836-3.029 3.092-4.27 1.302-1.287 2.824-2.35 4.484-3.125 1.309-.612 2.701-1.043 4.127-1.28.768-.127 1.544-.196 2.323-.213l.412-.003zm-.194 1.913c-.688.006-1.374.058-2.054.162-1.259.192-2.49.557-3.649 1.082-1.419.642-2.729 1.521-3.862 2.589-1.152 1.086-2.12 2.364-2.851 3.768-.611 1.174-1.054 2.435-1.311 3.734-.302 1.522-.35 3.096-.145 4.634.188 1.406.591 2.782 1.192 4.068.706 1.512 1.684 2.895 2.872 4.069 1.249 1.234 2.727 2.233 4.34 2.927 1.695.73 3.531 1.117 5.377 1.14 1.852.024 3.705-.317 5.425-1.008 1.631-.655 3.134-1.619 4.413-2.824 1.235-1.164 2.258-2.549 3.005-4.073.635-1.298 1.068-2.693 1.277-4.123.225-1.537.197-3.111-.087-4.638-.241-1.303-.669-2.571-1.266-3.754-.701-1.388-1.633-2.658-2.746-3.744-1.113-1.087-2.406-1.99-3.812-2.657-1.147-.545-2.369-.932-3.621-1.148-.675-.116-1.357-.18-2.042-.2l-.455-.004z" /></svg>
|
@@ -28,6 +28,7 @@ var loader = require( './enhancement/loader' );
|
|
28
28
|
var waypoints = require( './enhancement/waypoints' );
|
29
29
|
var notice = require( './enhancement/notice' );
|
30
30
|
var sticky = require( './enhancement/sticky' );
|
31
|
+
var lightbox = require( './enhancement/lightbox' );
|
31
32
|
var esvg = require( './_svg' );
|
32
33
|
// var swap = require( './enhancement/swap' );
|
33
34
|
|
@@ -72,6 +73,7 @@ window.ratchet = module.exports = {
|
|
72
73
|
waypoints : waypoints,
|
73
74
|
notice : notice,
|
74
75
|
sticky : sticky,
|
76
|
+
lightbox : lightbox,
|
75
77
|
esvg : esvg,
|
76
78
|
event : event
|
77
79
|
}
|
@@ -1,14 +1,12 @@
|
|
1
1
|
/**
|
2
|
-
* Swap 0.0.2
|
3
|
-
* Compose swappable element module
|
2
|
+
* Swap.js 0.0.2
|
4
3
|
* @author Kyle Foster (@hkfoster)
|
5
4
|
* @license MIT
|
6
5
|
**/
|
7
6
|
|
8
7
|
// Dependencies
|
9
|
-
var
|
8
|
+
var matches = require( '../utility/matches' );
|
10
9
|
|
11
|
-
// Transport
|
12
10
|
;( function( root, factory ) {
|
13
11
|
if ( typeof define === 'function' && define.amd ) {
|
14
12
|
define( factory );
|
@@ -21,100 +19,109 @@ var ScrollTo = require('../utility/scroll_to')
|
|
21
19
|
|
22
20
|
'use strict';
|
23
21
|
|
24
|
-
|
22
|
+
// Overridable defaults
|
23
|
+
var defaults = {
|
24
|
+
activeClass : 'open',
|
25
|
+
assignHash : false
|
26
|
+
};
|
25
27
|
|
26
|
-
|
28
|
+
// Public API function
|
29
|
+
var swap = function( element, settings ) {
|
27
30
|
|
28
|
-
//
|
29
|
-
var
|
31
|
+
// Parameter variables
|
32
|
+
var options = Object.assign( {}, defaults, settings ),
|
33
|
+
selectors = document.querySelectorAll( element ),
|
34
|
+
location;
|
30
35
|
|
31
|
-
//
|
32
|
-
|
36
|
+
// Only run if selector exists
|
37
|
+
if ( !selectors.length ) return false;
|
33
38
|
|
34
|
-
|
35
|
-
|
39
|
+
// Attach window load listener (if hashes are turned on)
|
40
|
+
if ( options.assignHash ) window.addEventListener( 'load', hashHandler, false );
|
36
41
|
|
37
|
-
|
38
|
-
for ( var i = 0; i < currentSelection.length; i++ ) {
|
39
|
-
currentSelection[ i ].classList.remove( 'selected' );
|
40
|
-
}
|
41
|
-
|
42
|
-
// Select our new elements
|
43
|
-
trigger.classList.add( 'selected' );
|
44
|
-
target.classList.add( 'selected' );
|
45
|
-
};
|
42
|
+
for ( var i = 0; i < selectors.length; i++ ) {
|
46
43
|
|
47
|
-
|
48
|
-
|
49
|
-
return location.split( '#' )[ 1 ];
|
50
|
-
};
|
44
|
+
// Attach click event listener
|
45
|
+
selectors[ i ].addEventListener( 'click', clickHandler, false );
|
51
46
|
|
52
|
-
|
53
|
-
var getLinkTarget = function( link ) {
|
54
|
-
return link.href.split( '#' )[ 1 ];
|
55
|
-
};
|
47
|
+
}
|
56
48
|
|
57
|
-
//
|
58
|
-
|
49
|
+
// Window hash handler function
|
50
|
+
function hashHandler() {
|
59
51
|
|
60
|
-
//
|
61
|
-
|
52
|
+
// Cache window hash
|
53
|
+
var windowHash = window.location.hash;
|
62
54
|
|
63
|
-
|
64
|
-
|
65
|
-
firstTarget = document.querySelector( '.swappable' );
|
55
|
+
// If no window hash exists
|
56
|
+
if ( !windowHash ) {
|
66
57
|
|
67
|
-
//
|
68
|
-
swap(
|
58
|
+
// Perform swap function on selector’s first instance of anchor link
|
59
|
+
swap( selector.querySelector( 'a[href^="#"]' ) );
|
69
60
|
|
70
61
|
// Otherwise
|
71
62
|
} else {
|
72
63
|
|
73
64
|
// Stop default anchor tag jump
|
74
|
-
|
75
|
-
|
76
|
-
// Assign appropriate element(s) variables
|
77
|
-
var loadedTarget = document.querySelector( '#' + getHash() ),
|
78
|
-
loadedTrigger = document.querySelector('[href="#' + getHash() + '"]' );
|
65
|
+
window.scrollTo( 0, 0 );
|
79
66
|
|
80
|
-
//
|
81
|
-
swap(
|
67
|
+
// Perform swap function on appropriate anchor link
|
68
|
+
swap( selector.querySelector( 'a[href="' + windowHash + '"]' ) );
|
82
69
|
|
83
70
|
}
|
84
71
|
|
85
|
-
}
|
72
|
+
}
|
86
73
|
|
87
74
|
// Click handler function
|
88
|
-
|
75
|
+
function clickHandler( event ) {
|
76
|
+
|
77
|
+
// Only run on anchor links
|
78
|
+
if ( !matches( event.target, 'a[href^="#"]' ) ) return false;
|
89
79
|
|
90
80
|
// Prevent default behavior
|
91
|
-
event.stopPropagation();
|
92
81
|
event.preventDefault();
|
93
82
|
|
94
|
-
//
|
95
|
-
|
96
|
-
linkTarget = getLinkTarget( triggerElem ),
|
97
|
-
targetElem = document.querySelector( '#' + linkTarget );
|
83
|
+
// Only run if not clicking on currently active element
|
84
|
+
if ( event.target.classList.contains( options.activeClass ) ) return false;
|
98
85
|
|
99
|
-
//
|
100
|
-
swap
|
86
|
+
// Swap out the appropriate element
|
87
|
+
swap( event.target );
|
101
88
|
|
102
|
-
|
103
|
-
history.replaceState( null, '', '#' + linkTarget );
|
89
|
+
}
|
104
90
|
|
105
|
-
|
91
|
+
// Where the magic happens
|
92
|
+
function swap( target ) {
|
106
93
|
|
107
|
-
|
108
|
-
|
94
|
+
// Scoped variables
|
95
|
+
var newAnchor = target,
|
96
|
+
oldAnchor = newAnchor.parentNode.querySelector( '.' + options.activeClass ),
|
97
|
+
newTarget = document.querySelector( '#' + newAnchor.href.split( '#' )[ 1 ] ),
|
98
|
+
oldTarget = newTarget.parentNode.querySelector( ':scope > .' + options.activeClass );
|
109
99
|
|
110
|
-
|
111
|
-
|
100
|
+
// If an old active anchor exists, deactivate it
|
101
|
+
if ( oldAnchor ) oldAnchor.classList.remove( options.activeClass );
|
112
102
|
|
113
|
-
// And
|
114
|
-
|
103
|
+
// And activate the new achor
|
104
|
+
newAnchor.classList.add( options.activeClass );
|
105
|
+
|
106
|
+
// If an old active element exists, deactivate it
|
107
|
+
if ( oldTarget ) oldTarget.classList.remove( options.activeClass );
|
108
|
+
|
109
|
+
// And activate the new element
|
110
|
+
newTarget.classList.add( options.activeClass );
|
111
|
+
|
112
|
+
// Then replace the hash (if hashes are turned on)
|
113
|
+
if ( options.assignHash ) history.pushState( null, '', '#' + newAnchor.href.split( '#' )[ 1 ] );
|
115
114
|
|
116
115
|
}
|
117
116
|
|
118
|
-
}
|
117
|
+
};
|
118
|
+
|
119
|
+
// Public API
|
120
|
+
return swap;
|
119
121
|
|
120
122
|
});
|
123
|
+
|
124
|
+
// Instantiation
|
125
|
+
swap( '.swap-nav', {
|
126
|
+
activeClass : 'selected'
|
127
|
+
});
|
@@ -0,0 +1,256 @@
|
|
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 loader = require( '../enhancement/loader' ),
|
10
|
+
timeout = require( '../utility/timeout' );
|
11
|
+
|
12
|
+
// Public API function
|
13
|
+
var lightbox = function( element, settings ) {
|
14
|
+
|
15
|
+
// Overridable defaults
|
16
|
+
var defaults = {
|
17
|
+
initWidth : '700px'
|
18
|
+
},
|
19
|
+
|
20
|
+
// Main variables
|
21
|
+
options = Object.assign( {}, defaults, settings ),
|
22
|
+
selectors = document.querySelectorAll( element ),
|
23
|
+
widthQuery = window.matchMedia( '(min-width: ' + options.initWidth + ')' ),
|
24
|
+
spinner = loader({ loadingMessage: 'Loading image', failureMessage : 'No image found' }),
|
25
|
+
docBody = document.body,
|
26
|
+
tempImg,
|
27
|
+
active;
|
28
|
+
|
29
|
+
// Only run when selectors exist
|
30
|
+
if ( !selectors.length ) return false;
|
31
|
+
|
32
|
+
// Call media query listener function explicitly at run time
|
33
|
+
queryHandler( widthQuery );
|
34
|
+
|
35
|
+
// Attach media query listener
|
36
|
+
widthQuery.addListener( queryHandler );
|
37
|
+
|
38
|
+
// Media query handler function
|
39
|
+
function queryHandler( condition ) {
|
40
|
+
|
41
|
+
// If media query matches init width
|
42
|
+
if ( condition.matches ) {
|
43
|
+
|
44
|
+
// Initialize lightbox
|
45
|
+
init();
|
46
|
+
|
47
|
+
// Otherwise
|
48
|
+
} else {
|
49
|
+
|
50
|
+
// Terminate lightbox
|
51
|
+
terminate();
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
// Initialize lightbox function
|
58
|
+
function init() {
|
59
|
+
|
60
|
+
// Turn on active state
|
61
|
+
active = true;
|
62
|
+
|
63
|
+
// If a lightbox has already been initiated
|
64
|
+
if ( document.querySelector( '.lightbox' ) ) {
|
65
|
+
|
66
|
+
// Loop over lightbox images
|
67
|
+
for ( var i = 0; i < selectors.length; i++ ) {
|
68
|
+
|
69
|
+
// And activate their anchor links
|
70
|
+
selectors[ i ].parentNode.setAttribute( 'data-open-lightbox', '' );
|
71
|
+
|
72
|
+
}
|
73
|
+
|
74
|
+
// Then kick rocks
|
75
|
+
return false;
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
// Insert lightbox container into body
|
80
|
+
docBody.insertAdjacentHTML( 'afterbegin', '<aside class="lightbox"><figure><img src="" alt=""><button data-close-lightbox></button></figure></aside>' );
|
81
|
+
|
82
|
+
// Cache temporary placeholder image
|
83
|
+
tempImg = document.querySelector( '.lightbox img' );
|
84
|
+
|
85
|
+
// Loop over lightbox images
|
86
|
+
for ( var j = 0; j < selectors.length; j++ ) {
|
87
|
+
|
88
|
+
// Cache current img selector
|
89
|
+
var selector = selectors[ j ],
|
90
|
+
imgSrc = selector.src,
|
91
|
+
dataSrc = selector.getAttribute( 'data-lightbox' ),
|
92
|
+
lightboxSrc = dataSrc !== '' ? dataSrc : imgSrc;
|
93
|
+
|
94
|
+
// If thumbnail size is passed and image is in Cloudinary
|
95
|
+
if ( selector.hasAttribute( 'data-thumb-size' ) && imgSrc.split( '//' )[ 1 ].substring( 0, 18 ) === 'res.cloudinary.com' ) {
|
96
|
+
|
97
|
+
// Split img src url
|
98
|
+
var splitSrc = imgSrc.split( 'upload' );
|
99
|
+
|
100
|
+
// Switch out image src for Cloudinary-resized src
|
101
|
+
selector.src = splitSrc[ 0 ] + 'upload/w_' + selector.getAttribute( 'data-thumb-size' ) + splitSrc[ 1 ];
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
// Wrap the image in a `data-lightbox` anchor tag
|
106
|
+
selector.insertAdjacentHTML( 'beforebegin', '<a data-open-lightbox href="' + lightboxSrc + '"></a>' );
|
107
|
+
selector.previousSibling.insertAdjacentElement( 'afterbegin', selector );
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
// Attach click listener
|
112
|
+
docBody.addEventListener( 'click', clickHandler, false );
|
113
|
+
|
114
|
+
}
|
115
|
+
|
116
|
+
// Terminate lightbox function
|
117
|
+
function terminate() {
|
118
|
+
|
119
|
+
// Turn off active state
|
120
|
+
active = false;
|
121
|
+
|
122
|
+
// If no lightbox exists, fugetaboutit … capisce?
|
123
|
+
if ( !document.querySelector( '.lightbox' ) ) return false;
|
124
|
+
|
125
|
+
// Remove lightbox classes from body
|
126
|
+
docBody.classList.remove( 'lightbox-active' );
|
127
|
+
|
128
|
+
// Loop over lightbox images
|
129
|
+
for ( var i = 0; i < selectors.length; i++ ) {
|
130
|
+
|
131
|
+
// And inactivate their anchor links
|
132
|
+
selectors[ i ].parentNode.setAttribute( 'data-open-lightbox', 'inactive' );
|
133
|
+
|
134
|
+
}
|
135
|
+
|
136
|
+
}
|
137
|
+
|
138
|
+
// Hide lightbox function
|
139
|
+
function hideLightbox() {
|
140
|
+
|
141
|
+
// And hide the spinner
|
142
|
+
spinner.hide();
|
143
|
+
|
144
|
+
// Remove active lightbox class from body
|
145
|
+
docBody.classList.remove( 'lightbox-active' );
|
146
|
+
|
147
|
+
// Remove loaded class from lightbox image
|
148
|
+
tempImg.classList.remove( 'loaded' );
|
149
|
+
|
150
|
+
// Reset lightbox image source
|
151
|
+
tempImg.src = '';
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
// Image load pending function
|
156
|
+
function loadPending( target ) {
|
157
|
+
|
158
|
+
// Show loading icon
|
159
|
+
spinner.show( 'pending' );
|
160
|
+
|
161
|
+
// Set temp image source appropriately
|
162
|
+
tempImg.src = target.parentNode.href;
|
163
|
+
|
164
|
+
// Add `lightbox-active` class to body
|
165
|
+
docBody.classList.add( 'lightbox-active' );
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
// Image load success function
|
170
|
+
function loadSuccess() {
|
171
|
+
|
172
|
+
// Hide the spinner
|
173
|
+
spinner.hide();
|
174
|
+
|
175
|
+
// Bada bing, bada boom
|
176
|
+
tempImg.classList.add( 'loaded' );
|
177
|
+
|
178
|
+
}
|
179
|
+
|
180
|
+
// Image load failure function
|
181
|
+
function loadFailure( event ) {
|
182
|
+
|
183
|
+
// Prevent any further attempts to open image
|
184
|
+
document.querySelector( 'a[href="' + event.target.src + '"]' ).setAttribute( 'data-open-lightbox', 'inactive' );
|
185
|
+
|
186
|
+
// Wait a second…
|
187
|
+
timeout.set( function() {
|
188
|
+
|
189
|
+
// Show spinner failure state
|
190
|
+
spinner.show( 'failure' );
|
191
|
+
|
192
|
+
}, 1000 );
|
193
|
+
|
194
|
+
// Wait a couple more seconds…
|
195
|
+
timeout.set( function() {
|
196
|
+
|
197
|
+
// Hide the lightbox
|
198
|
+
hideLightbox();
|
199
|
+
|
200
|
+
}, 2500 );
|
201
|
+
|
202
|
+
// Remove image load event listener
|
203
|
+
tempImg.removeEventListener( 'load', loadSuccess, false );
|
204
|
+
|
205
|
+
// Remove image error event listener
|
206
|
+
tempImg.removeEventListener( 'error', loadFailure, false );
|
207
|
+
}
|
208
|
+
|
209
|
+
// Click handler function
|
210
|
+
function clickHandler( event ) {
|
211
|
+
|
212
|
+
// Only run on `data-open-lightbox` links
|
213
|
+
if ( event.target.parentNode.hasAttribute( 'data-open-lightbox' ) ) {
|
214
|
+
|
215
|
+
// Prevent default behavior
|
216
|
+
event.preventDefault();
|
217
|
+
|
218
|
+
// Abort if lightbox and/or link is no longer active
|
219
|
+
if ( !active || event.target.parentNode.getAttribute( 'data-open-lightbox' ) === 'inactive' ) return false;
|
220
|
+
|
221
|
+
// Load lightbox image
|
222
|
+
loadPending( event.target );
|
223
|
+
|
224
|
+
// If it has loaded successfully
|
225
|
+
if ( tempImg.complete ) {
|
226
|
+
|
227
|
+
// Kick off image load success function
|
228
|
+
loadSuccess();
|
229
|
+
|
230
|
+
// Otherwise
|
231
|
+
} else {
|
232
|
+
|
233
|
+
// Listen for image load event
|
234
|
+
tempImg.addEventListener( 'load', loadSuccess, false );
|
235
|
+
|
236
|
+
// Listen for image error event
|
237
|
+
tempImg.addEventListener( 'error', loadFailure, false );
|
238
|
+
|
239
|
+
}
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
// Run on `close lightbox` links
|
244
|
+
if ( event.target.hasAttribute( 'data-close-lightbox') || event.target.classList.contains( 'lightbox' ) ) {
|
245
|
+
|
246
|
+
// Hide the lightbox
|
247
|
+
hideLightbox();
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
};
|
254
|
+
|
255
|
+
// Public API
|
256
|
+
module.exports = lightbox;
|
@@ -30,26 +30,26 @@ var loader = function( settings ) {
|
|
30
30
|
var element = document.querySelector( 'div.' + options.loaderClass );
|
31
31
|
|
32
32
|
// Show loader icon function
|
33
|
-
var show = function( state ) {
|
33
|
+
var show = function( state, message ) {
|
34
34
|
|
35
35
|
// Loader pending state
|
36
36
|
if ( state === 'pending' ) {
|
37
37
|
|
38
|
-
element.textContent = options.loadingMessage;
|
38
|
+
element.textContent = message || options.loadingMessage;
|
39
39
|
element.classList.remove( options.successClass, options.failureClass );
|
40
40
|
element.classList.add( options.loadingClass );
|
41
41
|
|
42
42
|
// Loader failure state
|
43
43
|
} else if ( state === 'failure' ) {
|
44
44
|
|
45
|
-
element.textContent = options.failureMessage;
|
45
|
+
element.textContent = message || options.failureMessage;
|
46
46
|
element.classList.remove( options.loadingClass );
|
47
47
|
element.classList.add( options.failureClass );
|
48
48
|
|
49
49
|
// Loader success state
|
50
50
|
} else if ( state === 'success' ) {
|
51
51
|
|
52
|
-
element.textContent = options.successMessage;
|
52
|
+
element.textContent = message || options.successMessage;
|
53
53
|
element.classList.remove( options.loadingClass );
|
54
54
|
element.classList.add( options.successClass );
|
55
55
|
|
@@ -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
|
+
})();
|