hexo-theme-shokax 0.3.13 → 0.4.0-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/_config.yml +16 -9
- package/layout/_mixin/comment.pug +4 -4
- package/layout/_partials/footer.pug +1 -1
- package/layout/_partials/head/head.pug +7 -1
- package/layout/_partials/header.pug +1 -1
- package/layout/_partials/layout.pug +0 -10
- package/layout/_partials/post/footer.pug +1 -2
- package/package.json +10 -5
- package/scripts/generaters/archive.js +1 -1
- package/scripts/generaters/script.js +64 -42
- package/scripts/helpers/asset.js +1 -1
- package/scripts/helpers/list_categories.js +0 -4
- package/scripts/plugin/lib/injects.js +1 -1
- package/source/js/_app/components/comments.ts +33 -0
- package/source/js/_app/components/sidebar.ts +239 -0
- package/source/js/_app/globals/globalVars.ts +99 -0
- package/source/js/_app/globals/handles.ts +123 -0
- package/source/js/_app/globals/themeColor.ts +64 -0
- package/source/js/_app/globals/thirdparty.ts +63 -0
- package/source/js/_app/globals/tools.ts +75 -0
- package/source/js/_app/library/anime.ts +110 -0
- package/source/js/_app/library/declare.d.ts +126 -0
- package/source/js/_app/library/dom.ts +26 -0
- package/source/js/_app/library/loadFile.ts +43 -0
- package/source/js/_app/library/proto.ts +141 -0
- package/source/js/_app/library/scriptPjax.ts +72 -0
- package/source/js/_app/library/storage.ts +12 -0
- package/source/js/_app/library/vue.ts +50 -0
- package/source/js/_app/page/common.ts +42 -0
- package/source/js/_app/page/fancybox.ts +71 -0
- package/source/js/_app/page/post.ts +266 -0
- package/source/js/_app/page/search.ts +135 -0
- package/source/js/_app/page/tab.ts +60 -0
- package/source/js/_app/pjax/domInit.ts +96 -0
- package/source/js/_app/pjax/refresh.ts +78 -0
- package/source/js/_app/pjax/siteInit.ts +72 -0
- package/source/js/_app/player.ts +799 -0
- package/source/assets/beian.webp +0 -0
- package/source/js/_app/components/sidebar.js +0 -209
- 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 -98
- package/source/js/_app/globals/themeColor.js +0 -62
- package/source/js/_app/globals/thirdparty.js +0 -62
- package/source/js/_app/globals/tools.js +0 -66
- package/source/js/_app/library/anime.js +0 -106
- 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 -52
- package/source/js/_app/pjax/siteInit.js +0 -51
- package/source/js/_app/player.js +0 -771
@@ -1,106 +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
|
-
// @ts-ignore
|
70
|
-
animation = type;
|
71
|
-
// @ts-ignore
|
72
|
-
display = type.display;
|
73
|
-
break;
|
74
|
-
}
|
75
|
-
anime(Object.assign({
|
76
|
-
targets: target,
|
77
|
-
duration: 200,
|
78
|
-
easing: 'linear',
|
79
|
-
begin() {
|
80
|
-
begin && begin();
|
81
|
-
},
|
82
|
-
complete() {
|
83
|
-
target.display(display);
|
84
|
-
complete && complete();
|
85
|
-
}
|
86
|
-
}, animation)).play();
|
87
|
-
};
|
88
|
-
export const pageScroll = (target, offset, complete) => {
|
89
|
-
// target: 滚动到的目标元素或坐标(number)
|
90
|
-
// offset: 可选的偏移量
|
91
|
-
// complete: 可选的回调函数,在动画完成时调用
|
92
|
-
anime({
|
93
|
-
// 动画目标
|
94
|
-
targets: typeof offset === 'number' && typeof target !== 'number' ? target.parentNode : document.scrollingElement,
|
95
|
-
// 动画持续时间
|
96
|
-
duration: 500,
|
97
|
-
// 动画缓动函数
|
98
|
-
easing: 'easeInOutQuad',
|
99
|
-
// 如果 offset 存在,则滚动到 offset,如果 target 是数字,则滚动到 target,如果 target 是 DOM 元素,则滚动到下述表达式
|
100
|
-
scrollTop: offset || (typeof target === 'number' ? target : (target ? target.getTop() + document.documentElement.scrollTop - siteNavHeight : 0)),
|
101
|
-
// 完成回调函数
|
102
|
-
complete() {
|
103
|
-
complete && complete();
|
104
|
-
}
|
105
|
-
}).play();
|
106
|
-
};
|
@@ -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
|
-
};
|