MediaWiki:BibleGet.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 33:
let rect = $bGetTIP[0].getBoundingClientRect();
let excessHeight = (rect.y + rect.height) - window.innerHeight;
let excessWidth = (rect.x + rect.width) - window.innerWidth;
//if this amount is less than the distance from the top of the screen,
// then let's just move our div up by that much
if(!$bGetTIP.hasClass('sticky') && excessHeight < rect.y){
letif(excessWidth newTop> =0 top&& -excessWidth excessHeight;< rect.x){
console.log('This element was offscreen!off the right hand side of the screen');
$bGetTIP.css({"top":newTop});
} let else {newLeft;
if(!$bGetTIPspan.hasClassoffset('sticky').left > rect.width){
newLeft = $bGetTIPspan.addClassoffset('sticky');.left - rect.width;
} else {
newLeft = $span.offset().left - rect.width / 2; //center it on the span as a last resort!
}
$bGetTIP.css({"left":newLeft});
}
if(excessHeight > 0 && excessHeight < rect.y){
//howconsole.log('This farelement was off the bottom of the screen are we?');
let newTop = top - excessHeight;
$bGetTIP.css({"top":newTop});
} else if (excessHeight > rect.y){
$bGetTIP.cssaddClass({"top":newTop}'sticky');
$bGetTIP.append($('<div>',{class:'closeButton',text:'x'}));
$bGetTIP.on('click','.closeButton',function(){
Line 46 ⟶ 58:
$bGetTIP.css({"top":'',"left":''});
});
//distance of the top of the current window from the top of the document
let newTop = (window.pageYOffset || (document.documentElement || document.body.parentNode || document.body).scrollTop) + 20;
$bGetTIP.css({"top":newTop});
}
//distance of the top of the current window from the top of the document
let newTop = (window.pageYOffset || (document.documentElement || document.body.parentNode || document.body).scrollTop) + 20;
$bGetTIP.css({"top":newTop});
}
}
Line 104 ⟶ 116:
$bGetTIP.css({"top":top,"left":left});
if($bGetTIP.hasClass('sticky') || $bGetTIP.is(':offscreen') ){
//are we off the bottom or the right side of the screen, and how much?
console.log('This element was offscreen!');
//how far off the bottom of the screen are we?
let rect = $bGetTIP[0].getBoundingClientRect();
let excessHeight = (rect.y + rect.height) - window.innerHeight;
let excessWidth = (rect.x + rect.width) - window.innerWidth;
//if this amount is less than the distance from the top of the screen,
// then let's just move our div up by that much
if(!$bGetTIP.hasClass('sticky') && excessHeight < rect.y){
letif(excessWidth newTop> =0 top&& -excessWidth excessHeight;< rect.x){
console.log('This element was off the right hand side of the screen');
$bGetTIP.css({"top":newTop});
} let else {newLeft;
if(!$bGetTIPspan.hasClassoffset('sticky').left > rect.width){
newLeft = $span.offset().left - rect.width;
} else {
newLeft = $span.offset().left - rect.width / 2; //center it on the span as a last resort!
}
$bGetTIP.css({"topleft":newTopnewLeft});
}
if(excessHeight > 0 && excessHeight < rect.y){
console.log('This element was off the bottom of the screen');
let newTop = top - excessHeight;
$bGetTIP.css({"top":newTop});
} else if (excessHeight >= rect.y){
$bGetTIP.addClass('sticky');
$bGetTIP.append($('<div>',{class:'closeButton',text:'x'}));
Line 121 ⟶ 144:
$bGetTIP.css({"top":'',"left":''});
});
//distance of the top of the current window from the top of the document
let newTop = (window.pageYOffset || (document.documentElement || document.body.parentNode || document.body).scrollTop) + 20;
$bGetTIP.css({"top":newTop});
}
//distance of the top of the current window from the top of the document
let newTop = (window.pageYOffset || (document.documentElement || document.body.parentNode || document.body).scrollTop) + 20;
$bGetTIP.css({"top":newTop});
}
}