Skip to content

Commit 7f48603

Browse files
committed
移除 docs & 更新 toc 来源
1 parent a2443a3 commit 7f48603

File tree

152 files changed

+120
-8287
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+120
-8287
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2013 Alex Ghiculescu
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// https://github.com/ghiculescu/jekyll-table-of-contents
2+
// share under MIT License
3+
(function($){
4+
$.fn.toc = function(options) {
5+
var defaults = {
6+
noBackToTopLinks: false,
7+
title: '<i>Jump to...</i>',
8+
minimumHeaders: 3,
9+
headers: 'h1, h2, h3, h4, h5, h6',
10+
listType: 'ol', // values: [ol|ul]
11+
showEffect: 'show', // values: [show|slideDown|fadeIn|none]
12+
showSpeed: 'slow', // set to 0 to deactivate effect
13+
classes: { list: '',
14+
item: '',
15+
link: ''
16+
}
17+
},
18+
settings = $.extend(defaults, options);
19+
20+
function fixedEncodeURIComponent (str) {
21+
return encodeURIComponent(str).replace(/[!'()*]/g, function(c) {
22+
return '%' + c.charCodeAt(0).toString(16);
23+
});
24+
}
25+
26+
function createLink (header) {
27+
var innerText = (header.textContent === undefined) ? header.innerText : header.textContent;
28+
return "<a class='"+settings.classes.link+"' href='#" + fixedEncodeURIComponent(header.id) + "'>" + innerText + "</a>";
29+
}
30+
31+
var headers = $(settings.headers).filter(function() {
32+
// get all headers with an ID
33+
var previousSiblingName = $(this).prev().attr( "name" );
34+
if (!this.id && previousSiblingName) {
35+
this.id = $(this).attr( "id", previousSiblingName.replace(/\./g, "-") );
36+
}
37+
return this.id;
38+
}), output = $(this);
39+
if (!headers.length || headers.length < settings.minimumHeaders || !output.length) {
40+
$(this).hide();
41+
return;
42+
}
43+
44+
if (0 === settings.showSpeed) {
45+
settings.showEffect = 'none';
46+
}
47+
48+
var render = {
49+
show: function() { output.hide().html(html).show(settings.showSpeed); },
50+
slideDown: function() { output.hide().html(html).slideDown(settings.showSpeed); },
51+
fadeIn: function() { output.hide().html(html).fadeIn(settings.showSpeed); },
52+
none: function() { output.html(html); }
53+
};
54+
55+
var get_level = function(ele) { return parseInt(ele.nodeName.replace("H", ""), 10); };
56+
var highest_level = headers.map(function(_, ele) { return get_level(ele); }).get().sort()[0];
57+
var return_to_top = '<i class="icon-arrow-up back-to-top"> </i>';
58+
59+
var level = get_level(headers[0]),
60+
this_level,
61+
html = settings.title + " <" +settings.listType + " class=\"" + settings.classes.list +"\">";
62+
headers.on('click', function() {
63+
if (!settings.noBackToTopLinks) {
64+
window.location.hash = this.id;
65+
}
66+
})
67+
.addClass('clickable-header')
68+
.each(function(_, header) {
69+
this_level = get_level(header);
70+
if (!settings.noBackToTopLinks && this_level === highest_level) {
71+
$(header).addClass('top-level-header').after(return_to_top);
72+
}
73+
if (this_level === level) // same level as before; same indenting
74+
html += "<li class=\"" + settings.classes.item + "\">" + createLink(header);
75+
else if (this_level <= level){ // higher level than before; end parent ol
76+
for(var i = this_level; i < level; i++) {
77+
html += "</li></"+settings.listType+">"
78+
}
79+
html += "<li class=\"" + settings.classes.item + "\">" + createLink(header);
80+
}
81+
else if (this_level > level) { // lower level than before; expand the previous to contain a ol
82+
for(i = this_level; i > level; i--) {
83+
html += "<" + settings.listType + " class=\"" + settings.classes.list +"\">" +
84+
"<li class=\"" + settings.classes.item + "\">"
85+
}
86+
html += createLink(header);
87+
}
88+
level = this_level; // update for the next one
89+
});
90+
html += "</"+settings.listType+">";
91+
if (!settings.noBackToTopLinks) {
92+
$(document).on('click', '.back-to-top', function() {
93+
$(window).scrollTop(0);
94+
window.location.hash = '';
95+
});
96+
}
97+
98+
render[settings.showEffect]();
99+
};
100+
})(jQuery);

assets/js/jekyll_table_of_contents.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
var SOURCES = window.TEXT_VARIABLES.sources;
33
window.Lazyload.js(SOURCES.jquery, function () {
44
var JSElement=document.createElement("script");
5-
JSElement.setAttribute("src","//cdn.jsdelivr.net/gh/ghiculescu/jekyll-table-of-contents/toc.min.js");
5+
JSElement.setAttribute("src","//cdn.jsdelivr.net/gh/Young-Lord/Young-Lord.github.io/assets/js/jekyll-table-of-contents/toc.min.js");
66
document.body.appendChild(JSElement)
77
document.addEventListener("DOMContentLoaded", function () { $('#toc').toc(); });
88
})

0 commit comments

Comments
 (0)