User:WelpThatWorked/vector.js: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(Body top border support script) |
(Debounce) |
||
Line 1: | Line 1: | ||
$.bodyBorderResize = function() { |
$.bodyBorderResize = mw.util.debounce(0, function() { |
||
var $body = $("#content"); |
var $body = $("#content"); |
||
var $lnav = $("#left-navigation"); |
var $lnav = $("#left-navigation"); |
||
Line 10: | Line 10: | ||
$body.css("--p3", $body.outerWidth() + parseFloat($body.css("margin-right")) - $("#p-search").outerWidth(true) + "px"); |
$body.css("--p3", $body.outerWidth() + parseFloat($body.css("margin-right")) - $("#p-search").outerWidth(true) + "px"); |
||
} |
} |
||
}; |
}); |
||
$(window).on("resize", $.bodyBorderResize); |
$(window).on("resize", $.bodyBorderResize); |
||
var obs = new MutationObserver($.bodyBorderResize); |
var obs = new MutationObserver($.bodyBorderResize); |
Revision as of 15:56, 19 January 2024
$.bodyBorderResize = mw.util.debounce(0, function() {
var $body = $("#content");
var $lnav = $("#left-navigation");
var $rnav = $("#right-navigation");
$body.css("--p1", $lnav.outerWidth() + "px");
if( ($lnav.outerWidth()+$rnav.outerWidth()) > $body.outerWidth()){
$body.css("--p2", $body.outerWidth() + "px");
} else {
$body.css("--p2", $body.outerWidth() + parseFloat($body.css("margin-right")) - $rnav.outerWidth(true) + "px");
$body.css("--p3", $body.outerWidth() + parseFloat($body.css("margin-right")) - $("#p-search").outerWidth(true) + "px");
}
});
$(window).on("resize", $.bodyBorderResize);
var obs = new MutationObserver($.bodyBorderResize);
obs.observe(document.querySelector("#right-navigation"), { subtree: true, attributes: true });
console.warn("test");