Diferencia entre revisiones de «MediaWiki:Common.js»
Apariencia
Sin resumen de edición |
Sin resumen de edición |
||
Línea 1: | Línea 1: | ||
/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */ | /* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */ | ||
$(document).ready(function() { | $(document).ready(function() { | ||
// | // Ocultar/Mostrar sidebar | ||
$('.mw-portlet h3').click(function() { | $('.mw-portlet h3').append(' <span class="toggle-sidebar">(ocultar)</span>'); | ||
$(this).next('div').toggle(); | $('.toggle-sidebar').click(function() { | ||
$(this).parent().next('div').toggle(); | |||
$(this).text($(this).text() === '(ocultar)' ? '(mostrar)' : '(ocultar)'); | |||
}); | }); | ||
// | // Agregar funcionalidad de expandir/colapsar | ||
$('.mw-portlet li:contains(":expand")').each(function() { | $('.mw-portlet li:contains(":expand")').each(function() { | ||
$(this).html('<span class="toggle">▼</span> ' + $ | var $this = $(this); | ||
$( | $this.html('<span class="toggle">▼</span> ' + $this.html().replace(':expand ', '')); | ||
$(this). | $this.children('.toggle').click(function() { | ||
$(this).parent().nextAll().toggle(); | |||
$(this).text($(this).text() === '▼' ? '▶' : '▼'); | |||
}); | }); | ||
}); | }); | ||
// Ocultar subniveles al inicio | |||
$('.mw-portlet li:contains(":expand")').nextAll().hide(); | |||
}); | }); |
Revisión del 01:28 6 mar 2025
/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */ $(document).ready(function() { // Ocultar/Mostrar sidebar $('.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)'); }); // Agregar funcionalidad de expandir/colapsar $('.mw-portlet li:contains(":expand")').each(function() { var $this = $(this); $this.html('<span class="toggle">▼</span> ' + $this.html().replace(':expand ', '')); $this.children('.toggle').click(function() { $(this).parent().nextAll().toggle(); $(this).text($(this).text() === '▼' ? '▶' : '▼'); }); }); // Ocultar subniveles al inicio $('.mw-portlet li:contains(":expand")').nextAll().hide(); });