parent
0c7010e381
commit
32ff8d601f
3 changed files with 52 additions and 7 deletions
|
|
@ -7,13 +7,6 @@ function setVisibleTags(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var isMobile = window.screen.width < 720;
|
|
||||||
if (localStorage.getItem("openside") === null) {
|
|
||||||
window.sidebarExpanded = !isMobile;
|
|
||||||
} else {
|
|
||||||
window.sidebarExpanded = (localStorage.getItem("openside") === "true");
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateSidebar(notransition) {
|
function updateSidebar(notransition) {
|
||||||
if (notransition) {
|
if (notransition) {
|
||||||
document.querySelectorAll("#sidebar")[0].classList.add("notransition");
|
document.querySelectorAll("#sidebar")[0].classList.add("notransition");
|
||||||
|
|
@ -40,8 +33,42 @@ function sidebarClick() {
|
||||||
updateSidebar(false);
|
updateSidebar(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getNextPrev() {
|
||||||
|
// thanks iznogoodd from #nim @ freenode.net
|
||||||
|
var links = document.querySelectorAll('#sidebar a[href]');
|
||||||
|
|
||||||
|
var nav = {prev: null, next: null};
|
||||||
|
for(var i = 0; i < links.length; i++){
|
||||||
|
var item = links.item(i);
|
||||||
|
if(item && item.getAttribute('href') === window.location.pathname){
|
||||||
|
nav.prev = links.item(i - 1) && links.item(i - 1).getAttribute('href');
|
||||||
|
nav.next = links.item(i + 1) && links.item(i + 1).getAttribute('href');
|
||||||
|
return nav;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateNextPrevButtons() {
|
||||||
|
var nav = getNextPrev();
|
||||||
|
|
||||||
|
var prev = document.getElementById("arrow-prev");
|
||||||
|
var next = document.getElementById("arrow-next");
|
||||||
|
|
||||||
|
if (nav.prev != null) { prev.classList.remove("disabled"); prev.href = nav.prev; }
|
||||||
|
if (nav.next != null) { next.classList.remove("disabled"); next.href = nav.next; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var isMobile = window.screen.width < 720;
|
||||||
|
if (localStorage.getItem("openside") === null) {
|
||||||
|
window.sidebarExpanded = !isMobile;
|
||||||
|
} else {
|
||||||
|
window.sidebarExpanded = (localStorage.getItem("openside") === "true");
|
||||||
|
}
|
||||||
|
|
||||||
localStorage.setItem(window.location.pathname, true);
|
localStorage.setItem(window.location.pathname, true);
|
||||||
window.onload = function(){
|
window.onload = function(){
|
||||||
updateSidebar(true);
|
updateSidebar(true);
|
||||||
setVisibleTags();
|
setVisibleTags();
|
||||||
|
updateNextPrevButtons();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,16 @@ body {
|
||||||
.nav-toggle span { margin-top: 9.5px; }
|
.nav-toggle span { margin-top: 9.5px; }
|
||||||
|
|
||||||
|
|
||||||
|
#nextprev {
|
||||||
|
overflow: hidden;
|
||||||
|
padding: .5em 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-icon { font-size: 5em; }
|
||||||
|
#arrow-prev { float: left; }
|
||||||
|
#arrow-next { float: right; }
|
||||||
|
|
||||||
|
|
||||||
article {
|
article {
|
||||||
margin: 15px;
|
margin: 15px;
|
||||||
|
|
||||||
|
|
@ -70,6 +80,9 @@ a { text-decoration: none; }
|
||||||
a:link, a:visited { color: #B45D47; }
|
a:link, a:visited { color: #B45D47; }
|
||||||
a:hover { color: #FE3B3B; }
|
a:hover { color: #FE3B3B; }
|
||||||
|
|
||||||
|
a.disabled, a:link.disabled, a:visited.disabled { color: #999; pointer-events: none; }
|
||||||
|
a:hover.disabled { color: #888; }
|
||||||
|
|
||||||
|
|
||||||
pre, code { font-family: Monaco, Menlo, Consolas, "Courier New", monospace; }
|
pre, code { font-family: Monaco, Menlo, Consolas, "Courier New", monospace; }
|
||||||
code {
|
code {
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,11 @@
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
<div id=nextprev>
|
||||||
|
<a id=arrow-prev class="text-icon disabled" href="https://please-enable-js/">↽</a>
|
||||||
|
<a id=arrow-next class="text-icon disabled" href="https://please-enable-js/">⇁</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<footer>
|
<footer>
|
||||||
<%= @items["/footer/"].compiled_content(snapshot: :last) %>
|
<%= @items["/footer/"].compiled_content(snapshot: :last) %>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue