playbook_ui 13.32.0.pre.alpha.PLAY14143251 → 13.32.0.pre.alpha.PLAY14143255
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dist/chunks/_typeahead.js +33694 -0
- data/dist/chunks/_weekday_stacked.js +13022 -0
- data/dist/chunks/lazysizes.js +611 -0
- data/dist/chunks/pb_form_validation.js +60 -0
- data/dist/chunks/vendor.js +6 -0
- data/dist/menu.yml +568 -0
- data/dist/playbook-doc.js +67968 -0
- data/dist/playbook-rails-react-bindings.js +97 -0
- data/dist/playbook.css +60105 -0
- data/lib/playbook/engine.rb +2 -0
- data/lib/playbook/version.rb +1 -1
- metadata +10 -1
@@ -0,0 +1,611 @@
|
|
1
|
+
var lazysizes = { exports: {} };
|
2
|
+
var hasRequiredLazysizes;
|
3
|
+
function requireLazysizes() {
|
4
|
+
if (hasRequiredLazysizes) return lazysizes.exports;
|
5
|
+
hasRequiredLazysizes = 1;
|
6
|
+
(function(module) {
|
7
|
+
(function(window2, factory) {
|
8
|
+
var lazySizes = factory(window2, window2.document, Date);
|
9
|
+
window2.lazySizes = lazySizes;
|
10
|
+
if (module.exports) {
|
11
|
+
module.exports = lazySizes;
|
12
|
+
}
|
13
|
+
})(
|
14
|
+
typeof window != "undefined" ? window : {},
|
15
|
+
/**
|
16
|
+
* import("./types/global")
|
17
|
+
* @typedef { import("./types/lazysizes-config").LazySizesConfigPartial } LazySizesConfigPartial
|
18
|
+
*/
|
19
|
+
function l(window2, document, Date2) {
|
20
|
+
var lazysizes2, lazySizesCfg;
|
21
|
+
(function() {
|
22
|
+
var prop;
|
23
|
+
var lazySizesDefaults = {
|
24
|
+
lazyClass: "lazyload",
|
25
|
+
loadedClass: "lazyloaded",
|
26
|
+
loadingClass: "lazyloading",
|
27
|
+
preloadClass: "lazypreload",
|
28
|
+
errorClass: "lazyerror",
|
29
|
+
//strictClass: 'lazystrict',
|
30
|
+
autosizesClass: "lazyautosizes",
|
31
|
+
fastLoadedClass: "ls-is-cached",
|
32
|
+
iframeLoadMode: 0,
|
33
|
+
srcAttr: "data-src",
|
34
|
+
srcsetAttr: "data-srcset",
|
35
|
+
sizesAttr: "data-sizes",
|
36
|
+
//preloadAfterLoad: false,
|
37
|
+
minSize: 40,
|
38
|
+
customMedia: {},
|
39
|
+
init: true,
|
40
|
+
expFactor: 1.5,
|
41
|
+
hFac: 0.8,
|
42
|
+
loadMode: 2,
|
43
|
+
loadHidden: true,
|
44
|
+
ricTimeout: 0,
|
45
|
+
throttleDelay: 125
|
46
|
+
};
|
47
|
+
lazySizesCfg = window2.lazySizesConfig || window2.lazysizesConfig || {};
|
48
|
+
for (prop in lazySizesDefaults) {
|
49
|
+
if (!(prop in lazySizesCfg)) {
|
50
|
+
lazySizesCfg[prop] = lazySizesDefaults[prop];
|
51
|
+
}
|
52
|
+
}
|
53
|
+
})();
|
54
|
+
if (!document || !document.getElementsByClassName) {
|
55
|
+
return {
|
56
|
+
init: function() {
|
57
|
+
},
|
58
|
+
/**
|
59
|
+
* @type { LazySizesConfigPartial }
|
60
|
+
*/
|
61
|
+
cfg: lazySizesCfg,
|
62
|
+
/**
|
63
|
+
* @type { true }
|
64
|
+
*/
|
65
|
+
noSupport: true
|
66
|
+
};
|
67
|
+
}
|
68
|
+
var docElem = document.documentElement;
|
69
|
+
var supportPicture = window2.HTMLPictureElement;
|
70
|
+
var _addEventListener = "addEventListener";
|
71
|
+
var _getAttribute = "getAttribute";
|
72
|
+
var addEventListener = window2[_addEventListener].bind(window2);
|
73
|
+
var setTimeout = window2.setTimeout;
|
74
|
+
var requestAnimationFrame = window2.requestAnimationFrame || setTimeout;
|
75
|
+
var requestIdleCallback = window2.requestIdleCallback;
|
76
|
+
var regPicture = /^picture$/i;
|
77
|
+
var loadEvents = ["load", "error", "lazyincluded", "_lazyloaded"];
|
78
|
+
var regClassCache = {};
|
79
|
+
var forEach = Array.prototype.forEach;
|
80
|
+
var hasClass = function(ele, cls) {
|
81
|
+
if (!regClassCache[cls]) {
|
82
|
+
regClassCache[cls] = new RegExp("(\\s|^)" + cls + "(\\s|$)");
|
83
|
+
}
|
84
|
+
return regClassCache[cls].test(ele[_getAttribute]("class") || "") && regClassCache[cls];
|
85
|
+
};
|
86
|
+
var addClass = function(ele, cls) {
|
87
|
+
if (!hasClass(ele, cls)) {
|
88
|
+
ele.setAttribute("class", (ele[_getAttribute]("class") || "").trim() + " " + cls);
|
89
|
+
}
|
90
|
+
};
|
91
|
+
var removeClass = function(ele, cls) {
|
92
|
+
var reg;
|
93
|
+
if (reg = hasClass(ele, cls)) {
|
94
|
+
ele.setAttribute("class", (ele[_getAttribute]("class") || "").replace(reg, " "));
|
95
|
+
}
|
96
|
+
};
|
97
|
+
var addRemoveLoadEvents = function(dom, fn, add) {
|
98
|
+
var action = add ? _addEventListener : "removeEventListener";
|
99
|
+
if (add) {
|
100
|
+
addRemoveLoadEvents(dom, fn);
|
101
|
+
}
|
102
|
+
loadEvents.forEach(function(evt) {
|
103
|
+
dom[action](evt, fn);
|
104
|
+
});
|
105
|
+
};
|
106
|
+
var triggerEvent = function(elem, name, detail, noBubbles, noCancelable) {
|
107
|
+
var event = document.createEvent("Event");
|
108
|
+
if (!detail) {
|
109
|
+
detail = {};
|
110
|
+
}
|
111
|
+
detail.instance = lazysizes2;
|
112
|
+
event.initEvent(name, !noBubbles, !noCancelable);
|
113
|
+
event.detail = detail;
|
114
|
+
elem.dispatchEvent(event);
|
115
|
+
return event;
|
116
|
+
};
|
117
|
+
var updatePolyfill = function(el, full) {
|
118
|
+
var polyfill;
|
119
|
+
if (!supportPicture && (polyfill = window2.picturefill || lazySizesCfg.pf)) {
|
120
|
+
if (full && full.src && !el[_getAttribute]("srcset")) {
|
121
|
+
el.setAttribute("srcset", full.src);
|
122
|
+
}
|
123
|
+
polyfill({ reevaluate: true, elements: [el] });
|
124
|
+
} else if (full && full.src) {
|
125
|
+
el.src = full.src;
|
126
|
+
}
|
127
|
+
};
|
128
|
+
var getCSS = function(elem, style) {
|
129
|
+
return (getComputedStyle(elem, null) || {})[style];
|
130
|
+
};
|
131
|
+
var getWidth = function(elem, parent, width) {
|
132
|
+
width = width || elem.offsetWidth;
|
133
|
+
while (width < lazySizesCfg.minSize && parent && !elem._lazysizesWidth) {
|
134
|
+
width = parent.offsetWidth;
|
135
|
+
parent = parent.parentNode;
|
136
|
+
}
|
137
|
+
return width;
|
138
|
+
};
|
139
|
+
var rAF = function() {
|
140
|
+
var running, waiting;
|
141
|
+
var firstFns = [];
|
142
|
+
var secondFns = [];
|
143
|
+
var fns = firstFns;
|
144
|
+
var run = function() {
|
145
|
+
var runFns = fns;
|
146
|
+
fns = firstFns.length ? secondFns : firstFns;
|
147
|
+
running = true;
|
148
|
+
waiting = false;
|
149
|
+
while (runFns.length) {
|
150
|
+
runFns.shift()();
|
151
|
+
}
|
152
|
+
running = false;
|
153
|
+
};
|
154
|
+
var rafBatch = function(fn, queue) {
|
155
|
+
if (running && !queue) {
|
156
|
+
fn.apply(this, arguments);
|
157
|
+
} else {
|
158
|
+
fns.push(fn);
|
159
|
+
if (!waiting) {
|
160
|
+
waiting = true;
|
161
|
+
(document.hidden ? setTimeout : requestAnimationFrame)(run);
|
162
|
+
}
|
163
|
+
}
|
164
|
+
};
|
165
|
+
rafBatch._lsFlush = run;
|
166
|
+
return rafBatch;
|
167
|
+
}();
|
168
|
+
var rAFIt = function(fn, simple) {
|
169
|
+
return simple ? function() {
|
170
|
+
rAF(fn);
|
171
|
+
} : function() {
|
172
|
+
var that = this;
|
173
|
+
var args = arguments;
|
174
|
+
rAF(function() {
|
175
|
+
fn.apply(that, args);
|
176
|
+
});
|
177
|
+
};
|
178
|
+
};
|
179
|
+
var throttle = function(fn) {
|
180
|
+
var running;
|
181
|
+
var lastTime = 0;
|
182
|
+
var gDelay = lazySizesCfg.throttleDelay;
|
183
|
+
var rICTimeout = lazySizesCfg.ricTimeout;
|
184
|
+
var run = function() {
|
185
|
+
running = false;
|
186
|
+
lastTime = Date2.now();
|
187
|
+
fn();
|
188
|
+
};
|
189
|
+
var idleCallback = requestIdleCallback && rICTimeout > 49 ? function() {
|
190
|
+
requestIdleCallback(run, { timeout: rICTimeout });
|
191
|
+
if (rICTimeout !== lazySizesCfg.ricTimeout) {
|
192
|
+
rICTimeout = lazySizesCfg.ricTimeout;
|
193
|
+
}
|
194
|
+
} : rAFIt(function() {
|
195
|
+
setTimeout(run);
|
196
|
+
}, true);
|
197
|
+
return function(isPriority) {
|
198
|
+
var delay;
|
199
|
+
if (isPriority = isPriority === true) {
|
200
|
+
rICTimeout = 33;
|
201
|
+
}
|
202
|
+
if (running) {
|
203
|
+
return;
|
204
|
+
}
|
205
|
+
running = true;
|
206
|
+
delay = gDelay - (Date2.now() - lastTime);
|
207
|
+
if (delay < 0) {
|
208
|
+
delay = 0;
|
209
|
+
}
|
210
|
+
if (isPriority || delay < 9) {
|
211
|
+
idleCallback();
|
212
|
+
} else {
|
213
|
+
setTimeout(idleCallback, delay);
|
214
|
+
}
|
215
|
+
};
|
216
|
+
};
|
217
|
+
var debounce = function(func) {
|
218
|
+
var timeout, timestamp;
|
219
|
+
var wait = 99;
|
220
|
+
var run = function() {
|
221
|
+
timeout = null;
|
222
|
+
func();
|
223
|
+
};
|
224
|
+
var later = function() {
|
225
|
+
var last = Date2.now() - timestamp;
|
226
|
+
if (last < wait) {
|
227
|
+
setTimeout(later, wait - last);
|
228
|
+
} else {
|
229
|
+
(requestIdleCallback || run)(run);
|
230
|
+
}
|
231
|
+
};
|
232
|
+
return function() {
|
233
|
+
timestamp = Date2.now();
|
234
|
+
if (!timeout) {
|
235
|
+
timeout = setTimeout(later, wait);
|
236
|
+
}
|
237
|
+
};
|
238
|
+
};
|
239
|
+
var loader = function() {
|
240
|
+
var preloadElems, isCompleted, resetPreloadingTimer, loadMode, started;
|
241
|
+
var eLvW, elvH, eLtop, eLleft, eLright, eLbottom, isBodyHidden;
|
242
|
+
var regImg = /^img$/i;
|
243
|
+
var regIframe = /^iframe$/i;
|
244
|
+
var supportScroll = "onscroll" in window2 && !/(gle|ing)bot/.test(navigator.userAgent);
|
245
|
+
var shrinkExpand = 0;
|
246
|
+
var currentExpand = 0;
|
247
|
+
var isLoading = 0;
|
248
|
+
var lowRuns = -1;
|
249
|
+
var resetPreloading = function(e) {
|
250
|
+
isLoading--;
|
251
|
+
if (!e || isLoading < 0 || !e.target) {
|
252
|
+
isLoading = 0;
|
253
|
+
}
|
254
|
+
};
|
255
|
+
var isVisible = function(elem) {
|
256
|
+
if (isBodyHidden == null) {
|
257
|
+
isBodyHidden = getCSS(document.body, "visibility") == "hidden";
|
258
|
+
}
|
259
|
+
return isBodyHidden || !(getCSS(elem.parentNode, "visibility") == "hidden" && getCSS(elem, "visibility") == "hidden");
|
260
|
+
};
|
261
|
+
var isNestedVisible = function(elem, elemExpand) {
|
262
|
+
var outerRect;
|
263
|
+
var parent = elem;
|
264
|
+
var visible = isVisible(elem);
|
265
|
+
eLtop -= elemExpand;
|
266
|
+
eLbottom += elemExpand;
|
267
|
+
eLleft -= elemExpand;
|
268
|
+
eLright += elemExpand;
|
269
|
+
while (visible && (parent = parent.offsetParent) && parent != document.body && parent != docElem) {
|
270
|
+
visible = (getCSS(parent, "opacity") || 1) > 0;
|
271
|
+
if (visible && getCSS(parent, "overflow") != "visible") {
|
272
|
+
outerRect = parent.getBoundingClientRect();
|
273
|
+
visible = eLright > outerRect.left && eLleft < outerRect.right && eLbottom > outerRect.top - 1 && eLtop < outerRect.bottom + 1;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
return visible;
|
277
|
+
};
|
278
|
+
var checkElements = function() {
|
279
|
+
var eLlen, i, rect, autoLoadElem, loadedSomething, elemExpand, elemNegativeExpand, elemExpandVal, beforeExpandVal, defaultExpand, preloadExpand, hFac;
|
280
|
+
var lazyloadElems = lazysizes2.elements;
|
281
|
+
if ((loadMode = lazySizesCfg.loadMode) && isLoading < 8 && (eLlen = lazyloadElems.length)) {
|
282
|
+
i = 0;
|
283
|
+
lowRuns++;
|
284
|
+
for (; i < eLlen; i++) {
|
285
|
+
if (!lazyloadElems[i] || lazyloadElems[i]._lazyRace) {
|
286
|
+
continue;
|
287
|
+
}
|
288
|
+
if (!supportScroll || lazysizes2.prematureUnveil && lazysizes2.prematureUnveil(lazyloadElems[i])) {
|
289
|
+
unveilElement(lazyloadElems[i]);
|
290
|
+
continue;
|
291
|
+
}
|
292
|
+
if (!(elemExpandVal = lazyloadElems[i][_getAttribute]("data-expand")) || !(elemExpand = elemExpandVal * 1)) {
|
293
|
+
elemExpand = currentExpand;
|
294
|
+
}
|
295
|
+
if (!defaultExpand) {
|
296
|
+
defaultExpand = !lazySizesCfg.expand || lazySizesCfg.expand < 1 ? docElem.clientHeight > 500 && docElem.clientWidth > 500 ? 500 : 370 : lazySizesCfg.expand;
|
297
|
+
lazysizes2._defEx = defaultExpand;
|
298
|
+
preloadExpand = defaultExpand * lazySizesCfg.expFactor;
|
299
|
+
hFac = lazySizesCfg.hFac;
|
300
|
+
isBodyHidden = null;
|
301
|
+
if (currentExpand < preloadExpand && isLoading < 1 && lowRuns > 2 && loadMode > 2 && !document.hidden) {
|
302
|
+
currentExpand = preloadExpand;
|
303
|
+
lowRuns = 0;
|
304
|
+
} else if (loadMode > 1 && lowRuns > 1 && isLoading < 6) {
|
305
|
+
currentExpand = defaultExpand;
|
306
|
+
} else {
|
307
|
+
currentExpand = shrinkExpand;
|
308
|
+
}
|
309
|
+
}
|
310
|
+
if (beforeExpandVal !== elemExpand) {
|
311
|
+
eLvW = innerWidth + elemExpand * hFac;
|
312
|
+
elvH = innerHeight + elemExpand;
|
313
|
+
elemNegativeExpand = elemExpand * -1;
|
314
|
+
beforeExpandVal = elemExpand;
|
315
|
+
}
|
316
|
+
rect = lazyloadElems[i].getBoundingClientRect();
|
317
|
+
if ((eLbottom = rect.bottom) >= elemNegativeExpand && (eLtop = rect.top) <= elvH && (eLright = rect.right) >= elemNegativeExpand * hFac && (eLleft = rect.left) <= eLvW && (eLbottom || eLright || eLleft || eLtop) && (lazySizesCfg.loadHidden || isVisible(lazyloadElems[i])) && (isCompleted && isLoading < 3 && !elemExpandVal && (loadMode < 3 || lowRuns < 4) || isNestedVisible(lazyloadElems[i], elemExpand))) {
|
318
|
+
unveilElement(lazyloadElems[i]);
|
319
|
+
loadedSomething = true;
|
320
|
+
if (isLoading > 9) {
|
321
|
+
break;
|
322
|
+
}
|
323
|
+
} else if (!loadedSomething && isCompleted && !autoLoadElem && isLoading < 4 && lowRuns < 4 && loadMode > 2 && (preloadElems[0] || lazySizesCfg.preloadAfterLoad) && (preloadElems[0] || !elemExpandVal && (eLbottom || eLright || eLleft || eLtop || lazyloadElems[i][_getAttribute](lazySizesCfg.sizesAttr) != "auto"))) {
|
324
|
+
autoLoadElem = preloadElems[0] || lazyloadElems[i];
|
325
|
+
}
|
326
|
+
}
|
327
|
+
if (autoLoadElem && !loadedSomething) {
|
328
|
+
unveilElement(autoLoadElem);
|
329
|
+
}
|
330
|
+
}
|
331
|
+
};
|
332
|
+
var throttledCheckElements = throttle(checkElements);
|
333
|
+
var switchLoadingClass = function(e) {
|
334
|
+
var elem = e.target;
|
335
|
+
if (elem._lazyCache) {
|
336
|
+
delete elem._lazyCache;
|
337
|
+
return;
|
338
|
+
}
|
339
|
+
resetPreloading(e);
|
340
|
+
addClass(elem, lazySizesCfg.loadedClass);
|
341
|
+
removeClass(elem, lazySizesCfg.loadingClass);
|
342
|
+
addRemoveLoadEvents(elem, rafSwitchLoadingClass);
|
343
|
+
triggerEvent(elem, "lazyloaded");
|
344
|
+
};
|
345
|
+
var rafedSwitchLoadingClass = rAFIt(switchLoadingClass);
|
346
|
+
var rafSwitchLoadingClass = function(e) {
|
347
|
+
rafedSwitchLoadingClass({ target: e.target });
|
348
|
+
};
|
349
|
+
var changeIframeSrc = function(elem, src) {
|
350
|
+
var loadMode2 = elem.getAttribute("data-load-mode") || lazySizesCfg.iframeLoadMode;
|
351
|
+
if (loadMode2 == 0) {
|
352
|
+
elem.contentWindow.location.replace(src);
|
353
|
+
} else if (loadMode2 == 1) {
|
354
|
+
elem.src = src;
|
355
|
+
}
|
356
|
+
};
|
357
|
+
var handleSources = function(source) {
|
358
|
+
var customMedia;
|
359
|
+
var sourceSrcset = source[_getAttribute](lazySizesCfg.srcsetAttr);
|
360
|
+
if (customMedia = lazySizesCfg.customMedia[source[_getAttribute]("data-media") || source[_getAttribute]("media")]) {
|
361
|
+
source.setAttribute("media", customMedia);
|
362
|
+
}
|
363
|
+
if (sourceSrcset) {
|
364
|
+
source.setAttribute("srcset", sourceSrcset);
|
365
|
+
}
|
366
|
+
};
|
367
|
+
var lazyUnveil = rAFIt(function(elem, detail, isAuto, sizes, isImg) {
|
368
|
+
var src, srcset, parent, isPicture, event, firesLoad;
|
369
|
+
if (!(event = triggerEvent(elem, "lazybeforeunveil", detail)).defaultPrevented) {
|
370
|
+
if (sizes) {
|
371
|
+
if (isAuto) {
|
372
|
+
addClass(elem, lazySizesCfg.autosizesClass);
|
373
|
+
} else {
|
374
|
+
elem.setAttribute("sizes", sizes);
|
375
|
+
}
|
376
|
+
}
|
377
|
+
srcset = elem[_getAttribute](lazySizesCfg.srcsetAttr);
|
378
|
+
src = elem[_getAttribute](lazySizesCfg.srcAttr);
|
379
|
+
if (isImg) {
|
380
|
+
parent = elem.parentNode;
|
381
|
+
isPicture = parent && regPicture.test(parent.nodeName || "");
|
382
|
+
}
|
383
|
+
firesLoad = detail.firesLoad || "src" in elem && (srcset || src || isPicture);
|
384
|
+
event = { target: elem };
|
385
|
+
addClass(elem, lazySizesCfg.loadingClass);
|
386
|
+
if (firesLoad) {
|
387
|
+
clearTimeout(resetPreloadingTimer);
|
388
|
+
resetPreloadingTimer = setTimeout(resetPreloading, 2500);
|
389
|
+
addRemoveLoadEvents(elem, rafSwitchLoadingClass, true);
|
390
|
+
}
|
391
|
+
if (isPicture) {
|
392
|
+
forEach.call(parent.getElementsByTagName("source"), handleSources);
|
393
|
+
}
|
394
|
+
if (srcset) {
|
395
|
+
elem.setAttribute("srcset", srcset);
|
396
|
+
} else if (src && !isPicture) {
|
397
|
+
if (regIframe.test(elem.nodeName)) {
|
398
|
+
changeIframeSrc(elem, src);
|
399
|
+
} else {
|
400
|
+
elem.src = src;
|
401
|
+
}
|
402
|
+
}
|
403
|
+
if (isImg && (srcset || isPicture)) {
|
404
|
+
updatePolyfill(elem, { src });
|
405
|
+
}
|
406
|
+
}
|
407
|
+
if (elem._lazyRace) {
|
408
|
+
delete elem._lazyRace;
|
409
|
+
}
|
410
|
+
removeClass(elem, lazySizesCfg.lazyClass);
|
411
|
+
rAF(function() {
|
412
|
+
var isLoaded = elem.complete && elem.naturalWidth > 1;
|
413
|
+
if (!firesLoad || isLoaded) {
|
414
|
+
if (isLoaded) {
|
415
|
+
addClass(elem, lazySizesCfg.fastLoadedClass);
|
416
|
+
}
|
417
|
+
switchLoadingClass(event);
|
418
|
+
elem._lazyCache = true;
|
419
|
+
setTimeout(function() {
|
420
|
+
if ("_lazyCache" in elem) {
|
421
|
+
delete elem._lazyCache;
|
422
|
+
}
|
423
|
+
}, 9);
|
424
|
+
}
|
425
|
+
if (elem.loading == "lazy") {
|
426
|
+
isLoading--;
|
427
|
+
}
|
428
|
+
}, true);
|
429
|
+
});
|
430
|
+
var unveilElement = function(elem) {
|
431
|
+
if (elem._lazyRace) {
|
432
|
+
return;
|
433
|
+
}
|
434
|
+
var detail;
|
435
|
+
var isImg = regImg.test(elem.nodeName);
|
436
|
+
var sizes = isImg && (elem[_getAttribute](lazySizesCfg.sizesAttr) || elem[_getAttribute]("sizes"));
|
437
|
+
var isAuto = sizes == "auto";
|
438
|
+
if ((isAuto || !isCompleted) && isImg && (elem[_getAttribute]("src") || elem.srcset) && !elem.complete && !hasClass(elem, lazySizesCfg.errorClass) && hasClass(elem, lazySizesCfg.lazyClass)) {
|
439
|
+
return;
|
440
|
+
}
|
441
|
+
detail = triggerEvent(elem, "lazyunveilread").detail;
|
442
|
+
if (isAuto) {
|
443
|
+
autoSizer.updateElem(elem, true, elem.offsetWidth);
|
444
|
+
}
|
445
|
+
elem._lazyRace = true;
|
446
|
+
isLoading++;
|
447
|
+
lazyUnveil(elem, detail, isAuto, sizes, isImg);
|
448
|
+
};
|
449
|
+
var afterScroll = debounce(function() {
|
450
|
+
lazySizesCfg.loadMode = 3;
|
451
|
+
throttledCheckElements();
|
452
|
+
});
|
453
|
+
var altLoadmodeScrollListner = function() {
|
454
|
+
if (lazySizesCfg.loadMode == 3) {
|
455
|
+
lazySizesCfg.loadMode = 2;
|
456
|
+
}
|
457
|
+
afterScroll();
|
458
|
+
};
|
459
|
+
var onload = function() {
|
460
|
+
if (isCompleted) {
|
461
|
+
return;
|
462
|
+
}
|
463
|
+
if (Date2.now() - started < 999) {
|
464
|
+
setTimeout(onload, 999);
|
465
|
+
return;
|
466
|
+
}
|
467
|
+
isCompleted = true;
|
468
|
+
lazySizesCfg.loadMode = 3;
|
469
|
+
throttledCheckElements();
|
470
|
+
addEventListener("scroll", altLoadmodeScrollListner, true);
|
471
|
+
};
|
472
|
+
return {
|
473
|
+
_: function() {
|
474
|
+
started = Date2.now();
|
475
|
+
lazysizes2.elements = document.getElementsByClassName(lazySizesCfg.lazyClass);
|
476
|
+
preloadElems = document.getElementsByClassName(lazySizesCfg.lazyClass + " " + lazySizesCfg.preloadClass);
|
477
|
+
addEventListener("scroll", throttledCheckElements, true);
|
478
|
+
addEventListener("resize", throttledCheckElements, true);
|
479
|
+
addEventListener("pageshow", function(e) {
|
480
|
+
if (e.persisted) {
|
481
|
+
var loadingElements = document.querySelectorAll("." + lazySizesCfg.loadingClass);
|
482
|
+
if (loadingElements.length && loadingElements.forEach) {
|
483
|
+
requestAnimationFrame(function() {
|
484
|
+
loadingElements.forEach(function(img) {
|
485
|
+
if (img.complete) {
|
486
|
+
unveilElement(img);
|
487
|
+
}
|
488
|
+
});
|
489
|
+
});
|
490
|
+
}
|
491
|
+
}
|
492
|
+
});
|
493
|
+
if (window2.MutationObserver) {
|
494
|
+
new MutationObserver(throttledCheckElements).observe(docElem, { childList: true, subtree: true, attributes: true });
|
495
|
+
} else {
|
496
|
+
docElem[_addEventListener]("DOMNodeInserted", throttledCheckElements, true);
|
497
|
+
docElem[_addEventListener]("DOMAttrModified", throttledCheckElements, true);
|
498
|
+
setInterval(throttledCheckElements, 999);
|
499
|
+
}
|
500
|
+
addEventListener("hashchange", throttledCheckElements, true);
|
501
|
+
["focus", "mouseover", "click", "load", "transitionend", "animationend"].forEach(function(name) {
|
502
|
+
document[_addEventListener](name, throttledCheckElements, true);
|
503
|
+
});
|
504
|
+
if (/d$|^c/.test(document.readyState)) {
|
505
|
+
onload();
|
506
|
+
} else {
|
507
|
+
addEventListener("load", onload);
|
508
|
+
document[_addEventListener]("DOMContentLoaded", throttledCheckElements);
|
509
|
+
setTimeout(onload, 2e4);
|
510
|
+
}
|
511
|
+
if (lazysizes2.elements.length) {
|
512
|
+
checkElements();
|
513
|
+
rAF._lsFlush();
|
514
|
+
} else {
|
515
|
+
throttledCheckElements();
|
516
|
+
}
|
517
|
+
},
|
518
|
+
checkElems: throttledCheckElements,
|
519
|
+
unveil: unveilElement,
|
520
|
+
_aLSL: altLoadmodeScrollListner
|
521
|
+
};
|
522
|
+
}();
|
523
|
+
var autoSizer = function() {
|
524
|
+
var autosizesElems;
|
525
|
+
var sizeElement = rAFIt(function(elem, parent, event, width) {
|
526
|
+
var sources, i, len;
|
527
|
+
elem._lazysizesWidth = width;
|
528
|
+
width += "px";
|
529
|
+
elem.setAttribute("sizes", width);
|
530
|
+
if (regPicture.test(parent.nodeName || "")) {
|
531
|
+
sources = parent.getElementsByTagName("source");
|
532
|
+
for (i = 0, len = sources.length; i < len; i++) {
|
533
|
+
sources[i].setAttribute("sizes", width);
|
534
|
+
}
|
535
|
+
}
|
536
|
+
if (!event.detail.dataAttr) {
|
537
|
+
updatePolyfill(elem, event.detail);
|
538
|
+
}
|
539
|
+
});
|
540
|
+
var getSizeElement = function(elem, dataAttr, width) {
|
541
|
+
var event;
|
542
|
+
var parent = elem.parentNode;
|
543
|
+
if (parent) {
|
544
|
+
width = getWidth(elem, parent, width);
|
545
|
+
event = triggerEvent(elem, "lazybeforesizes", { width, dataAttr: !!dataAttr });
|
546
|
+
if (!event.defaultPrevented) {
|
547
|
+
width = event.detail.width;
|
548
|
+
if (width && width !== elem._lazysizesWidth) {
|
549
|
+
sizeElement(elem, parent, event, width);
|
550
|
+
}
|
551
|
+
}
|
552
|
+
}
|
553
|
+
};
|
554
|
+
var updateElementsSizes = function() {
|
555
|
+
var i;
|
556
|
+
var len = autosizesElems.length;
|
557
|
+
if (len) {
|
558
|
+
i = 0;
|
559
|
+
for (; i < len; i++) {
|
560
|
+
getSizeElement(autosizesElems[i]);
|
561
|
+
}
|
562
|
+
}
|
563
|
+
};
|
564
|
+
var debouncedUpdateElementsSizes = debounce(updateElementsSizes);
|
565
|
+
return {
|
566
|
+
_: function() {
|
567
|
+
autosizesElems = document.getElementsByClassName(lazySizesCfg.autosizesClass);
|
568
|
+
addEventListener("resize", debouncedUpdateElementsSizes);
|
569
|
+
},
|
570
|
+
checkElems: debouncedUpdateElementsSizes,
|
571
|
+
updateElem: getSizeElement
|
572
|
+
};
|
573
|
+
}();
|
574
|
+
var init = function() {
|
575
|
+
if (!init.i && document.getElementsByClassName) {
|
576
|
+
init.i = true;
|
577
|
+
autoSizer._();
|
578
|
+
loader._();
|
579
|
+
}
|
580
|
+
};
|
581
|
+
setTimeout(function() {
|
582
|
+
if (lazySizesCfg.init) {
|
583
|
+
init();
|
584
|
+
}
|
585
|
+
});
|
586
|
+
lazysizes2 = {
|
587
|
+
/**
|
588
|
+
* @type { LazySizesConfigPartial }
|
589
|
+
*/
|
590
|
+
cfg: lazySizesCfg,
|
591
|
+
autoSizer,
|
592
|
+
loader,
|
593
|
+
init,
|
594
|
+
uP: updatePolyfill,
|
595
|
+
aC: addClass,
|
596
|
+
rC: removeClass,
|
597
|
+
hC: hasClass,
|
598
|
+
fire: triggerEvent,
|
599
|
+
gW: getWidth,
|
600
|
+
rAF
|
601
|
+
};
|
602
|
+
return lazysizes2;
|
603
|
+
}
|
604
|
+
);
|
605
|
+
})(lazysizes);
|
606
|
+
return lazysizes.exports;
|
607
|
+
}
|
608
|
+
requireLazysizes();
|
609
|
+
export {
|
610
|
+
requireLazysizes as r
|
611
|
+
};
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import { P as PbEnhancedElement, l as lodashExports } from "./lib.js";
|
2
|
+
const KIT_SELECTOR = '[class^="pb_"][class*="_kit"]';
|
3
|
+
const ERROR_MESSAGE_SELECTOR = ".pb_body_kit_negative";
|
4
|
+
const FORM_SELECTOR = 'form[data-pb-form-validation="true"]';
|
5
|
+
const REQUIRED_FIELDS_SELECTOR = "input[required],textarea[required],select[required]";
|
6
|
+
const FIELD_EVENTS = [
|
7
|
+
"change",
|
8
|
+
"valid",
|
9
|
+
"invalid"
|
10
|
+
];
|
11
|
+
class PbFormValidation extends PbEnhancedElement {
|
12
|
+
static get selector() {
|
13
|
+
return FORM_SELECTOR;
|
14
|
+
}
|
15
|
+
connect() {
|
16
|
+
this.formValidationFields.forEach((field) => {
|
17
|
+
FIELD_EVENTS.forEach((e) => {
|
18
|
+
field.addEventListener(e, lodashExports.debounce((event) => {
|
19
|
+
this.validateFormField(event);
|
20
|
+
}, 250), false);
|
21
|
+
});
|
22
|
+
});
|
23
|
+
}
|
24
|
+
validateFormField(event) {
|
25
|
+
event.preventDefault();
|
26
|
+
const { target } = event;
|
27
|
+
target.setCustomValidity("");
|
28
|
+
const isValid = event.target.validity.valid;
|
29
|
+
if (isValid) {
|
30
|
+
this.clearError(target);
|
31
|
+
} else {
|
32
|
+
this.showValidationMessage(target);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
showValidationMessage(target) {
|
36
|
+
const { parentElement } = target;
|
37
|
+
this.clearError(target);
|
38
|
+
parentElement.closest(KIT_SELECTOR).classList.add("error");
|
39
|
+
const errorMessageContainer = this.errorMessageContainer;
|
40
|
+
if (target.dataset.message) target.setCustomValidity(target.dataset.message);
|
41
|
+
errorMessageContainer.innerHTML = target.validationMessage;
|
42
|
+
parentElement.appendChild(errorMessageContainer);
|
43
|
+
}
|
44
|
+
clearError(target) {
|
45
|
+
const { parentElement } = target;
|
46
|
+
parentElement.closest(KIT_SELECTOR).classList.remove("error");
|
47
|
+
const errorMessageContainer = parentElement.querySelector(ERROR_MESSAGE_SELECTOR);
|
48
|
+
if (errorMessageContainer) errorMessageContainer.remove();
|
49
|
+
}
|
50
|
+
get errorMessageContainer() {
|
51
|
+
const errorContainer = document.createElement("div");
|
52
|
+
const kitClassName = ERROR_MESSAGE_SELECTOR.replace(/\./, "");
|
53
|
+
errorContainer.classList.add(kitClassName);
|
54
|
+
return errorContainer;
|
55
|
+
}
|
56
|
+
get formValidationFields() {
|
57
|
+
return this._formValidationFields = this._formValidationFields || this.element.querySelectorAll(REQUIRED_FIELDS_SELECTOR);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
window.PbFormValidation = PbFormValidation;
|