mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-14 23:02:34 +00:00
Hide theme selector popup on interaction outside of it
Also set cursor to pointer on theme selector items.
This commit is contained in:
parent
69b3e2b5cb
commit
672d91e6c2
3 changed files with 12 additions and 1 deletions
|
@ -273,6 +273,7 @@ table thead td {
|
||||||
padding: 2px 10px;
|
padding: 2px 10px;
|
||||||
line-height: 25px;
|
line-height: 25px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.theme-popup .theme:hover:first-child,
|
.theme-popup .theme:hover:first-child,
|
||||||
.theme-popup .theme:hover:last-child {
|
.theme-popup .theme:hover:last-child {
|
||||||
|
|
|
@ -101,11 +101,20 @@ $( document ).ready(function() {
|
||||||
|
|
||||||
$('.theme').click(function(){
|
$('.theme').click(function(){
|
||||||
var theme = $(this).attr('id');
|
var theme = $(this).attr('id');
|
||||||
|
|
||||||
set_theme(theme);
|
set_theme(theme);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Hide theme selector popup when clicking outside of it
|
||||||
|
$(document).click(function(event){
|
||||||
|
var popup = $('.theme-popup');
|
||||||
|
if(popup.length) {
|
||||||
|
var target = $(event.target);
|
||||||
|
if(!target.closest('.theme').length && !target.closest('#theme-toggle').length) {
|
||||||
|
popup.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function set_theme(theme) {
|
function set_theme(theme) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
padding: 2px 10px
|
padding: 2px 10px
|
||||||
line-height: 25px
|
line-height: 25px
|
||||||
white-space: nowrap
|
white-space: nowrap
|
||||||
|
cursor: pointer
|
||||||
|
|
||||||
&:hover:first-child,
|
&:hover:first-child,
|
||||||
&:hover:last-child {
|
&:hover:last-child {
|
||||||
|
|
Loading…
Reference in a new issue