Difference between revisions of "MediaWiki:Common.js"
Jump to navigation
Jump to search
(58 intermediate revisions by 2 users not shown) | |||
Line 7: | Line 7: | ||
*/ | */ | ||
// hide il_fixed when it overlaps with feed | |||
/* | |||
var feedIsInViewport = function () { | |||
// console.log('version 1.0') | |||
var elem = document.getElementById("taboola-below-article-thumbnails") | |||
var distance = elem.getBoundingClientRect(); | |||
return ( | |||
distance.top <= (window.innerHeight || document.documentElement.clientHeight) | |||
); | |||
}; | |||
window.addEventListener("scroll", function(){ | |||
// console.log('scrolling') | |||
if (document.getElementById("IL_INSEARCH") && document.getElementById("taboola-below-article-thumbnails")){ | |||
if (feedIsInViewport()) { | |||
// console.log('it is in viewport!') | |||
var il_fixed= $("#IL_INSEARCH"); | |||
il_fixed.addClass('displaynone'); | |||
} else { | |||
// console.log('it is not in viewport') | |||
var il_fixed = $("#IL_INSEARCH"); | |||
il_fixed.removeClass('displaynone'); | |||
} | |||
} | |||
}) | |||
*/ | |||
Latest revision as of 13:24, 29 January 2021
/* Any JavaScript here will be loaded for all users on every page load. */ // Scripts to use when viewing articles /* if (mw.config.get('wgIsArticle') || window.location.href.indexOf('action=submit') > -1 || mw.config.get('wgNamespaceNumber') == -1) { mw.loader.load( '/index.php?title=MediaWiki:CollapsibleTables.js&action=raw&ctype=text/javascript' ); } */ // hide il_fixed when it overlaps with feed /* var feedIsInViewport = function () { // console.log('version 1.0') var elem = document.getElementById("taboola-below-article-thumbnails") var distance = elem.getBoundingClientRect(); return ( distance.top <= (window.innerHeight || document.documentElement.clientHeight) ); }; window.addEventListener("scroll", function(){ // console.log('scrolling') if (document.getElementById("IL_INSEARCH") && document.getElementById("taboola-below-article-thumbnails")){ if (feedIsInViewport()) { // console.log('it is in viewport!') var il_fixed= $("#IL_INSEARCH"); il_fixed.addClass('displaynone'); } else { // console.log('it is not in viewport') var il_fixed = $("#IL_INSEARCH"); il_fixed.removeClass('displaynone'); } } }) */