pull in v11.0.1 from upstream
This commit is contained in:
18
resources/js/app.js
Normal file
18
resources/js/app.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import.meta.glob([
|
||||
'../images/**',
|
||||
'../fonts/**',
|
||||
]);
|
||||
|
||||
import domReady from '@wordpress/dom-ready';
|
||||
import blocks from './blocks.js';
|
||||
import Header from './sections/header.js';
|
||||
import LazyLoad from './lib/Lazy.js';
|
||||
|
||||
/**
|
||||
* Application entrypoint
|
||||
*/
|
||||
domReady(async () => {
|
||||
LazyLoad();
|
||||
blocks();
|
||||
Header();
|
||||
});
|
||||
6
resources/js/blocks.js
Normal file
6
resources/js/blocks.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import BadExample from "./blocks/BadExample";
|
||||
|
||||
export default function()
|
||||
{
|
||||
BadExample();
|
||||
}
|
||||
4
resources/js/blocks/BadExample.js
Normal file
4
resources/js/blocks/BadExample.js
Normal file
@@ -0,0 +1,4 @@
|
||||
export default function BadExample()
|
||||
{
|
||||
|
||||
}
|
||||
5
resources/js/editor.js
Normal file
5
resources/js/editor.js
Normal file
@@ -0,0 +1,5 @@
|
||||
import domReady from '@wordpress/dom-ready';
|
||||
|
||||
domReady(() => {
|
||||
//
|
||||
});
|
||||
33
resources/js/lib/Lazy.js
Normal file
33
resources/js/lib/Lazy.js
Normal file
@@ -0,0 +1,33 @@
|
||||
export default function LazyLoadInit()
|
||||
{
|
||||
document.addEventListener('DOMContentLoaded', LazyLoad());
|
||||
}
|
||||
|
||||
function LazyLoad() {
|
||||
|
||||
var lazyImages = [].slice.call(document.querySelectorAll('img.lazy'));
|
||||
|
||||
if ('IntersectionObserver' in window) {
|
||||
let lazyImageObserver = new IntersectionObserver(function(entries, observer) {
|
||||
entries.forEach(function(entry) {
|
||||
if (entry.isIntersecting) {
|
||||
let lazyImage = entry.target;
|
||||
lazyImage.src = lazyImage.dataset.src;
|
||||
|
||||
if(lazyImage.dataset.srcset) {
|
||||
lazyImage.srcset = lazyImage.dataset.srcset;
|
||||
}
|
||||
|
||||
lazyImage.classList.remove('lazy');
|
||||
lazyImageObserver.unobserve(lazyImage);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
lazyImages.forEach(function(lazyImage) {
|
||||
lazyImageObserver.observe(lazyImage);
|
||||
});
|
||||
} else {
|
||||
// Possibly fall back to a more compatible method here
|
||||
}
|
||||
}
|
||||
24
resources/js/lib/VideoSrcset.js
Normal file
24
resources/js/lib/VideoSrcset.js
Normal file
@@ -0,0 +1,24 @@
|
||||
export default function VideoSrcset( element )
|
||||
{
|
||||
const sizes = JSON.parse(element.dataset.sizes);
|
||||
|
||||
Object.keys(sizes).forEach((key) => {
|
||||
const size = key;
|
||||
const source = element.querySelector('.bgvid-' + size);
|
||||
|
||||
if(source) {
|
||||
const sourceWidth = source.dataset.width;
|
||||
const poster = source.dataset.poster;
|
||||
|
||||
if(window.innerWidth >= sourceWidth) {
|
||||
console.log('screen width is greater than or equal to the source width');
|
||||
console.log('screen width: ' + window.innerWidth);
|
||||
console.log('source width: ' + sourceWidth);
|
||||
|
||||
element.src = source.src;
|
||||
element.poster = poster;
|
||||
element.load;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
33
resources/js/sections/header.js
Normal file
33
resources/js/sections/header.js
Normal file
@@ -0,0 +1,33 @@
|
||||
export default function Header() {
|
||||
const body = document.querySelector("body");
|
||||
// const menuToggle = document.querySelector(".js-menu-toggle");
|
||||
// const menuClose = document.querySelector(".js-menu-close");
|
||||
|
||||
// menuToggle.addEventListener("click", (e) => {
|
||||
// e.preventDefault();
|
||||
// body.classList.toggle("menu-open");
|
||||
// });
|
||||
|
||||
// menuClose.addEventListener("click", (e) => {
|
||||
// e.preventDefault();
|
||||
// body.classList.remove("menu-open");
|
||||
// });
|
||||
|
||||
// document.addEventListener("keyup", function (event) {
|
||||
// if (event.key === "Escape") {
|
||||
// body.classList.remove("menu-open");
|
||||
// }
|
||||
// });
|
||||
|
||||
document.addEventListener("scroll", () => {
|
||||
const scrolled = document.scrollingElement.scrollTop;
|
||||
const position = body.offsetTop;
|
||||
const header = document.querySelector(".site-header");
|
||||
|
||||
if (scrolled > position + header.offsetHeight) {
|
||||
body.classList.add("scrolled");
|
||||
} else {
|
||||
body.classList.remove("scrolled");
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user