Cookies help us deliver our services. By using our services, you agree to our use of cookies. More information

We are currently changing the appearance of the wiki to a responsive theme to eliminate switching between desktop and mobile themes. Please report any issues on the Wiki Support page

 Actions

MediaWiki

Difference between revisions of "Monobook.js"

From Dragon Mania Legends Wiki

(To test JS button in non-active theme)
 
m (Test MW way of scrolling sections in monobook)
Line 2: Line 2:
  
 
mw.loader.load( '/index.php?title=MediaWiki:ScrollTop.js&action=raw&ctype=text/javascript' );
 
mw.loader.load( '/index.php?title=MediaWiki:ScrollTop.js&action=raw&ctype=text/javascript' );
 +
 +
<!-- Test MW way of doing this -->
 +
$( function () {
 +
var elems = document.getElementsByClassName('editsection'); // *** NOTE: ClassName may need to be 'mw-editsection' instead
 +
for (i = 0; i < elems.length; i++) {
 +
var span = document.createElement('span');
 +
var link = document.createElement('a');
 +
link.href = '#top';
 +
link.appendChild(document.createTextNode('back to top'));
 +
span.appendChild(document.createTextNode('['));
 +
span.appendChild(link);
 +
span.appendChild(document.createTextNode('] '));
 +
elems[i].insertBefore(span, elems[i].firstChild);
 +
}
 +
});

Revision as of 00:14, 14 July 2019

/* Any JavaScript here will be loaded for users using the MonoBook skin */

mw.loader.load( '/index.php?title=MediaWiki:ScrollTop.js&action=raw&ctype=text/javascript' );

<!-- Test MW way of doing this -->
$( function () {
	var elems = document.getElementsByClassName('editsection'); // *** NOTE: ClassName may need to be 'mw-editsection' instead
	for (i = 0; i < elems.length; i++) {
		var span = document.createElement('span');
		var link = document.createElement('a');
		link.href = '#top';
		link.appendChild(document.createTextNode('back to top'));
		span.appendChild(document.createTextNode('['));
		span.appendChild(link);
		span.appendChild(document.createTextNode('] '));
		elems[i].insertBefore(span, elems[i].firstChild);
	}
});