Diff
checker
Text
Text
Images
Documents
Excel
Folders
Legal
Enterprise
Desktop
Pricing
Sign in
Download Diffchecker Desktop
Compare text
Find the difference between two text files
Tools
History
Real-time editor
Hide unchanged lines
Disable line wrap
Layout
Split
Unified
Diff precision
Smart
Word
Char
Syntax highlighting
Choose syntax
Ignore
Transform text
Go to first change
Edit input
Diffchecker Desktop
The most secure way to run Diffchecker. Get the Diffchecker Desktop app: your diffs never leave your computer!
Get Desktop
_s Navigation dropdowns macOS Safari fix
Created
4 years ago
Diff never expires
Clear
Export
Share
Explain
0 removals
Lines
Total
Removed
Characters
Total
Removed
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
100 lines
Copy
6 additions
Lines
Total
Added
Characters
Total
Added
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
102 lines
Copy
/**
/**
* File navigation.js.
* File navigation.js.
*
*
* Handles toggling the navigation menu for small screens and enables TAB key
* Handles toggling the navigation menu for small screens and enables TAB key
* navigation support for dropdown menus.
* navigation support for dropdown menus.
*/
*/
( function() {
( function() {
const siteNavigation = document.getElementById( 'site-navigation' );
const siteNavigation = document.getElementById( 'site-navigation' );
// Return early if the navigation doesn't exist.
// Return early if the navigation doesn't exist.
if ( ! siteNavigation ) {
if ( ! siteNavigation ) {
return;
return;
}
}
const button = siteNavigation.getElementsByTagName( 'button' )[ 0 ];
const button = siteNavigation.getElementsByTagName( 'button' )[ 0 ];
// Return early if the button doesn't exist.
// Return early if the button doesn't exist.
if ( 'undefined' === typeof button ) {
if ( 'undefined' === typeof button ) {
return;
return;
}
}
const menu = siteNavigation.getElementsByTagName( 'ul' )[ 0 ];
const menu = siteNavigation.getElementsByTagName( 'ul' )[ 0 ];
// Hide menu toggle button if menu is empty and return early.
// Hide menu toggle button if menu is empty and return early.
if ( 'undefined' === typeof menu ) {
if ( 'undefined' === typeof menu ) {
button.style.display = 'none';
button.style.display = 'none';
return;
return;
}
}
if ( ! menu.classList.contains( 'nav-menu' ) ) {
if ( ! menu.classList.contains( 'nav-menu' ) ) {
menu.classList.add( 'nav-menu' );
menu.classList.add( 'nav-menu' );
}
}
// Toggle the .toggled class and the aria-expanded value each time the button is clicked.
// Toggle the .toggled class and the aria-expanded value each time the button is clicked.
button.addEventListener( 'click', function() {
button.addEventListener( 'click', function() {
siteNavigation.classList.toggle( 'toggled' );
siteNavigation.classList.toggle( 'toggled' );
if ( button.getAttribute( 'aria-expanded' ) === 'true' ) {
if ( button.getAttribute( 'aria-expanded' ) === 'true' ) {
button.setAttribute( 'aria-expanded', 'false' );
button.setAttribute( 'aria-expanded', 'false' );
} else {
} else {
button.setAttribute( 'aria-expanded', 'true' );
button.setAttribute( 'aria-expanded', 'true' );
}
}
} );
} );
// Remove the .toggled class and set aria-expanded to false when the user clicks outside the navigation.
// Remove the .toggled class and set aria-expanded to false when the user clicks outside the navigation.
document.addEventListener( 'click', function( event ) {
document.addEventListener( 'click', function( event ) {
const isClickInside = siteNavigation.contains( event.target );
const isClickInside = siteNavigation.contains( event.target );
if ( ! isClickInside ) {
if ( ! isClickInside ) {
siteNavigation.classList.remove( 'toggled' );
siteNavigation.classList.remove( 'toggled' );
button.setAttribute( 'aria-expanded', 'false' );
button.setAttribute( 'aria-expanded', 'false' );
}
}
} );
} );
// Get all the link elements within the menu.
// Get all the link elements within the menu.
const links = menu.getElementsByTagName( 'a' );
const links = menu.getElementsByTagName( 'a' );
// Get all the link elements with children within the menu.
// Get all the link elements with children within the menu.
const linksWithChildren = menu.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
const linksWithChildren = menu.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
// Toggle focus each time a menu link is focused or blurred.
// Toggle focus each time a menu link is focused or blurred.
for ( const link of links ) {
for ( const link of links ) {
Copy
Copied
Copy
Copied
link.addEventListener( 'focus', toggleFocus, true );
// Disabled to fix submenus on iOS/Android
link.addEventListener( 'blur', toggleFocus, true );
//
link.addEventListener( 'focus', toggleFocus, true );
//
link.addEventListener( 'blur', toggleFocus, true );
}
}
// Toggle focus each time a menu link with children receive a touch event.
// Toggle focus each time a menu link with children receive a touch event.
for ( const link of linksWithChildren ) {
for ( const link of linksWithChildren ) {
link.addEventListener( 'touchstart', toggleFocus, false );
link.addEventListener( 'touchstart', toggleFocus, false );
Copy
Copied
Copy
Copied
link.addEventListener( 'click', toggleFocus, true ); // macOS Safari fix
}
}
/**
/**
* Sets or removes .focus class on an element.
* Sets or removes .focus class on an element.
*/
*/
function toggleFocus() {
function toggleFocus() {
if ( event.type === 'focus' || event.type === 'blur' ) {
if ( event.type === 'focus' || event.type === 'blur' ) {
let self = this;
let self = this;
// Move up through the ancestors of the current link until we hit .nav-menu.
// Move up through the ancestors of the current link until we hit .nav-menu.
while ( ! self.classList.contains( 'nav-menu' ) ) {
while ( ! self.classList.contains( 'nav-menu' ) ) {
// On li elements toggle the class .focus.
// On li elements toggle the class .focus.
if ( 'li' === self.tagName.toLowerCase() ) {
if ( 'li' === self.tagName.toLowerCase() ) {
self.classList.toggle( 'focus' );
self.classList.toggle( 'focus' );
}
}
self = self.parentNode;
self = self.parentNode;
}
}
}
}
Copy
Copied
Copy
Copied
if ( event.type ===
'touchstart' ) {
if ( event.type ===
'click' || event.type ===
'touchstart' ) {
// macOS Safari fix
const menuItem = this.parentNode;
const menuItem = this.parentNode;
event.preventDefault();
event.preventDefault();
for ( const link of menuItem.parentNode.children ) {
for ( const link of menuItem.parentNode.children ) {
if ( menuItem !== link ) {
if ( menuItem !== link ) {
link.classList.remove( 'focus' );
link.classList.remove( 'focus' );
}
}
}
}
menuItem.classList.toggle( 'focus' );
menuItem.classList.toggle( 'focus' );
}
}
}
}
}() );
}() );
Saved diffs
Original text
Open file
/** * File navigation.js. * * Handles toggling the navigation menu for small screens and enables TAB key * navigation support for dropdown menus. */ ( function() { const siteNavigation = document.getElementById( 'site-navigation' ); // Return early if the navigation doesn't exist. if ( ! siteNavigation ) { return; } const button = siteNavigation.getElementsByTagName( 'button' )[ 0 ]; // Return early if the button doesn't exist. if ( 'undefined' === typeof button ) { return; } const menu = siteNavigation.getElementsByTagName( 'ul' )[ 0 ]; // Hide menu toggle button if menu is empty and return early. if ( 'undefined' === typeof menu ) { button.style.display = 'none'; return; } if ( ! menu.classList.contains( 'nav-menu' ) ) { menu.classList.add( 'nav-menu' ); } // Toggle the .toggled class and the aria-expanded value each time the button is clicked. button.addEventListener( 'click', function() { siteNavigation.classList.toggle( 'toggled' ); if ( button.getAttribute( 'aria-expanded' ) === 'true' ) { button.setAttribute( 'aria-expanded', 'false' ); } else { button.setAttribute( 'aria-expanded', 'true' ); } } ); // Remove the .toggled class and set aria-expanded to false when the user clicks outside the navigation. document.addEventListener( 'click', function( event ) { const isClickInside = siteNavigation.contains( event.target ); if ( ! isClickInside ) { siteNavigation.classList.remove( 'toggled' ); button.setAttribute( 'aria-expanded', 'false' ); } } ); // Get all the link elements within the menu. const links = menu.getElementsByTagName( 'a' ); // Get all the link elements with children within the menu. const linksWithChildren = menu.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' ); // Toggle focus each time a menu link is focused or blurred. for ( const link of links ) { link.addEventListener( 'focus', toggleFocus, true ); link.addEventListener( 'blur', toggleFocus, true ); } // Toggle focus each time a menu link with children receive a touch event. for ( const link of linksWithChildren ) { link.addEventListener( 'touchstart', toggleFocus, false ); } /** * Sets or removes .focus class on an element. */ function toggleFocus() { if ( event.type === 'focus' || event.type === 'blur' ) { let self = this; // Move up through the ancestors of the current link until we hit .nav-menu. while ( ! self.classList.contains( 'nav-menu' ) ) { // On li elements toggle the class .focus. if ( 'li' === self.tagName.toLowerCase() ) { self.classList.toggle( 'focus' ); } self = self.parentNode; } } if ( event.type === 'touchstart' ) { const menuItem = this.parentNode; event.preventDefault(); for ( const link of menuItem.parentNode.children ) { if ( menuItem !== link ) { link.classList.remove( 'focus' ); } } menuItem.classList.toggle( 'focus' ); } } }() );
Changed text
Open file
/** * File navigation.js. * * Handles toggling the navigation menu for small screens and enables TAB key * navigation support for dropdown menus. */ ( function() { const siteNavigation = document.getElementById( 'site-navigation' ); // Return early if the navigation doesn't exist. if ( ! siteNavigation ) { return; } const button = siteNavigation.getElementsByTagName( 'button' )[ 0 ]; // Return early if the button doesn't exist. if ( 'undefined' === typeof button ) { return; } const menu = siteNavigation.getElementsByTagName( 'ul' )[ 0 ]; // Hide menu toggle button if menu is empty and return early. if ( 'undefined' === typeof menu ) { button.style.display = 'none'; return; } if ( ! menu.classList.contains( 'nav-menu' ) ) { menu.classList.add( 'nav-menu' ); } // Toggle the .toggled class and the aria-expanded value each time the button is clicked. button.addEventListener( 'click', function() { siteNavigation.classList.toggle( 'toggled' ); if ( button.getAttribute( 'aria-expanded' ) === 'true' ) { button.setAttribute( 'aria-expanded', 'false' ); } else { button.setAttribute( 'aria-expanded', 'true' ); } } ); // Remove the .toggled class and set aria-expanded to false when the user clicks outside the navigation. document.addEventListener( 'click', function( event ) { const isClickInside = siteNavigation.contains( event.target ); if ( ! isClickInside ) { siteNavigation.classList.remove( 'toggled' ); button.setAttribute( 'aria-expanded', 'false' ); } } ); // Get all the link elements within the menu. const links = menu.getElementsByTagName( 'a' ); // Get all the link elements with children within the menu. const linksWithChildren = menu.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' ); // Toggle focus each time a menu link is focused or blurred. for ( const link of links ) { // Disabled to fix submenus on iOS/Android //link.addEventListener( 'focus', toggleFocus, true ); //link.addEventListener( 'blur', toggleFocus, true ); } // Toggle focus each time a menu link with children receive a touch event. for ( const link of linksWithChildren ) { link.addEventListener( 'touchstart', toggleFocus, false ); link.addEventListener( 'click', toggleFocus, true ); // macOS Safari fix } /** * Sets or removes .focus class on an element. */ function toggleFocus() { if ( event.type === 'focus' || event.type === 'blur' ) { let self = this; // Move up through the ancestors of the current link until we hit .nav-menu. while ( ! self.classList.contains( 'nav-menu' ) ) { // On li elements toggle the class .focus. if ( 'li' === self.tagName.toLowerCase() ) { self.classList.toggle( 'focus' ); } self = self.parentNode; } } if ( event.type === 'click' || event.type === 'touchstart' ) { // macOS Safari fix const menuItem = this.parentNode; event.preventDefault(); for ( const link of menuItem.parentNode.children ) { if ( menuItem !== link ) { link.classList.remove( 'focus' ); } } menuItem.classList.toggle( 'focus' ); } } }() );
Find difference