Diferencia entre revisiones de «MediaWiki:Common.js»
Apariencia
Sin resumen de edición |
Sin resumen de edición |
||
Línea 1: | Línea 1: | ||
$(document).ready(function() { | $(document).ready(function() { | ||
// | // Manejo del botón "ocultar" | ||
$('.mw-portlet h3').append(' <span class="toggle-sidebar">(ocultar)</span>'); | $('.mw-portlet h3').append(' <span class="toggle-sidebar">(ocultar)</span>'); | ||
$('.toggle-sidebar').click(function() { | $('.toggle-sidebar').click(function() { | ||
Línea 8: | Línea 7: | ||
}); | }); | ||
// | // Funcionalidad de expandir/cerrar subniveles | ||
$('.mw-portlet li:contains(":expand")').each(function() { | $('.mw-portlet li:contains(":expand")').each(function() { | ||
var $this = $(this); | var $this = $(this); | ||
$this.html('<span class="toggle">▼</span> ' + | var sectionTitle = $this.text().replace(':expand ', ''); | ||
$this | $this.html('<span class="toggle">▼</span> ' + sectionTitle); | ||
$(this | $this.click(function() { | ||
$(this).text( | $(this).nextAll('li').toggle(); | ||
var toggleSymbol = $(this).children('.toggle'); | |||
toggleSymbol.text(toggleSymbol.text() === '▼' ? '▶' : '▼'); | |||
}); | }); | ||
}); | }); | ||
// Ocultar subniveles al inicio | // Ocultar subniveles al inicio | ||
$('.mw-portlet li:contains(":expand")').nextAll().hide(); | $('.mw-portlet li:contains(":expand")').nextAll('li').hide(); | ||
}); | }); |
Revisión del 01:30 6 mar 2025
$(document).ready(function() { // Manejo del botón "ocultar" $('.mw-portlet h3').append(' <span class="toggle-sidebar">(ocultar)</span>'); $('.toggle-sidebar').click(function() { $(this).parent().next('div').toggle(); $(this).text($(this).text() === '(ocultar)' ? '(mostrar)' : '(ocultar)'); }); // Funcionalidad de expandir/cerrar subniveles $('.mw-portlet li:contains(":expand")').each(function() { var $this = $(this); var sectionTitle = $this.text().replace(':expand ', ''); $this.html('<span class="toggle">▼</span> ' + sectionTitle); $this.click(function() { $(this).nextAll('li').toggle(); var toggleSymbol = $(this).children('.toggle'); toggleSymbol.text(toggleSymbol.text() === '▼' ? '▶' : '▼'); }); }); // Ocultar subniveles al inicio $('.mw-portlet li:contains(":expand")').nextAll('li').hide(); });