Diff
checker
Texto
Texto
Imágenes
Documentos
Excel
Carpetas
Legal
Enterprise
Aplicación de escritorio
Precios
Iniciar sesión
Descargar Diffchecker Desktop
Comparar texto
Encuentra la diferencia entre dos archivos de texto
Herramientas
Historial
Editor live
Ocultar sin cambios
Sin ajuste de línea
Vista
Dividido
Unificado
Nivel de detalle
Inteligente
Palabra
Letra
Resaltado de sintaxis
Elegir sintaxis
Ignorar
Transformar texto
Ir al primer cambio
Editar entrada
Diffchecker Desktop
La forma más segura de usar Diffchecker. ¡Obtén la app de Diffchecker Desktop: tus diffs nunca salen de tu computadora!
Obtener Desktop
_s Navigation dropdowns macOS Safari fix
Creado
hace 4 años
El diff nunca expira
Borrar
Exportar
Compartir
Explicar
0 eliminaciones
Líneas
Total
Eliminado
Caracteres
Total
Eliminado
Para continuar usando esta función, actualice a
Diff
checker
Pro
Ver precios
100 líneas
Copiar todo
6 adiciones
Líneas
Total
Añadido
Caracteres
Total
Añadido
Para continuar usando esta función, actualice a
Diff
checker
Pro
Ver precios
102 líneas
Copiar todo
/**
/**
* 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 ) {
Copiar
Copiado
Copiar
Copiado
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 );
Copiar
Copiado
Copiar
Copiado
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;
}
}
}
}
Copiar
Copiado
Copiar
Copiado
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' );
}
}
}
}
}() );
}() );
Diferencias guardadas
Texto original
Abrir archivo
/** * 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' ); } } }() );
Texto modificado
Abrir archivo
/** * 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' ); } } }() );
Encontrar la diferencia