2014-03-13 19:16:11 +01:00
|
|
|
|
2018-06-19 20:16:00 +02:00
|
|
|
var scroll_bar = (function () {
|
|
|
|
|
|
|
|
var exports = {};
|
2014-03-13 19:16:11 +01:00
|
|
|
|
2017-08-22 21:15:20 +02:00
|
|
|
// From https://stackoverflow.com/questions/13382516/getting-scroll-bar-width-using-javascript
|
|
|
|
function getScrollbarWidth() {
|
|
|
|
var outer = document.createElement("div");
|
|
|
|
outer.style.visibility = "hidden";
|
|
|
|
outer.style.width = "100px";
|
|
|
|
outer.style.msOverflowStyle = "scrollbar"; // needed for WinJS apps
|
2014-03-13 19:16:11 +01:00
|
|
|
|
2017-08-22 21:15:20 +02:00
|
|
|
document.body.appendChild(outer);
|
2014-03-13 19:16:11 +01:00
|
|
|
|
2017-08-22 21:15:20 +02:00
|
|
|
var widthNoScroll = outer.offsetWidth;
|
|
|
|
// force scrollbars
|
|
|
|
outer.style.overflow = "scroll";
|
|
|
|
|
|
|
|
// add innerdiv
|
|
|
|
var inner = document.createElement("div");
|
|
|
|
inner.style.width = "100%";
|
|
|
|
outer.appendChild(inner);
|
|
|
|
|
|
|
|
var widthWithScroll = inner.offsetWidth;
|
|
|
|
|
|
|
|
// remove divs
|
|
|
|
outer.parentNode.removeChild(outer);
|
|
|
|
|
|
|
|
return widthNoScroll - widthWithScroll;
|
2014-03-13 19:16:11 +01:00
|
|
|
}
|
|
|
|
|
2018-06-19 20:16:00 +02:00
|
|
|
exports.initialize = function () {
|
2014-03-13 19:16:11 +01:00
|
|
|
// Workaround for browsers with fixed scrollbars
|
2018-05-06 21:43:17 +02:00
|
|
|
var sbWidth = getScrollbarWidth();
|
|
|
|
|
|
|
|
if (sbWidth > 0) {
|
|
|
|
$(".header").css("left", "-" + sbWidth + "px");
|
|
|
|
$(".header-main").css("left", sbWidth + "px");
|
2018-06-06 18:50:09 +02:00
|
|
|
$(".header-main").css("max-width", 1400 + sbWidth + "px");
|
|
|
|
$(".header-main .column-middle").css("margin-right", 250 + sbWidth + "px");
|
2018-05-06 21:43:17 +02:00
|
|
|
|
|
|
|
$(".fixed-app").css("left", "-" + sbWidth + "px");
|
2018-06-06 18:50:09 +02:00
|
|
|
$(".fixed-app .app-main").css("max-width", 1400 + sbWidth + "px");
|
|
|
|
$(".fixed-app .column-middle").css("margin-left", 250 + sbWidth + "px");
|
2018-05-06 21:43:17 +02:00
|
|
|
|
|
|
|
$(".column-right").css("right", sbWidth + "px");
|
2018-06-06 18:19:09 +02:00
|
|
|
$(".app-main .right-sidebar").css({"margin-left": sbWidth + "px",
|
2018-06-06 18:50:09 +02:00
|
|
|
width: 250 - sbWidth + "px"});
|
2018-05-06 21:43:17 +02:00
|
|
|
|
|
|
|
$("#compose").css("left", "-" + sbWidth + "px");
|
|
|
|
$(".compose-content").css({left: sbWidth + "px",
|
2018-06-06 18:50:09 +02:00
|
|
|
"margin-right": 250 + sbWidth + "px"});
|
|
|
|
$("#compose-container").css("max-width", 1400 + sbWidth + "px");
|
2018-08-19 23:18:51 +02:00
|
|
|
$('#keyboard-icon').css({right: sbWidth + 13 + "px"});
|
2018-05-06 21:43:17 +02:00
|
|
|
|
|
|
|
$("head").append("<style> @media (max-width: 1025px) { .compose-content, .header-main .column-middle { margin-right: " + (7 + sbWidth) + "px !important; } } " +
|
|
|
|
"@media (max-width: 775px) { .fixed-app .column-middle { margin-left: " + (7 + sbWidth) + "px !important; } } " +
|
|
|
|
"</style>");
|
|
|
|
}
|
2014-03-13 19:16:11 +01:00
|
|
|
|
2018-06-19 20:16:00 +02:00
|
|
|
ui.set_up_scrollbar($("#stream-filters-container"));
|
|
|
|
};
|
|
|
|
|
|
|
|
return exports;
|
|
|
|
}());
|
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = scroll_bar;
|
|
|
|
}
|
2018-05-28 08:04:36 +02:00
|
|
|
|
|
|
|
window.scroll_bar = scroll_bar;
|