modified file upgrade-temp-backup
This commit is contained in:
@ -0,0 +1,65 @@
|
||||
( function() {
|
||||
'use strict';
|
||||
|
||||
// Feature Test
|
||||
if ( 'querySelector' in document && 'addEventListener' in window ) {
|
||||
var goTopBtn = document.querySelector( '.generate-back-to-top' );
|
||||
|
||||
var trackScroll = function() {
|
||||
var scrolled = window.pageYOffset;
|
||||
var coords = goTopBtn.getAttribute( 'data-start-scroll' );
|
||||
|
||||
if ( scrolled > coords ) {
|
||||
goTopBtn.classList.add( 'generate-back-to-top__show' );
|
||||
}
|
||||
|
||||
if ( scrolled < coords ) {
|
||||
goTopBtn.classList.remove( 'generate-back-to-top__show' );
|
||||
}
|
||||
};
|
||||
|
||||
// Function to animate the scroll
|
||||
var smoothScroll = function( anchor, duration ) {
|
||||
// Calculate how far and how fast to scroll
|
||||
var startLocation = window.pageYOffset;
|
||||
var endLocation = document.body.offsetTop;
|
||||
var distance = endLocation - startLocation;
|
||||
var increments = distance / ( duration / 16 );
|
||||
var stopAnimation;
|
||||
|
||||
// Scroll the page by an increment, and check if it's time to stop
|
||||
var animateScroll = function() {
|
||||
window.scrollBy( 0, increments );
|
||||
stopAnimation();
|
||||
};
|
||||
|
||||
// Stop animation when you reach the anchor OR the top of the page
|
||||
stopAnimation = function() {
|
||||
var travelled = window.pageYOffset;
|
||||
if ( travelled <= ( endLocation || 0 ) ) {
|
||||
clearInterval( runAnimation );
|
||||
document.activeElement.blur();
|
||||
}
|
||||
};
|
||||
|
||||
// Loop the animation function
|
||||
var runAnimation = setInterval( animateScroll, 16 );
|
||||
};
|
||||
|
||||
if ( goTopBtn ) {
|
||||
// Show the button when scrolling down.
|
||||
window.addEventListener( 'scroll', trackScroll );
|
||||
|
||||
// Scroll back to top when clicked.
|
||||
goTopBtn.addEventListener( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
if ( generatepressBackToTop.smooth ) {
|
||||
smoothScroll( document.body, goTopBtn.getAttribute( 'data-scroll-speed' ) || 400 );
|
||||
} else {
|
||||
window.scrollTo( 0, 0 );
|
||||
}
|
||||
}, false );
|
||||
}
|
||||
}
|
||||
}() );
|
1
wp-content/upgrade-temp-backup/themes/generatepress/assets/js/back-to-top.min.js
vendored
Normal file
1
wp-content/upgrade-temp-backup/themes/generatepress/assets/js/back-to-top.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(){"use strict";var c;"querySelector"in document&&"addEventListener"in window&&(c=document.querySelector(".generate-back-to-top"),c&&(window.addEventListener("scroll",function(){var e=window.pageYOffset,t=c.getAttribute("data-start-scroll");t<e&&c.classList.add("generate-back-to-top__show"),e<t&&c.classList.remove("generate-back-to-top__show")}),c.addEventListener("click",function(e){var t,o,n,a,r;e.preventDefault(),generatepressBackToTop.smooth?(document.body,t=c.getAttribute("data-scroll-speed")||400,e=window.pageYOffset,o=document.body.offsetTop,n=(o-e)/(t/16),a=function(){window.pageYOffset<=(o||0)&&(clearInterval(r),document.activeElement.blur())},r=setInterval(function(){window.scrollBy(0,n),a()},16)):window.scrollTo(0,0)},!1)))}();
|
@ -0,0 +1,240 @@
|
||||
/*
|
||||
* classList.js: Cross-browser full element.classList implementation.
|
||||
* 1.1.20170427
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com
|
||||
* License: Dedicated to the public domain.
|
||||
* See https://github.com/eligrey/classList.js/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/*global self, document, DOMException */
|
||||
|
||||
/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */
|
||||
|
||||
if ("document" in self) {
|
||||
|
||||
// Full polyfill for browsers with no classList support
|
||||
// Including IE < Edge missing SVGElement.classList
|
||||
if (!("classList" in document.createElement("_"))
|
||||
|| document.createElementNS && !("classList" in document.createElementNS("http://www.w3.org/2000/svg","g"))) {
|
||||
|
||||
(function (view) {
|
||||
|
||||
"use strict";
|
||||
|
||||
if (!('Element' in view)) return;
|
||||
|
||||
var
|
||||
classListProp = "classList"
|
||||
, protoProp = "prototype"
|
||||
, elemCtrProto = view.Element[protoProp]
|
||||
, objCtr = Object
|
||||
, strTrim = String[protoProp].trim || function () {
|
||||
return this.replace(/^\s+|\s+$/g, "");
|
||||
}
|
||||
, arrIndexOf = Array[protoProp].indexOf || function (item) {
|
||||
var
|
||||
i = 0
|
||||
, len = this.length
|
||||
;
|
||||
for (; i < len; i++) {
|
||||
if (i in this && this[i] === item) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
// Vendors: please allow content code to instantiate DOMExceptions
|
||||
, DOMEx = function (type, message) {
|
||||
this.name = type;
|
||||
this.code = DOMException[type];
|
||||
this.message = message;
|
||||
}
|
||||
, checkTokenAndGetIndex = function (classList, token) {
|
||||
if (token === "") {
|
||||
throw new DOMEx(
|
||||
"SYNTAX_ERR"
|
||||
, "An invalid or illegal string was specified"
|
||||
);
|
||||
}
|
||||
if (/\s/.test(token)) {
|
||||
throw new DOMEx(
|
||||
"INVALID_CHARACTER_ERR"
|
||||
, "String contains an invalid character"
|
||||
);
|
||||
}
|
||||
return arrIndexOf.call(classList, token);
|
||||
}
|
||||
, ClassList = function (elem) {
|
||||
var
|
||||
trimmedClasses = strTrim.call(elem.getAttribute("class") || "")
|
||||
, classes = trimmedClasses ? trimmedClasses.split(/\s+/) : []
|
||||
, i = 0
|
||||
, len = classes.length
|
||||
;
|
||||
for (; i < len; i++) {
|
||||
this.push(classes[i]);
|
||||
}
|
||||
this._updateClassName = function () {
|
||||
elem.setAttribute("class", this.toString());
|
||||
};
|
||||
}
|
||||
, classListProto = ClassList[protoProp] = []
|
||||
, classListGetter = function () {
|
||||
return new ClassList(this);
|
||||
}
|
||||
;
|
||||
// Most DOMException implementations don't allow calling DOMException's toString()
|
||||
// on non-DOMExceptions. Error's toString() is sufficient here.
|
||||
DOMEx[protoProp] = Error[protoProp];
|
||||
classListProto.item = function (i) {
|
||||
return this[i] || null;
|
||||
};
|
||||
classListProto.contains = function (token) {
|
||||
token += "";
|
||||
return checkTokenAndGetIndex(this, token) !== -1;
|
||||
};
|
||||
classListProto.add = function () {
|
||||
var
|
||||
tokens = arguments
|
||||
, i = 0
|
||||
, l = tokens.length
|
||||
, token
|
||||
, updated = false
|
||||
;
|
||||
do {
|
||||
token = tokens[i] + "";
|
||||
if (checkTokenAndGetIndex(this, token) === -1) {
|
||||
this.push(token);
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
while (++i < l);
|
||||
|
||||
if (updated) {
|
||||
this._updateClassName();
|
||||
}
|
||||
};
|
||||
classListProto.remove = function () {
|
||||
var
|
||||
tokens = arguments
|
||||
, i = 0
|
||||
, l = tokens.length
|
||||
, token
|
||||
, updated = false
|
||||
, index
|
||||
;
|
||||
do {
|
||||
token = tokens[i] + "";
|
||||
index = checkTokenAndGetIndex(this, token);
|
||||
while (index !== -1) {
|
||||
this.splice(index, 1);
|
||||
updated = true;
|
||||
index = checkTokenAndGetIndex(this, token);
|
||||
}
|
||||
}
|
||||
while (++i < l);
|
||||
|
||||
if (updated) {
|
||||
this._updateClassName();
|
||||
}
|
||||
};
|
||||
classListProto.toggle = function (token, force) {
|
||||
token += "";
|
||||
|
||||
var
|
||||
result = this.contains(token)
|
||||
, method = result ?
|
||||
force !== true && "remove"
|
||||
:
|
||||
force !== false && "add"
|
||||
;
|
||||
|
||||
if (method) {
|
||||
this[method](token);
|
||||
}
|
||||
|
||||
if (force === true || force === false) {
|
||||
return force;
|
||||
} else {
|
||||
return !result;
|
||||
}
|
||||
};
|
||||
classListProto.toString = function () {
|
||||
return this.join(" ");
|
||||
};
|
||||
|
||||
if (objCtr.defineProperty) {
|
||||
var classListPropDesc = {
|
||||
get: classListGetter
|
||||
, enumerable: true
|
||||
, configurable: true
|
||||
};
|
||||
try {
|
||||
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
|
||||
} catch (ex) { // IE 8 doesn't support enumerable:true
|
||||
// adding undefined to fight this issue https://github.com/eligrey/classList.js/issues/36
|
||||
// modernie IE8-MSW7 machine has IE8 8.0.6001.18702 and is affected
|
||||
if (ex.number === undefined || ex.number === -0x7FF5EC54) {
|
||||
classListPropDesc.enumerable = false;
|
||||
objCtr.defineProperty(elemCtrProto, classListProp, classListPropDesc);
|
||||
}
|
||||
}
|
||||
} else if (objCtr[protoProp].__defineGetter__) {
|
||||
elemCtrProto.__defineGetter__(classListProp, classListGetter);
|
||||
}
|
||||
|
||||
}(self));
|
||||
|
||||
}
|
||||
|
||||
// There is full or partial native classList support, so just check if we need
|
||||
// to normalize the add/remove and toggle APIs.
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
var testElement = document.createElement("_");
|
||||
|
||||
testElement.classList.add("c1", "c2");
|
||||
|
||||
// Polyfill for IE 10/11 and Firefox <26, where classList.add and
|
||||
// classList.remove exist but support only one argument at a time.
|
||||
if (!testElement.classList.contains("c2")) {
|
||||
var createMethod = function(method) {
|
||||
var original = DOMTokenList.prototype[method];
|
||||
|
||||
DOMTokenList.prototype[method] = function(token) {
|
||||
var i, len = arguments.length;
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
token = arguments[i];
|
||||
original.call(this, token);
|
||||
}
|
||||
};
|
||||
};
|
||||
createMethod('add');
|
||||
createMethod('remove');
|
||||
}
|
||||
|
||||
testElement.classList.toggle("c3", false);
|
||||
|
||||
// Polyfill for IE 10 and Firefox <24, where classList.toggle does not
|
||||
// support the second argument.
|
||||
if (testElement.classList.contains("c3")) {
|
||||
var _toggle = DOMTokenList.prototype.toggle;
|
||||
|
||||
DOMTokenList.prototype.toggle = function(token, force) {
|
||||
if (1 in arguments && !this.contains(token) === !force) {
|
||||
return force;
|
||||
} else {
|
||||
return _toggle.call(this, token);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
testElement = null;
|
||||
}());
|
||||
|
||||
}
|
2
wp-content/upgrade-temp-backup/themes/generatepress/assets/js/classList.min.js
vendored
Normal file
2
wp-content/upgrade-temp-backup/themes/generatepress/assets/js/classList.min.js
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/*! @source http://purl.eligrey.com/github/classList.js/blob/master/classList.js */
|
||||
"document"in self&&("classList"in document.createElement("_")&&(!document.createElementNS||"classList"in document.createElementNS("http://www.w3.org/2000/svg","g"))||!function(t){"use strict";if("Element"in t){var e="classList",n="prototype",i=t.Element[n],s=Object,r=String[n].trim||function(){return this.replace(/^\s+|\s+$/g,"")},o=Array[n].indexOf||function(t){for(var e=0,n=this.length;n>e;e++)if(e in this&&this[e]===t)return e;return-1},a=function(t,e){this.name=t,this.code=DOMException[t],this.message=e},c=function(t,e){if(""===e)throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new a("INVALID_CHARACTER_ERR","String contains an invalid character");return o.call(t,e)},l=function(t){for(var e=r.call(t.getAttribute("class")||""),n=e?e.split(/\s+/):[],i=0,s=n.length;s>i;i++)this.push(n[i]);this._updateClassName=function(){t.setAttribute("class",""+this)}},u=l[n]=[],h=function(){return new l(this)};if(a[n]=Error[n],u.item=function(t){return this[t]||null},u.contains=function(t){return t+="",-1!==c(this,t)},u.add=function(){var t,e=arguments,n=0,i=e.length,s=!1;do t=e[n]+"",-1===c(this,t)&&(this.push(t),s=!0);while(++n<i);s&&this._updateClassName()},u.remove=function(){var t,e,n=arguments,i=0,s=n.length,r=!1;do for(t=n[i]+"",e=c(this,t);-1!==e;)this.splice(e,1),r=!0,e=c(this,t);while(++i<s);r&&this._updateClassName()},u.toggle=function(t,e){t+="";var n=this.contains(t),i=n?e!==!0&&"remove":e!==!1&&"add";return i&&this[i](t),e===!0||e===!1?e:!n},u.toString=function(){return this.join(" ")},s.defineProperty){var f={get:h,enumerable:!0,configurable:!0};try{s.defineProperty(i,e,f)}catch(g){(void 0===g.number||-2146823252===g.number)&&(f.enumerable=!1,s.defineProperty(i,e,f))}}else s[n].__defineGetter__&&i.__defineGetter__(e,h)}}(self),function(){"use strict";var t=document.createElement("_");if(t.classList.add("c1","c2"),!t.classList.contains("c2")){var e=function(t){var e=DOMTokenList.prototype[t];DOMTokenList.prototype[t]=function(t){var n,i=arguments.length;for(n=0;i>n;n++)t=arguments[n],e.call(this,t)}};e("add"),e("remove")}if(t.classList.toggle("c3",!1),t.classList.contains("c3")){var n=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(t,e){return 1 in arguments&&!this.contains(t)==!e?e:n.call(this,t)}}t=null}());
|
@ -0,0 +1,123 @@
|
||||
( function() {
|
||||
'use strict';
|
||||
|
||||
if ( 'querySelector' in document && 'addEventListener' in window ) {
|
||||
var body = document.body,
|
||||
i;
|
||||
/**
|
||||
* Dropdown click
|
||||
*
|
||||
* @param {Object} e The event.
|
||||
* @param {Object} _this The clicked item.
|
||||
*/
|
||||
var dropdownClick = function( e, _this ) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
if ( ! _this ) {
|
||||
_this = this;
|
||||
}
|
||||
|
||||
var closestLi = _this.closest( 'li' );
|
||||
|
||||
// Close other sub-menus
|
||||
var openedSubMenus = _this.closest( 'nav' ).querySelectorAll( 'ul.toggled-on' );
|
||||
if ( openedSubMenus && ! _this.closest( 'ul' ).classList.contains( 'toggled-on' ) && ! _this.closest( 'li' ).classList.contains( 'sfHover' ) ) {
|
||||
for ( var o = 0; o < openedSubMenus.length; o++ ) {
|
||||
openedSubMenus[ o ].classList.remove( 'toggled-on' );
|
||||
openedSubMenus[ o ].closest( 'li' ).classList.remove( 'sfHover' );
|
||||
}
|
||||
}
|
||||
|
||||
// Add sfHover class to parent li
|
||||
closestLi.classList.toggle( 'sfHover' );
|
||||
|
||||
// Set aria-expanded on arrow
|
||||
var dropdownToggle = closestLi.querySelector( '.dropdown-menu-toggle' );
|
||||
if ( 'false' === dropdownToggle.getAttribute( 'aria-expanded' ) || ! dropdownToggle.getAttribute( 'aria-expanded' ) ) {
|
||||
dropdownToggle.setAttribute( 'aria-expanded', 'true' );
|
||||
} else {
|
||||
dropdownToggle.setAttribute( 'aria-expanded', 'false' );
|
||||
}
|
||||
|
||||
if ( closestLi.querySelector( '.sub-menu' ) ) {
|
||||
var subMenuSelector = '.sub-menu';
|
||||
} else {
|
||||
subMenuSelector = '.children';
|
||||
}
|
||||
|
||||
// Open the sub-menu
|
||||
if ( body.classList.contains( 'dropdown-click-menu-item' ) ) {
|
||||
_this.parentNode.querySelector( subMenuSelector ).classList.toggle( 'toggled-on' );
|
||||
} else if ( body.classList.contains( 'dropdown-click-arrow' ) ) {
|
||||
closestLi.querySelector( subMenuSelector ).classList.toggle( 'toggled-on' );
|
||||
}
|
||||
};
|
||||
|
||||
// Do stuff if click dropdown if enabled
|
||||
var parentElementLinks = document.querySelectorAll( '.main-nav .menu-item-has-children > a' );
|
||||
|
||||
// Open the sub-menu by clicking on the entire link element
|
||||
if ( body.classList.contains( 'dropdown-click-menu-item' ) ) {
|
||||
for ( i = 0; i < parentElementLinks.length; i++ ) {
|
||||
parentElementLinks[ i ].addEventListener( 'click', dropdownClick, true );
|
||||
}
|
||||
}
|
||||
|
||||
// Open the sub-menu by clicking on a dropdown arrow
|
||||
if ( body.classList.contains( 'dropdown-click-arrow' ) ) {
|
||||
// Add a class to sub-menu items that are set to #
|
||||
for ( i = 0; i < document.querySelectorAll( '.main-nav .menu-item-has-children > a' ).length; i++ ) {
|
||||
if ( '#' === document.querySelectorAll( '.main-nav .menu-item-has-children > a' )[ i ].getAttribute( 'href' ) ) {
|
||||
document.querySelectorAll( '.main-nav .menu-item-has-children > a' )[ i ].classList.add( 'menu-item-dropdown-click' );
|
||||
}
|
||||
}
|
||||
|
||||
var dropdownToggleLinks = document.querySelectorAll( '.main-nav .menu-item-has-children > a .dropdown-menu-toggle' );
|
||||
for ( i = 0; i < dropdownToggleLinks.length; i++ ) {
|
||||
dropdownToggleLinks[ i ].addEventListener( 'click', dropdownClick, false );
|
||||
|
||||
dropdownToggleLinks[ i ].addEventListener( 'keydown', function( e ) {
|
||||
var _this = this;
|
||||
|
||||
if ( 'Enter' === e.key ) {
|
||||
dropdownClick( e, _this );
|
||||
}
|
||||
}, false );
|
||||
}
|
||||
|
||||
for ( i = 0; i < document.querySelectorAll( '.main-nav .menu-item-has-children > a.menu-item-dropdown-click' ).length; i++ ) {
|
||||
document.querySelectorAll( '.main-nav .menu-item-has-children > a.menu-item-dropdown-click' )[ i ].addEventListener( 'click', dropdownClick, false );
|
||||
}
|
||||
}
|
||||
|
||||
var closeSubMenus = function() {
|
||||
if ( document.querySelector( 'nav ul .toggled-on' ) ) {
|
||||
var activeSubMenus = document.querySelectorAll( 'nav ul .toggled-on' );
|
||||
var activeDropdownToggles = document.querySelectorAll( 'nav .dropdown-menu-toggle' );
|
||||
for ( i = 0; i < activeSubMenus.length; i++ ) {
|
||||
activeSubMenus[ i ].classList.remove( 'toggled-on' );
|
||||
activeSubMenus[ i ].closest( '.sfHover' ).classList.remove( 'sfHover' );
|
||||
}
|
||||
|
||||
for ( i = 0; i < activeDropdownToggles.length; i++ ) {
|
||||
activeDropdownToggles[ i ].setAttribute( 'aria-expanded', 'false' );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Close sub-menus when clicking elsewhere
|
||||
document.addEventListener( 'click', function( event ) {
|
||||
if ( ! event.target.closest( '.sfHover' ) ) {
|
||||
closeSubMenus();
|
||||
}
|
||||
}, false );
|
||||
|
||||
// Close sub-menus on escape key
|
||||
document.addEventListener( 'keydown', function( e ) {
|
||||
if ( 'Escape' === e.key ) { // 27 is esc
|
||||
closeSubMenus();
|
||||
}
|
||||
}, false );
|
||||
}
|
||||
}() );
|
1
wp-content/upgrade-temp-backup/themes/generatepress/assets/js/dropdown-click.min.js
vendored
Normal file
1
wp-content/upgrade-temp-backup/themes/generatepress/assets/js/dropdown-click.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(){"use strict";if("querySelector"in document&&"addEventListener"in window){var r=document.body,t=function(e,t){e.preventDefault(),e.stopPropagation();var n=(t=t||this).closest("li"),o=t.closest("nav").querySelectorAll("ul.toggled-on");if(o&&!t.closest("ul").classList.contains("toggled-on")&&!t.closest("li").classList.contains("sfHover"))for(var l=0;l<o.length;l++)o[l].classList.remove("toggled-on"),o[l].closest("li").classList.remove("sfHover");n.classList.toggle("sfHover");e=n.querySelector(".dropdown-menu-toggle");"false"!==e.getAttribute("aria-expanded")&&e.getAttribute("aria-expanded")?e.setAttribute("aria-expanded","false"):e.setAttribute("aria-expanded","true"),e=n.querySelector(".sub-menu")?".sub-menu":".children",r.classList.contains("dropdown-click-menu-item")?t.parentNode.querySelector(e).classList.toggle("toggled-on"):r.classList.contains("dropdown-click-arrow")&&n.querySelector(e).classList.toggle("toggled-on")},e=document.querySelectorAll(".main-nav .menu-item-has-children > a");if(r.classList.contains("dropdown-click-menu-item"))for(o=0;o<e.length;o++)e[o].addEventListener("click",t,!0);if(r.classList.contains("dropdown-click-arrow")){for(o=0;o<document.querySelectorAll(".main-nav .menu-item-has-children > a").length;o++)"#"===document.querySelectorAll(".main-nav .menu-item-has-children > a")[o].getAttribute("href")&&document.querySelectorAll(".main-nav .menu-item-has-children > a")[o].classList.add("menu-item-dropdown-click");for(var n=document.querySelectorAll(".main-nav .menu-item-has-children > a .dropdown-menu-toggle"),o=0;o<n.length;o++)n[o].addEventListener("click",t,!1),n[o].addEventListener("keydown",function(e){"Enter"===e.key&&t(e,this)},!1);for(o=0;o<document.querySelectorAll(".main-nav .menu-item-has-children > a.menu-item-dropdown-click").length;o++)document.querySelectorAll(".main-nav .menu-item-has-children > a.menu-item-dropdown-click")[o].addEventListener("click",t,!1)}var l=function(){if(document.querySelector("nav ul .toggled-on")){var e=document.querySelectorAll("nav ul .toggled-on"),t=document.querySelectorAll("nav .dropdown-menu-toggle");for(o=0;o<e.length;o++)e[o].classList.remove("toggled-on"),e[o].closest(".sfHover").classList.remove("sfHover");for(o=0;o<t.length;o++)t[o].setAttribute("aria-expanded","false")}};document.addEventListener("click",function(e){e.target.closest(".sfHover")||l()},!1),document.addEventListener("keydown",function(e){"Escape"===e.key&&l()},!1)}}();
|
@ -0,0 +1,415 @@
|
||||
( function() {
|
||||
'use strict';
|
||||
|
||||
if ( 'querySelector' in document && 'addEventListener' in window ) {
|
||||
/**
|
||||
* matches() pollyfil
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Browser_compatibility
|
||||
*/
|
||||
if ( ! Element.prototype.matches ) {
|
||||
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
||||
}
|
||||
|
||||
/**
|
||||
* closest() pollyfil
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Browser_compatibility
|
||||
* @param {Object} s The element to check.
|
||||
* @return {Object} The closest object.
|
||||
*/
|
||||
if ( ! Element.prototype.closest ) {
|
||||
Element.prototype.closest = function( s ) {
|
||||
var el = this;
|
||||
var ancestor = this;
|
||||
if ( ! document.documentElement.contains( el ) ) {
|
||||
return null;
|
||||
}
|
||||
do {
|
||||
if ( ancestor.matches( s ) ) {
|
||||
return ancestor;
|
||||
}
|
||||
ancestor = ancestor.parentElement;
|
||||
} while ( ancestor !== null );
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
var getSiblings = function( elem ) {
|
||||
return Array.prototype.filter.call( elem.parentNode.children, function( sibling ) {
|
||||
return sibling !== elem;
|
||||
} );
|
||||
};
|
||||
|
||||
var allNavToggles = document.querySelectorAll( '.menu-toggle' ),
|
||||
dropdownToggles = document.querySelectorAll( 'nav .dropdown-menu-toggle' ),
|
||||
navLinks = document.querySelectorAll( 'nav .main-nav ul a' ),
|
||||
mobileMenuControls = document.querySelector( '.mobile-menu-control-wrapper' ),
|
||||
body = document.body,
|
||||
htmlEl = document.documentElement,
|
||||
i;
|
||||
|
||||
var enableDropdownArrows = function( nav ) {
|
||||
if ( nav && body.classList.contains( 'dropdown-hover' ) ) {
|
||||
var dropdownItems = nav.querySelectorAll( 'li.menu-item-has-children' );
|
||||
|
||||
for ( i = 0; i < dropdownItems.length; i++ ) {
|
||||
dropdownItems[ i ].querySelector( '.dropdown-menu-toggle' ).setAttribute( 'tabindex', '0' );
|
||||
dropdownItems[ i ].querySelector( '.dropdown-menu-toggle' ).setAttribute( 'role', 'button' );
|
||||
dropdownItems[ i ].querySelector( '.dropdown-menu-toggle' ).setAttribute( 'aria-expanded', 'false' );
|
||||
dropdownItems[ i ].querySelector( '.dropdown-menu-toggle' ).setAttribute( 'aria-label', generatepressMenu.openSubMenuLabel );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var disableDropdownArrows = function( nav ) {
|
||||
if ( nav && body.classList.contains( 'dropdown-hover' ) ) {
|
||||
var dropdownItems = nav.querySelectorAll( 'li.menu-item-has-children' );
|
||||
|
||||
for ( i = 0; i < dropdownItems.length; i++ ) {
|
||||
dropdownItems[ i ].querySelector( '.dropdown-menu-toggle' ).removeAttribute( 'tabindex' );
|
||||
dropdownItems[ i ].querySelector( '.dropdown-menu-toggle' ).setAttribute( 'role', 'presentation' );
|
||||
dropdownItems[ i ].querySelector( '.dropdown-menu-toggle' ).removeAttribute( 'aria-expanded' );
|
||||
dropdownItems[ i ].querySelector( '.dropdown-menu-toggle' ).removeAttribute( 'aria-label' );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var setDropdownArrowAttributes = function( arrow ) {
|
||||
if ( 'false' === arrow.getAttribute( 'aria-expanded' ) || ! arrow.getAttribute( 'aria-expanded' ) ) {
|
||||
arrow.setAttribute( 'aria-expanded', 'true' );
|
||||
arrow.setAttribute( 'aria-label', generatepressMenu.closeSubMenuLabel );
|
||||
} else {
|
||||
arrow.setAttribute( 'aria-expanded', 'false' );
|
||||
arrow.setAttribute( 'aria-label', generatepressMenu.openSubMenuLabel );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Start mobile menu toggle.
|
||||
*
|
||||
* @param {Object} e The event.
|
||||
* @param {Object} _this The clicked item.
|
||||
*/
|
||||
var toggleNav = function( e, _this ) {
|
||||
if ( ! _this ) {
|
||||
_this = this;
|
||||
}
|
||||
|
||||
var parentContainer = '';
|
||||
|
||||
if ( _this.getAttribute( 'data-nav' ) ) {
|
||||
parentContainer = document.getElementById( _this.getAttribute( 'data-nav' ) );
|
||||
} else {
|
||||
parentContainer = document.getElementById( _this.closest( 'nav' ).getAttribute( 'id' ) );
|
||||
}
|
||||
|
||||
if ( ! parentContainer ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var isExternalToggle = false;
|
||||
|
||||
if ( _this.closest( '.mobile-menu-control-wrapper' ) ) {
|
||||
isExternalToggle = true;
|
||||
}
|
||||
|
||||
var nav = parentContainer.getElementsByTagName( 'ul' )[ 0 ];
|
||||
|
||||
if ( parentContainer.classList.contains( 'toggled' ) ) {
|
||||
parentContainer.classList.remove( 'toggled' );
|
||||
htmlEl.classList.remove( 'mobile-menu-open' );
|
||||
|
||||
if ( nav ) {
|
||||
nav.setAttribute( 'aria-hidden', 'true' );
|
||||
}
|
||||
|
||||
_this.setAttribute( 'aria-expanded', 'false' );
|
||||
|
||||
if ( isExternalToggle ) {
|
||||
mobileMenuControls.classList.remove( 'toggled' );
|
||||
} else if ( mobileMenuControls && parentContainer.classList.contains( 'main-navigation' ) ) {
|
||||
mobileMenuControls.classList.remove( 'toggled' );
|
||||
}
|
||||
|
||||
disableDropdownArrows( nav );
|
||||
} else {
|
||||
parentContainer.classList.add( 'toggled' );
|
||||
htmlEl.classList.add( 'mobile-menu-open' );
|
||||
|
||||
if ( nav ) {
|
||||
nav.setAttribute( 'aria-hidden', 'false' );
|
||||
}
|
||||
|
||||
_this.setAttribute( 'aria-expanded', 'true' );
|
||||
|
||||
if ( isExternalToggle ) {
|
||||
mobileMenuControls.classList.add( 'toggled' );
|
||||
|
||||
if ( mobileMenuControls.querySelector( '.search-item' ) ) {
|
||||
if ( mobileMenuControls.querySelector( '.search-item' ).classList.contains( 'active' ) ) {
|
||||
mobileMenuControls.querySelector( '.search-item' ).click();
|
||||
}
|
||||
}
|
||||
} else if ( mobileMenuControls && parentContainer.classList.contains( 'main-navigation' ) ) {
|
||||
mobileMenuControls.classList.add( 'toggled' );
|
||||
}
|
||||
|
||||
enableDropdownArrows( nav );
|
||||
}
|
||||
};
|
||||
|
||||
for ( i = 0; i < allNavToggles.length; i++ ) {
|
||||
allNavToggles[ i ].addEventListener( 'click', toggleNav, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Open sub-menus
|
||||
*
|
||||
* @param {Object} e The event.
|
||||
* @param {Object} _this The clicked item.
|
||||
*/
|
||||
var toggleSubNav = function( e, _this ) {
|
||||
if ( ! _this ) {
|
||||
_this = this;
|
||||
}
|
||||
|
||||
if ( ( _this.closest( 'nav' ).classList.contains( 'toggled' ) || htmlEl.classList.contains( 'slide-opened' ) ) && ! body.classList.contains( 'dropdown-click' ) ) {
|
||||
e.preventDefault();
|
||||
var closestLi = _this.closest( 'li' );
|
||||
|
||||
setDropdownArrowAttributes( closestLi.querySelector( '.dropdown-menu-toggle' ) );
|
||||
|
||||
if ( closestLi.querySelector( '.sub-menu' ) ) {
|
||||
var subMenu = closestLi.querySelector( '.sub-menu' );
|
||||
} else {
|
||||
subMenu = closestLi.querySelector( '.children' );
|
||||
}
|
||||
|
||||
if ( generatepressMenu.toggleOpenedSubMenus ) {
|
||||
var siblings = getSiblings( closestLi );
|
||||
|
||||
for ( i = 0; i < siblings.length; i++ ) {
|
||||
if ( siblings[ i ].classList.contains( 'sfHover' ) ) {
|
||||
siblings[ i ].classList.remove( 'sfHover' );
|
||||
siblings[ i ].querySelector( '.toggled-on' ).classList.remove( 'toggled-on' );
|
||||
setDropdownArrowAttributes( siblings[ i ].querySelector( '.dropdown-menu-toggle' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closestLi.classList.toggle( 'sfHover' );
|
||||
subMenu.classList.toggle( 'toggled-on' );
|
||||
}
|
||||
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
for ( i = 0; i < dropdownToggles.length; i++ ) {
|
||||
dropdownToggles[ i ].addEventListener( 'click', toggleSubNav, false );
|
||||
dropdownToggles[ i ].addEventListener( 'keypress', function( e ) {
|
||||
if ( 'Enter' === e.key || ' ' === e.key ) {
|
||||
toggleSubNav( e, this );
|
||||
}
|
||||
}, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the mobile menu if our toggle isn't visible.
|
||||
* Makes it possible to style mobile item with .toggled class.
|
||||
*/
|
||||
var checkMobile = function() {
|
||||
var openedMobileMenus = document.querySelectorAll( '.toggled, .has-active-search' );
|
||||
|
||||
for ( i = 0; i < openedMobileMenus.length; i++ ) {
|
||||
var menuToggle = openedMobileMenus[ i ].querySelector( '.menu-toggle' );
|
||||
|
||||
if ( mobileMenuControls && ! menuToggle.closest( 'nav' ).classList.contains( 'mobile-menu-control-wrapper' ) ) {
|
||||
menuToggle = mobileMenuControls.querySelector( '.menu-toggle' );
|
||||
}
|
||||
|
||||
if ( menuToggle && menuToggle.offsetParent === null ) {
|
||||
if ( openedMobileMenus[ i ].classList.contains( 'toggled' ) ) {
|
||||
var remoteNav = false;
|
||||
|
||||
if ( openedMobileMenus[ i ].classList.contains( 'mobile-menu-control-wrapper' ) ) {
|
||||
remoteNav = true;
|
||||
}
|
||||
|
||||
if ( ! remoteNav ) {
|
||||
// Navigation is toggled, but .menu-toggle isn't visible on the page (display: none).
|
||||
var closestNav = openedMobileMenus[ i ].getElementsByTagName( 'ul' )[ 0 ],
|
||||
closestNavItems = closestNav ? closestNav.getElementsByTagName( 'li' ) : [],
|
||||
closestSubMenus = closestNav ? closestNav.getElementsByTagName( 'ul' ) : [];
|
||||
}
|
||||
|
||||
document.activeElement.blur();
|
||||
openedMobileMenus[ i ].classList.remove( 'toggled' );
|
||||
|
||||
htmlEl.classList.remove( 'mobile-menu-open' );
|
||||
menuToggle.setAttribute( 'aria-expanded', 'false' );
|
||||
|
||||
if ( ! remoteNav ) {
|
||||
for ( var li = 0; li < closestNavItems.length; li++ ) {
|
||||
closestNavItems[ li ].classList.remove( 'sfHover' );
|
||||
}
|
||||
|
||||
for ( var sm = 0; sm < closestSubMenus.length; sm++ ) {
|
||||
closestSubMenus[ sm ].classList.remove( 'toggled-on' );
|
||||
}
|
||||
|
||||
if ( closestNav ) {
|
||||
closestNav.removeAttribute( 'aria-hidden' );
|
||||
}
|
||||
}
|
||||
|
||||
disableDropdownArrows( openedMobileMenus[ i ] );
|
||||
}
|
||||
|
||||
if ( mobileMenuControls.querySelector( '.search-item' ) ) {
|
||||
if ( mobileMenuControls.querySelector( '.search-item' ).classList.contains( 'active' ) ) {
|
||||
mobileMenuControls.querySelector( '.search-item' ).click();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
window.addEventListener( 'resize', checkMobile, false );
|
||||
window.addEventListener( 'orientationchange', checkMobile, false );
|
||||
|
||||
if ( body.classList.contains( 'dropdown-hover' ) ) {
|
||||
/**
|
||||
* Do some essential things when menu items are clicked.
|
||||
*/
|
||||
for ( i = 0; i < navLinks.length; i++ ) {
|
||||
navLinks[ i ].addEventListener( 'click', function( e ) {
|
||||
// Remove sfHover class if we're going to another site.
|
||||
if ( this.hostname !== window.location.hostname ) {
|
||||
document.activeElement.blur();
|
||||
}
|
||||
|
||||
var closestNav = this.closest( 'nav' );
|
||||
if ( closestNav.classList.contains( 'toggled' ) || htmlEl.classList.contains( 'slide-opened' ) ) {
|
||||
var url = this.getAttribute( 'href' );
|
||||
|
||||
// Open the sub-menu if the link has no destination
|
||||
if ( '#' === url || '' === url ) {
|
||||
e.preventDefault();
|
||||
var closestLi = this.closest( 'li' );
|
||||
closestLi.classList.toggle( 'sfHover' );
|
||||
var subMenu = closestLi.querySelector( '.sub-menu' );
|
||||
|
||||
if ( subMenu ) {
|
||||
subMenu.classList.toggle( 'toggled-on' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}, false );
|
||||
}
|
||||
}
|
||||
|
||||
if ( body.classList.contains( 'dropdown-hover' ) ) {
|
||||
var menuBarItems = document.querySelectorAll( '.menu-bar-items .menu-bar-item > a' );
|
||||
|
||||
/**
|
||||
* Make menu items tab accessible when using the hover dropdown type
|
||||
*/
|
||||
var toggleFocus = function() {
|
||||
if ( this.closest( 'nav' ).classList.contains( 'toggled' ) || this.closest( 'nav' ).classList.contains( 'slideout-navigation' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
while ( -1 === self.className.indexOf( 'main-nav' ) ) {
|
||||
if ( 'li' === self.tagName.toLowerCase() ) {
|
||||
self.classList.toggle( 'sfHover' );
|
||||
}
|
||||
|
||||
self = self.parentElement;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Make our menu bar items tab accessible.
|
||||
*/
|
||||
var toggleMenuBarItemFocus = function() {
|
||||
if ( this.closest( 'nav' ).classList.contains( 'toggled' ) || this.closest( 'nav' ).classList.contains( 'slideout-navigation' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var self = this;
|
||||
|
||||
while ( -1 === self.className.indexOf( 'menu-bar-items' ) ) {
|
||||
if ( self.classList.contains( 'menu-bar-item' ) ) {
|
||||
self.classList.toggle( 'sfHover' );
|
||||
}
|
||||
|
||||
self = self.parentElement;
|
||||
}
|
||||
};
|
||||
|
||||
for ( i = 0; i < navLinks.length; i++ ) {
|
||||
navLinks[ i ].addEventListener( 'focus', toggleFocus );
|
||||
navLinks[ i ].addEventListener( 'blur', toggleFocus );
|
||||
}
|
||||
|
||||
for ( i = 0; i < menuBarItems.length; i++ ) {
|
||||
menuBarItems[ i ].addEventListener( 'focus', toggleMenuBarItemFocus );
|
||||
menuBarItems[ i ].addEventListener( 'blur', toggleMenuBarItemFocus );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make hover dropdown touch-friendly.
|
||||
*/
|
||||
if ( 'ontouchend' in document.documentElement && document.body.classList.contains( 'dropdown-hover' ) ) {
|
||||
var parentElements = document.querySelectorAll( '.sf-menu .menu-item-has-children' );
|
||||
|
||||
for ( i = 0; i < parentElements.length; i++ ) {
|
||||
parentElements[ i ].addEventListener( 'touchend', function( e ) {
|
||||
// Bail on mobile
|
||||
if ( this.closest( 'nav' ).classList.contains( 'toggled' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( e.touches.length === 1 || e.touches.length === 0 ) {
|
||||
// Prevent touch events within dropdown bubbling down to document
|
||||
e.stopPropagation();
|
||||
|
||||
// Toggle hover
|
||||
if ( ! this.classList.contains( 'sfHover' ) ) {
|
||||
// Prevent link on first touch
|
||||
if ( e.target === this || e.target.parentNode === this || e.target.parentNode.parentNode ) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
// Close other sub-menus.
|
||||
var closestLi = this.closest( 'li' ),
|
||||
siblings = getSiblings( closestLi );
|
||||
|
||||
for ( i = 0; i < siblings.length; i++ ) {
|
||||
if ( siblings[ i ].classList.contains( 'sfHover' ) ) {
|
||||
siblings[ i ].classList.remove( 'sfHover' );
|
||||
}
|
||||
}
|
||||
|
||||
this.classList.add( 'sfHover' );
|
||||
|
||||
// Hide dropdown on touch outside
|
||||
var closeDropdown,
|
||||
thisItem = this;
|
||||
|
||||
document.addEventListener( 'touchend', closeDropdown = function( event ) {
|
||||
event.stopPropagation();
|
||||
|
||||
thisItem.classList.remove( 'sfHover' );
|
||||
document.removeEventListener( 'touchend', closeDropdown );
|
||||
} );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
}() );
|
1
wp-content/upgrade-temp-backup/themes/generatepress/assets/js/menu.min.js
vendored
Normal file
1
wp-content/upgrade-temp-backup/themes/generatepress/assets/js/menu.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,126 @@
|
||||
( function() {
|
||||
'use strict';
|
||||
|
||||
if ( 'querySelector' in document && 'addEventListener' in window ) {
|
||||
/**
|
||||
* Navigation search.
|
||||
*
|
||||
* @param {Object} e The event.
|
||||
* @param {Object} item The clicked item.
|
||||
*/
|
||||
var toggleSearch = function( e, item ) {
|
||||
e.preventDefault();
|
||||
|
||||
if ( ! item ) {
|
||||
item = this;
|
||||
}
|
||||
|
||||
var forms = document.querySelectorAll( '.navigation-search' ),
|
||||
toggles = document.querySelectorAll( '.search-item' ),
|
||||
focusableEls = document.querySelectorAll( 'a[href], area[href], input:not([disabled]):not(.navigation-search), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]' ),
|
||||
nav = '';
|
||||
|
||||
if ( item.closest( '.mobile-menu-control-wrapper' ) ) {
|
||||
nav = document.getElementById( 'site-navigation' );
|
||||
}
|
||||
|
||||
for ( var i = 0; i < forms.length; i++ ) {
|
||||
if ( forms[ i ].classList.contains( 'nav-search-active' ) ) {
|
||||
if ( forms[ i ].closest( '#sticky-placeholder' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
forms[ i ].classList.remove( 'nav-search-active' );
|
||||
|
||||
var activeSearch = document.querySelector( '.has-active-search' );
|
||||
|
||||
if ( activeSearch ) {
|
||||
activeSearch.classList.remove( 'has-active-search' );
|
||||
}
|
||||
|
||||
for ( var t = 0; t < toggles.length; t++ ) {
|
||||
toggles[ t ].classList.remove( 'close-search' );
|
||||
toggles[ t ].classList.remove( 'active' );
|
||||
toggles[ t ].querySelector( 'a' ).setAttribute( 'aria-label', generatepressNavSearch.open );
|
||||
|
||||
// Allow tabindex on items again.
|
||||
for ( var f = 0; f < focusableEls.length; f++ ) {
|
||||
if ( ! focusableEls[ f ].closest( '.navigation-search' ) && ! focusableEls[ f ].closest( '.search-item' ) ) {
|
||||
focusableEls[ f ].removeAttribute( 'tabindex' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.activeElement.blur();
|
||||
} else {
|
||||
if ( forms[ i ].closest( '#sticky-placeholder' ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var openedMobileMenu = forms[ i ].closest( '.toggled' );
|
||||
|
||||
if ( openedMobileMenu ) {
|
||||
// Close the mobile menu.
|
||||
openedMobileMenu.querySelector( 'button.menu-toggle' ).click();
|
||||
}
|
||||
|
||||
if ( nav ) {
|
||||
nav.classList.add( 'has-active-search' );
|
||||
}
|
||||
|
||||
forms[ i ].classList.add( 'nav-search-active' );
|
||||
|
||||
var container = this.closest( 'nav' );
|
||||
|
||||
if ( container ) {
|
||||
if ( container.classList.contains( 'mobile-menu-control-wrapper' ) ) {
|
||||
container = nav;
|
||||
}
|
||||
|
||||
var searchField = container.querySelector( '.search-field' );
|
||||
|
||||
if ( searchField ) {
|
||||
searchField.focus();
|
||||
}
|
||||
}
|
||||
|
||||
for ( t = 0; t < toggles.length; t++ ) {
|
||||
toggles[ t ].classList.add( 'active' );
|
||||
toggles[ t ].querySelector( 'a' ).setAttribute( 'aria-label', generatepressNavSearch.close );
|
||||
|
||||
// Trap tabindex within the search element
|
||||
for ( f = 0; f < focusableEls.length; f++ ) {
|
||||
if ( ! focusableEls[ f ].closest( '.navigation-search' ) && ! focusableEls[ f ].closest( '.search-item' ) ) {
|
||||
focusableEls[ f ].setAttribute( 'tabindex', '-1' );
|
||||
}
|
||||
}
|
||||
|
||||
toggles[ t ].classList.add( 'close-search' );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if ( document.body.classList.contains( 'nav-search-enabled' ) ) {
|
||||
var searchItems = document.querySelectorAll( '.search-item' );
|
||||
|
||||
for ( var i = 0; i < searchItems.length; i++ ) {
|
||||
searchItems[ i ].addEventListener( 'click', toggleSearch, false );
|
||||
}
|
||||
|
||||
// Close navigation search on escape key
|
||||
document.addEventListener( 'keydown', function( e ) {
|
||||
if ( document.querySelector( '.navigation-search.nav-search-active' ) ) {
|
||||
if ( 'Escape' === e.key ) {
|
||||
var activeSearchItems = document.querySelectorAll( '.search-item.active' );
|
||||
|
||||
for ( var activeSearchItem = 0; activeSearchItem < activeSearchItems.length; activeSearchItem++ ) {
|
||||
toggleSearch( e, activeSearchItems[ activeSearchItem ] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}, false );
|
||||
}
|
||||
}
|
||||
}() );
|
1
wp-content/upgrade-temp-backup/themes/generatepress/assets/js/navigation-search.min.js
vendored
Normal file
1
wp-content/upgrade-temp-backup/themes/generatepress/assets/js/navigation-search.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(){"use strict";if("querySelector"in document&&"addEventListener"in window){var s=function(e,t){e.preventDefault(),t=t||this;var a=document.querySelectorAll(".navigation-search"),s=document.querySelectorAll(".search-item"),c=document.querySelectorAll('a[href], area[href], input:not([disabled]):not(.navigation-search), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),r="";t.closest(".mobile-menu-control-wrapper")&&(r=document.getElementById("site-navigation"));for(var i=0;i<a.length;i++)if(a[i].classList.contains("nav-search-active")){if(!a[i].closest("#sticky-placeholder")){a[i].classList.remove("nav-search-active");var n=document.querySelector(".has-active-search");n&&n.classList.remove("has-active-search");for(var o=0;o<s.length;o++){s[o].classList.remove("close-search"),s[o].classList.remove("active"),s[o].querySelector("a").setAttribute("aria-label",generatepressNavSearch.open);for(var l=0;l<c.length;l++)c[l].closest(".navigation-search")||c[l].closest(".search-item")||c[l].removeAttribute("tabindex")}document.activeElement.blur()}}else if(!a[i].closest("#sticky-placeholder")){n=a[i].closest(".toggled");n&&n.querySelector("button.menu-toggle").click(),r&&r.classList.add("has-active-search"),a[i].classList.add("nav-search-active");n=this.closest("nav");for(!n||(n=(n=n.classList.contains("mobile-menu-control-wrapper")?r:n).querySelector(".search-field"))&&n.focus(),o=0;o<s.length;o++){for(s[o].classList.add("active"),s[o].querySelector("a").setAttribute("aria-label",generatepressNavSearch.close),l=0;l<c.length;l++)c[l].closest(".navigation-search")||c[l].closest(".search-item")||c[l].setAttribute("tabindex","-1");s[o].classList.add("close-search")}}};if(document.body.classList.contains("nav-search-enabled")){for(var e=document.querySelectorAll(".search-item"),t=0;t<e.length;t++)e[t].addEventListener("click",s,!1);document.addEventListener("keydown",function(e){if(document.querySelector(".navigation-search.nav-search-active")&&"Escape"===e.key)for(var t=document.querySelectorAll(".search-item.active"),a=0;a<t.length;a++){s(e,t[a]);break}},!1)}}}();
|
Reference in New Issue
Block a user