Sidebar - highlight navigated sidebar item on page load - dynamically highlight sidebar item as user navigates

This commit is contained in:
Akkadius 2017-10-03 15:14:39 -05:00
parent c224536472
commit 5a2cd55414
3 changed files with 33 additions and 6 deletions

View File

@ -15,13 +15,38 @@ var loader_html = '<div class="preloader"> \
$(document).ready(function () {
remove_init_form();
/* Remove 'active' class from 'li' items */
setTimeout(function(){
$('li.active').removeClass("active");
$('.list > li').each(function(){
var href = $(this).find('a').attr("href");
if(typeof href !== "undefined"){
// console.log(href);
// console.log(document.location.pathname);
if(href == document.location.pathname){
$(this).addClass("active");
}
}
});
}, 500);
});
/*
* When a sidebar item is clicked - let's make sure we set the active/inactive components
*/
$(document).on('on_pjax_click', function (e, href) {
$('li.active').removeClass("active");
href.parent('li').addClass("active");
});
/*
* When a sidebar item is clicked in mobile - let's make sure we push the sidebar back in
*/
$(document).on('on_pjax_complete', function () {
$(document).on('on_pjax_complete', function (e) {
if ($('.ls-closed').length > 0) {
$('body').removeClass('overlay-open');
$('.overlay').css("display", "none");

View File

@ -41,10 +41,10 @@ function connect_websocket() {
}
}
/*
Note: the only thing I stream currently is dhcp log - so later incoming messages will need to be
keyed by their "type" via json
*/
/*
Note: the only thing I stream currently is dhcp log - so later incoming messages will need to be
keyed by their "type" via json
*/
var grep_value = document.getElementById("grep_fitler").value;

View File

@ -64,6 +64,8 @@ $('body').on('click', 'a', function (e) {
do_pjax_request(request_url);
$( document ).trigger( "on_pjax_click", [$(this)]);
return false;
}
});