hexo-theme-shokax 0.3.12 → 0.3.14
Sign up to get free protection for your applications and to get access to all the features.
- package/CODE_OF_CONDUCT.md +128 -128
- package/CONTRIBUTING.md +58 -58
- package/LICENSE +660 -660
- package/LICENSE-shoka +21 -21
- package/README.md +99 -92
- package/README_en.MD +90 -82
- package/UsageRestrictions.md +25 -25
- package/_config.yml +370 -373
- package/_images.yml +9 -9
- package/languages/README.md +19 -19
- package/languages/default.yml +1 -1
- package/languages/en.yml +153 -153
- package/languages/ja.yml +153 -153
- package/languages/zh-CN.yml +153 -153
- package/languages/zh-HK.yml +153 -153
- package/languages/zh-TW.yml +153 -153
- package/layout/_alternate/atom.ejs +30 -30
- package/layout/_alternate/json.ejs +16 -16
- package/layout/_alternate/rss.ejs +34 -34
- package/layout/_mixin/breadcrumb.pug +33 -33
- package/layout/_mixin/card.pug +38 -38
- package/layout/_mixin/comment.pug +41 -41
- package/layout/_mixin/postmeta.pug +29 -29
- package/layout/_mixin/segment.pug +32 -32
- package/layout/_mixin/sidebar.pug +40 -40
- package/layout/_mixin/widgets.pug +33 -33
- package/layout/_partials/footer.pug +42 -42
- package/layout/_partials/head/head.pug +57 -58
- package/layout/_partials/head/head_com.pug +17 -17
- package/layout/_partials/head/pwa.pug +18 -18
- package/layout/_partials/header.pug +18 -18
- package/layout/_partials/layout.pug +139 -139
- package/layout/_partials/loading.pug +13 -13
- package/layout/_partials/pagination.pug +4 -4
- package/layout/_partials/post/copyright.pug +20 -20
- package/layout/_partials/post/footer.pug +25 -25
- package/layout/_partials/post/nav.pug +13 -13
- package/layout/_partials/post/post.pug +41 -41
- package/layout/_partials/post/reward.pug +18 -18
- package/layout/_partials/sidebar/menu.pug +37 -37
- package/layout/_partials/sidebar/overview.pug +42 -42
- package/layout/_partials/third-party/baidu-analytics.pug +11 -11
- package/layout/_partials/third-party/clarity.pug +8 -8
- package/layout/_partials/third-party/google-analytics.pug +9 -9
- package/layout/archive.pug +118 -118
- package/layout/category.pug +59 -59
- package/layout/index.pug +33 -33
- package/layout/page.pug +55 -55
- package/layout/post.pug +36 -36
- package/layout/tag.pug +43 -43
- package/package.json +47 -47
- package/source/assets/algolia_logo.svg +9 -9
- package/source/assets/logo.svg +16 -16
- package/source/css/_colors.styl +207 -207
- package/source/css/_common/components/components.styl +6 -6
- package/source/css/_common/components/highlight/highlight.styl +357 -357
- package/source/css/_common/components/highlight/operation.styl +21 -21
- package/source/css/_common/components/pages/collapse.styl +119 -119
- package/source/css/_common/components/pages/home.styl +391 -391
- package/source/css/_common/components/pages/pages.styl +56 -56
- package/source/css/_common/components/pages/tag-cloud.styl +12 -12
- package/source/css/_common/components/post/breadcrumb.styl +39 -39
- package/source/css/_common/components/post/copyright.styl +41 -41
- package/source/css/_common/components/post/expand.styl +263 -263
- package/source/css/_common/components/post/footer.styl +11 -11
- package/source/css/_common/components/post/header.styl +79 -79
- package/source/css/_common/components/post/nav.styl +63 -63
- package/source/css/_common/components/post/post.styl +29 -29
- package/source/css/_common/components/post/reward.styl +50 -50
- package/source/css/_common/components/post/rtl.styl +12 -12
- package/source/css/_common/components/post/tags.styl +39 -39
- package/source/css/_common/components/tags/collapse.styl +72 -72
- package/source/css/_common/components/tags/container.styl +49 -49
- package/source/css/_common/components/tags/label.styl +12 -12
- package/source/css/_common/components/tags/links.styl +77 -77
- package/source/css/_common/components/tags/list.styl +131 -131
- package/source/css/_common/components/tags/note.styl +70 -70
- package/source/css/_common/components/tags/player.styl +361 -361
- package/source/css/_common/components/tags/quiz.styl +200 -200
- package/source/css/_common/components/tags/tabs.styl +89 -87
- package/source/css/_common/components/tags/tags.styl +9 -9
- package/source/css/_common/components/third-party/loading.styl +222 -222
- package/source/css/_common/components/third-party/mermaid/class.styl +90 -90
- package/source/css/_common/components/third-party/mermaid/flowchart.styl +72 -72
- package/source/css/_common/components/third-party/mermaid/gantt.styl +251 -251
- package/source/css/_common/components/third-party/mermaid/git.styl +7 -7
- package/source/css/_common/components/third-party/mermaid/mermaid.styl +37 -37
- package/source/css/_common/components/third-party/mermaid/pie.styl +9 -9
- package/source/css/_common/components/third-party/mermaid/sequence.styl +95 -95
- package/source/css/_common/components/third-party/mermaid/state.styl +130 -130
- package/source/css/_common/components/third-party/pace.styl +18 -18
- package/source/css/_common/components/third-party/search.styl +167 -167
- package/source/css/_common/components/third-party/theme.styl +151 -151
- package/source/css/_common/components/third-party/third-party.styl +22 -22
- package/source/css/_common/components/third-party/widgets.styl +57 -57
- package/source/css/_common/outline/footer/footer.styl +69 -69
- package/source/css/_common/outline/header/brand.styl +77 -77
- package/source/css/_common/outline/header/header.styl +20 -20
- package/source/css/_common/outline/header/image.styl +85 -85
- package/source/css/_common/outline/header/menu.styl +117 -117
- package/source/css/_common/outline/header/nav.styl +81 -81
- package/source/css/_common/outline/header/right.styl +15 -15
- package/source/css/_common/outline/header/tool.styl +207 -207
- package/source/css/_common/outline/header/waves.styl +57 -57
- package/source/css/_common/outline/mobile.styl +46 -46
- package/source/css/_common/outline/outline.styl +78 -78
- package/source/css/_common/outline/sidebar/author.styl +59 -59
- package/source/css/_common/outline/sidebar/dimmer.styl +23 -23
- package/source/css/_common/outline/sidebar/menu.styl +63 -63
- package/source/css/_common/outline/sidebar/quick.styl +43 -43
- package/source/css/_common/outline/sidebar/related.styl +56 -56
- package/source/css/_common/outline/sidebar/sidebar.styl +75 -75
- package/source/css/_common/outline/sidebar/social.styl +69 -69
- package/source/css/_common/outline/sidebar/state.styl +37 -37
- package/source/css/_common/outline/sidebar/tab.styl +71 -71
- package/source/css/_common/outline/sidebar/toc.styl +47 -47
- package/source/css/_common/scaffolding/animate.styl +322 -322
- package/source/css/_common/scaffolding/base.styl +190 -190
- package/source/css/_common/scaffolding/buttons.styl +48 -48
- package/source/css/_common/scaffolding/divider.styl +36 -36
- package/source/css/_common/scaffolding/iconfont.styl +443 -443
- package/source/css/_common/scaffolding/normalize.styl +273 -273
- package/source/css/_common/scaffolding/pagination.styl +81 -81
- package/source/css/_common/scaffolding/ribbon.styl +38 -38
- package/source/css/_common/scaffolding/scaffolding.styl +14 -14
- package/source/css/_common/scaffolding/scrollbar.styl +37 -37
- package/source/css/_common/scaffolding/tables.styl +50 -50
- package/source/css/_common/scaffolding/tip.styl +19 -19
- package/source/css/_common/scaffolding/toggles.styl +59 -59
- package/source/css/_iconfont.styl +455 -451
- package/source/css/_mixins.styl +148 -148
- package/source/css/_variables.styl +89 -89
- package/source/css/app.styl +41 -41
- package/source/css/comment.styl +3 -3
- package/source/css/mermaid.styl +5 -5
- package/source/css/optimize.styl +5 -5
- package/scripts/filters/locals.js +0 -52
- package/scripts/filters/post.js +0 -5
- package/scripts/generaters/archive.js +0 -133
- package/scripts/generaters/config.js +0 -48
- package/scripts/generaters/images.js +0 -23
- package/scripts/generaters/index.js +0 -107
- package/scripts/generaters/pages.js +0 -15
- package/scripts/generaters/script.js +0 -115
- package/scripts/helpers/asset.js +0 -147
- package/scripts/helpers/engine.js +0 -153
- package/scripts/helpers/list_categories.js +0 -84
- package/scripts/helpers/summary_ai.js +0 -107
- package/scripts/helpers/symbols_count_time.js +0 -69
- package/scripts/plugin/check.js +0 -32
- package/scripts/plugin/index.js +0 -78
- package/scripts/plugin/lib/injects-point.js +0 -20
- package/scripts/plugin/lib/injects.js +0 -89
- package/scripts/tags/links.js +0 -44
- package/scripts/tags/media.js +0 -19
- package/scripts/utils.js +0 -14
- package/source/css/twikoo.css +0 -2002
- package/source/js/_app/components/sidebar.js +0 -210
- package/source/js/_app/fireworks.js +0 -10
- package/source/js/_app/globals/globalVars.js +0 -80
- package/source/js/_app/globals/handles.js +0 -138
- package/source/js/_app/globals/themeColor.js +0 -62
- package/source/js/_app/globals/thirdparty.js +0 -71
- package/source/js/_app/globals/tools.js +0 -92
- package/source/js/_app/library/anime.js +0 -109
- package/source/js/_app/library/dom.js +0 -34
- package/source/js/_app/library/loadFile.js +0 -36
- package/source/js/_app/library/proto.js +0 -163
- package/source/js/_app/library/scriptPjax.js +0 -70
- package/source/js/_app/library/storage.js +0 -12
- package/source/js/_app/library/vue.js +0 -53
- package/source/js/_app/page/comment.js +0 -23
- package/source/js/_app/page/common.js +0 -41
- package/source/js/_app/page/fancybox.js +0 -65
- package/source/js/_app/page/post.js +0 -244
- package/source/js/_app/page/search.js +0 -118
- package/source/js/_app/page/tab.js +0 -53
- package/source/js/_app/pjax/domInit.js +0 -76
- package/source/js/_app/pjax/refresh.js +0 -53
- package/source/js/_app/pjax/siteInit.js +0 -49
- package/source/js/_app/player.js +0 -774
@@ -1,109 +0,0 @@
|
|
1
|
-
import anime from 'theme-shokax-anime';
|
2
|
-
import { siteNavHeight } from '../globals/globalVars';
|
3
|
-
/**
|
4
|
-
* 参数 动画效果
|
5
|
-
* 0 元素逐渐消失
|
6
|
-
* 1 元素逐渐出现
|
7
|
-
* bounceUpIn 元素从下方弹跳出现
|
8
|
-
* shrinkIn 元素从放大到正常大小出现
|
9
|
-
* slideRightIn 元素从右侧滑入
|
10
|
-
* slideRightOut 元素向右侧滑出
|
11
|
-
* TODO 函数功能过于复杂,需要拆分
|
12
|
-
*/
|
13
|
-
export const transition = (target, type, complete, begin) => {
|
14
|
-
let animation;
|
15
|
-
let display = 'none';
|
16
|
-
switch (type) {
|
17
|
-
case 0:
|
18
|
-
animation = { opacity: [1, 0] };
|
19
|
-
break;
|
20
|
-
case 1:
|
21
|
-
animation = { opacity: [0, 1] };
|
22
|
-
display = 'block';
|
23
|
-
break;
|
24
|
-
case 'bounceUpIn':
|
25
|
-
animation = {
|
26
|
-
begin(anim) {
|
27
|
-
target.display('block');
|
28
|
-
},
|
29
|
-
translateY: [
|
30
|
-
{ value: -60, duration: 200 },
|
31
|
-
{ value: 10, duration: 200 },
|
32
|
-
{ value: -5, duration: 200 },
|
33
|
-
{ value: 0, duration: 200 }
|
34
|
-
],
|
35
|
-
opacity: [0, 1]
|
36
|
-
};
|
37
|
-
display = 'block';
|
38
|
-
break;
|
39
|
-
case 'shrinkIn':
|
40
|
-
animation = {
|
41
|
-
begin(anim) {
|
42
|
-
target.display('block');
|
43
|
-
},
|
44
|
-
scale: [
|
45
|
-
{ value: 1.1, duration: 300 },
|
46
|
-
{ value: 1, duration: 200 }
|
47
|
-
],
|
48
|
-
opacity: 1
|
49
|
-
};
|
50
|
-
display = 'block';
|
51
|
-
break;
|
52
|
-
case 'slideRightIn':
|
53
|
-
animation = {
|
54
|
-
begin(anim) {
|
55
|
-
target.display('block');
|
56
|
-
},
|
57
|
-
translateX: ['100%', '0%'],
|
58
|
-
opacity: [0, 1]
|
59
|
-
};
|
60
|
-
display = 'block';
|
61
|
-
break;
|
62
|
-
case 'slideRightOut':
|
63
|
-
animation = {
|
64
|
-
translateX: ['0%', '100%'],
|
65
|
-
opacity: [1, 0]
|
66
|
-
};
|
67
|
-
break;
|
68
|
-
default:
|
69
|
-
animation = type;
|
70
|
-
// @ts-ignore
|
71
|
-
display = type.display;
|
72
|
-
break;
|
73
|
-
}
|
74
|
-
anime(Object.assign({
|
75
|
-
targets: target,
|
76
|
-
duration: 200,
|
77
|
-
easing: 'linear',
|
78
|
-
begin() {
|
79
|
-
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
80
|
-
begin && begin();
|
81
|
-
},
|
82
|
-
complete() {
|
83
|
-
target.display(display);
|
84
|
-
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
85
|
-
complete && complete();
|
86
|
-
}
|
87
|
-
}, animation)).play();
|
88
|
-
};
|
89
|
-
export const pageScroll = (target, offset, complete) => {
|
90
|
-
// target: 滚动到的目标元素或坐标(number)
|
91
|
-
// offset: 可选的偏移量
|
92
|
-
// complete: 可选的回调函数,在动画完成时调用
|
93
|
-
anime({
|
94
|
-
// 动画目标
|
95
|
-
targets: typeof offset === 'number' && typeof target !== 'number' ? target.parentNode : document.scrollingElement,
|
96
|
-
// 动画持续时间
|
97
|
-
duration: 500,
|
98
|
-
// 动画缓动函数
|
99
|
-
easing: 'easeInOutQuad',
|
100
|
-
// 如果 offset 存在,则滚动到 offset,如果 target 是数字,则滚动到 target,如果 target 是 DOM 元素,则滚动到下述表达式
|
101
|
-
scrollTop: offset || (typeof target === 'number' ? target : (target ? target.getTop() + document.documentElement.scrollTop - siteNavHeight : 0)),
|
102
|
-
// 完成回调函数
|
103
|
-
complete() {
|
104
|
-
// eslint-disable-next-line chai-friendly/no-unused-expressions
|
105
|
-
complete && complete();
|
106
|
-
}
|
107
|
-
}).play();
|
108
|
-
// 调用 anime.js 函数,并传入参数
|
109
|
-
};
|
@@ -1,34 +0,0 @@
|
|
1
|
-
const getDocHeight = () => $dom('main > .inner').offsetHeight;
|
2
|
-
/**
|
3
|
-
* 获取一个dom选择器对应的元素
|
4
|
-
*/
|
5
|
-
const $dom = (selector, element = document) => {
|
6
|
-
// 在测试环境中这能优化0.01-0.02ms左右
|
7
|
-
if (selector[0] === '#') {
|
8
|
-
return element.getElementById(selector.substring(1));
|
9
|
-
}
|
10
|
-
return element.querySelector(selector);
|
11
|
-
};
|
12
|
-
/**
|
13
|
-
* 获取具有此选择器的所有dom节点
|
14
|
-
*/
|
15
|
-
$dom.all = (selector, element = document) => {
|
16
|
-
return element.querySelectorAll(selector);
|
17
|
-
};
|
18
|
-
/**
|
19
|
-
* 获取具有此选择器的所有dom节点,并依次执行callback函数
|
20
|
-
*/
|
21
|
-
$dom.each = (selector, callback, element) => {
|
22
|
-
$dom.all(selector, element).forEach(callback);
|
23
|
-
};
|
24
|
-
// TODO 异步化意义不明确,代码实现存在问题
|
25
|
-
$dom.asyncify = async (selector, element = document) => {
|
26
|
-
if (selector[0] === '#') {
|
27
|
-
return element.getElementById(selector.substring(1));
|
28
|
-
}
|
29
|
-
return element.querySelector(selector);
|
30
|
-
};
|
31
|
-
$dom.asyncifyEach = (selector, callback, element) => {
|
32
|
-
$dom.all(selector, element).forEach(callback);
|
33
|
-
};
|
34
|
-
export { $dom, getDocHeight };
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import { getScript } from './scriptPjax';
|
2
|
-
/**
|
3
|
-
* 用途是根据不同的资源名称和类型生成相应的资源 URL。
|
4
|
-
*/
|
5
|
-
const assetUrl = (asset, type) => {
|
6
|
-
const str = CONFIG[asset][type];
|
7
|
-
if (str.includes('http')) {
|
8
|
-
return str;
|
9
|
-
}
|
10
|
-
if (str.includes('gh') || str.includes('combine')) {
|
11
|
-
return `https://cdn.jsdelivr.net/${str}`;
|
12
|
-
}
|
13
|
-
if (str.includes('npm')) {
|
14
|
-
return `https://cdn.jsdelivr.net/${str}`;
|
15
|
-
}
|
16
|
-
return `/${str}`;
|
17
|
-
};
|
18
|
-
export const vendorJs = (type, callback, condition) => {
|
19
|
-
if (LOCAL[type]) {
|
20
|
-
getScript(assetUrl('js', type), callback || function () {
|
21
|
-
window[type] = true;
|
22
|
-
}, condition || window[type]);
|
23
|
-
}
|
24
|
-
};
|
25
|
-
export const vendorCss = (type, condition) => {
|
26
|
-
if (window['css' + type]) {
|
27
|
-
return;
|
28
|
-
}
|
29
|
-
if (LOCAL[type]) {
|
30
|
-
document.head.createChild('link', {
|
31
|
-
rel: 'stylesheet',
|
32
|
-
href: assetUrl('css', type)
|
33
|
-
});
|
34
|
-
window['css' + type] = true;
|
35
|
-
}
|
36
|
-
};
|
@@ -1,163 +0,0 @@
|
|
1
|
-
import { $dom } from './dom';
|
2
|
-
export default function initProto() {
|
3
|
-
Object.assign(HTMLElement.prototype, {
|
4
|
-
/**
|
5
|
-
* 创建一个子节点并放置
|
6
|
-
*/
|
7
|
-
createChild(tag, obj, positon) {
|
8
|
-
const child = document.createElement(tag);
|
9
|
-
Object.assign(child, obj);
|
10
|
-
switch (positon) {
|
11
|
-
case 'after':
|
12
|
-
this.insertAfter(child);
|
13
|
-
break;
|
14
|
-
case 'replace':
|
15
|
-
this.innerHTML = '';
|
16
|
-
this.appendChild(child);
|
17
|
-
break;
|
18
|
-
default:
|
19
|
-
this.appendChild(child);
|
20
|
-
}
|
21
|
-
return child;
|
22
|
-
},
|
23
|
-
/**
|
24
|
-
* 此方法使用`<div>`包装一个 DOM 元素
|
25
|
-
* @param obj 需要被包装的对象
|
26
|
-
*/
|
27
|
-
wrapObject(obj) {
|
28
|
-
const box = document.createElement('div');
|
29
|
-
Object.assign(box, obj);
|
30
|
-
this.parentNode.insertBefore(box, this);
|
31
|
-
this.parentNode.removeChild(this);
|
32
|
-
box.appendChild(this);
|
33
|
-
},
|
34
|
-
changeOrGetHeight(h) {
|
35
|
-
if (h) {
|
36
|
-
// TODO 0rem是期望的值吗?
|
37
|
-
this.style.height = typeof h === 'number' ? h + 'rem' : h;
|
38
|
-
}
|
39
|
-
return this.getBoundingClientRect().height;
|
40
|
-
},
|
41
|
-
/**
|
42
|
-
此函数将元素的宽度设置为指定值,如果未提供值,则返回元素的宽度.<br />
|
43
|
-
宽度可以作为数字提供(假定它以`rem`为单位).作为字符串提供则直接设置为元素宽度
|
44
|
-
*/
|
45
|
-
changeOrGetWidth(w) {
|
46
|
-
if (w) {
|
47
|
-
// TODO 0rem是期望的值吗?
|
48
|
-
this.style.width = typeof w === 'number' ? w + 'rem' : w;
|
49
|
-
}
|
50
|
-
return this.getBoundingClientRect().width;
|
51
|
-
},
|
52
|
-
getTop() {
|
53
|
-
return this.getBoundingClientRect().top;
|
54
|
-
},
|
55
|
-
left() {
|
56
|
-
return this.getBoundingClientRect().left;
|
57
|
-
},
|
58
|
-
/**
|
59
|
-
* 该函数接受两个参数:`type`字符串和 `value`字符串的可选参数。该函数具有基于参数值的三个主要逻辑分支。 <br />
|
60
|
-
* 1. `value`如果是`null`,则该函数从当前上下文中删除具有`type`函数名称的属性。 <br />
|
61
|
-
* 2. `value`如果为真,则该函数将使用`type`参数指定的名称将属性设置为当前上下文中`value`参数的值。然后,该函数返回当前上下文。 <br />
|
62
|
-
* 3. `value`如果不是真,则该函数返回属性的值,该值具有当前上下文中的参数指定的名称。
|
63
|
-
*/
|
64
|
-
attr(type, value) {
|
65
|
-
if (value === null) {
|
66
|
-
return this.removeAttribute(type);
|
67
|
-
}
|
68
|
-
if (value) {
|
69
|
-
this.setAttribute(type, value);
|
70
|
-
return this;
|
71
|
-
}
|
72
|
-
else {
|
73
|
-
return this.getAttribute(type);
|
74
|
-
}
|
75
|
-
},
|
76
|
-
/**
|
77
|
-
* 将此节点插入父节点的下一个节点之前
|
78
|
-
*/
|
79
|
-
insertAfter(element) {
|
80
|
-
const parent = this.parentNode;
|
81
|
-
if (parent.lastChild === this) {
|
82
|
-
parent.appendChild(element);
|
83
|
-
}
|
84
|
-
else {
|
85
|
-
parent.insertBefore(element, this.nextSibling);
|
86
|
-
}
|
87
|
-
},
|
88
|
-
/**
|
89
|
-
* 当d为空时返回此节点的CSSStyle display属性 <br />
|
90
|
-
* 反之,将d设置为此节点的CSSStyle display属性
|
91
|
-
*/
|
92
|
-
display(d) {
|
93
|
-
if (d == null) {
|
94
|
-
return this.style.display;
|
95
|
-
}
|
96
|
-
else {
|
97
|
-
this.style.display = d;
|
98
|
-
return this;
|
99
|
-
}
|
100
|
-
},
|
101
|
-
/**
|
102
|
-
* 找到此节点第一个符合selector选择器的子节点
|
103
|
-
*/
|
104
|
-
child(selector) {
|
105
|
-
return $dom(selector, this);
|
106
|
-
},
|
107
|
-
/**
|
108
|
-
* 找到此节点所有符合selector选择器的子节点
|
109
|
-
*/
|
110
|
-
find(selector) {
|
111
|
-
return $dom.all(selector, this);
|
112
|
-
},
|
113
|
-
/**
|
114
|
-
* 这个方法接受三个参数:
|
115
|
-
* type 表示操作类型('add'、'remove'、'toggle'),
|
116
|
-
* className 是一个或多个要操作的类名,
|
117
|
-
* display 是一个可选的布尔值,用于在执行切换操作时指定类名是否应显示或隐藏。
|
118
|
-
* 该方法会根据操作类型执行相应的类名操作。
|
119
|
-
*/
|
120
|
-
_class(type, className, display) {
|
121
|
-
const classNames = className.indexOf(' ') ? className.split(' ') : [className];
|
122
|
-
classNames.forEach((name) => {
|
123
|
-
if (type === 'toggle') {
|
124
|
-
this.classList.toggle(name, display);
|
125
|
-
}
|
126
|
-
else {
|
127
|
-
this.classList[type](name);
|
128
|
-
}
|
129
|
-
});
|
130
|
-
},
|
131
|
-
/**
|
132
|
-
* 这个方法是对 _class 方法的封装,调用时会将操作类型设为 'add',然后执行添加类名的操作。
|
133
|
-
* 最后,它返回当前的 EventTarget,通常是 DOM 元素本身,以支持链式调用。
|
134
|
-
*/
|
135
|
-
addClass(className) {
|
136
|
-
this._class('add', className);
|
137
|
-
return this;
|
138
|
-
},
|
139
|
-
/**
|
140
|
-
* 这个方法是对 _class 方法的封装,调用时会将操作类型设为 'remove',然后执行移除类名的操作。
|
141
|
-
* 最后,它返回当前的 EventTarget,通常是 DOM 元素本身,以支持链式调用。
|
142
|
-
*/
|
143
|
-
removeClass(className) {
|
144
|
-
this._class('remove', className);
|
145
|
-
return this;
|
146
|
-
},
|
147
|
-
/**
|
148
|
-
* 这个方法是对 _class 方法的封装,调用时会将操作类型设为 'toggle',然后执行切换类名的操作。
|
149
|
-
* 如果提供了 display 参数,它将根据布尔值决定是否显示或隐藏类名。
|
150
|
-
* 最后,它返回当前的 EventTarget,通常是 DOM 元素本身,以支持链式调用。
|
151
|
-
*/
|
152
|
-
toggleClass(className, display) {
|
153
|
-
this._class('toggle', className, display);
|
154
|
-
return this;
|
155
|
-
},
|
156
|
-
/**
|
157
|
-
* 这个方法返回一个布尔值,表示元素是否包含指定的类名。
|
158
|
-
*/
|
159
|
-
hasClass(className) {
|
160
|
-
return this.classList.contains(className);
|
161
|
-
}
|
162
|
-
});
|
163
|
-
}
|
@@ -1,70 +0,0 @@
|
|
1
|
-
// rocket-loader & Auto minify(cloudflare) 补丁
|
2
|
-
// cloudflare 的上述功能会导致DOMContentLoaded事件无法触发,此补丁会将DOMContentLoaded重定向为load事件
|
3
|
-
export function cloudflareInit() {
|
4
|
-
let inCloudFlare = true;
|
5
|
-
window.addEventListener('DOMContentLoaded', function () {
|
6
|
-
inCloudFlare = false;
|
7
|
-
});
|
8
|
-
if (document.readyState === 'loading') {
|
9
|
-
window.addEventListener('load', function () {
|
10
|
-
if (inCloudFlare) {
|
11
|
-
window.dispatchEvent(new Event('DOMContentLoaded'));
|
12
|
-
console.log('%c ☁️cloudflare patch ' + '%c running(rocket & minify)', 'color: white; background: #ff8c00; padding: 5px 3px;', 'padding: 4px;border:1px solid #ff8c00');
|
13
|
-
}
|
14
|
-
});
|
15
|
-
}
|
16
|
-
}
|
17
|
-
export const getScript = (url, callback, condition) => {
|
18
|
-
// url: 脚本文件的URL地址
|
19
|
-
// callback: 当脚本加载完成时要执行的回调函数
|
20
|
-
// condition: 可选的条件参数,如果存在,则执行callback
|
21
|
-
if (condition) {
|
22
|
-
// 如果条件存在,则执行回调函数
|
23
|
-
callback();
|
24
|
-
}
|
25
|
-
else {
|
26
|
-
let script = document.createElement('script');
|
27
|
-
// @ts-ignore
|
28
|
-
script.onload = function (_, isAbort) {
|
29
|
-
// _: 事件对象
|
30
|
-
// isAbort: 是否中止
|
31
|
-
// @ts-ignore
|
32
|
-
if (isAbort || !script.readyState) {
|
33
|
-
console.log('abort!');
|
34
|
-
script.onload = null;
|
35
|
-
script = undefined;
|
36
|
-
if (!isAbort && callback)
|
37
|
-
setTimeout(callback, 0);
|
38
|
-
}
|
39
|
-
};
|
40
|
-
script.src = url;
|
41
|
-
document.head.appendChild(script);
|
42
|
-
}
|
43
|
-
};
|
44
|
-
export const pjaxScript = (element) => {
|
45
|
-
const { text, parentNode, id, className, type, src, dataset } = element;
|
46
|
-
const code = text || element.textContent || element.innerHTML || '';
|
47
|
-
parentNode.removeChild(element);
|
48
|
-
const script = document.createElement('script');
|
49
|
-
if (id) {
|
50
|
-
script.id = id;
|
51
|
-
}
|
52
|
-
if (className) {
|
53
|
-
script.className = className;
|
54
|
-
}
|
55
|
-
if (type) {
|
56
|
-
script.type = type;
|
57
|
-
}
|
58
|
-
if (src) {
|
59
|
-
// Force synchronous loading of peripheral JS.
|
60
|
-
script.src = src;
|
61
|
-
script.async = false;
|
62
|
-
}
|
63
|
-
if (dataset.pjax !== undefined) {
|
64
|
-
script.dataset.pjax = '';
|
65
|
-
}
|
66
|
-
if (code !== '') {
|
67
|
-
script.appendChild(document.createTextNode(code));
|
68
|
-
}
|
69
|
-
parentNode.appendChild(script);
|
70
|
-
};
|
@@ -1,53 +0,0 @@
|
|
1
|
-
import { $storage } from './storage';
|
2
|
-
import { transition } from './anime';
|
3
|
-
import { $dom } from './dom';
|
4
|
-
import { BODY } from '../globals/globalVars';
|
5
|
-
import { changeTheme } from '../globals/themeColor';
|
6
|
-
export function initVue() {
|
7
|
-
Vue.createApp({
|
8
|
-
data() {
|
9
|
-
return {};
|
10
|
-
},
|
11
|
-
methods: {
|
12
|
-
changeThemeByBtn() {
|
13
|
-
let c;
|
14
|
-
const btn = $dom('.theme').child('.ic');
|
15
|
-
const neko = BODY.createChild('div', {
|
16
|
-
id: 'neko',
|
17
|
-
innerHTML: '<div class="planet"><div class="sun"></div><div class="moon"></div></div><div class="body"><div class="face"><section class="eyes left"><span class="pupil"></span></section><section class="eyes right"><span class="pupil"></span></section><span class="nose"></span></div></div>'
|
18
|
-
});
|
19
|
-
const hideNeko = () => {
|
20
|
-
transition(neko, {
|
21
|
-
// @ts-ignore
|
22
|
-
delay: 2500,
|
23
|
-
opacity: 0
|
24
|
-
}, () => {
|
25
|
-
BODY.removeChild(neko);
|
26
|
-
});
|
27
|
-
};
|
28
|
-
if (btn.hasClass('i-sun')) {
|
29
|
-
c = () => {
|
30
|
-
neko.addClass('dark');
|
31
|
-
changeTheme('dark');
|
32
|
-
$storage.set('theme', 'dark');
|
33
|
-
hideNeko();
|
34
|
-
};
|
35
|
-
}
|
36
|
-
else {
|
37
|
-
neko.addClass('dark');
|
38
|
-
c = () => {
|
39
|
-
neko.removeClass('dark');
|
40
|
-
changeTheme();
|
41
|
-
$storage.set('theme', 'light');
|
42
|
-
hideNeko();
|
43
|
-
};
|
44
|
-
}
|
45
|
-
transition(neko, 1, () => {
|
46
|
-
setTimeout(c, 210);
|
47
|
-
}, () => {
|
48
|
-
neko.display('block');
|
49
|
-
});
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}).mount('#rightNav');
|
53
|
-
}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
import { $dom } from '../library/dom';
|
2
|
-
import { transition } from '../library/anime';
|
3
|
-
import { goToComment } from '../globals/globalVars';
|
4
|
-
// TODO 此函数在twikoo下可能不适用
|
5
|
-
export default function loadComments() {
|
6
|
-
const element = $dom('#comments');
|
7
|
-
if (!element) {
|
8
|
-
goToComment.display('none');
|
9
|
-
return;
|
10
|
-
}
|
11
|
-
else {
|
12
|
-
goToComment.display('');
|
13
|
-
}
|
14
|
-
const io = new IntersectionObserver((entries, observer) => {
|
15
|
-
const entry = entries[0];
|
16
|
-
// vendorCss('valine')
|
17
|
-
if (entry.isIntersecting || entry.intersectionRatio > 0) {
|
18
|
-
transition($dom('#comments'), 'bounceUpIn');
|
19
|
-
observer.disconnect();
|
20
|
-
}
|
21
|
-
});
|
22
|
-
io.observe(element);
|
23
|
-
}
|
@@ -1,41 +0,0 @@
|
|
1
|
-
import { $dom } from '../library/dom';
|
2
|
-
export const cardActive = () => {
|
3
|
-
if (!$dom('.index.wrap')) {
|
4
|
-
return;
|
5
|
-
}
|
6
|
-
const io = new IntersectionObserver((entries) => {
|
7
|
-
entries.forEach((article) => {
|
8
|
-
if (article.target.hasClass('show')) {
|
9
|
-
io.unobserve(article.target);
|
10
|
-
}
|
11
|
-
else {
|
12
|
-
if (article.isIntersecting || article.intersectionRatio > 0) {
|
13
|
-
article.target.addClass('show');
|
14
|
-
io.unobserve(article.target);
|
15
|
-
}
|
16
|
-
}
|
17
|
-
});
|
18
|
-
}, {
|
19
|
-
root: null,
|
20
|
-
threshold: [0.3]
|
21
|
-
});
|
22
|
-
$dom.each('.index.wrap article.item, .index.wrap section.item', (article) => {
|
23
|
-
io.observe(article);
|
24
|
-
});
|
25
|
-
$dom('.index.wrap .item:first-child').addClass('show');
|
26
|
-
$dom.each('.cards .item', (element) => {
|
27
|
-
['mouseenter', 'touchstart'].forEach((item) => {
|
28
|
-
element.addEventListener(item, () => {
|
29
|
-
if ($dom('.cards .item.active')) {
|
30
|
-
$dom('.cards .item.active').removeClass('active');
|
31
|
-
}
|
32
|
-
element.addClass('active');
|
33
|
-
}, { passive: true });
|
34
|
-
});
|
35
|
-
['mouseleave'].forEach((item) => {
|
36
|
-
element.addEventListener(item, () => {
|
37
|
-
element.removeClass('active');
|
38
|
-
}, { passive: true });
|
39
|
-
});
|
40
|
-
});
|
41
|
-
};
|
@@ -1,65 +0,0 @@
|
|
1
|
-
import { $dom } from '../library/dom';
|
2
|
-
import { vendorCss, vendorJs } from '../library/loadFile';
|
3
|
-
export const postFancybox = (p) => {
|
4
|
-
if ($dom(p + ' .md img')) {
|
5
|
-
vendorCss('fancybox');
|
6
|
-
vendorCss('justifiedGallery');
|
7
|
-
vendorJs('fancybox', () => {
|
8
|
-
const q = jQuery.noConflict();
|
9
|
-
$dom.each(p + ' p.gallery', (element) => {
|
10
|
-
const box = document.createElement('div');
|
11
|
-
box.className = 'gallery';
|
12
|
-
box.attr('data-height', String(element.attr('data-height') || 220));
|
13
|
-
box.innerHTML = element.innerHTML.replace(/<br>/g, '');
|
14
|
-
element.parentNode.insertBefore(box, element);
|
15
|
-
element.remove();
|
16
|
-
});
|
17
|
-
$dom.each(p + ' .md img:not(.emoji):not(.vemoji)', (element) => {
|
18
|
-
const $image = q(element);
|
19
|
-
const imageLink = $image.attr('data-src') || $image.attr('src'); // 替换
|
20
|
-
const $imageWrapLink = $image.wrap('<a class="fancybox" href="' + imageLink + '" itemscope itemtype="https://schema.org/ImageObject" itemprop="url"></a>').parent('a');
|
21
|
-
let info;
|
22
|
-
let captionClass = 'image-info';
|
23
|
-
if (!$image.is('a img')) {
|
24
|
-
$image.data('safe-src', imageLink);
|
25
|
-
if (!$image.is('.gallery img')) {
|
26
|
-
$imageWrapLink.attr('data-fancybox', 'default').attr('rel', 'default');
|
27
|
-
}
|
28
|
-
else {
|
29
|
-
captionClass = 'jg-caption';
|
30
|
-
}
|
31
|
-
}
|
32
|
-
if ((info = element.attr('title'))) {
|
33
|
-
$imageWrapLink.attr('data-caption', info);
|
34
|
-
const para = document.createElement('span');
|
35
|
-
const txt = document.createTextNode(info);
|
36
|
-
para.appendChild(txt);
|
37
|
-
para.addClass(captionClass);
|
38
|
-
element.insertAfter(para);
|
39
|
-
}
|
40
|
-
});
|
41
|
-
$dom.each(p + ' div.gallery', (el, i) => {
|
42
|
-
// @ts-ignore
|
43
|
-
q(el).justifiedGallery({
|
44
|
-
rowHeight: q(el).data('height') || 120,
|
45
|
-
rel: 'gallery-' + i
|
46
|
-
}).on('jg.complete', function () {
|
47
|
-
q(this).find('a').each((k, ele) => {
|
48
|
-
ele.attr('data-fancybox', 'gallery-' + i);
|
49
|
-
});
|
50
|
-
});
|
51
|
-
});
|
52
|
-
q.fancybox.defaults.hash = false;
|
53
|
-
q(p + ' .fancybox').fancybox({
|
54
|
-
loop: true,
|
55
|
-
// @ts-ignore
|
56
|
-
helpers: {
|
57
|
-
overlay: {
|
58
|
-
locked: false
|
59
|
-
}
|
60
|
-
}
|
61
|
-
});
|
62
|
-
// @ts-ignore
|
63
|
-
}, window.jQuery);
|
64
|
-
}
|
65
|
-
};
|