Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/AmazingRise/hugo-theme-diary.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/toc-collapse.js')
-rw-r--r--static/js/toc-collapse.js60
1 files changed, 0 insertions, 60 deletions
diff --git a/static/js/toc-collapse.js b/static/js/toc-collapse.js
deleted file mode 100644
index d9ffe1e..0000000
--- a/static/js/toc-collapse.js
+++ /dev/null
@@ -1,60 +0,0 @@
-var spy = function () {
- var elems = $(":header");
- if (elems.length == 0) {
- return;
- }
- var currentTop = $(window).scrollTop();
- var currentBottom = $(window).scrollTop() + $(window).height();
- var pageBottom = $('#EOF').offset().top;
-
- var meetUnread = false
- var currentIndex = elems.length - 1
- elems.each(function (idx) {
- var elemTop = $(this).offset().top;
- var id = $(this).attr('id');
- var navElem = $('#' + id + '-nav');
- if (currentTop + $(this).height() >= elemTop) {
- navElem.addClass('toc-active');
- } else {
- if (meetUnread == false) {
- meetUnread = true
- currentIndex = idx - 1
- }
- navElem.removeClass('toc-active');
- }
- })
- if (currentBottom >= pageBottom) {
- currentIndex = -1
- }
- //console.log(currentIndex);
- //Collapse them
- collapseOthers(currentIndex);
-}
-
-var onNavClick = function () {
- spy()
-}
-
-var collapseOthers = function (currentIndex) {
- if (currentIndex == -1) {
- $(".collapse").each(function (idx) {
- $(this).collapse("hide");
- });
- return;
- }
- var elems = $(":header");
- //console.log(currentIndex);
- currentId = "#" + elems[currentIndex].id + "-nav";
-
- $(currentId).parents(".collapse").each(function (idx) {
- $(this).collapse("show");
- });
- $(currentId).parent().next().filter(".collapse").collapse("show");
- $(".collapse").not($(currentId).parents()).not($(currentId).parent().next()).each(function (idx) {
- $(this).collapse("hide");
- });
-}
-
-//From https://github.com/lodash/lodash/blob/master/debounce.js
-// and https://github.com/lodash/lodash/blob/master/isObject.js
-