User:Gokudera ElPsyCongroo.reading.desktop/vector-2022.js: Difference between revisions
Appearance
Content deleted Content added
←Created page with 'importScript('User:Anomie/linkclassifier.js'); // Open image links in a new tab (disable Media Viewer to use it) $('a.image').attr('target', '_blank') →{{Projet:JavaScript/Script|FlecheHaut}}: →* Ajoute à chaque titre de section un lien de retour en haut de page * Auteur : Marc Mongenet * Mise à jour mediawiki 1.19 : Lgd * Dernière révision : 25 septembre 2018: mw.loader.using( 'user', function () { $( function ( $ ) { 'use...' |
No edit summary |
||
Line 1: | Line 1: | ||
importScript('User:Anomie/linkclassifier.js'); |
importScript('User:Anomie/linkclassifier.js'); |
||
// <nowiki> |
|||
// Open image links in a new tab (disable Media Viewer to use it) |
// Open image links in a new tab (disable Media Viewer to use it) |
||
$('a.image').attr('target', '_blank') |
$('a.image').attr('target', '_blank') |
||
Line 51: | Line 51: | ||
} ); |
} ); |
||
} ); |
} ); |
||
// </nowiki> |
Revision as of 13:58, 20 May 2023
importScript('User:Anomie/linkclassifier.js');
// <nowiki>
// Open image links in a new tab (disable Media Viewer to use it)
$('a.image').attr('target', '_blank')
/* {{Projet:JavaScript/Script|FlecheHaut}} */
/*
* Ajoute à chaque titre de section un lien de retour en haut de page
* Auteur : Marc Mongenet
* Mise à jour mediawiki 1.19 : Lgd
* Dernière révision : 25 septembre 2018
*/
mw.loader.using( 'user', function () {
$( function ( $ ) {
'use strict';
var options = {
text: '↑',
title: 'Haut de page',
animate: false,
animate_duration: 1000,
};
if ( typeof FlecheHaut_options !== 'undefined' ) {
$.extend( options, FlecheHaut_options );
}
var callback = function ( e ) {
e.preventDefault();
if ( options.animate ) {
// c'est bien sur les deux éléments, refs https://stackoverflow.com/a/5580397
$( 'html, body' ).animate( { scrollTop: 0 }, options.animate_duration );
} else {
window.scrollTo( 0, 0 );
}
};
var $lien = $( '<a href="#" class="noprint">' )
.text( options.text)
.attr( 'title', options.title)
.css( {
'margin-left': '0.3em',
'user-select': 'none' // jQuery se charge d'ajouter un vendor prefix si nécessaire
} )
.click( callback );
$( '#mw-content-text' ).find( 'h2, h3, h4, h5, h6' ).append( $lien );
} );
} );
// </nowiki>