summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehonal <yehonal.azeroth@gmail.com>2019-02-17 23:06:03 +0100
committerGitHub <noreply@github.com>2019-02-17 23:06:03 +0100
commit9f2cbaa676748c7757beec56dac572499687d569 (patch)
tree3e40ad532c707832aeffe51fd10db7c5923ec3a5
parentbea7878d3d3c8dfa5ea9821bd1d974f9bbb1a339 (diff)
downloadwiki-9f2cbaa676748c7757beec56dac572499687d569.tar.gz
wiki-9f2cbaa676748c7757beec56dac572499687d569.tar.bz2
wiki-9f2cbaa676748c7757beec56dac572499687d569.zip
Fixed toc script
-rw-r--r--assets/js/toc.js47
1 files changed, 24 insertions, 23 deletions
diff --git a/assets/js/toc.js b/assets/js/toc.js
index ac46c78..bf8fbec 100644
--- a/assets/js/toc.js
+++ b/assets/js/toc.js
@@ -1,6 +1,8 @@
// https://github.com/ghiculescu/jekyll-table-of-contents
(function ($) {
$.fn.toc = function (options) {
+ var element = $(this);
+
setTimeout(function () {
var defaults = {
noBackToTopLinks: false,
@@ -30,21 +32,20 @@
var headers = $(settings.headers).filter(function () {
// get all headers with an ID
- var previousSiblingName = $(this).prev().attr("name");
+ var previousSiblingName = element.prev().attr("name");
if (!this.id && previousSiblingName) {
- this.id = $(this).attr("id", previousSiblingName.replace(/\./g, "-"));
+ this.id = element.attr("id", previousSiblingName.replace(/\./g, "-"));
}
// Yehonal
if (!this.id) {
- this.id = $(this).text().replace(/\W/g, '_');
+ this.id = element.text().replace(/\W/g, '_');
}
return this.id;
- }),
- output = $(this);
- if (!headers.length || headers.length < settings.minimumHeaders || !output.length) {
- $(this).hide();
+ });
+ if (!headers.length || headers.length < settings.minimumHeaders || !element.length) {
+ element.hide();
return;
}
@@ -52,21 +53,6 @@
settings.showEffect = 'none';
}
- var render = {
- show: function () {
- output.hide().html(html).show(settings.showSpeed);
- },
- slideDown: function () {
- output.hide().html(html).slideDown(settings.showSpeed);
- },
- fadeIn: function () {
- output.hide().html(html).fadeIn(settings.showSpeed);
- },
- none: function () {
- output.html(html);
- }
- };
-
var get_level = function (ele) {
return parseInt(ele.nodeName.replace("H", ""), 10);
};
@@ -113,7 +99,22 @@
});
}
+ var render = {
+ show: function () {
+ element.hide().html(html).show(settings.showSpeed);
+ },
+ slideDown: function () {
+ element.hide().html(html).slideDown(settings.showSpeed);
+ },
+ fadeIn: function () {
+ element.hide().html(html).fadeIn(settings.showSpeed);
+ },
+ none: function () {
+ element.html(html).show();
+ }
+ };
+
render[settings.showEffect]();
}, 0);
}
-})(jQuery); \ No newline at end of file
+})(jQuery);