MediaWiki:Common.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
sblocco |
v. https://it.wikiquote.org/wiki/Wikiquote:Bar/Archivio_2023-01--05#Template:Int,_parametro_h Etichetta: Annullato |
||
Riga 97: | Riga 97: | ||
$( document ).ready( headersClass ); |
$( document ).ready( headersClass ); |
||
/** |
|||
* Mobile collapsible fixed. |
|||
* This snippet fixes headings with links. |
|||
* So, the first time you click on the heading, it does not visit the link, |
|||
* but it opens the collapsible instead. |
|||
* @author [[User:Valerio_Bozzolan]] |
|||
* @licese CC BY-SA 4.0 or GNU GPL v2+ at your opinion. |
|||
*/ |
|||
$(function() { |
|||
// Match links from mobile headings |
|||
$('h2.collapsible-heading a').click(function(e) { |
|||
// Do not visit the link if the block is closed. |
|||
// Since the user may just want to open the collapsible. |
|||
var $linkInHeading = $(this); |
|||
var $heading = $linkInHeading.closest( 'h1,h2' ); |
|||
if( !$heading.hasClass('open-block') ) { |
|||
// Don't visit the link |
|||
e.preventDefault(); |
|||
// Open the collapsible instead. |
|||
$heading.click(); |
|||
} |
|||
}); |
|||
}); |
|||
// Altro in MediaWiki:Gadget-site.js! |
// Altro in MediaWiki:Gadget-site.js! |
||
Versione delle 10:16, 14 gen 2024
/* Il codice JavaScript inserito qui viene caricato da ciascuna pagina, per tutti gli utenti */
// Codice JavaScript: inizio...
/* Modifica il testo della linguetta "Voce" in "Pagina principale"
* e aggiunge il link all'elenco completo di tutte le lingue
*
* Ultimo controllo al codice: 12/12/2013 */
if ( mw.config.get( 'wgIsMainPage' ) || mw.config.get( 'wgPageName' ) === 'Discussione:Pagina_principale' ) {
$( document ).ready( function() {
if ( mw.config.get( 'wgUserLanguage' ) === 'it' )
$( '#ca-nstab-main a' ).text( 'Pagina principale' );
mw.loader.using(['mediawiki.util']).then(function() {
mw.util.addPortletLink( 'p-lang', '//meta.wikimedia.org/wiki/Wikiquote/it#Lista_delle_Wikiquote',
'Elenco completo', 'interwiki-completelist', 'Elenco completo delle Wikiquote' );
} );
} );
};
/* Change Special:Search to use a drop-down menu
*
* Description: Change Special:Search to use a drop-down menu,
* with the default being the internal MediaWiki engine
*
* Created and maintained by: [[w:en:User:Gracenotes]]
*
* Ultimo controllo al codice: 20/02/2014 */
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' )
$( function() {
var searchEngines = [];
var createOption = function( site, action, mainQ, addQ, addV ) {
var opt = document.createElement( 'option' );
opt.appendChild( document.createTextNode( site ) );
searchEngines[searchEngines.length] = [action, mainQ, addQ, addV];
return opt;
};
var searchForm = document.forms['powersearch'] || document.forms['search'];
var searchBox = searchForm.lsearchbox || searchForm.search;
var selectBox = document.createElement( 'select' );
selectBox.id = 'searchEngine';
searchForm.onsubmit = function() {
var optSelected = searchEngines[document.getElementById( 'searchEngine' ).selectedIndex];
searchForm.action = optSelected[0];
searchBox.name = optSelected[1];
searchForm.title.value = optSelected[3];
searchForm.title.name = optSelected[2];
};
selectBox.appendChild( createOption( 'MediaWiki', mw.config.get( 'wgScriptPath' ) + '/index.php', 'search', 'title', 'Special:Search' ) );
selectBox.appendChild( createOption( 'Google', '//www.google.com/search', 'q', 'sitesearch', 'it.wikiquote.org') );
selectBox.appendChild( createOption( 'Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'it.wikiquote.org') );
selectBox.appendChild( createOption( 'Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:it.wikiquote.org' ) );
searchBox.style.marginLeft = '0px';
// 'searchText' is the firt search text. 'powerSearchText' is the second, used only if the first is not existent (e.g.: not yet done any search)
buttonSearch = document.getElementById( 'searchText' ) || document.getElementById( 'powerSearchText' );
buttonSearch.parentNode.insertBefore( selectBox, buttonSearch.nextSibling );
} );
/* Test if an element has a certain class
*
* Description: Uses regular expressions and caching for better performance.
* Maintainers: [[wikt:en:User:Mike Dillon]], [[w:en:User:R. Koot]], [[w:en:User:SG]]
*
* Ultimo controllo al codice: 12/12/2013 */
// DEPRECATO; sostituito con $( element ).hasClass( className )
var hasClass = function( element, className ) {
return $( element ).hasClass( className );
};
/* Simula i titoli delle sezioni senza indicizzazione e senza link di modifica
*
* Per garantire l'accessibilità anche agli utenti che non utilizzano JavaScript
* nel [[Mediawiki:Common.css]] vengono definite le classi: nojs-h1... h2/h3/h4/h5/h6,
* che qui vengono rimosse.
*
* Vedi: [[Template:Titolo sezione]]
* Creato da: [[q:it:User:FRacco]]
*
* Ultimo controllo al codice: 12/12/2013 */
var headersClass = $( function() {
for ( j = 1; j <= 6; j++ ) {
$( ".h" + j ).removeClass( "nojs-h" + j ).html( function( undefined, text ) {
return "<h" + j + ">" + text + "</h" + j + ">";
} );
};
} );
$( document ).ready( headersClass );
/**
* Mobile collapsible fixed.
* This snippet fixes headings with links.
* So, the first time you click on the heading, it does not visit the link,
* but it opens the collapsible instead.
* @author [[User:Valerio_Bozzolan]]
* @licese CC BY-SA 4.0 or GNU GPL v2+ at your opinion.
*/
$(function() {
// Match links from mobile headings
$('h2.collapsible-heading a').click(function(e) {
// Do not visit the link if the block is closed.
// Since the user may just want to open the collapsible.
var $linkInHeading = $(this);
var $heading = $linkInHeading.closest( 'h1,h2' );
if( !$heading.hasClass('open-block') ) {
// Don't visit the link
e.preventDefault();
// Open the collapsible instead.
$heading.click();
}
});
});
// Altro in MediaWiki:Gadget-site.js!
// Codice JavaScript: ...fine