Created scroll_bar.js (with code taken from ui.js).

(imported from commit 0c4e8538031ceb1a0f50eea9a34e315e23e7d9ff)
This commit is contained in:
Steve Howell 2014-03-13 14:16:11 -04:00 committed by Leo Franchi
parent be2a1c2893
commit 84b59d4335
4 changed files with 52 additions and 50 deletions

50
static/js/scroll_bar.js Normal file
View File

@ -0,0 +1,50 @@
$(function () {
$("#stream-filters-container").perfectScrollbar({
suppressScrollX: true,
useKeyboard: false,
wheelSpeed: 20
});
});
function scrollbarWidth() {
$('body').prepend('<div id="outertest" style="width:200px; height:150px; position: absolute; top: 0; left: 0; overflow-x:hidden; overflow-y:scroll; background: #ff0000; visibility: hidden;"><div id="innertest" style="width:100%; height: 200px; overflow-y: visible;">&nbsp;</div></div>');
var scrollwidth = $("#outertest").outerWidth() - $("#innertest").outerWidth();
$("#outertest").remove();
return scrollwidth;
}
// Workaround for browsers with fixed scrollbars
$(function () {
var sbWidth = scrollbarWidth();
if (sbWidth > 0) {
$(".header").css("left", "-" + sbWidth + "px");
$(".header-main").css("left", sbWidth + "px");
$(".header-main").css("max-width", (1400 + sbWidth) + "px");
$(".header-main .column-middle").css("margin-right", (250 + sbWidth) + "px");
$(".fixed-app").css("left", "-" + sbWidth + "px");
$(".fixed-app .app-main").css("max-width", (1400 + sbWidth) + "px");
$(".fixed-app .column-middle").css("margin-left", (250 + sbWidth) + "px");
$(".column-right").css("right", sbWidth + "px");
$(".app-main .right-sidebar").css({"margin-left": (sbWidth) + "px",
"width": (250 - sbWidth) + "px"});
$("#compose").css("left", "-" + sbWidth + "px");
$(".compose-content").css({"left": sbWidth + "px",
"margin-right": (250 + sbWidth) + "px"});
$("#compose-container").css("max-width", (1400 + sbWidth) + "px");
$("head").append("<style> @media (max-width: 975px) { .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>");
}
});

View File

@ -1356,56 +1356,7 @@ $(function () {
}
});
$(function () {
$("#stream-filters-container").perfectScrollbar({
suppressScrollX: true,
useKeyboard: false,
wheelSpeed: 20
});
});
function scrollbarWidth() {
$('body').prepend('<div id="outertest" style="width:200px; height:150px; position: absolute; top: 0; left: 0; overflow-x:hidden; overflow-y:scroll; background: #ff0000; visibility: hidden;"><div id="innertest" style="width:100%; height: 200px; overflow-y: visible;">&nbsp;</div></div>');
var scrollwidth = $("#outertest").outerWidth() - $("#innertest").outerWidth();
$("#outertest").remove();
return scrollwidth;
}
// Workaround for browsers with fixed scrollbars
$(function () {
var sbWidth = scrollbarWidth();
if (sbWidth > 0) {
$(".header").css("left", "-" + sbWidth + "px");
$(".header-main").css("left", sbWidth + "px");
$(".header-main").css("max-width", (1400 + sbWidth) + "px");
$(".header-main .column-middle").css("margin-right", (250 + sbWidth) + "px");
$(".fixed-app").css("left", "-" + sbWidth + "px");
$(".fixed-app .app-main").css("max-width", (1400 + sbWidth) + "px");
$(".fixed-app .column-middle").css("margin-left", (250 + sbWidth) + "px");
$(".column-right").css("right", sbWidth + "px");
$(".app-main .right-sidebar").css({"margin-left": (sbWidth) + "px",
"width": (250 - sbWidth) + "px"});
$("#compose").css("left", "-" + sbWidth + "px");
$(".compose-content").css({"left": sbWidth + "px",
"margin-right": (250 + sbWidth) + "px"});
$("#compose-container").css("max-width", (1400 + sbWidth) + "px");
$("head").append("<style> @media (max-width: 975px) { .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>");
}
});
return exports;
}());

View File

@ -28,7 +28,7 @@ var globals =
+ ' message_edit tab_bar emoji popovers navigate people settings alert_words_ui message_store'
+ ' avatar feature_flags search_suggestion referral stream_color Dict'
+ ' Filter summary admin stream_data muting WinChan muting_ui Socket channel'
+ ' message_flags bot_data loading favicon resize'
+ ' message_flags bot_data loading favicon resize scroll_bar'
// colorspace.js
+ ' colorspace'

View File

@ -544,6 +544,7 @@ JS_SPECS = {
'js/message_edit.js',
'js/resize.js',
'js/ui.js',
'js/scroll_bar.js',
'js/popovers.js',
'js/typeahead_helper.js',
'js/search_suggestion.js',