-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix sidebar hover when initially pinned
- Loading branch information
1 parent
9067d30
commit 3ab0d7b
Showing
1 changed file
with
92 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,104 @@ | ||
jQuery(function ($) { | ||
// Dropdown menu | ||
$('.sidebar-dropdown > a').click(function () { | ||
$('.sidebar-submenu').slideUp(200); | ||
if ($(this).parent().hasClass('active')) { | ||
$('.sidebar-dropdown').removeClass('active'); | ||
$(this).parent().removeClass('active'); | ||
} else { | ||
$('.sidebar-dropdown').removeClass('active'); | ||
$(this).next('.sidebar-submenu').slideDown(200); | ||
$(this).parent().addClass('active'); | ||
} | ||
}); | ||
|
||
// Dropdown menu | ||
$(".sidebar-dropdown > a").click(function () { | ||
$(".sidebar-submenu").slideUp(200); | ||
if ($(this).parent().hasClass("active")) { | ||
$(".sidebar-dropdown").removeClass("active"); | ||
$(this).parent().removeClass("active"); | ||
} else { | ||
$(".sidebar-dropdown").removeClass("active"); | ||
$(this).next(".sidebar-submenu").slideDown(200); | ||
$(this).parent().addClass("active"); | ||
} | ||
//toggle sidebar | ||
$('#toggle-sidebar').click(function () { | ||
$('.page-wrapper').toggleClass('toggled'); | ||
}); | ||
|
||
}); | ||
|
||
//toggle sidebar | ||
$("#toggle-sidebar").click(function () { | ||
$(".page-wrapper").toggleClass("toggled"); | ||
}); | ||
//Pin sidebar | ||
$("#pin-sidebar").click(function () { | ||
if ($(".page-wrapper").hasClass("pinned")) { | ||
// unpin sidebar when hovered | ||
$(".page-wrapper").removeClass("pinned"); | ||
$("#sidebar").unbind( "hover"); | ||
} else { | ||
$(".page-wrapper").addClass("pinned"); | ||
$("#sidebar").hover( | ||
function () { | ||
console.log("mouseenter"); | ||
$(".page-wrapper").addClass("sidebar-hovered"); | ||
}, | ||
function () { | ||
console.log("mouseout"); | ||
$(".page-wrapper").removeClass("sidebar-hovered"); | ||
} | ||
) | ||
// bind hover if pinned is initially enabled | ||
if ($('.page-wrapper').hasClass('pinned')) { | ||
$('#sidebar').hover( | ||
function () { | ||
console.log('mouseenter'); | ||
$('.page-wrapper').addClass('sidebar-hovered'); | ||
}, | ||
function () { | ||
console.log('mouseout'); | ||
$('.page-wrapper').removeClass('sidebar-hovered'); | ||
} | ||
); | ||
} | ||
|
||
//Pin sidebar | ||
$('#pin-sidebar').click(function () { | ||
if ($('.page-wrapper').hasClass('pinned')) { | ||
// unpin sidebar when hovered | ||
$('.page-wrapper').removeClass('pinned'); | ||
$('#sidebar').unbind('hover'); | ||
} else { | ||
$('.page-wrapper').addClass('pinned'); | ||
$('#sidebar').hover( | ||
function () { | ||
console.log('mouseenter'); | ||
$('.page-wrapper').addClass('sidebar-hovered'); | ||
}, | ||
function () { | ||
console.log('mouseout'); | ||
$('.page-wrapper').removeClass('sidebar-hovered'); | ||
} | ||
}); | ||
); | ||
} | ||
}); | ||
|
||
//toggle sidebar overlay | ||
$('#overlay').click(function () { | ||
$('.page-wrapper').toggleClass('toggled'); | ||
}); | ||
|
||
//toggle sidebar overlay | ||
$("#overlay").click(function () { | ||
$(".page-wrapper").toggleClass("toggled"); | ||
}); | ||
//switch between themes | ||
var themes = | ||
'default-theme legacy-theme chiller-theme ice-theme cool-theme light-theme'; | ||
$('[data-theme]').click(function () { | ||
$('[data-theme]').removeClass('selected'); | ||
$(this).addClass('selected'); | ||
$('.page-wrapper').removeClass(themes); | ||
$('.page-wrapper').addClass($(this).attr('data-theme')); | ||
}); | ||
|
||
//switch between themes | ||
var themes = "default-theme legacy-theme chiller-theme ice-theme cool-theme light-theme"; | ||
$('[data-theme]').click(function () { | ||
$('[data-theme]').removeClass("selected"); | ||
$(this).addClass("selected"); | ||
$('.page-wrapper').removeClass(themes); | ||
$('.page-wrapper').addClass($(this).attr('data-theme')); | ||
}); | ||
// switch between background images | ||
var bgs = 'bg1 bg2 bg3 bg4'; | ||
$('[data-bg]').click(function () { | ||
$('[data-bg]').removeClass('selected'); | ||
$(this).addClass('selected'); | ||
$('.page-wrapper').removeClass(bgs); | ||
$('.page-wrapper').addClass($(this).attr('data-bg')); | ||
}); | ||
|
||
// switch between background images | ||
var bgs = "bg1 bg2 bg3 bg4"; | ||
$('[data-bg]').click(function () { | ||
$('[data-bg]').removeClass("selected"); | ||
$(this).addClass("selected"); | ||
$('.page-wrapper').removeClass(bgs); | ||
$('.page-wrapper').addClass($(this).attr('data-bg')); | ||
}); | ||
// toggle background image | ||
$('#toggle-bg').change(function (e) { | ||
e.preventDefault(); | ||
$('.page-wrapper').toggleClass('sidebar-bg'); | ||
}); | ||
|
||
// toggle background image | ||
$("#toggle-bg").change(function (e) { | ||
e.preventDefault(); | ||
$('.page-wrapper').toggleClass("sidebar-bg"); | ||
}); | ||
// toggle border radius | ||
$('#toggle-border-radius').change(function (e) { | ||
e.preventDefault(); | ||
$('.page-wrapper').toggleClass('boder-radius-on'); | ||
}); | ||
|
||
// toggle border radius | ||
$("#toggle-border-radius").change(function (e) { | ||
e.preventDefault(); | ||
$('.page-wrapper').toggleClass("boder-radius-on"); | ||
//custom scroll bar is only used on desktop | ||
if ( | ||
!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( | ||
navigator.userAgent | ||
) | ||
) { | ||
$('.sidebar-content').mCustomScrollbar({ | ||
axis: 'y', | ||
autoHideScrollbar: true, | ||
scrollInertia: 300, | ||
}); | ||
|
||
//custom scroll bar is only used on desktop | ||
if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { | ||
$(".sidebar-content").mCustomScrollbar({ | ||
axis: "y", | ||
autoHideScrollbar: true, | ||
scrollInertia: 300 | ||
}); | ||
$(".sidebar-content").addClass("desktop"); | ||
|
||
} | ||
}); | ||
$('.sidebar-content').addClass('desktop'); | ||
} | ||
}); |