hexo-theme-solitude 1.8.10 → 1.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_config.yml +1 -0
- package/languages/default.yml +3 -0
- package/languages/en.yml +3 -0
- package/languages/zh-CN.yml +3 -0
- package/languages/zh-TW.yml +3 -0
- package/layout/includes/footer.pug +1 -1
- package/layout/includes/head/page_config.pug +1 -1
- package/layout/includes/inject/body.pug +5 -5
- package/layout/includes/inject/head.pug +1 -1
- package/layout/includes/page/music.pug +6 -1
- package/layout/includes/widgets/aside/asideWebInfo.pug +12 -4
- package/layout/includes/widgets/home/carousel.pug +27 -21
- package/layout/includes/widgets/post/post-ai.pug +2 -2
- package/layout/includes/widgets/post/postMeta.pug +6 -2
- package/layout/includes/widgets/third-party/comments/artalk.pug +3 -3
- package/layout/includes/widgets/third-party/comments/twikoo.pug +4 -2
- package/layout/includes/widgets/third-party/comments/valine.pug +5 -3
- package/layout/includes/widgets/third-party/comments/waline.pug +4 -2
- package/package.json +1 -1
- package/plugins.yml +5 -1
- package/source/css/_layout/header.styl +7 -6
- package/source/css/_page/_home/carousel.styl +73 -89
- package/source/css/_page/links.styl +1 -1
- package/source/js/barrage_comment.js +63 -70
- package/source/js/covercolor/api.js +35 -52
- package/source/js/covercolor/local.js +22 -27
- package/source/js/main.js +473 -566
- package/source/js/music.js +15 -5
- package/source/js/right_menu.js +38 -47
- package/source/js/search/local.js +16 -11
- package/source/js/utils.js +109 -136
package/source/js/music.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
/**
|
2
2
|
* Music Player
|
3
|
-
*
|
4
|
-
* date: 2024-03-19
|
5
|
-
* update: 2024-03-19
|
3
|
+
* @description Initialize the music player and add event listeners to control the player
|
6
4
|
*/
|
7
|
-
|
8
5
|
class ScoMusicPlayer {
|
6
|
+
constructor() {
|
7
|
+
this.init();
|
8
|
+
}
|
9
9
|
init() {
|
10
10
|
this.getCustomPlayList();
|
11
11
|
this.addEventListenerToDocument();
|
@@ -106,6 +106,16 @@ class ScoMusicPlayer {
|
|
106
106
|
break;
|
107
107
|
}
|
108
108
|
}
|
109
|
+
destroy() {
|
110
|
+
document.removeEventListener("keydown", this.handleKeydown);
|
111
|
+
}
|
109
112
|
}
|
110
113
|
|
111
|
-
|
114
|
+
/**
|
115
|
+
* Initialize the music player
|
116
|
+
*/
|
117
|
+
function initializeMusicPlayer() {
|
118
|
+
let exitingMusic = window.scoMusic;
|
119
|
+
if (exitingMusic) exitingMusic.destroy();
|
120
|
+
window.scoMusic = new ScoMusicPlayer();
|
121
|
+
}
|
package/source/js/right_menu.js
CHANGED
@@ -93,19 +93,8 @@ const rm = {
|
|
93
93
|
utils.snackbarShow(GLOBAL_CONFIG.right_menu.img_error, false, 2000)
|
94
94
|
}
|
95
95
|
},
|
96
|
-
copyImage:
|
97
|
-
|
98
|
-
const response = await fetch(imgUrl);
|
99
|
-
const blob = await response.blob();
|
100
|
-
const data = new ClipboardItem({
|
101
|
-
'image/png': blob
|
102
|
-
});
|
103
|
-
await navigator.clipboard.write([data]);
|
104
|
-
|
105
|
-
utils.snackbarShow(GLOBAL_CONFIG.lang.copy.success, false, 3e3)
|
106
|
-
} catch (error) {
|
107
|
-
utils.snackbarShow(GLOBAL_CONFIG.right_menu.img_error, false, 2000)
|
108
|
-
}
|
96
|
+
copyImage: function (imgUrl = this.domsrc) {
|
97
|
+
window.open(imgUrl)
|
109
98
|
},
|
110
99
|
mode: (darkmode) => (darkmode ? document.querySelector('.menu-darkmode-text').textContent = GLOBAL_CONFIG.right_menu.mode.light : document.querySelector('.menu-darkmode-text').textContent = GLOBAL_CONFIG.right_menu.mode.dark) && rm.hideRightMenu(),
|
111
100
|
barrage: (enable) => (enable ? document.querySelector(".menu-commentBarrage-text").textContent = GLOBAL_CONFIG.right_menu.barrage.open : document.querySelector(".menu-commentBarrage-text").textContent = GLOBAL_CONFIG.right_menu.barrage.close) && rm.hideRightMenu()
|
@@ -185,51 +174,53 @@ window.oncontextmenu = (ele) => {
|
|
185
174
|
return false;
|
186
175
|
}
|
187
176
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
rm.menuItems.
|
192
|
-
rm.menuItems.
|
177
|
+
(function() {
|
178
|
+
const addEventListener = (element, event, handler) => element.addEventListener(event, handler);
|
179
|
+
|
180
|
+
addEventListener(rm.menuItems.back, 'click', () => window.history.back() || rm.hideRightMenu());
|
181
|
+
addEventListener(rm.menuItems.forward, 'click', () => window.history.forward() || rm.hideRightMenu());
|
182
|
+
addEventListener(rm.menuItems.refresh, 'click', () => window.location.reload());
|
183
|
+
addEventListener(rm.menuItems.top, 'click', () => sco.toTop() || rm.hideRightMenu());
|
193
184
|
|
194
185
|
if (GLOBAL_CONFIG.right_menu.music) {
|
195
|
-
rm.menuItems.music[0]
|
196
|
-
sco.musicToggle()
|
197
|
-
rm.hideRightMenu()
|
198
|
-
})
|
199
|
-
rm.menuItems.music[1]
|
200
|
-
document.querySelector('meting-js').aplayer.skipBack()
|
201
|
-
rm.hideRightMenu()
|
202
|
-
})
|
203
|
-
rm.menuItems.music[2]
|
204
|
-
document.querySelector('meting-js').aplayer.skipForward()
|
205
|
-
rm.hideRightMenu()
|
206
|
-
})
|
207
|
-
rm.menuItems.music[3]
|
186
|
+
addEventListener(rm.menuItems.music[0], 'click', () => {
|
187
|
+
sco.musicToggle();
|
188
|
+
rm.hideRightMenu();
|
189
|
+
});
|
190
|
+
addEventListener(rm.menuItems.music[1], 'click', () => {
|
191
|
+
document.querySelector('meting-js').aplayer.skipBack();
|
192
|
+
rm.hideRightMenu();
|
193
|
+
});
|
194
|
+
addEventListener(rm.menuItems.music[2], 'click', () => {
|
195
|
+
document.querySelector('meting-js').aplayer.skipForward();
|
196
|
+
rm.hideRightMenu();
|
197
|
+
});
|
198
|
+
addEventListener(rm.menuItems.music[3], 'click', () => {
|
208
199
|
const title = Array.from(document.querySelectorAll('.aplayer-title')).map(e => e.innerText)[0];
|
209
|
-
rm.copyText(title)
|
210
|
-
})
|
200
|
+
rm.copyText(title);
|
201
|
+
});
|
211
202
|
}
|
212
203
|
|
213
|
-
rm.menuItems.copy
|
204
|
+
addEventListener(rm.menuItems.copy, 'click', () => {
|
214
205
|
if (GLOBAL_CONFIG.copyright) {
|
215
|
-
const {limit, author, link, source, info} = GLOBAL_CONFIG.copyright
|
206
|
+
const {limit, author, link, source, info} = GLOBAL_CONFIG.copyright;
|
216
207
|
if (selectTextNow.length > limit) {
|
217
|
-
selectTextNow = `${selectTextNow}\n\n${author}\n${link}${window.location.href}\n${source}\n${info}
|
208
|
+
selectTextNow = `${selectTextNow}\n\n${author}\n${link}${window.location.href}\n${source}\n${info}`;
|
218
209
|
}
|
219
210
|
}
|
220
|
-
rm.copyText(selectTextNow)
|
221
|
-
rm.hideRightMenu()
|
222
|
-
})
|
211
|
+
rm.copyText(selectTextNow);
|
212
|
+
rm.hideRightMenu();
|
213
|
+
});
|
223
214
|
|
224
|
-
if(utils.saveToLocal.get('commentBarrageSwitch')!==null){
|
225
|
-
rm.menuItems.barrage && rm.barrage(!utils.saveToLocal.get('commentBarrageSwitch'))
|
215
|
+
if(utils.saveToLocal.get('commentBarrageSwitch') !== null){
|
216
|
+
rm.menuItems.barrage && rm.barrage(!utils.saveToLocal.get('commentBarrageSwitch'));
|
226
217
|
}
|
227
218
|
|
228
|
-
rm.menuItems.paste
|
229
|
-
GLOBAL_CONFIG.comment && rm.menuItems.comment
|
230
|
-
rm.menuItems.new
|
231
|
-
rm.menuItems.downloadImg
|
232
|
-
rm.menuItems.copyImg
|
233
|
-
}()
|
219
|
+
addEventListener(rm.menuItems.paste, 'click', () => rm.pasteText() && rm.hideRightMenu());
|
220
|
+
GLOBAL_CONFIG.comment && addEventListener(rm.menuItems.comment, 'click', () => rm.hideRightMenu() || sco.toTalk(selectTextNow));
|
221
|
+
addEventListener(rm.menuItems.new, 'click', () => window.open(rm.domhref) && rm.hideRightMenu());
|
222
|
+
addEventListener(rm.menuItems.downloadImg, 'click', () => rm.downloadImage() && rm.hideRightMenu());
|
223
|
+
addEventListener(rm.menuItems.copyImg, 'click', () => rm.copyImage() && rm.hideRightMenu());
|
224
|
+
})();
|
234
225
|
|
235
226
|
is_rm = true
|
@@ -1,4 +1,4 @@
|
|
1
|
-
window.
|
1
|
+
window.addEventListener("load", () => {
|
2
2
|
let store = [];
|
3
3
|
const $searchMask = document.getElementById("search-mask");
|
4
4
|
const $searchDialog = document.querySelector("#local-search .search-dialog");
|
@@ -30,7 +30,7 @@ window.onload = () => {
|
|
30
30
|
|
31
31
|
const addEventTagList = () => {
|
32
32
|
const list = document.querySelectorAll("#local-search .tag-list");
|
33
|
-
if(list.length > 0){
|
33
|
+
if (list.length > 0) {
|
34
34
|
list.forEach(el => el.addEventListener("click", (e) => closeSearch()))
|
35
35
|
}
|
36
36
|
}
|
@@ -44,15 +44,15 @@ window.onload = () => {
|
|
44
44
|
|
45
45
|
searchFnOnce();
|
46
46
|
|
47
|
-
const searchClickFn = () =>{
|
47
|
+
const searchClickFn = () => {
|
48
48
|
utils.addEventListenerPjax(document.querySelector("#search-button > .search"), "click", openSearch);
|
49
49
|
|
50
|
-
GLOBAL_CONFIG.right_menu && document.getElementById("menu-search").addEventListener("click", function (){
|
50
|
+
GLOBAL_CONFIG.right_menu && document.getElementById("menu-search").addEventListener("click", function () {
|
51
51
|
rm.hideRightMenu();
|
52
52
|
openSearch();
|
53
|
-
let t=document.getElementsByClassName('search-box-input')[0];
|
53
|
+
let t = document.getElementsByClassName('search-box-input')[0];
|
54
54
|
let evt = document.createEvent('HTMLEvents');
|
55
|
-
evt.initEvent('input', true,true)
|
55
|
+
evt.initEvent('input', true, true)
|
56
56
|
t.value = selectTextNow
|
57
57
|
t.dispatchEvent(evt)
|
58
58
|
})
|
@@ -81,6 +81,7 @@ window.onload = () => {
|
|
81
81
|
})
|
82
82
|
.catch(err => console.error("Error loading search data:", err));
|
83
83
|
}
|
84
|
+
|
84
85
|
let query = ''
|
85
86
|
let currentPage = 0;
|
86
87
|
const resultsPerPage = 10;
|
@@ -104,19 +105,22 @@ window.onload = () => {
|
|
104
105
|
}
|
105
106
|
});
|
106
107
|
}
|
108
|
+
|
107
109
|
function clearSearchResults() {
|
108
110
|
const $results = document.getElementById("search-results");
|
109
111
|
const $pagination = document.getElementById("search-pagination");
|
110
112
|
const $tips = document.getElementById("search-tips");
|
111
|
-
|
113
|
+
|
112
114
|
$results.innerHTML = '';
|
113
115
|
$pagination.innerHTML = '';
|
114
116
|
$tips.innerHTML = '';
|
115
117
|
}
|
118
|
+
|
116
119
|
function search(query) {
|
117
120
|
const regex = new RegExp(query.split('').join('.*'), 'i');
|
118
121
|
return store.filter(page => regex.test(page.title) || regex.test(page.content));
|
119
|
-
}
|
122
|
+
}
|
123
|
+
|
120
124
|
function renderResults(results, page) {
|
121
125
|
const $search_results = document.getElementById("search-results");
|
122
126
|
$search_results.innerHTML = '';
|
@@ -146,12 +150,12 @@ window.onload = () => {
|
|
146
150
|
count.innerHTML = GLOBAL_CONFIG.lang.search.count.replace(/\$\{count}/, results.length)
|
147
151
|
$tips.appendChild(count);
|
148
152
|
}
|
149
|
-
|
153
|
+
|
150
154
|
function highlightSearchKeyword(text, keyword) {
|
151
155
|
const regex = new RegExp(`(${keyword.split(' ').join('|')})`, 'gi');
|
152
156
|
return text.replace(regex, '<em>$1</em>');
|
153
157
|
}
|
154
|
-
|
158
|
+
|
155
159
|
function renderPagination(totalResults) {
|
156
160
|
const totalPages = Math.ceil(totalResults / resultsPerPage);
|
157
161
|
const paginationContainer = document.getElementById("search-pagination");
|
@@ -178,6 +182,7 @@ window.onload = () => {
|
|
178
182
|
}
|
179
183
|
paginationContainer.appendChild(paginationList);
|
180
184
|
}
|
185
|
+
|
181
186
|
init();
|
182
187
|
initUI();
|
183
188
|
window.addEventListener('DOMContentLoaded', (event) => {
|
@@ -186,4 +191,4 @@ window.onload = () => {
|
|
186
191
|
window.addEventListener('pjax:complete', () => {
|
187
192
|
searchClickFn()
|
188
193
|
})
|
189
|
-
}
|
194
|
+
});
|
package/source/js/utils.js
CHANGED
@@ -1,75 +1,63 @@
|
|
1
1
|
(() => {
|
2
2
|
const utilsFn = {
|
3
|
-
throttle: (func, wait,
|
4
|
-
let timeout,
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
func.apply(context, args)
|
10
|
-
context = args = null
|
11
|
-
}
|
3
|
+
throttle: (func, wait, {leading = true, trailing = true} = {}) => {
|
4
|
+
let timeout, previous = 0;
|
5
|
+
const later = (context, args) => {
|
6
|
+
timeout = previous = leading === false ? 0 : Date.now();
|
7
|
+
func.apply(context, args);
|
8
|
+
};
|
12
9
|
return function () {
|
13
|
-
const now =
|
14
|
-
if (!previous &&
|
15
|
-
const remaining = wait - (now - previous)
|
16
|
-
context = this
|
17
|
-
args = arguments
|
10
|
+
const now = Date.now();
|
11
|
+
if (!previous && leading === false) previous = now;
|
12
|
+
const remaining = wait - (now - previous);
|
18
13
|
if (remaining <= 0 || remaining > wait) {
|
19
14
|
if (timeout) {
|
20
|
-
clearTimeout(timeout)
|
21
|
-
timeout = null
|
15
|
+
clearTimeout(timeout);
|
16
|
+
timeout = null;
|
22
17
|
}
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
} else if (!timeout && options.trailing !== false) {
|
27
|
-
timeout = setTimeout(later, remaining)
|
18
|
+
later(this, arguments);
|
19
|
+
} else if (!timeout && trailing !== false) {
|
20
|
+
timeout = setTimeout(() => later(this, arguments), remaining);
|
28
21
|
}
|
29
|
-
}
|
22
|
+
};
|
30
23
|
},
|
31
24
|
fadeIn: (ele, time) => ele.style.cssText = `display:block;animation: to_show ${time}s`,
|
32
25
|
fadeOut: (ele, time) => {
|
33
|
-
|
34
|
-
ele.style.cssText = "display: none; animation: '' "
|
35
|
-
ele.removeEventListener('animationend',
|
36
|
-
}
|
37
|
-
ele.
|
26
|
+
const resetStyles = () => {
|
27
|
+
ele.style.cssText = "display: none; animation: '' ";
|
28
|
+
ele.removeEventListener('animationend', resetStyles);
|
29
|
+
};
|
30
|
+
ele.addEventListener('animationend', resetStyles);
|
31
|
+
ele.style.animation = `to_hide ${time}s`;
|
38
32
|
},
|
39
33
|
sidebarPaddingR: () => {
|
40
|
-
const
|
41
|
-
|
42
|
-
|
43
|
-
if (innerWidth !== clientWidth) {
|
44
|
-
document.body.style.paddingRight = paddingRight + 'px'
|
34
|
+
const paddingRight = window.innerWidth - document.body.clientWidth;
|
35
|
+
if (paddingRight > 0) {
|
36
|
+
document.body.style.paddingRight = `${paddingRight}px`;
|
45
37
|
}
|
46
38
|
},
|
47
|
-
snackbarShow: (text, showAction, duration) => {
|
48
|
-
|
49
|
-
const dur = (typeof duration !== 'undefined') ? duration : 5000
|
50
|
-
document.styleSheets[0].addRule(':root', '--efu-snackbar-time:' + dur + 'ms!important')
|
39
|
+
snackbarShow: (text, showAction = false, duration = 5000) => {
|
40
|
+
document.styleSheets[0].addRule(':root', `--efu-snackbar-time:${duration}ms!important`);
|
51
41
|
Snackbar.show({
|
52
|
-
text
|
53
|
-
showAction
|
54
|
-
duration
|
42
|
+
text,
|
43
|
+
showAction,
|
44
|
+
duration,
|
55
45
|
pos: 'top-center'
|
56
|
-
})
|
46
|
+
});
|
57
47
|
},
|
58
48
|
copy: async (text) => {
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
utils.snackbarShow(GLOBAL_CONFIG.lang.copy.error, false, 2000)
|
64
|
-
}
|
49
|
+
const message = await navigator.clipboard.writeText(text)
|
50
|
+
.then(() => GLOBAL_CONFIG.lang.copy.success)
|
51
|
+
.catch(() => GLOBAL_CONFIG.lang.copy.error);
|
52
|
+
utils.snackbarShow(message, false, 2000);
|
65
53
|
},
|
66
54
|
getEleTop: ele => {
|
67
|
-
let actualTop =
|
68
|
-
while (ele) {
|
69
|
-
|
70
|
-
|
55
|
+
let actualTop = ele.offsetTop;
|
56
|
+
while (ele.offsetParent) {
|
57
|
+
ele = ele.offsetParent;
|
58
|
+
actualTop += ele.offsetTop;
|
71
59
|
}
|
72
|
-
return actualTop
|
60
|
+
return actualTop;
|
73
61
|
},
|
74
62
|
randomNum: (length) => {
|
75
63
|
return Math.floor(Math.random() * length)
|
@@ -79,36 +67,29 @@
|
|
79
67
|
return Math.floor(timeDiff / (1000 * 3600 * 24));
|
80
68
|
},
|
81
69
|
scrollToDest: (pos, time = 500) => {
|
82
|
-
const currentPos = window.pageYOffset
|
83
|
-
const isNavFixed = document.getElementById('page-header').classList.contains('nav-fixed')
|
84
|
-
|
70
|
+
const currentPos = window.pageYOffset;
|
71
|
+
const isNavFixed = document.getElementById('page-header').classList.contains('nav-fixed');
|
72
|
+
pos = currentPos > pos || isNavFixed ? pos - 70 : pos;
|
73
|
+
|
85
74
|
if ('scrollBehavior' in document.documentElement.style) {
|
86
|
-
window.scrollTo({
|
87
|
-
|
88
|
-
behavior: 'smooth'
|
89
|
-
})
|
90
|
-
return
|
75
|
+
window.scrollTo({top: pos, behavior: 'smooth'});
|
76
|
+
return;
|
91
77
|
}
|
92
|
-
|
93
|
-
const distance = pos - currentPos
|
94
|
-
|
95
|
-
start =
|
96
|
-
const progress = currentTime - start
|
78
|
+
|
79
|
+
const distance = pos - currentPos;
|
80
|
+
const step = currentTime => {
|
81
|
+
const start = start || currentTime;
|
82
|
+
const progress = currentTime - start;
|
83
|
+
|
97
84
|
if (progress < time) {
|
98
|
-
window.scrollTo(0, currentPos + distance * progress / time)
|
99
|
-
window.requestAnimationFrame(step)
|
85
|
+
window.scrollTo(0, currentPos + distance * progress / time);
|
86
|
+
window.requestAnimationFrame(step);
|
100
87
|
} else {
|
101
|
-
window.scrollTo(0, pos)
|
88
|
+
window.scrollTo(0, pos);
|
102
89
|
}
|
103
|
-
}
|
104
|
-
|
105
|
-
|
106
|
-
return [...ele.parentNode.children].filter((child) => {
|
107
|
-
if (selector) {
|
108
|
-
return child !== ele && child.matches(selector)
|
109
|
-
}
|
110
|
-
return child !== ele
|
111
|
-
})
|
90
|
+
};
|
91
|
+
|
92
|
+
window.requestAnimationFrame(step);
|
112
93
|
},
|
113
94
|
isMobile: () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),
|
114
95
|
isHidden: e => 0 === e.offsetHeight && 0 === e.offsetWidth,
|
@@ -119,16 +100,16 @@
|
|
119
100
|
})
|
120
101
|
},
|
121
102
|
animateIn: (ele, text) => {
|
122
|
-
ele.style
|
123
|
-
ele.style.animation = text
|
103
|
+
Object.assign(ele.style, {display: 'block', animation: text});
|
124
104
|
},
|
125
105
|
animateOut: (ele, text) => {
|
126
|
-
|
127
|
-
ele.style.display = ''
|
128
|
-
ele.style.animation = ''
|
129
|
-
ele.removeEventListener('animationend',
|
130
|
-
}
|
131
|
-
ele.
|
106
|
+
const resetAnimation = () => {
|
107
|
+
ele.style.display = '';
|
108
|
+
ele.style.animation = '';
|
109
|
+
ele.removeEventListener('animationend', resetAnimation);
|
110
|
+
};
|
111
|
+
ele.addEventListener('animationend', resetAnimation);
|
112
|
+
ele.style.animation = text;
|
132
113
|
},
|
133
114
|
wrap: (selector, eleType, options) => {
|
134
115
|
const createEle = document.createElement(eleType)
|
@@ -138,68 +119,63 @@
|
|
138
119
|
selector.parentNode.insertBefore(createEle, selector)
|
139
120
|
createEle.appendChild(selector)
|
140
121
|
},
|
141
|
-
lazyloadImg:
|
122
|
+
lazyloadImg: () => {
|
142
123
|
window.lazyLoadInstance = new LazyLoad({
|
143
124
|
elements_selector: 'img',
|
144
125
|
threshold: 0,
|
145
126
|
data_src: 'lazy-src',
|
146
|
-
callback_error:
|
147
|
-
|
148
|
-
}
|
149
|
-
})
|
127
|
+
callback_error: img => img.src = GLOBAL_CONFIG.lazyload.error
|
128
|
+
});
|
150
129
|
},
|
151
130
|
lightbox: function (selector) {
|
152
131
|
const lightboxType = GLOBAL_CONFIG.lightbox;
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
132
|
+
const options = {
|
133
|
+
class: 'fancybox',
|
134
|
+
'data-fancybox': 'gallery',
|
135
|
+
};
|
136
|
+
|
137
|
+
if (lightboxType === 'mediumZoom') {
|
138
|
+
mediumZoom && mediumZoom(selector, {background: "var(--efu-card-bg)"});
|
139
|
+
} else if (lightboxType === 'fancybox') {
|
140
|
+
selector.forEach(i => {
|
141
|
+
if (i.parentNode.tagName !== 'A') {
|
142
|
+
options.href = options['data-thumb'] = i.dataset.lazySrc || i.src;
|
143
|
+
options['data-caption'] = i.title || i.alt || '';
|
144
|
+
utils.wrap(i, 'a', options);
|
145
|
+
}
|
146
|
+
});
|
147
|
+
|
148
|
+
if (!window.fancyboxRun) {
|
149
|
+
Fancybox.bind('[data-fancybox]', {
|
150
|
+
Hash: false,
|
151
|
+
Thumbs: {showOnStart: false},
|
152
|
+
Images: {Panzoom: {maxScale: 4}},
|
153
|
+
Carousel: {transition: 'slide'},
|
154
|
+
Toolbar: {
|
155
|
+
display: {
|
156
|
+
left: ['infobar'],
|
157
|
+
middle: ['zoomIn', 'zoomOut', 'toggle1to1', 'rotateCCW', 'rotateCW', 'flipX', 'flipY'],
|
158
|
+
right: ['slideshow', 'thumbs', 'close']
|
159
|
+
}
|
169
160
|
}
|
170
161
|
});
|
171
|
-
|
172
|
-
|
173
|
-
Hash: false,
|
174
|
-
Thumbs: {showOnStart: false},
|
175
|
-
Images: {Panzoom: {maxScale: 4}},
|
176
|
-
Carousel: {transition: 'slide'},
|
177
|
-
Toolbar: {
|
178
|
-
display: {
|
179
|
-
left: ['infobar'],
|
180
|
-
middle: ['zoomIn', 'zoomOut', 'toggle1to1', 'rotateCCW', 'rotateCW', 'flipX', 'flipY'],
|
181
|
-
right: ['slideshow', 'thumbs', 'close']
|
182
|
-
}
|
183
|
-
}
|
184
|
-
});
|
185
|
-
window.fancyboxRun = true;
|
186
|
-
}
|
187
|
-
break;
|
162
|
+
window.fancyboxRun = true;
|
163
|
+
}
|
188
164
|
}
|
189
165
|
},
|
190
166
|
diffDate: (d, more = false) => {
|
191
167
|
const dateNow = new Date();
|
192
168
|
const datePost = new Date(d);
|
193
|
-
const dateDiff = dateNow - datePost;
|
169
|
+
const dateDiff = dateNow - datePost;
|
194
170
|
const minute = 60000;
|
195
171
|
const hour = 3600000;
|
196
172
|
const day = 86400000;
|
197
173
|
const month = 2592000000;
|
198
174
|
const {time} = GLOBAL_CONFIG.lang;
|
199
|
-
|
175
|
+
const dayCount = Math.floor(dateDiff / day)
|
176
|
+
if (!more) return dayCount
|
200
177
|
const minuteCount = Math.floor(dateDiff / minute)
|
201
178
|
const hourCount = Math.floor(dateDiff / hour)
|
202
|
-
const dayCount = Math.floor(dateDiff / day)
|
203
179
|
const monthCount = Math.floor(dateDiff / month)
|
204
180
|
if (monthCount > 12) return datePost.toISOString().slice(0, 10)
|
205
181
|
if (monthCount >= 1) return `${monthCount} ${time.month}`
|
@@ -209,17 +185,14 @@
|
|
209
185
|
return time.just
|
210
186
|
},
|
211
187
|
loadComment: (dom, callback) => {
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
} else {
|
221
|
-
callback()
|
222
|
-
}
|
188
|
+
const observerItem = 'IntersectionObserver' in window ? new IntersectionObserver((entries) => {
|
189
|
+
if (entries[0].isIntersecting) {
|
190
|
+
callback();
|
191
|
+
observerItem.disconnect();
|
192
|
+
}
|
193
|
+
}, {threshold: [0]}) : null;
|
194
|
+
|
195
|
+
observerItem ? observerItem.observe(dom) : callback();
|
223
196
|
},
|
224
197
|
}
|
225
198
|
window.utils = {...window.utils, ...utilsFn};
|