Edit File by line
/home/barbar84/www/wp-conte.../themes/twentytw.../assets/js
File: index.js
/* -----------------------------------------------------------------------------------------------
[0] Fix | Delete
Namespace
[1] Fix | Delete
--------------------------------------------------------------------------------------------------- */
[2] Fix | Delete
[3] Fix | Delete
var twentytwenty = twentytwenty || {};
[4] Fix | Delete
[5] Fix | Delete
// Set a default value for scrolled.
[6] Fix | Delete
twentytwenty.scrolled = 0;
[7] Fix | Delete
[8] Fix | Delete
// polyfill closest
[9] Fix | Delete
// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
[10] Fix | Delete
if ( ! Element.prototype.closest ) {
[11] Fix | Delete
Element.prototype.closest = function( s ) {
[12] Fix | Delete
var el = this;
[13] Fix | Delete
[14] Fix | Delete
do {
[15] Fix | Delete
if ( el.matches( s ) ) {
[16] Fix | Delete
return el;
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
el = el.parentElement || el.parentNode;
[20] Fix | Delete
} while ( el !== null && el.nodeType === 1 );
[21] Fix | Delete
[22] Fix | Delete
return null;
[23] Fix | Delete
};
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
// polyfill forEach
[27] Fix | Delete
// https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#Polyfill
[28] Fix | Delete
if ( window.NodeList && ! NodeList.prototype.forEach ) {
[29] Fix | Delete
NodeList.prototype.forEach = function( callback, thisArg ) {
[30] Fix | Delete
var i;
[31] Fix | Delete
var len = this.length;
[32] Fix | Delete
[33] Fix | Delete
thisArg = thisArg || window;
[34] Fix | Delete
[35] Fix | Delete
for ( i = 0; i < len; i++ ) {
[36] Fix | Delete
callback.call( thisArg, this[ i ], i, this );
[37] Fix | Delete
}
[38] Fix | Delete
};
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
// event "polyfill"
[42] Fix | Delete
twentytwenty.createEvent = function( eventName ) {
[43] Fix | Delete
var event;
[44] Fix | Delete
if ( typeof window.Event === 'function' ) {
[45] Fix | Delete
event = new Event( eventName );
[46] Fix | Delete
} else {
[47] Fix | Delete
event = document.createEvent( 'Event' );
[48] Fix | Delete
event.initEvent( eventName, true, false );
[49] Fix | Delete
}
[50] Fix | Delete
return event;
[51] Fix | Delete
};
[52] Fix | Delete
[53] Fix | Delete
// matches "polyfill"
[54] Fix | Delete
// https://developer.mozilla.org/es/docs/Web/API/Element/matches
[55] Fix | Delete
if ( ! Element.prototype.matches ) {
[56] Fix | Delete
Element.prototype.matches =
[57] Fix | Delete
Element.prototype.matchesSelector ||
[58] Fix | Delete
Element.prototype.mozMatchesSelector ||
[59] Fix | Delete
Element.prototype.msMatchesSelector ||
[60] Fix | Delete
Element.prototype.oMatchesSelector ||
[61] Fix | Delete
Element.prototype.webkitMatchesSelector ||
[62] Fix | Delete
function( s ) {
[63] Fix | Delete
var matches = ( this.document || this.ownerDocument ).querySelectorAll( s ),
[64] Fix | Delete
i = matches.length;
[65] Fix | Delete
while ( --i >= 0 && matches.item( i ) !== this ) {}
[66] Fix | Delete
return i > -1;
[67] Fix | Delete
};
[68] Fix | Delete
}
[69] Fix | Delete
[70] Fix | Delete
// Add a class to the body for when touch is enabled for browsers that don't support media queries
[71] Fix | Delete
// for interaction media features. Adapted from <https://codepen.io/Ferie/pen/vQOMmO>.
[72] Fix | Delete
twentytwenty.touchEnabled = {
[73] Fix | Delete
[74] Fix | Delete
init: function() {
[75] Fix | Delete
var matchMedia = function() {
[76] Fix | Delete
// Include the 'heartz' as a way to have a non-matching MQ to help terminate the join. See <https://git.io/vznFH>.
[77] Fix | Delete
var prefixes = [ '-webkit-', '-moz-', '-o-', '-ms-' ];
[78] Fix | Delete
var query = [ '(', prefixes.join( 'touch-enabled),(' ), 'heartz', ')' ].join( '' );
[79] Fix | Delete
return window.matchMedia && window.matchMedia( query ).matches;
[80] Fix | Delete
};
[81] Fix | Delete
[82] Fix | Delete
if ( ( 'ontouchstart' in window ) || ( window.DocumentTouch && document instanceof window.DocumentTouch ) || matchMedia() ) {
[83] Fix | Delete
document.body.classList.add( 'touch-enabled' );
[84] Fix | Delete
}
[85] Fix | Delete
}
[86] Fix | Delete
}; // twentytwenty.touchEnabled
[87] Fix | Delete
[88] Fix | Delete
/* -----------------------------------------------------------------------------------------------
[89] Fix | Delete
Cover Modals
[90] Fix | Delete
--------------------------------------------------------------------------------------------------- */
[91] Fix | Delete
[92] Fix | Delete
twentytwenty.coverModals = {
[93] Fix | Delete
[94] Fix | Delete
init: function() {
[95] Fix | Delete
if ( document.querySelector( '.cover-modal' ) ) {
[96] Fix | Delete
// Handle cover modals when they're toggled.
[97] Fix | Delete
this.onToggle();
[98] Fix | Delete
[99] Fix | Delete
// When toggled, untoggle if visitor clicks on the wrapping element of the modal.
[100] Fix | Delete
this.outsideUntoggle();
[101] Fix | Delete
[102] Fix | Delete
// Close on escape key press.
[103] Fix | Delete
this.closeOnEscape();
[104] Fix | Delete
[105] Fix | Delete
// Hide and show modals before and after their animations have played out.
[106] Fix | Delete
this.hideAndShowModals();
[107] Fix | Delete
}
[108] Fix | Delete
},
[109] Fix | Delete
[110] Fix | Delete
// Handle cover modals when they're toggled.
[111] Fix | Delete
onToggle: function() {
[112] Fix | Delete
document.querySelectorAll( '.cover-modal' ).forEach( function( element ) {
[113] Fix | Delete
element.addEventListener( 'toggled', function( event ) {
[114] Fix | Delete
var modal = event.target,
[115] Fix | Delete
body = document.body;
[116] Fix | Delete
[117] Fix | Delete
if ( modal.classList.contains( 'active' ) ) {
[118] Fix | Delete
body.classList.add( 'showing-modal' );
[119] Fix | Delete
} else {
[120] Fix | Delete
body.classList.remove( 'showing-modal' );
[121] Fix | Delete
body.classList.add( 'hiding-modal' );
[122] Fix | Delete
[123] Fix | Delete
// Remove the hiding class after a delay, when animations have been run.
[124] Fix | Delete
setTimeout( function() {
[125] Fix | Delete
body.classList.remove( 'hiding-modal' );
[126] Fix | Delete
}, 500 );
[127] Fix | Delete
}
[128] Fix | Delete
} );
[129] Fix | Delete
} );
[130] Fix | Delete
},
[131] Fix | Delete
[132] Fix | Delete
// Close modal on outside click.
[133] Fix | Delete
outsideUntoggle: function() {
[134] Fix | Delete
document.addEventListener( 'click', function( event ) {
[135] Fix | Delete
var target = event.target;
[136] Fix | Delete
var modal = document.querySelector( '.cover-modal.active' );
[137] Fix | Delete
[138] Fix | Delete
// if target onclick is <a> with # within the href attribute
[139] Fix | Delete
if ( event.target.tagName.toLowerCase() === 'a' && event.target.hash.includes( '#' ) && modal !== null ) {
[140] Fix | Delete
// untoggle the modal
[141] Fix | Delete
this.untoggleModal( modal );
[142] Fix | Delete
// wait 550 and scroll to the anchor
[143] Fix | Delete
setTimeout( function() {
[144] Fix | Delete
var anchor = document.getElementById( event.target.hash.slice( 1 ) );
[145] Fix | Delete
anchor.scrollIntoView();
[146] Fix | Delete
}, 550 );
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
if ( target === modal ) {
[150] Fix | Delete
this.untoggleModal( target );
[151] Fix | Delete
}
[152] Fix | Delete
}.bind( this ) );
[153] Fix | Delete
},
[154] Fix | Delete
[155] Fix | Delete
// Close modal on escape key press.
[156] Fix | Delete
closeOnEscape: function() {
[157] Fix | Delete
document.addEventListener( 'keydown', function( event ) {
[158] Fix | Delete
if ( event.keyCode === 27 ) {
[159] Fix | Delete
event.preventDefault();
[160] Fix | Delete
document.querySelectorAll( '.cover-modal.active' ).forEach( function( element ) {
[161] Fix | Delete
this.untoggleModal( element );
[162] Fix | Delete
}.bind( this ) );
[163] Fix | Delete
}
[164] Fix | Delete
}.bind( this ) );
[165] Fix | Delete
},
[166] Fix | Delete
[167] Fix | Delete
// Hide and show modals before and after their animations have played out.
[168] Fix | Delete
hideAndShowModals: function() {
[169] Fix | Delete
var _doc = document,
[170] Fix | Delete
_win = window,
[171] Fix | Delete
modals = _doc.querySelectorAll( '.cover-modal' ),
[172] Fix | Delete
htmlStyle = _doc.documentElement.style,
[173] Fix | Delete
adminBar = _doc.querySelector( '#wpadminbar' );
[174] Fix | Delete
[175] Fix | Delete
function getAdminBarHeight( negativeValue ) {
[176] Fix | Delete
var height,
[177] Fix | Delete
currentScroll = _win.pageYOffset;
[178] Fix | Delete
[179] Fix | Delete
if ( adminBar ) {
[180] Fix | Delete
height = currentScroll + adminBar.getBoundingClientRect().height;
[181] Fix | Delete
[182] Fix | Delete
return negativeValue ? -height : height;
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
return currentScroll === 0 ? 0 : -currentScroll;
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
function htmlStyles() {
[189] Fix | Delete
var overflow = _win.innerHeight > _doc.documentElement.getBoundingClientRect().height;
[190] Fix | Delete
[191] Fix | Delete
return {
[192] Fix | Delete
'overflow-y': overflow ? 'hidden' : 'scroll',
[193] Fix | Delete
position: 'fixed',
[194] Fix | Delete
width: '100%',
[195] Fix | Delete
top: getAdminBarHeight( true ) + 'px',
[196] Fix | Delete
left: 0
[197] Fix | Delete
};
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
// Show the modal.
[201] Fix | Delete
modals.forEach( function( modal ) {
[202] Fix | Delete
modal.addEventListener( 'toggle-target-before-inactive', function( event ) {
[203] Fix | Delete
var styles = htmlStyles(),
[204] Fix | Delete
offsetY = _win.pageYOffset,
[205] Fix | Delete
paddingTop = ( Math.abs( getAdminBarHeight() ) - offsetY ) + 'px',
[206] Fix | Delete
mQuery = _win.matchMedia( '(max-width: 600px)' );
[207] Fix | Delete
[208] Fix | Delete
if ( event.target !== modal ) {
[209] Fix | Delete
return;
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
Object.keys( styles ).forEach( function( styleKey ) {
[213] Fix | Delete
htmlStyle.setProperty( styleKey, styles[ styleKey ] );
[214] Fix | Delete
} );
[215] Fix | Delete
[216] Fix | Delete
_win.twentytwenty.scrolled = parseInt( styles.top, 10 );
[217] Fix | Delete
[218] Fix | Delete
if ( adminBar ) {
[219] Fix | Delete
_doc.body.style.setProperty( 'padding-top', paddingTop );
[220] Fix | Delete
[221] Fix | Delete
if ( mQuery.matches ) {
[222] Fix | Delete
if ( offsetY >= getAdminBarHeight() ) {
[223] Fix | Delete
modal.style.setProperty( 'top', 0 );
[224] Fix | Delete
} else {
[225] Fix | Delete
modal.style.setProperty( 'top', ( getAdminBarHeight() - offsetY ) + 'px' );
[226] Fix | Delete
}
[227] Fix | Delete
}
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
modal.classList.add( 'show-modal' );
[231] Fix | Delete
} );
[232] Fix | Delete
[233] Fix | Delete
// Hide the modal after a delay, so animations have time to play out.
[234] Fix | Delete
modal.addEventListener( 'toggle-target-after-inactive', function( event ) {
[235] Fix | Delete
if ( event.target !== modal ) {
[236] Fix | Delete
return;
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
setTimeout( function() {
[240] Fix | Delete
var clickedEl = twentytwenty.toggles.clickedEl;
[241] Fix | Delete
[242] Fix | Delete
modal.classList.remove( 'show-modal' );
[243] Fix | Delete
[244] Fix | Delete
Object.keys( htmlStyles() ).forEach( function( styleKey ) {
[245] Fix | Delete
htmlStyle.removeProperty( styleKey );
[246] Fix | Delete
} );
[247] Fix | Delete
[248] Fix | Delete
if ( adminBar ) {
[249] Fix | Delete
_doc.body.style.removeProperty( 'padding-top' );
[250] Fix | Delete
modal.style.removeProperty( 'top' );
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
if ( clickedEl !== false ) {
[254] Fix | Delete
clickedEl.focus();
[255] Fix | Delete
clickedEl = false;
[256] Fix | Delete
}
[257] Fix | Delete
[258] Fix | Delete
_win.scrollTo( 0, Math.abs( _win.twentytwenty.scrolled + getAdminBarHeight() ) );
[259] Fix | Delete
[260] Fix | Delete
_win.twentytwenty.scrolled = 0;
[261] Fix | Delete
}, 500 );
[262] Fix | Delete
} );
[263] Fix | Delete
} );
[264] Fix | Delete
},
[265] Fix | Delete
[266] Fix | Delete
// Untoggle a modal.
[267] Fix | Delete
untoggleModal: function( modal ) {
[268] Fix | Delete
var modalTargetClass,
[269] Fix | Delete
modalToggle = false;
[270] Fix | Delete
[271] Fix | Delete
// If the modal has specified the string (ID or class) used by toggles to target it, untoggle the toggles with that target string.
[272] Fix | Delete
// The modal-target-string must match the string toggles use to target the modal.
[273] Fix | Delete
if ( modal.dataset.modalTargetString ) {
[274] Fix | Delete
modalTargetClass = modal.dataset.modalTargetString;
[275] Fix | Delete
[276] Fix | Delete
modalToggle = document.querySelector( '*[data-toggle-target="' + modalTargetClass + '"]' );
[277] Fix | Delete
}
[278] Fix | Delete
[279] Fix | Delete
// If a modal toggle exists, trigger it so all of the toggle options are included.
[280] Fix | Delete
if ( modalToggle ) {
[281] Fix | Delete
modalToggle.click();
[282] Fix | Delete
[283] Fix | Delete
// If one doesn't exist, just hide the modal.
[284] Fix | Delete
} else {
[285] Fix | Delete
modal.classList.remove( 'active' );
[286] Fix | Delete
}
[287] Fix | Delete
}
[288] Fix | Delete
[289] Fix | Delete
}; // twentytwenty.coverModals
[290] Fix | Delete
[291] Fix | Delete
/* -----------------------------------------------------------------------------------------------
[292] Fix | Delete
Intrinsic Ratio Embeds
[293] Fix | Delete
--------------------------------------------------------------------------------------------------- */
[294] Fix | Delete
[295] Fix | Delete
twentytwenty.intrinsicRatioVideos = {
[296] Fix | Delete
[297] Fix | Delete
init: function() {
[298] Fix | Delete
this.makeFit();
[299] Fix | Delete
[300] Fix | Delete
window.addEventListener( 'resize', function() {
[301] Fix | Delete
this.makeFit();
[302] Fix | Delete
}.bind( this ) );
[303] Fix | Delete
},
[304] Fix | Delete
[305] Fix | Delete
makeFit: function() {
[306] Fix | Delete
document.querySelectorAll( 'iframe, object, video' ).forEach( function( video ) {
[307] Fix | Delete
var ratio, iTargetWidth,
[308] Fix | Delete
container = video.parentNode;
[309] Fix | Delete
[310] Fix | Delete
// Skip videos we want to ignore.
[311] Fix | Delete
if ( video.classList.contains( 'intrinsic-ignore' ) || video.parentNode.classList.contains( 'intrinsic-ignore' ) ) {
[312] Fix | Delete
return true;
[313] Fix | Delete
}
[314] Fix | Delete
[315] Fix | Delete
if ( ! video.dataset.origwidth ) {
[316] Fix | Delete
// Get the video element proportions.
[317] Fix | Delete
video.setAttribute( 'data-origwidth', video.width );
[318] Fix | Delete
video.setAttribute( 'data-origheight', video.height );
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
iTargetWidth = container.offsetWidth;
[322] Fix | Delete
[323] Fix | Delete
// Get ratio from proportions.
[324] Fix | Delete
ratio = iTargetWidth / video.dataset.origwidth;
[325] Fix | Delete
[326] Fix | Delete
// Scale based on ratio, thus retaining proportions.
[327] Fix | Delete
video.style.width = iTargetWidth + 'px';
[328] Fix | Delete
video.style.height = ( video.dataset.origheight * ratio ) + 'px';
[329] Fix | Delete
} );
[330] Fix | Delete
}
[331] Fix | Delete
[332] Fix | Delete
}; // twentytwenty.instrinsicRatioVideos
[333] Fix | Delete
[334] Fix | Delete
/* -----------------------------------------------------------------------------------------------
[335] Fix | Delete
Modal Menu
[336] Fix | Delete
--------------------------------------------------------------------------------------------------- */
[337] Fix | Delete
twentytwenty.modalMenu = {
[338] Fix | Delete
[339] Fix | Delete
init: function() {
[340] Fix | Delete
// If the current menu item is in a sub level, expand all the levels higher up on load.
[341] Fix | Delete
this.expandLevel();
[342] Fix | Delete
this.keepFocusInModal();
[343] Fix | Delete
},
[344] Fix | Delete
[345] Fix | Delete
expandLevel: function() {
[346] Fix | Delete
var modalMenus = document.querySelectorAll( '.modal-menu' );
[347] Fix | Delete
[348] Fix | Delete
modalMenus.forEach( function( modalMenu ) {
[349] Fix | Delete
var activeMenuItem = modalMenu.querySelector( '.current-menu-item' );
[350] Fix | Delete
[351] Fix | Delete
if ( activeMenuItem ) {
[352] Fix | Delete
twentytwentyFindParents( activeMenuItem, 'li' ).forEach( function( element ) {
[353] Fix | Delete
var subMenuToggle = element.querySelector( '.sub-menu-toggle' );
[354] Fix | Delete
if ( subMenuToggle ) {
[355] Fix | Delete
twentytwenty.toggles.performToggle( subMenuToggle, true );
[356] Fix | Delete
}
[357] Fix | Delete
} );
[358] Fix | Delete
}
[359] Fix | Delete
} );
[360] Fix | Delete
},
[361] Fix | Delete
[362] Fix | Delete
keepFocusInModal: function() {
[363] Fix | Delete
var _doc = document;
[364] Fix | Delete
[365] Fix | Delete
_doc.addEventListener( 'keydown', function( event ) {
[366] Fix | Delete
var toggleTarget, modal, selectors, elements, menuType, bottomMenu, activeEl, lastEl, firstEl, tabKey, shiftKey,
[367] Fix | Delete
clickedEl = twentytwenty.toggles.clickedEl;
[368] Fix | Delete
[369] Fix | Delete
if ( clickedEl && _doc.body.classList.contains( 'showing-modal' ) ) {
[370] Fix | Delete
toggleTarget = clickedEl.dataset.toggleTarget;
[371] Fix | Delete
selectors = 'input, a, button';
[372] Fix | Delete
modal = _doc.querySelector( toggleTarget );
[373] Fix | Delete
[374] Fix | Delete
elements = modal.querySelectorAll( selectors );
[375] Fix | Delete
elements = Array.prototype.slice.call( elements );
[376] Fix | Delete
[377] Fix | Delete
if ( '.menu-modal' === toggleTarget ) {
[378] Fix | Delete
menuType = window.matchMedia( '(min-width: 1000px)' ).matches;
[379] Fix | Delete
menuType = menuType ? '.expanded-menu' : '.mobile-menu';
[380] Fix | Delete
[381] Fix | Delete
elements = elements.filter( function( element ) {
[382] Fix | Delete
return null !== element.closest( menuType ) && null !== element.offsetParent;
[383] Fix | Delete
} );
[384] Fix | Delete
[385] Fix | Delete
elements.unshift( _doc.querySelector( '.close-nav-toggle' ) );
[386] Fix | Delete
[387] Fix | Delete
bottomMenu = _doc.querySelector( '.menu-bottom > nav' );
[388] Fix | Delete
[389] Fix | Delete
if ( bottomMenu ) {
[390] Fix | Delete
bottomMenu.querySelectorAll( selectors ).forEach( function( element ) {
[391] Fix | Delete
elements.push( element );
[392] Fix | Delete
} );
[393] Fix | Delete
}
[394] Fix | Delete
}
[395] Fix | Delete
[396] Fix | Delete
lastEl = elements[ elements.length - 1 ];
[397] Fix | Delete
firstEl = elements[0];
[398] Fix | Delete
activeEl = _doc.activeElement;
[399] Fix | Delete
tabKey = event.keyCode === 9;
[400] Fix | Delete
shiftKey = event.shiftKey;
[401] Fix | Delete
[402] Fix | Delete
if ( ! shiftKey && tabKey && lastEl === activeEl ) {
[403] Fix | Delete
event.preventDefault();
[404] Fix | Delete
firstEl.focus();
[405] Fix | Delete
}
[406] Fix | Delete
[407] Fix | Delete
if ( shiftKey && tabKey && firstEl === activeEl ) {
[408] Fix | Delete
event.preventDefault();
[409] Fix | Delete
lastEl.focus();
[410] Fix | Delete
}
[411] Fix | Delete
}
[412] Fix | Delete
} );
[413] Fix | Delete
}
[414] Fix | Delete
}; // twentytwenty.modalMenu
[415] Fix | Delete
[416] Fix | Delete
/* -----------------------------------------------------------------------------------------------
[417] Fix | Delete
Primary Menu
[418] Fix | Delete
--------------------------------------------------------------------------------------------------- */
[419] Fix | Delete
[420] Fix | Delete
twentytwenty.primaryMenu = {
[421] Fix | Delete
[422] Fix | Delete
init: function() {
[423] Fix | Delete
this.focusMenuWithChildren();
[424] Fix | Delete
},
[425] Fix | Delete
[426] Fix | Delete
// The focusMenuWithChildren() function implements Keyboard Navigation in the Primary Menu
[427] Fix | Delete
// by adding the '.focus' class to all 'li.menu-item-has-children' when the focus is on the 'a' element.
[428] Fix | Delete
focusMenuWithChildren: function() {
[429] Fix | Delete
// Get all the link elements within the primary menu.
[430] Fix | Delete
var links, i, len,
[431] Fix | Delete
menu = document.querySelector( '.primary-menu-wrapper' );
[432] Fix | Delete
[433] Fix | Delete
if ( ! menu ) {
[434] Fix | Delete
return false;
[435] Fix | Delete
}
[436] Fix | Delete
[437] Fix | Delete
links = menu.getElementsByTagName( 'a' );
[438] Fix | Delete
[439] Fix | Delete
// Each time a menu link is focused or blurred, toggle focus.
[440] Fix | Delete
for ( i = 0, len = links.length; i < len; i++ ) {
[441] Fix | Delete
links[i].addEventListener( 'focus', toggleFocus, true );
[442] Fix | Delete
links[i].addEventListener( 'blur', toggleFocus, true );
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
//Sets or removes the .focus class on an element.
[446] Fix | Delete
function toggleFocus() {
[447] Fix | Delete
var self = this;
[448] Fix | Delete
[449] Fix | Delete
// Move up through the ancestors of the current link until we hit .primary-menu.
[450] Fix | Delete
while ( -1 === self.className.indexOf( 'primary-menu' ) ) {
[451] Fix | Delete
// On li elements toggle the class .focus.
[452] Fix | Delete
if ( 'li' === self.tagName.toLowerCase() ) {
[453] Fix | Delete
if ( -1 !== self.className.indexOf( 'focus' ) ) {
[454] Fix | Delete
self.className = self.className.replace( ' focus', '' );
[455] Fix | Delete
} else {
[456] Fix | Delete
self.className += ' focus';
[457] Fix | Delete
}
[458] Fix | Delete
}
[459] Fix | Delete
self = self.parentElement;
[460] Fix | Delete
}
[461] Fix | Delete
}
[462] Fix | Delete
}
[463] Fix | Delete
}; // twentytwenty.primaryMenu
[464] Fix | Delete
[465] Fix | Delete
/* -----------------------------------------------------------------------------------------------
[466] Fix | Delete
Toggles
[467] Fix | Delete
--------------------------------------------------------------------------------------------------- */
[468] Fix | Delete
[469] Fix | Delete
twentytwenty.toggles = {
[470] Fix | Delete
[471] Fix | Delete
clickedEl: false,
[472] Fix | Delete
[473] Fix | Delete
init: function() {
[474] Fix | Delete
// Do the toggle.
[475] Fix | Delete
this.toggle();
[476] Fix | Delete
[477] Fix | Delete
// Check for toggle/untoggle on resize.
[478] Fix | Delete
this.resizeCheck();
[479] Fix | Delete
[480] Fix | Delete
// Check for untoggle on escape key press.
[481] Fix | Delete
this.untoggleOnEscapeKeyPress();
[482] Fix | Delete
},
[483] Fix | Delete
[484] Fix | Delete
performToggle: function( element, instantly ) {
[485] Fix | Delete
var target, timeOutTime, classToToggle,
[486] Fix | Delete
self = this,
[487] Fix | Delete
_doc = document,
[488] Fix | Delete
// Get our targets.
[489] Fix | Delete
toggle = element,
[490] Fix | Delete
targetString = toggle.dataset.toggleTarget,
[491] Fix | Delete
activeClass = 'active';
[492] Fix | Delete
[493] Fix | Delete
// Elements to focus after modals are closed.
[494] Fix | Delete
if ( ! _doc.querySelectorAll( '.show-modal' ).length ) {
[495] Fix | Delete
self.clickedEl = _doc.activeElement;
[496] Fix | Delete
}
[497] Fix | Delete
[498] Fix | Delete
if ( targetString === 'next' ) {
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function