Skip to content

Commit 49c9022

Browse files
eksperimentalJosé Valim
authored andcommitted
final version of toc
Signed-off-by: José Valim <jose.valim@plataformatec.com.br>
1 parent 403e870 commit 49c9022

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

_includes/bottom.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242

4343
</script>
4444
</body>
45-
</html>
45+
</html>

css/style.css

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -848,13 +848,24 @@ li.image {
848848
/* table of contents */
849849
/* Jekyll Table of Contents
850850
----------------------------------------------------- */
851-
.jekyll-toc ol { counter-reset: item; }
852-
.jekyll-toc ol li { display: block }
853-
.jekyll-toc ol li:before {
851+
ol.jekyll-toc,
852+
ol.jekyll-toc ol {
853+
counter-reset: item;
854+
}
855+
856+
ol.jekyll-toc {
857+
margin: 0.3125em 0 0 3.125em;
858+
}
859+
ol.jekyll-toc ol {
860+
margin: 0.625em 0 0 0;
861+
margin-bottom: -0.8em;
862+
}
863+
ol.jekyll-toc li { display: block }
864+
ol.jekyll-toc li:before {
854865
content: counters(item, ".") " ";
855866
counter-increment: item;
856867
}
857-
.jekyll-toc ol li {
868+
ol.jekyll-toc li {
858869
list-style-position: inside;
859870
text-indent: -1em;
860871
padding-left: 1em;
@@ -910,13 +921,11 @@ li.image {
910921
margin-left: 10px;
911922
width:1em;
912923
text-align: right;
913-
/* vertical-align: top; */
914924
}
915925

916926
/* extending jekyll-toc */
917-
.icon {
927+
.jekyll-toc-header .icon {
918928
font: normal normal normal 16px/1 icons !important;
919-
/* display: inline-block; */
920929
text-decoration: none;
921930
text-rendering: auto;
922931
-webkit-font-smoothing: antialiased;
@@ -925,12 +934,4 @@ li.image {
925934
-moz-user-select: none;
926935
-ms-user-select: none;
927936
user-select: none;
928-
}
929-
930-
/* dev */
931-
/*
932-
.jekyll-toc-header {border:1px solid red; background-color:yellow;}
933-
.jekyll-toc-header a.jekyll-toc-anchor {border:1px solid blue;}
934-
.jekyll-toc-header a.jekyll-toc-anchor a.jekyll-toc-icon{border:1px solid red;}
935-
}
936-
*/
937+
}

js/toc/toc.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
window.location.hash = hash;
7070
}
7171

72-
function update_hash(hash) {
72+
function update_hash(hash) {
7373
if(history.pushState) {
7474
history.pushState(null, null, '#'+hash);
7575
} else {
@@ -78,8 +78,13 @@
7878
}
7979

8080
function animate_link_here(header_id) {
81-
update_hash( (typeof header_id === "undefined") ? '' : header_id );
82-
$('html,body').animate({scrollTop:$(document.getElementById(header_id)).offset().top}, settings.linkHereDuration);
81+
var hash = (typeof header_id === "undefined") ? '' : header_id;
82+
if ( settings.linkHereDuration > 0 ) {
83+
update_hash(hash);
84+
$('html,body').animate({scrollTop:$(document.getElementById(header_id)).offset().top}, settings.linkHereDuration);
85+
} else {
86+
force_update_hash(hash);
87+
}
8388
}
8489

8590
if (settings.backToTop) {
@@ -94,11 +99,12 @@
9499
} else {
95100
var top_element = ( $(settings.backToTopSelector).length ) ? $(settings.backToTopSelector).first() : $('html, body');
96101
var top_element_id = $(top_element).attr('id');
97-
update_hash ( (typeof top_element_id === "undefined") ? '' : top_element_id );
98-
if ( settings.backToTopDuration > 0 || window.location.hash == '' ) {
102+
var hash = (typeof top_element_id === "undefined") ? '' : top_element_id
103+
if ( settings.backToTopDuration > 0 || hash == '' ) {
104+
update_hash(hash);
99105
$('html, body').animate({scrollTop: top_element.offset().top}, settings.backToTopDuration);
100106
} else {
101-
force_update_hash(window.location.hash);
107+
force_update_hash(hash);
102108
}
103109
}
104110
});

0 commit comments

Comments
 (0)