MediaWiki:Mobile.js: Difference between revisions

From Seeds of the Word, the encyclopedia of the influence of the Gospel on culture
Content deleted Content added
No edit summary
Tags: Mobile edit Mobile web edit
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Any JavaScript here will be loaded for users using the mobile site */
/* Any JavaScript here will be loaded for users using the mobile site */

mw.loader.load( '/w/index.php?title=MediaWiki:BibleGet.js&action=raw&ctype=text/javascript' );
console.log('Running from Mobile.js');
mw.hook('wikipage.content').add(function() {
console.log('Hello World from Mobile.js');
});
// Commenting out the following line since it should be taken care of by Global.js
//mw.loader.load( '/w/index.php?title=MediaWiki:BibleGet.js&action=raw&ctype=text/javascript' );
//mw.loader.using('mobile.site.styles');
//mw.loader.using('mobile.site.styles');
// MakeMobileCollapsible, enables collapsible templates/infoboxes on the mobile site.
// MakeMobileCollapsible, enables collapsible templates/infoboxes on the mobile site.
Line 6: Line 12:
// This is a spinoff from Factotum. (https://en.wikipedia.org/wiki/User:Alexis_Jazz/Factotum)
// This is a spinoff from Factotum. (https://en.wikipedia.org/wiki/User:Alexis_Jazz/Factotum)
// MakeMobileCollapsible is public domain, irrevocably released as WTFPL Version 2[www.wtfpl.net/about/] by its author, Alexis Jazz.
// MakeMobileCollapsible is public domain, irrevocably released as WTFPL Version 2[www.wtfpl.net/about/] by its author, Alexis Jazz.
/*globals $:false,mw:false*/
// globals $:false,mw:false
//<nowiki>
//<nowiki>
/*
let MMCollap = {};
let MMCollap = {};
MMCollap.do = function( $content ) {
MMCollap.do = function( $content ) {
console.log('MMCollap.do was called');
console.log('MMCollap.do was called');
/* Outcommented for now, to be revisited later as some people raised potential concerns with providing mobile-only features:
// Commented out for now, to be revisited later as some people raised potential concerns with providing mobile-only features:
Allow content to be collapsible only on the mobile site which could be useful as mobile displays are smaller, so the threshold to wish to make something collapsible could be greater
// Allow content to be collapsible only on the mobile site which could be useful as mobile displays are smaller, so the threshold to wish to make something collapsible could be greater
to achieve this, change "mw-" to "MMC-" in all classes used. Do NOT use custom toggles as they won't be hidden on the desktop site.
// to achieve this, change "mw-" to "MMC-" in all classes used. Do NOT use custom toggles as they won't be hidden on the desktop site.
classes = ['collapsible','collapsed','collapsible-toggle','collapsible-content','collapsible-toggle-placeholder','collapsible-toggle-expanded'];
// classes = ['collapsible','collapsed','collapsible-toggle','collapsible-content','collapsible-toggle-placeholder','collapsible-toggle-expanded'];
if ( $('.MMC-collapsible,.MMC-collapsed')[0] ) {
// if ( $('.MMC-collapsible,.MMC-collapsed')[0] ) {
for(int=0;int<classes.length;int++){
// for(int=0;int<classes.length;int++){
$('.MMC-'+classes[int]).addClass('mw-'+classes[int]);
// $('.MMC-'+classes[int]).addClass('mw-'+classes[int]);
}
// }
}*/
// }
MMCollap.modules = [];
MMCollap.modules = [];
MMCollap.els = $content.find( '.mw-collapsible' );
MMCollap.els = $content.find( '.mw-collapsible' );
Line 40: Line 47:
mw.hook( 'wikipage.content' ).add( MMCollap.do ); //make collapsible content collapsible whenever the page is rendered, on load but also e.g. after saving an edit
mw.hook( 'wikipage.content' ).add( MMCollap.do ); //make collapsible content collapsible whenever the page is rendered, on load but also e.g. after saving an edit
//</nowiki>
//</nowiki>
*/

Latest revision as of 10:26, August 25, 2024

/* Any JavaScript here will be loaded for users using the mobile site */

console.log('Running from Mobile.js');
mw.hook('wikipage.content').add(function() {
    console.log('Hello World from Mobile.js');
});
// Commenting out the following line since it should be taken care of by Global.js
//mw.loader.load( '/w/index.php?title=MediaWiki:BibleGet.js&action=raw&ctype=text/javascript' );
//mw.loader.using('mobile.site.styles');
// MakeMobileCollapsible, enables collapsible templates/infoboxes on the mobile site.
// See https://en.wikipedia.org/wiki/Wikipedia:MakeMobileCollapsible for more information.
// This is a spinoff from Factotum. (https://en.wikipedia.org/wiki/User:Alexis_Jazz/Factotum)
// MakeMobileCollapsible is public domain, irrevocably released as WTFPL Version 2[www.wtfpl.net/about/] by its author, Alexis Jazz.
// globals $:false,mw:false
//<nowiki>
/*
let MMCollap = {};
MMCollap.do = function( $content ) {
	console.log('MMCollap.do was called');
	// Commented out for now, to be revisited later as some people raised potential concerns with providing mobile-only features:
	// Allow content to be collapsible only on the mobile site which could be useful as mobile displays are smaller, so the threshold to wish to make something collapsible could be greater
	// to achieve this, change "mw-" to "MMC-" in all classes used. Do NOT use custom toggles as they won't be hidden on the desktop site.
	// classes = ['collapsible','collapsed','collapsible-toggle','collapsible-content','collapsible-toggle-placeholder','collapsible-toggle-expanded'];
	// if ( $('.MMC-collapsible,.MMC-collapsed')[0] ) {
	//	 for(int=0;int<classes.length;int++){
	//		$('.MMC-'+classes[int]).addClass('mw-'+classes[int]);
	//	 }
	// }
	MMCollap.modules = [];
	MMCollap.els = $content.find( '.mw-collapsible' );
	if ( MMCollap.els.length ) {
		MMCollap.modules.push( 'jquery.makeCollapsible' );
	}
	if ( MMCollap.modules.length ) {
		console.log('collapsible elements were found');
		mw.loader.using( MMCollap.modules ).then( function () {
			if ( MMCollap.els && MMCollap.els.length ) {
				mw.loader.addStyleTag('.mw-parser-output .mw-collapsible-toggle{font-weight:normal;min-width:6em}');
				$(MMCollap.els).makeCollapsible(); //T111565 FTFY
			}
		});
	}
	if ( $content[ 0 ] && $content[ 0 ].isConnected === false ) {
		mw.log.warn( 'wikipage.content hook should not be fired on unattached content' );
	}
};
mw.hook( 'wikipage.content' ).add( MMCollap.do ); //make collapsible content collapsible whenever the page is rendered, on load but also e.g. after saving an edit
//</nowiki>
*/