Revision 90ebb597
Added by Tomer Brisker about 8 years ago
app/assets/javascripts/topbar.js | ||
---|---|---|
$(function() {
|
||
var clone = $('.persist-header').clone();
|
||
$('.persist-header').after(clone);
|
||
$('.persist-header:first').hide();
|
||
$('.persist-header:last').css({
|
||
'position': 'static', 'top': '0'
|
||
});
|
||
|
||
mark_active_menu();
|
||
|
||
$('.dropdown-toggle').dropdown();
|
||
if(!is_mobile()){
|
||
$(window).on('scroll', function() {onScroll(this)});
|
||
$(window).on('scroll', persistHeader);
|
||
}
|
||
})
|
||
|
||
... | ... | |
});
|
||
|
||
function mark_active_menu() {
|
||
var menus = $('.menu_tab_dropdown'),
|
||
path = window.location.pathname + window.location.search,
|
||
link = $("[href='%s']".replace('%s', path));
|
||
|
||
menus.removeClass('active');
|
||
$("[class^='menu_tab_']").removeClass('active');
|
||
var link = "[href='"+window.location.pathname + window.location.search+"']";
|
||
|
||
menus.each(function(index, element) {
|
||
element = $(element);
|
||
if (element.find(link).length) {
|
||
element.addClass('active');
|
||
}
|
||
});
|
||
$('.menu_tab_dropdown ').has(link).addClass('active');
|
||
}
|
||
|
||
function is_mobile() {
|
||
... | ... | |
return check;
|
||
}
|
||
|
||
function onScroll(item){
|
||
var offset = 25;
|
||
var dist = $(item).scrollTop();
|
||
var header_height = $('.persist-header:first').height();
|
||
function persistHeader(){
|
||
var offset = $('.navbar-outer').height();
|
||
var dist = $(window).scrollTop();
|
||
var header_height = $('.persist-header').height();
|
||
if (dist >= offset) {
|
||
$('.persist-header:first').show();
|
||
$('.persist-header:last').css({
|
||
'position': 'fixed'
|
||
});
|
||
$('#content').css({'padding-top': header_height+'px'})
|
||
$('.persist-header').css('position', 'fixed');
|
||
$('#content').css('padding-top', header_height)
|
||
} else {
|
||
$('.persist-header:last').css({
|
||
'position': 'static'
|
||
});
|
||
$('.persist-header:first').hide();
|
||
$('.persist-header').css('position', 'static');
|
||
$('#content').css({'padding-top': '0'})
|
||
}
|
||
}
|
app/assets/stylesheets/topbar.scss | ||
---|---|---|
.navbar-header {
|
||
float: none;
|
||
}
|
||
|
||
.org-switcher > a {
|
||
font-size: 14px;
|
||
border-right: solid 1px $border_color;
|
||
|
||
.caret {
|
||
margin-left: 20px;
|
||
}
|
||
}
|
||
}
|
||
|
||
.navbar-brand {
|
||
... | ... | |
clear: both;
|
||
left: 0;
|
||
min-height: 40px;
|
||
position: absolute;
|
||
position: static;
|
||
right: 0;
|
||
top: 0;
|
||
padding: 0 40px;
|
||
|
||
@include linear-gradient($primary_gradient_start, $primary_gradient_end);
|
||
... | ... | |
padding-top: 10px;
|
||
padding-bottom: 9px;
|
||
}
|
||
}
|
||
|
||
.dropdown .caret {
|
||
margin-left: 4px;
|
||
}
|
||
|
||
.nav-header {
|
||
padding: 3px 10px;
|
||
font-size: 11px;
|
||
font-weight: bold;
|
||
line-height: 20px;
|
||
color: #999999;
|
||
text-transform: uppercase;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.navbar .nav .org-switcher > a {
|
||
font-size: 14px;
|
||
border-right: solid 1px $border_color;
|
||
|
||
.caret {
|
||
margin-left: 20px;
|
||
}
|
||
}
|
||
|
||
.navbar-inner {
|
||
a.manage-menu {
|
||
font-size: 11px;
|
||
color: #0088cc;
|
||
... | ... | |
}
|
||
}
|
||
|
||
// Responsive menu display
|
||
.navbar-collapse.in li .dropdown-menu:after {
|
||
display: none;
|
||
.dropdown .caret {
|
||
margin-left: 4px;
|
||
}
|
||
|
||
.nav-header {
|
||
padding: 3px 10px;
|
||
font-size: 11px;
|
||
font-weight: bold;
|
||
line-height: 20px;
|
||
color: #999999;
|
||
text-transform: uppercase;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.navbar-collapse.in{
|
||
... | ... | |
.open {
|
||
background-color: transparent;
|
||
}
|
||
|
||
// Responsive menu display
|
||
li .dropdown-menu:after {
|
||
display: none;
|
||
}
|
||
}
|
||
|
||
// Necessary to override bootstrap3 media query restyling for small screens
|
Also available in: Unified diff
Fixes #14456 - Cleanup navbar handling code and style