MediaWiki:Mobile.js: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(16 intermediate revisions by the same user not shown)
Line 2: Line 2:


/*
/*
* Note that some of the style changes that are applied when enabling ads are
if (document.readyState === 'complete') {
* already applied via MW:Vector.css, but only for anonymous visitors, so apply
bg3wikiCheckAdBlock();
* them again in case ads are enabled explicitly, e.g. for testing.
} else {
*/
window.addEventListener('load', bg3wikiCheckAdBlock);
 
if (mw.config.get("wgUserId") == null) {
bg3wikiEnableAds();
}
}


function bg3wikiEnableAds() {
function bg3wikiCheckAdBlock() {
// This class is normally added through a hook in LocalSettings.php, when
var adsEnabled = document.body.classList.contains("mw-ads-enabled");
// the visitor is not a logged-in user.  The class is added here as well,
if (adsEnabled && window.fusetag === undefined) {
// since this function could be called for testing purposes.
bg3wikiHideAdSlots();
document.body.classList.add("mw-ads-enabled");
}
 
bg3wikiEnableFooterAd();
}
}


function bg3wikiEnableFooterAd() {
function bg3wikiHideAdSlots() {
if (window.innerHeight < 720) {
document.body.classList.replace("mw-ads-enabled", "mw-ads-disabled");
return;
}
return; // TODO
// The "header" is actually at the bottom.
var header = document.getElementsByClassName("citizen-header")[0];
header.style.bottom = "50px";
// Floating page actions thingy above the "header"
var actions = document.getElementsByClassName("page-actions")[0];
actions.style.bottom = "calc(50px + var(--header-size) + var(--space-xs))";
// Actual page contents
var content = document.getElementsByClassName("citizen-page-container")[0];
content.style.marginBottom = "50px";
var ad = document.createElement("div");
ad.id = "bg3wiki-footer-ad";
ad.classList.add("bg3wiki-ad");
ad.style.height = "50px";
ad.style.width = "100%";
ad.style.position = "fixed";
ad.style.bottom = "0";
ad.style.zIndex = "999";
ad.style.background = "var(--color-surface-3)";
ad.style.alignContent = "center";
document.body.appendChild(ad);
var p = document.createElement("p");
p.style.textAlign = "center";
p.style.fontSize = "0.9em";
p.style.fontStyle = "italic";
p.style.color = "var(--color-subtle)";
p.innerText = "Ad placeholder";
ad.appendChild(p);
}
}
*/

Latest revision as of 21:13, 14 August 2024

/* All JavaScript here will be loaded for users of the mobile site */

/*
if (document.readyState === 'complete') {
	bg3wikiCheckAdBlock();
} else {
	window.addEventListener('load', bg3wikiCheckAdBlock);
}

function bg3wikiCheckAdBlock() {
	var adsEnabled = document.body.classList.contains("mw-ads-enabled");
	if (adsEnabled && window.fusetag === undefined) {
		bg3wikiHideAdSlots();
	}
}

function bg3wikiHideAdSlots() {
	document.body.classList.replace("mw-ads-enabled", "mw-ads-disabled");
}
*/