Diferencia entre revisiones de «MediaWiki:Common.js»
De 15Mpedia
(siempre colapsadas) |
(cuando visitas el wiki como anónimo, las navbox no se colapsan siempre aparecen desplegadas, a ver si este nuevo código funciona) |
||
Línea 45: | Línea 45: | ||
} | } | ||
− | /** | + | /** |
− | + | * Collapsible tables; reimplemented with mw-collapsible | |
− | + | * Styling is also in place to avoid FOUC | |
− | + | * | |
− | + | * Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]]. | |
− | + | * @version 3.0.0 (2018-05-20) | |
− | + | * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js | |
− | + | * @author [[User:R. Koot]] | |
− | + | * @author [[User:Krinkle]] | |
− | + | * @author [[User:TheDJ]] | |
− | + | * @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which | |
− | + | * is supported in MediaWiki core. Shimmable since MediaWiki 1.32 | |
− | + | * | |
− | + | * @param {jQuery} $content | |
− | + | */ | |
− | + | function makeCollapsibleMwCollapsible( $content ) { | |
− | + | var $tables = $content | |
− | + | .find( 'table.collapsible:not(.mw-collapsible)' ) | |
− | + | .addClass( 'mw-collapsible' ); | |
− | + | ||
− | + | $.each( $tables, function ( index, table ) { | |
− | + | // mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.'); | |
− | + | if ( $( table ).hasClass( 'collapsed' ) ) { | |
− | + | $( table ).addClass( 'mw-collapsed' ); | |
− | + | // mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.'); | |
− | + | } | |
− | + | } ); | |
− | + | if ( $tables.length > 0 ) { | |
− | + | mw.loader.using( 'jquery.makeCollapsible' ).then( function () { | |
− | + | $tables.makeCollapsible(); | |
− | + | } ); | |
− | + | } | |
− | + | } | |
− | + | mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible ); | |
− | }; | + | |
− | + | /** | |
− | + | * Add support to mw-collapsible for autocollapse, innercollapse and outercollapse | |
− | + | * | |
− | + | * Maintainers: TheDJ | |
− | + | */ | |
− | + | function mwCollapsibleSetup( $collapsibleContent ) { | |
− | + | var $element, | |
− | + | $toggle, | |
− | + | autoCollapseThreshold = 2; | |
− | + | $.each( $collapsibleContent, function ( index, element ) { | |
− | + | $element = $( element ); | |
− | + | if ( $element.hasClass( 'collapsible' ) ) { | |
− | + | $element.find( 'tr:first > th:first' ).prepend( $element.find( 'tr:first > * > .mw-collapsible-toggle' ) ); | |
− | + | } | |
− | + | if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) { | |
− | + | $element.data( 'mw-collapsible' ).collapse(); | |
− | + | } else if ( $element.hasClass( 'innercollapse' ) ) { | |
− | + | if ( $element.parents( '.outercollapse' ).length > 0 ) { | |
− | + | $element.data( 'mw-collapsible' ).collapse(); | |
− | + | } | |
− | + | } | |
− | + | // because of colored backgrounds, style the link in the text color | |
− | + | // to ensure accessible contrast | |
− | + | $toggle = $element.find( '.mw-collapsible-toggle' ); | |
− | + | if ( $toggle.length ) { | |
− | + | // Make the toggle inherit text color (Updated for T333357 2023-04-29) | |
− | + | if ( $toggle.parent()[ 0 ].style.color ) { | |
− | + | $toggle.css( 'color', 'inherit' ); | |
− | + | $toggle.find( '.mw-collapsible-text' ).css( 'color', 'inherit' ); | |
− | + | } | |
− | + | } | |
− | + | } ); | |
− | + | } | |
− | + | ||
− | + | mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup ); | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Revisión de 18:23 25 jul 2023
/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */ // oculta categorías en español en páginas de otros idiomas /*if ( mw.config.get( 'wgNamespaceNumber') === 0 && mw.config.get( 'wgPageName' ).indexOf('/') === (mw.config.get( 'wgPageName' ).length - 3) ) { document.getElementById('catlinks').style.display = "none"; }*/ //buscador document.getElementById('p-search').style.width = '400px'; document.getElementById('searchform').style.width = '400px'; document.getElementById('simpleSearch').style.width = '400px'; document.getElementById('searchInput').style.width = '400px'; document.getElementById('searchInput').style.fontWeight = 'bold'; document.getElementById('searchInput').style.fontSize = '95%'; document.getElementById('simpleSearch').style.border = '2px solid #347BFF'; document.getElementById('searchInput').focus(); // negritas en pestaña [editar] if (document.getElementById('ca-form_edit')) { document.getElementById('ca-form_edit').getElementsByTagName('a')[0].text = 'Modificar'; document.getElementById('ca-form_edit').style.fontWeight = 'bold'; document.getElementById('ca-edit').getElementsByTagName('a')[0].text = 'Código fuente'; } else { document.getElementById('ca-edit').getElementsByTagName('a')[0].text = 'Modificar'; document.getElementById('ca-edit').style.fontWeight = 'bold'; } var editsections = document.getElementsByClassName("editsection"); [].forEach.call(editsections, function (editsection) { editsection.getElementsByTagName('a')[0].text = 'modificar' }); // iconos de compartir en FB, TW, etc document.getElementById('firstHeading').innerHTML = '<div><span style="float: right;"><a href="https://www.facebook.com/sharer/sharer.php?u='+document.URL+'" title="Compartir esta página en Facebook"><img alt="Facebook.png" src="/w/images/5/55/Facebook.png" width="15" height="15" /></a> <a href="https://twitter.com/intent/tweet?text=Estoy+leyendo+'+encodeURIComponent(document.URL)+'+en+%4015Mpedia" title="Compartir esta página en Twitter"><img alt="Twitter.png" src="/w/images/f/f7/Twitter.png" width="15" height="19" /></a></span></div>' + document.getElementById('firstHeading').innerHTML; //document.getElementById('firstHeading').innerHTML = '<div><span style="float: right;"><a href="https://www.facebook.com/sharer/sharer.php?u='+document.URL+'" title="Compartir esta página en Facebook"><img alt="Facebook.png" src="/w/images/5/55/Facebook.png" width="15" height="15" /></a> <a href="https://twitter.com/home?status=Estoy+leyendo+'+encodeURIComponent(document.URL)+'+en+%4015Mpedia" title="Compartir esta página en Twitter"><img alt="Twitter.png" src="/w/images/f/f7/Twitter.png" width="15" height="19" /></a> <a href="https://identi.ca/notice/new?status_textarea=Estoy+leyendo+'+encodeURIComponent(document.URL)+'+en+15Mpedia" title="Compartir esta página en Identi.ca"><img alt="Identica.png" src="/w/images/9/9e/Identica.png" width="15" height="15" /></a></span></div>' + document.getElementById('firstHeading').innerHTML; // ocultar h1 de headertabs en TOC var liobjs = document.getElementsByTagName('li'); for (var i = 0; i < liobjs.length; i++) { if (liobjs.item(i).className == 'toclevel-1' && liobjs.item(i).innerHTML.indexOf('<span></span>') != -1) { liobjs.item(i).style.display = 'none'; } } // ocultar thumb en archivos embebidos if ( mw.config.get( 'wgNamespaceNumber' ) == 6 && mw.config.get( 'wgCategories' ).indexOf('Archivos embebidos') > -1 ) { document.getElementById('file').style.display = 'none'; //no funciona //document.getElementsByTagName('fullMedia').style.display = 'none'; } /** * Collapsible tables; reimplemented with mw-collapsible * Styling is also in place to avoid FOUC * * Allows tables to be collapsed, showing only the header. See [[Help:Collapsing]]. * @version 3.0.0 (2018-05-20) * @source https://www.mediawiki.org/wiki/MediaWiki:Gadget-collapsibleTables.js * @author [[User:R. Koot]] * @author [[User:Krinkle]] * @author [[User:TheDJ]] * @deprecated Since MediaWiki 1.20: Use class="mw-collapsible" instead which * is supported in MediaWiki core. Shimmable since MediaWiki 1.32 * * @param {jQuery} $content */ function makeCollapsibleMwCollapsible( $content ) { var $tables = $content .find( 'table.collapsible:not(.mw-collapsible)' ) .addClass( 'mw-collapsible' ); $.each( $tables, function ( index, table ) { // mw.log.warn( 'This page is using the deprecated class collapsible. Please replace it with mw-collapsible.'); if ( $( table ).hasClass( 'collapsed' ) ) { $( table ).addClass( 'mw-collapsed' ); // mw.log.warn( 'This page is using the deprecated class collapsed. Please replace it with mw-collapsed.'); } } ); if ( $tables.length > 0 ) { mw.loader.using( 'jquery.makeCollapsible' ).then( function () { $tables.makeCollapsible(); } ); } } mw.hook( 'wikipage.content' ).add( makeCollapsibleMwCollapsible ); /** * Add support to mw-collapsible for autocollapse, innercollapse and outercollapse * * Maintainers: TheDJ */ function mwCollapsibleSetup( $collapsibleContent ) { var $element, $toggle, autoCollapseThreshold = 2; $.each( $collapsibleContent, function ( index, element ) { $element = $( element ); if ( $element.hasClass( 'collapsible' ) ) { $element.find( 'tr:first > th:first' ).prepend( $element.find( 'tr:first > * > .mw-collapsible-toggle' ) ); } if ( $collapsibleContent.length >= autoCollapseThreshold && $element.hasClass( 'autocollapse' ) ) { $element.data( 'mw-collapsible' ).collapse(); } else if ( $element.hasClass( 'innercollapse' ) ) { if ( $element.parents( '.outercollapse' ).length > 0 ) { $element.data( 'mw-collapsible' ).collapse(); } } // because of colored backgrounds, style the link in the text color // to ensure accessible contrast $toggle = $element.find( '.mw-collapsible-toggle' ); if ( $toggle.length ) { // Make the toggle inherit text color (Updated for T333357 2023-04-29) if ( $toggle.parent()[ 0 ].style.color ) { $toggle.css( 'color', 'inherit' ); $toggle.find( '.mw-collapsible-text' ).css( 'color', 'inherit' ); } } } ); } mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup );