j1_template_mde 2018.4.24 → 2018.4.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/themes/j1/layouts/content_generator_app.html +3 -3
- data/_includes/themes/j1/layouts/content_generator_blog_archive.html +8 -6
- data/_includes/themes/j1/layouts/content_generator_collection.html +7 -7
- data/_includes/themes/j1/layouts/content_generator_page.html +17 -6
- data/_includes/themes/j1/layouts/content_generator_post.html +8 -4
- data/_includes/themes/j1/layouts/content_generator_raw.html +3 -3
- data/_includes/themes/j1/layouts/layout_metadata_generator.html +7 -12
- data/_includes/themes/j1/layouts/layout_module_generator.html +3 -3
- data/_includes/themes/j1/layouts/layout_resource_generator.html +3 -3
- data/_includes/themes/j1/layouts/layout_shim_generator.html +2 -2
- data/_includes/themes/j1/layouts/layout_theme_generator.html +3 -3
- data/_includes/themes/j1/modules/connectors/comment/disqus.html +4 -4
- data/_includes/themes/j1/modules/footers/boxes/links_box.proc +4 -1
- data/_includes/themes/j1/modules/footers/boxes/news_box.proc +3 -3
- data/_includes/themes/j1/modules/footers/footer_light_generator.html +3 -3
- data/_includes/themes/j1/procedures/posts/collate_timeline.proc +10 -10
- data/_layouts/blog_archive.html +1 -1
- data/_layouts/page.html +1 -1
- data/_layouts/post.html +2 -2
- data/lib/j1/version.rb +1 -1
- data/lib/j1_app.rb +2 -2
- data/lib/j1_app/j1_auth_manager/auth_manager.rb +2 -4
- data/lib/j1_app/j1_auth_manager/config.rb +5 -5
- data/lib/j1_app/j1_auth_manager/helpers.rb +1 -1
- data/lib/starter_web/Gemfile +4 -2
- data/lib/starter_web/_config.yml +47 -21
- data/lib/starter_web/_config.yml.kapott +1064 -0
- data/lib/starter_web/_data/j1_resources.yml +18 -1
- data/lib/starter_web/_data/layouts/page.yml +10 -0
- data/lib/starter_web/_data/modules/j1_footer.yml +6 -7
- data/lib/starter_web/_data/modules/j1_header.yml +4 -2
- data/lib/starter_web/_data/modules/j1_jekyll_search.yml +1 -1
- data/lib/starter_web/assets/data/_panel.html +597 -0
- data/lib/starter_web/assets/data/panel.html +15 -15
- data/lib/starter_web/assets/data/{search.json → search.yml} +21 -23
- data/lib/starter_web/assets/themes/j1/core/css/bootstrap.css +328 -229
- data/lib/starter_web/assets/themes/j1/core/css/bootstrap.min.css +4 -4
- data/lib/starter_web/assets/themes/j1/core/css/uno.css +31 -2
- data/lib/starter_web/assets/themes/j1/core/css/uno.min.css +1 -1
- data/lib/starter_web/assets/themes/j1/core/css/vendor.css +403 -293
- data/lib/starter_web/assets/themes/j1/core/css/vendor.min.css +4 -5
- data/lib/starter_web/assets/themes/j1/core/js/adapter/master_header.js +23 -21
- data/lib/starter_web/assets/themes/j1/core/js/adapter/toccer.js +23 -43
- data/lib/starter_web/assets/themes/j1/core/js/adapter/toccer.js.new +265 -0
- data/lib/starter_web/assets/themes/j1/core/js/template.js +13 -6
- data/lib/starter_web/assets/themes/j1/core/js/template.js.map +1 -1
- data/lib/starter_web/assets/themes/j1/core/js/template.min.js +1 -1
- data/lib/starter_web/assets/themes/j1/extensions/stickyfill/LICENSE +21 -0
- data/lib/starter_web/assets/themes/j1/extensions/stickyfill/README.md +229 -0
- data/lib/starter_web/assets/themes/j1/extensions/stickyfill/js/stickyfill.es6.js +533 -0
- data/lib/starter_web/assets/themes/j1/extensions/stickyfill/js/stickyfill.js +546 -0
- data/lib/starter_web/assets/themes/j1/extensions/stickyfill/js/stickyfill.min.js +6 -0
- data/lib/starter_web/collections/posts/premium/series/_posts/2018-11-01-docker-using-shared-folders.adoc +8 -7
- data/lib/starter_web/package.json +1 -1
- data/lib/starter_web/pages/public/blog/navigator/index.html +1 -1
- data/lib/starter_web/pages/public/start/bmd_examples/{100_bmd_landing_page.adoc → 100_bmd_landing_page.asciidoc} +0 -0
- data/lib/starter_web/pages/public/start/change_me_first.adoc +7 -2
- data/lib/starter_web/pages/public/start/read_me_first.adoc +4 -0
- metadata +12 -5
- data/lib/j1_app/j1_auth_manager/auth_manager.previous.rb +0 -939
@@ -0,0 +1,546 @@
|
|
1
|
+
/*!
|
2
|
+
* Stickyfill – `position: sticky` polyfill
|
3
|
+
* v. 2.1.0 | https://github.com/wilddeer/stickyfill
|
4
|
+
* MIT License
|
5
|
+
*/
|
6
|
+
|
7
|
+
;(function(window, document) {
|
8
|
+
'use strict';
|
9
|
+
|
10
|
+
/*
|
11
|
+
* 1. Check if the browser supports `position: sticky` natively or is too old to run the polyfill.
|
12
|
+
* If either of these is the case set `seppuku` flag. It will be checked later to disable key features
|
13
|
+
* of the polyfill, but the API will remain functional to avoid breaking things.
|
14
|
+
*/
|
15
|
+
|
16
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
17
|
+
|
18
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
19
|
+
|
20
|
+
var seppuku = false;
|
21
|
+
|
22
|
+
var isWindowDefined = typeof window !== 'undefined';
|
23
|
+
|
24
|
+
// The polyfill can’t function properly without `window` or `window.getComputedStyle`.
|
25
|
+
if (!isWindowDefined || !window.getComputedStyle) seppuku = true;
|
26
|
+
// Dont’t get in a way if the browser supports `position: sticky` natively.
|
27
|
+
else {
|
28
|
+
(function () {
|
29
|
+
var testNode = document.createElement('div');
|
30
|
+
|
31
|
+
if (['', '-webkit-', '-moz-', '-ms-'].some(function (prefix) {
|
32
|
+
try {
|
33
|
+
testNode.style.position = prefix + 'sticky';
|
34
|
+
} catch (e) {}
|
35
|
+
|
36
|
+
return testNode.style.position != '';
|
37
|
+
})) seppuku = true;
|
38
|
+
})();
|
39
|
+
}
|
40
|
+
|
41
|
+
/*
|
42
|
+
* 2. “Global” vars used across the polyfill
|
43
|
+
*/
|
44
|
+
var isInitialized = false;
|
45
|
+
|
46
|
+
// Check if Shadow Root constructor exists to make further checks simpler
|
47
|
+
var shadowRootExists = typeof ShadowRoot !== 'undefined';
|
48
|
+
|
49
|
+
// Last saved scroll position
|
50
|
+
var scroll = {
|
51
|
+
top: null,
|
52
|
+
left: null
|
53
|
+
};
|
54
|
+
|
55
|
+
// Array of created Sticky instances
|
56
|
+
var stickies = [];
|
57
|
+
|
58
|
+
/*
|
59
|
+
* 3. Utility functions
|
60
|
+
*/
|
61
|
+
function extend(targetObj, sourceObject) {
|
62
|
+
for (var key in sourceObject) {
|
63
|
+
if (sourceObject.hasOwnProperty(key)) {
|
64
|
+
targetObj[key] = sourceObject[key];
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
function parseNumeric(val) {
|
70
|
+
return parseFloat(val) || 0;
|
71
|
+
}
|
72
|
+
|
73
|
+
function getDocOffsetTop(node) {
|
74
|
+
var docOffsetTop = 0;
|
75
|
+
|
76
|
+
while (node) {
|
77
|
+
docOffsetTop += node.offsetTop;
|
78
|
+
node = node.offsetParent;
|
79
|
+
}
|
80
|
+
|
81
|
+
return docOffsetTop;
|
82
|
+
}
|
83
|
+
|
84
|
+
/*
|
85
|
+
* 4. Sticky class
|
86
|
+
*/
|
87
|
+
|
88
|
+
var Sticky = function () {
|
89
|
+
function Sticky(node) {
|
90
|
+
_classCallCheck(this, Sticky);
|
91
|
+
|
92
|
+
if (!(node instanceof HTMLElement)) throw new Error('First argument must be HTMLElement');
|
93
|
+
if (stickies.some(function (sticky) {
|
94
|
+
return sticky._node === node;
|
95
|
+
})) throw new Error('Stickyfill is already applied to this node');
|
96
|
+
|
97
|
+
this._node = node;
|
98
|
+
this._stickyMode = null;
|
99
|
+
this._active = false;
|
100
|
+
|
101
|
+
stickies.push(this);
|
102
|
+
|
103
|
+
this.refresh();
|
104
|
+
}
|
105
|
+
|
106
|
+
_createClass(Sticky, [{
|
107
|
+
key: 'refresh',
|
108
|
+
value: function refresh() {
|
109
|
+
if (seppuku || this._removed) return;
|
110
|
+
if (this._active) this._deactivate();
|
111
|
+
|
112
|
+
var node = this._node;
|
113
|
+
|
114
|
+
/*
|
115
|
+
* 1. Save node computed props
|
116
|
+
*/
|
117
|
+
var nodeComputedStyle = getComputedStyle(node);
|
118
|
+
var nodeComputedProps = {
|
119
|
+
position: nodeComputedStyle.position,
|
120
|
+
top: nodeComputedStyle.top,
|
121
|
+
display: nodeComputedStyle.display,
|
122
|
+
marginTop: nodeComputedStyle.marginTop,
|
123
|
+
marginBottom: nodeComputedStyle.marginBottom,
|
124
|
+
marginLeft: nodeComputedStyle.marginLeft,
|
125
|
+
marginRight: nodeComputedStyle.marginRight,
|
126
|
+
cssFloat: nodeComputedStyle.cssFloat
|
127
|
+
};
|
128
|
+
|
129
|
+
/*
|
130
|
+
* 2. Check if the node can be activated
|
131
|
+
*/
|
132
|
+
if (isNaN(parseFloat(nodeComputedProps.top)) || nodeComputedProps.display == 'table-cell' || nodeComputedProps.display == 'none') return;
|
133
|
+
|
134
|
+
this._active = true;
|
135
|
+
|
136
|
+
/*
|
137
|
+
* 3. Check if the current node position is `sticky`. If it is, it means that the browser supports sticky positioning,
|
138
|
+
* but the polyfill was force-enabled. We set the node’s position to `static` before continuing, so that the node
|
139
|
+
* is in it’s initial position when we gather its params.
|
140
|
+
*/
|
141
|
+
var originalPosition = node.style.position;
|
142
|
+
if (nodeComputedStyle.position == 'sticky' || nodeComputedStyle.position == '-webkit-sticky') node.style.position = 'static';
|
143
|
+
|
144
|
+
/*
|
145
|
+
* 4. Get necessary node parameters
|
146
|
+
*/
|
147
|
+
var referenceNode = node.parentNode;
|
148
|
+
var parentNode = shadowRootExists && referenceNode instanceof ShadowRoot ? referenceNode.host : referenceNode;
|
149
|
+
var nodeWinOffset = node.getBoundingClientRect();
|
150
|
+
var parentWinOffset = parentNode.getBoundingClientRect();
|
151
|
+
var parentComputedStyle = getComputedStyle(parentNode);
|
152
|
+
|
153
|
+
this._parent = {
|
154
|
+
node: parentNode,
|
155
|
+
styles: {
|
156
|
+
position: parentNode.style.position
|
157
|
+
},
|
158
|
+
offsetHeight: parentNode.offsetHeight
|
159
|
+
};
|
160
|
+
this._offsetToWindow = {
|
161
|
+
left: nodeWinOffset.left,
|
162
|
+
right: document.documentElement.clientWidth - nodeWinOffset.right
|
163
|
+
};
|
164
|
+
this._offsetToParent = {
|
165
|
+
top: nodeWinOffset.top - parentWinOffset.top - parseNumeric(parentComputedStyle.borderTopWidth),
|
166
|
+
left: nodeWinOffset.left - parentWinOffset.left - parseNumeric(parentComputedStyle.borderLeftWidth),
|
167
|
+
right: -nodeWinOffset.right + parentWinOffset.right - parseNumeric(parentComputedStyle.borderRightWidth)
|
168
|
+
};
|
169
|
+
this._styles = {
|
170
|
+
position: originalPosition,
|
171
|
+
top: node.style.top,
|
172
|
+
bottom: node.style.bottom,
|
173
|
+
left: node.style.left,
|
174
|
+
right: node.style.right,
|
175
|
+
width: node.style.width,
|
176
|
+
marginTop: node.style.marginTop,
|
177
|
+
marginLeft: node.style.marginLeft,
|
178
|
+
marginRight: node.style.marginRight
|
179
|
+
};
|
180
|
+
|
181
|
+
var nodeTopValue = parseNumeric(nodeComputedProps.top);
|
182
|
+
this._limits = {
|
183
|
+
start: nodeWinOffset.top + window.pageYOffset - nodeTopValue,
|
184
|
+
end: parentWinOffset.top + window.pageYOffset + parentNode.offsetHeight - parseNumeric(parentComputedStyle.borderBottomWidth) - node.offsetHeight - nodeTopValue - parseNumeric(nodeComputedProps.marginBottom)
|
185
|
+
};
|
186
|
+
|
187
|
+
/*
|
188
|
+
* 5. Ensure that the node will be positioned relatively to the parent node
|
189
|
+
*/
|
190
|
+
var parentPosition = parentComputedStyle.position;
|
191
|
+
|
192
|
+
if (parentPosition != 'absolute' && parentPosition != 'relative') {
|
193
|
+
parentNode.style.position = 'relative';
|
194
|
+
}
|
195
|
+
|
196
|
+
/*
|
197
|
+
* 6. Recalc node position.
|
198
|
+
* It’s important to do this before clone injection to avoid scrolling bug in Chrome.
|
199
|
+
*/
|
200
|
+
this._recalcPosition();
|
201
|
+
|
202
|
+
/*
|
203
|
+
* 7. Create a clone
|
204
|
+
*/
|
205
|
+
var clone = this._clone = {};
|
206
|
+
clone.node = document.createElement('div');
|
207
|
+
|
208
|
+
// Apply styles to the clone
|
209
|
+
extend(clone.node.style, {
|
210
|
+
width: nodeWinOffset.right - nodeWinOffset.left + 'px',
|
211
|
+
height: nodeWinOffset.bottom - nodeWinOffset.top + 'px',
|
212
|
+
marginTop: nodeComputedProps.marginTop,
|
213
|
+
marginBottom: nodeComputedProps.marginBottom,
|
214
|
+
marginLeft: nodeComputedProps.marginLeft,
|
215
|
+
marginRight: nodeComputedProps.marginRight,
|
216
|
+
cssFloat: nodeComputedProps.cssFloat,
|
217
|
+
padding: 0,
|
218
|
+
border: 0,
|
219
|
+
borderSpacing: 0,
|
220
|
+
fontSize: '1em',
|
221
|
+
position: 'static'
|
222
|
+
});
|
223
|
+
|
224
|
+
referenceNode.insertBefore(clone.node, node);
|
225
|
+
clone.docOffsetTop = getDocOffsetTop(clone.node);
|
226
|
+
}
|
227
|
+
}, {
|
228
|
+
key: '_recalcPosition',
|
229
|
+
value: function _recalcPosition() {
|
230
|
+
if (!this._active || this._removed) return;
|
231
|
+
|
232
|
+
var stickyMode = scroll.top <= this._limits.start ? 'start' : scroll.top >= this._limits.end ? 'end' : 'middle';
|
233
|
+
|
234
|
+
if (this._stickyMode == stickyMode) return;
|
235
|
+
|
236
|
+
switch (stickyMode) {
|
237
|
+
case 'start':
|
238
|
+
extend(this._node.style, {
|
239
|
+
position: 'absolute',
|
240
|
+
left: this._offsetToParent.left + 'px',
|
241
|
+
right: this._offsetToParent.right + 'px',
|
242
|
+
top: this._offsetToParent.top + 'px',
|
243
|
+
bottom: 'auto',
|
244
|
+
width: 'auto',
|
245
|
+
marginLeft: 0,
|
246
|
+
marginRight: 0,
|
247
|
+
marginTop: 0
|
248
|
+
});
|
249
|
+
break;
|
250
|
+
|
251
|
+
case 'middle':
|
252
|
+
extend(this._node.style, {
|
253
|
+
position: 'fixed',
|
254
|
+
left: this._offsetToWindow.left + 'px',
|
255
|
+
right: this._offsetToWindow.right + 'px',
|
256
|
+
top: this._styles.top,
|
257
|
+
bottom: 'auto',
|
258
|
+
width: 'auto',
|
259
|
+
marginLeft: 0,
|
260
|
+
marginRight: 0,
|
261
|
+
marginTop: 0
|
262
|
+
});
|
263
|
+
break;
|
264
|
+
|
265
|
+
case 'end':
|
266
|
+
extend(this._node.style, {
|
267
|
+
position: 'absolute',
|
268
|
+
left: this._offsetToParent.left + 'px',
|
269
|
+
right: this._offsetToParent.right + 'px',
|
270
|
+
top: 'auto',
|
271
|
+
bottom: 0,
|
272
|
+
width: 'auto',
|
273
|
+
marginLeft: 0,
|
274
|
+
marginRight: 0
|
275
|
+
});
|
276
|
+
break;
|
277
|
+
}
|
278
|
+
|
279
|
+
this._stickyMode = stickyMode;
|
280
|
+
}
|
281
|
+
}, {
|
282
|
+
key: '_fastCheck',
|
283
|
+
value: function _fastCheck() {
|
284
|
+
if (!this._active || this._removed) return;
|
285
|
+
|
286
|
+
if (Math.abs(getDocOffsetTop(this._clone.node) - this._clone.docOffsetTop) > 1 || Math.abs(this._parent.node.offsetHeight - this._parent.offsetHeight) > 1) this.refresh();
|
287
|
+
}
|
288
|
+
}, {
|
289
|
+
key: '_deactivate',
|
290
|
+
value: function _deactivate() {
|
291
|
+
var _this = this;
|
292
|
+
|
293
|
+
if (!this._active || this._removed) return;
|
294
|
+
|
295
|
+
this._clone.node.parentNode.removeChild(this._clone.node);
|
296
|
+
delete this._clone;
|
297
|
+
|
298
|
+
extend(this._node.style, this._styles);
|
299
|
+
delete this._styles;
|
300
|
+
|
301
|
+
// Check whether element’s parent node is used by other stickies.
|
302
|
+
// If not, restore parent node’s styles.
|
303
|
+
if (!stickies.some(function (sticky) {
|
304
|
+
return sticky !== _this && sticky._parent && sticky._parent.node === _this._parent.node;
|
305
|
+
})) {
|
306
|
+
extend(this._parent.node.style, this._parent.styles);
|
307
|
+
}
|
308
|
+
delete this._parent;
|
309
|
+
|
310
|
+
this._stickyMode = null;
|
311
|
+
this._active = false;
|
312
|
+
|
313
|
+
delete this._offsetToWindow;
|
314
|
+
delete this._offsetToParent;
|
315
|
+
delete this._limits;
|
316
|
+
}
|
317
|
+
}, {
|
318
|
+
key: 'remove',
|
319
|
+
value: function remove() {
|
320
|
+
var _this2 = this;
|
321
|
+
|
322
|
+
this._deactivate();
|
323
|
+
|
324
|
+
stickies.some(function (sticky, index) {
|
325
|
+
if (sticky._node === _this2._node) {
|
326
|
+
stickies.splice(index, 1);
|
327
|
+
return true;
|
328
|
+
}
|
329
|
+
});
|
330
|
+
|
331
|
+
this._removed = true;
|
332
|
+
}
|
333
|
+
}]);
|
334
|
+
|
335
|
+
return Sticky;
|
336
|
+
}();
|
337
|
+
|
338
|
+
/*
|
339
|
+
* 5. Stickyfill API
|
340
|
+
*/
|
341
|
+
|
342
|
+
|
343
|
+
var Stickyfill = {
|
344
|
+
stickies: stickies,
|
345
|
+
Sticky: Sticky,
|
346
|
+
|
347
|
+
forceSticky: function forceSticky() {
|
348
|
+
seppuku = false;
|
349
|
+
init();
|
350
|
+
|
351
|
+
this.refreshAll();
|
352
|
+
},
|
353
|
+
addOne: function addOne(node) {
|
354
|
+
// Check whether it’s a node
|
355
|
+
if (!(node instanceof HTMLElement)) {
|
356
|
+
// Maybe it’s a node list of some sort?
|
357
|
+
// Take first node from the list then
|
358
|
+
if (node.length && node[0]) node = node[0];else return;
|
359
|
+
}
|
360
|
+
|
361
|
+
// Check if Stickyfill is already applied to the node
|
362
|
+
// and return existing sticky
|
363
|
+
for (var i = 0; i < stickies.length; i++) {
|
364
|
+
if (stickies[i]._node === node) return stickies[i];
|
365
|
+
}
|
366
|
+
|
367
|
+
// Create and return new sticky
|
368
|
+
return new Sticky(node);
|
369
|
+
},
|
370
|
+
add: function add(nodeList) {
|
371
|
+
// If it’s a node make an array of one node
|
372
|
+
if (nodeList instanceof HTMLElement) nodeList = [nodeList];
|
373
|
+
// Check if the argument is an iterable of some sort
|
374
|
+
if (!nodeList.length) return;
|
375
|
+
|
376
|
+
// Add every element as a sticky and return an array of created Sticky instances
|
377
|
+
var addedStickies = [];
|
378
|
+
|
379
|
+
var _loop = function _loop(i) {
|
380
|
+
var node = nodeList[i];
|
381
|
+
|
382
|
+
// If it’s not an HTMLElement – create an empty element to preserve 1-to-1
|
383
|
+
// correlation with input list
|
384
|
+
if (!(node instanceof HTMLElement)) {
|
385
|
+
addedStickies.push(void 0);
|
386
|
+
return 'continue';
|
387
|
+
}
|
388
|
+
|
389
|
+
// If Stickyfill is already applied to the node
|
390
|
+
// add existing sticky
|
391
|
+
if (stickies.some(function (sticky) {
|
392
|
+
if (sticky._node === node) {
|
393
|
+
addedStickies.push(sticky);
|
394
|
+
return true;
|
395
|
+
}
|
396
|
+
})) return 'continue';
|
397
|
+
|
398
|
+
// Create and add new sticky
|
399
|
+
addedStickies.push(new Sticky(node));
|
400
|
+
};
|
401
|
+
|
402
|
+
for (var i = 0; i < nodeList.length; i++) {
|
403
|
+
var _ret2 = _loop(i);
|
404
|
+
|
405
|
+
if (_ret2 === 'continue') continue;
|
406
|
+
}
|
407
|
+
|
408
|
+
return addedStickies;
|
409
|
+
},
|
410
|
+
refreshAll: function refreshAll() {
|
411
|
+
stickies.forEach(function (sticky) {
|
412
|
+
return sticky.refresh();
|
413
|
+
});
|
414
|
+
},
|
415
|
+
removeOne: function removeOne(node) {
|
416
|
+
// Check whether it’s a node
|
417
|
+
if (!(node instanceof HTMLElement)) {
|
418
|
+
// Maybe it’s a node list of some sort?
|
419
|
+
// Take first node from the list then
|
420
|
+
if (node.length && node[0]) node = node[0];else return;
|
421
|
+
}
|
422
|
+
|
423
|
+
// Remove the stickies bound to the nodes in the list
|
424
|
+
stickies.some(function (sticky) {
|
425
|
+
if (sticky._node === node) {
|
426
|
+
sticky.remove();
|
427
|
+
return true;
|
428
|
+
}
|
429
|
+
});
|
430
|
+
},
|
431
|
+
remove: function remove(nodeList) {
|
432
|
+
// If it’s a node make an array of one node
|
433
|
+
if (nodeList instanceof HTMLElement) nodeList = [nodeList];
|
434
|
+
// Check if the argument is an iterable of some sort
|
435
|
+
if (!nodeList.length) return;
|
436
|
+
|
437
|
+
// Remove the stickies bound to the nodes in the list
|
438
|
+
|
439
|
+
var _loop2 = function _loop2(i) {
|
440
|
+
var node = nodeList[i];
|
441
|
+
|
442
|
+
stickies.some(function (sticky) {
|
443
|
+
if (sticky._node === node) {
|
444
|
+
sticky.remove();
|
445
|
+
return true;
|
446
|
+
}
|
447
|
+
});
|
448
|
+
};
|
449
|
+
|
450
|
+
for (var i = 0; i < nodeList.length; i++) {
|
451
|
+
_loop2(i);
|
452
|
+
}
|
453
|
+
},
|
454
|
+
removeAll: function removeAll() {
|
455
|
+
while (stickies.length) {
|
456
|
+
stickies[0].remove();
|
457
|
+
}
|
458
|
+
}
|
459
|
+
};
|
460
|
+
|
461
|
+
/*
|
462
|
+
* 6. Setup events (unless the polyfill was disabled)
|
463
|
+
*/
|
464
|
+
function init() {
|
465
|
+
if (isInitialized) {
|
466
|
+
return;
|
467
|
+
}
|
468
|
+
|
469
|
+
isInitialized = true;
|
470
|
+
|
471
|
+
// Watch for scroll position changes and trigger recalc/refresh if needed
|
472
|
+
function checkScroll() {
|
473
|
+
if (window.pageXOffset != scroll.left) {
|
474
|
+
scroll.top = window.pageYOffset;
|
475
|
+
scroll.left = window.pageXOffset;
|
476
|
+
|
477
|
+
Stickyfill.refreshAll();
|
478
|
+
} else if (window.pageYOffset != scroll.top) {
|
479
|
+
scroll.top = window.pageYOffset;
|
480
|
+
scroll.left = window.pageXOffset;
|
481
|
+
|
482
|
+
// recalc position for all stickies
|
483
|
+
stickies.forEach(function (sticky) {
|
484
|
+
return sticky._recalcPosition();
|
485
|
+
});
|
486
|
+
}
|
487
|
+
}
|
488
|
+
|
489
|
+
checkScroll();
|
490
|
+
window.addEventListener('scroll', checkScroll);
|
491
|
+
|
492
|
+
// Watch for window resizes and device orientation changes and trigger refresh
|
493
|
+
window.addEventListener('resize', Stickyfill.refreshAll);
|
494
|
+
window.addEventListener('orientationchange', Stickyfill.refreshAll);
|
495
|
+
|
496
|
+
//Fast dirty check for layout changes every 500ms
|
497
|
+
var fastCheckTimer = void 0;
|
498
|
+
|
499
|
+
function startFastCheckTimer() {
|
500
|
+
fastCheckTimer = setInterval(function () {
|
501
|
+
stickies.forEach(function (sticky) {
|
502
|
+
return sticky._fastCheck();
|
503
|
+
});
|
504
|
+
}, 500);
|
505
|
+
}
|
506
|
+
|
507
|
+
function stopFastCheckTimer() {
|
508
|
+
clearInterval(fastCheckTimer);
|
509
|
+
}
|
510
|
+
|
511
|
+
var docHiddenKey = void 0;
|
512
|
+
var visibilityChangeEventName = void 0;
|
513
|
+
|
514
|
+
if ('hidden' in document) {
|
515
|
+
docHiddenKey = 'hidden';
|
516
|
+
visibilityChangeEventName = 'visibilitychange';
|
517
|
+
} else if ('webkitHidden' in document) {
|
518
|
+
docHiddenKey = 'webkitHidden';
|
519
|
+
visibilityChangeEventName = 'webkitvisibilitychange';
|
520
|
+
}
|
521
|
+
|
522
|
+
if (visibilityChangeEventName) {
|
523
|
+
if (!document[docHiddenKey]) startFastCheckTimer();
|
524
|
+
|
525
|
+
document.addEventListener(visibilityChangeEventName, function () {
|
526
|
+
if (document[docHiddenKey]) {
|
527
|
+
stopFastCheckTimer();
|
528
|
+
} else {
|
529
|
+
startFastCheckTimer();
|
530
|
+
}
|
531
|
+
});
|
532
|
+
} else startFastCheckTimer();
|
533
|
+
}
|
534
|
+
|
535
|
+
if (!seppuku) init();
|
536
|
+
|
537
|
+
/*
|
538
|
+
* 7. Expose Stickyfill
|
539
|
+
*/
|
540
|
+
if (typeof module != 'undefined' && module.exports) {
|
541
|
+
module.exports = Stickyfill;
|
542
|
+
} else if (isWindowDefined) {
|
543
|
+
window.Stickyfill = Stickyfill;
|
544
|
+
}
|
545
|
+
|
546
|
+
})(window, document);
|