@mlikiowa/nanaeo 1.0.1702968276783 → 1.0.1702969117186
Sign up to get free protection for your applications and to get access to all the features.
- package/2022/08/04/NewBlog/index.html +1 -3473
- package/2022/08/13/GaussWave/index.html +1 -3407
- package/about/index.html +1 -3236
- package/archives/2022/08/index.html +1 -3411
- package/archives/2022/index.html +1 -3411
- package/archives/index.html +1 -3308
- package/categories/DevLog/index.html +1 -3351
- package/categories/SiteLog/index.html +1 -3351
- package/categories/index.html +1 -3174
- package/content.json +1 -1
- package/css/Readme.html +1 -9
- package/css/first.css +2 -1504
- package/css/style.css +2 -7106
- package/friends/index.html +1 -3661
- package/index.html +1 -3421
- package/js/app.js +2 -1223
- package/js/plugins/aplayer.js +2 -186
- package/js/plugins/parallax.js +2 -191
- package/js/plugins/rightMenu.js +2 -577
- package/js/plugins/rightMenus.js +2 -618
- package/js/plugins/tags/contributors.js +2 -92
- package/js/plugins/tags/friends.js +2 -93
- package/js/plugins/tags/sites.js +2 -96
- package/js/search/hexo.js +2 -192
- package/maps/css/first.css.map +1 -0
- package/maps/css/style.css.map +1 -0
- package/maps/js/app.js.map +1 -0
- package/maps/js/plugins/aplayer.js.map +1 -0
- package/maps/js/plugins/parallax.js.map +1 -0
- package/maps/js/plugins/rightMenu.js.map +1 -0
- package/maps/js/plugins/rightMenus.js.map +1 -0
- package/maps/js/plugins/tags/contributors.js.map +1 -0
- package/maps/js/plugins/tags/friends.js.map +1 -0
- package/maps/js/plugins/tags/sites.js.map +1 -0
- package/maps/js/search/hexo.js.map +1 -0
- package/maps/volantis-sw.js.map +1 -0
- package/package.json +1 -1
- package/tags/DevLog/index.html +1 -3351
- package/tags/Gauss/index.html +1 -3351
- package/tags/Hexo/index.html +1 -3351
- package/tags/HexoThemes/index.html +1 -3351
- package/tags/SiteLog/index.html +1 -3351
- package/tags/index.html +1 -3159
- package/volantis-sw.js +2 -797
package/js/plugins/rightMenus.js
CHANGED
@@ -1,618 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
defaultEvent: ['copyText', 'copyLink', 'copyPaste', 'copyAll', 'copyCut', 'copyImg', 'printMode', 'readMode'],
|
4
|
-
defaultGroup: ['navigation', 'inputBox', 'seletctText', 'elementCheck', 'elementImage', 'articlePage'],
|
5
|
-
messageRightMenu: volantis.GLOBAL_CONFIG.plugins.message.enable && volantis.GLOBAL_CONFIG.plugins.message.rightmenu.enable,
|
6
|
-
corsAnywhere: volantis.GLOBAL_CONFIG.plugins.rightmenus.options.corsAnywhere,
|
7
|
-
urlRegx: /^((https|http)?:\/\/)+[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,
|
8
|
-
imgRegx: /\.(jpe?g|png|webp|svg|gif|jifi)(-|_|!|\?|\/)?.*$/,
|
9
|
-
|
10
|
-
/**
|
11
|
-
* 加载右键菜单
|
12
|
-
*/
|
13
|
-
initialMenu: () => {
|
14
|
-
RightMenus.fun.init();
|
15
|
-
volantis.pjax.send(() => {
|
16
|
-
RightMenus.fun.hideMenu();
|
17
|
-
if (volantis.isReadModel) RightMenus.fun.readMode();
|
18
|
-
})
|
19
|
-
},
|
20
|
-
|
21
|
-
/**
|
22
|
-
* 读取剪切板
|
23
|
-
* @returns text
|
24
|
-
*/
|
25
|
-
readClipboard: async () => {
|
26
|
-
let clipboardText;
|
27
|
-
const result = await navigator.permissions.query({ name: 'clipboard-read' });
|
28
|
-
switch (result.state) {
|
29
|
-
case 'granted':
|
30
|
-
case 'prompt':
|
31
|
-
clipboardText = await navigator.clipboard.readText()
|
32
|
-
break;
|
33
|
-
default:
|
34
|
-
window.clipboardRead = false;
|
35
|
-
break;
|
36
|
-
}
|
37
|
-
return clipboardText;
|
38
|
-
},
|
39
|
-
|
40
|
-
/**
|
41
|
-
* 写入文本到剪切板
|
42
|
-
* @param {String} text
|
43
|
-
*/
|
44
|
-
writeClipText: text => {
|
45
|
-
return navigator.clipboard
|
46
|
-
.writeText(text)
|
47
|
-
.then(() => {
|
48
|
-
return Promise.resolve()
|
49
|
-
})
|
50
|
-
.catch(err => {
|
51
|
-
return Promise.reject(err)
|
52
|
-
})
|
53
|
-
},
|
54
|
-
|
55
|
-
/**
|
56
|
-
* 写入图片到剪切板
|
57
|
-
* @param {*} link
|
58
|
-
* @param {*} success
|
59
|
-
* @param {*} error
|
60
|
-
*/
|
61
|
-
writeClipImg: async (link, success, error) => {
|
62
|
-
const image = new Image;
|
63
|
-
image.crossOrigin = "Anonymous";
|
64
|
-
image.addEventListener('load', () => {
|
65
|
-
let canvas = document.createElement("canvas");
|
66
|
-
let context = canvas.getContext("2d");
|
67
|
-
canvas.width = image.width;
|
68
|
-
canvas.height = image.height;
|
69
|
-
context.drawImage(image, 0, 0);
|
70
|
-
canvas.toBlob(blob => {
|
71
|
-
navigator.clipboard.write([
|
72
|
-
new ClipboardItem({ 'image/png': blob })
|
73
|
-
]).then(e => {
|
74
|
-
success(e)
|
75
|
-
}).catch(e => {
|
76
|
-
error(e)
|
77
|
-
})
|
78
|
-
}, 'image/png')
|
79
|
-
}, false)
|
80
|
-
image.src = `${link}?(lll¬ω¬)`;
|
81
|
-
},
|
82
|
-
|
83
|
-
/**
|
84
|
-
* 粘贴文本到剪切板
|
85
|
-
* @param {*} elemt
|
86
|
-
* @param {*} value
|
87
|
-
*/
|
88
|
-
insertAtCaret: (elemt, value) => {
|
89
|
-
const startPos = elemt.selectionStart,
|
90
|
-
endPos = elemt.selectionEnd;
|
91
|
-
if (document.selection) {
|
92
|
-
elemt.focus();
|
93
|
-
var sel = document.selection.createRange();
|
94
|
-
sel.text = value;
|
95
|
-
elemt.focus();
|
96
|
-
} else {
|
97
|
-
if (startPos || startPos == '0') {
|
98
|
-
var scrollTop = elemt.scrollTop;
|
99
|
-
elemt.value = elemt.value.substring(0, startPos) + value + elemt.value.substring(endPos, elemt.value.length);
|
100
|
-
elemt.focus();
|
101
|
-
elemt.selectionStart = startPos + value.length;
|
102
|
-
elemt.selectionEnd = startPos + value.length;
|
103
|
-
elemt.scrollTop = scrollTop;
|
104
|
-
} else {
|
105
|
-
elemt.value += value;
|
106
|
-
elemt.focus();
|
107
|
-
}
|
108
|
-
}
|
109
|
-
}
|
110
|
-
}
|
111
|
-
|
112
|
-
/**
|
113
|
-
* 事件处理区域
|
114
|
-
*/
|
115
|
-
RightMenus.fun = (() => {
|
116
|
-
const rightMenuConfig = volantis.GLOBAL_CONFIG.plugins.rightmenus;
|
117
|
-
|
118
|
-
const
|
119
|
-
fn = {},
|
120
|
-
_rightMenuWrapper = document.getElementById('rightmenu-wrapper'),
|
121
|
-
_rightMenuContent = document.getElementById('rightmenu-content'),
|
122
|
-
_rightMenuList = document.querySelectorAll('#rightmenu-content li.menuLoad-Content'),
|
123
|
-
_rightMenuListWithHr = document.querySelectorAll('#rightmenu-content li, #rightmenu-content hr, #menuMusic'),
|
124
|
-
_readBkg = document.getElementById('read_bkg'),
|
125
|
-
_menuMusic = document.getElementById('menuMusic'),
|
126
|
-
_backward = document.querySelector('#menuMusic .backward'),
|
127
|
-
_toggle = document.querySelector('#menuMusic .toggle'),
|
128
|
-
_forward = document.querySelector('#menuMusic .forward');
|
129
|
-
|
130
|
-
// 公共数据
|
131
|
-
let globalData = {
|
132
|
-
mouseEvent: null,
|
133
|
-
isInputBox: false,
|
134
|
-
selectText: '',
|
135
|
-
inputValue: '',
|
136
|
-
isLink: false,
|
137
|
-
linkUrl: '',
|
138
|
-
isMediaLink: false,
|
139
|
-
mediaLinkUrl: '',
|
140
|
-
isImage: false,
|
141
|
-
isArticle: false,
|
142
|
-
pathName: '',
|
143
|
-
isReadClipboard: true,
|
144
|
-
isShowMusic: false,
|
145
|
-
statusCheck: false
|
146
|
-
}
|
147
|
-
const globalDataBackup = Object.assign({}, globalData);
|
148
|
-
|
149
|
-
/**
|
150
|
-
* 初始化监听事件处理
|
151
|
-
*/
|
152
|
-
fn.initEvent = () => {
|
153
|
-
fn.elementAppend();
|
154
|
-
fn.contextmenu();
|
155
|
-
fn.menuEvent();
|
156
|
-
}
|
157
|
-
|
158
|
-
/**
|
159
|
-
* 预置元素设定
|
160
|
-
*/
|
161
|
-
fn.elementAppend = () => {
|
162
|
-
// 阅读模式
|
163
|
-
if (_readBkg) _readBkg.parentNode.removeChild(_readBkg);
|
164
|
-
const readBkg = document.createElement("div");
|
165
|
-
readBkg.className = "common_read_bkg common_read_hide";
|
166
|
-
readBkg.id = "read_bkg";
|
167
|
-
window.document.body.appendChild(readBkg);
|
168
|
-
}
|
169
|
-
|
170
|
-
/**
|
171
|
-
* 右键菜单位置设定
|
172
|
-
* @param {*} event
|
173
|
-
*/
|
174
|
-
fn.menuPosition = (event) => {
|
175
|
-
try {
|
176
|
-
let mouseClientX = event.clientX;
|
177
|
-
let mouseClientY = event.clientY;
|
178
|
-
let screenWidth = document.documentElement.clientWidth || document.body.clientWidth;
|
179
|
-
let screenHeight = document.documentElement.clientHeight || document.body.clientHeight;
|
180
|
-
|
181
|
-
_rightMenuWrapper.style.display = 'block';
|
182
|
-
fn.menuControl(event);
|
183
|
-
|
184
|
-
let menuWidth = _rightMenuContent.offsetWidth;
|
185
|
-
let menuHeight = _rightMenuContent.offsetHeight;
|
186
|
-
let showLeft = mouseClientX + menuWidth > screenWidth ? mouseClientX - menuWidth + 10 : mouseClientX;
|
187
|
-
let showTop = mouseClientY + menuHeight > screenHeight ? mouseClientY - menuHeight + 10 : mouseClientY;
|
188
|
-
showTop = mouseClientY + menuHeight > screenHeight && showTop < menuHeight && mouseClientY < menuHeight ?
|
189
|
-
showTop + (screenHeight - menuHeight - showTop - 10) : showTop;
|
190
|
-
_rightMenuWrapper.style.left = `${showLeft}px`;
|
191
|
-
_rightMenuWrapper.style.top = `${showTop}px`;
|
192
|
-
if (volantis.GLOBAL_CONFIG.plugins.message.rightmenu.notice) fn.menuNotic();
|
193
|
-
} catch (error) {
|
194
|
-
console.error(error);
|
195
|
-
fn.hideMenu();
|
196
|
-
return true;
|
197
|
-
}
|
198
|
-
return false;
|
199
|
-
}
|
200
|
-
|
201
|
-
/**
|
202
|
-
* 菜单项控制
|
203
|
-
* @param {*} event
|
204
|
-
*/
|
205
|
-
fn.menuControl = (event) => {
|
206
|
-
fn.globalDataSet(event);
|
207
|
-
if (!!_menuMusic) _menuMusic.style.display = globalData.isShowMusic ? 'block' : 'none';
|
208
|
-
_rightMenuList.forEach(item => {
|
209
|
-
item.style.display = 'none';
|
210
|
-
const nodeName = item.firstElementChild.nodeName;
|
211
|
-
const groupName = item.firstElementChild.getAttribute('data-group');
|
212
|
-
const itemEvent = item.firstElementChild.getAttribute('data-event');
|
213
|
-
if (globalData.statusCheck || globalData.isArticle) {
|
214
|
-
switch (groupName) {
|
215
|
-
case 'inputBox':
|
216
|
-
if (globalData.isInputBox) {
|
217
|
-
item.style.display = 'block';
|
218
|
-
if (itemEvent === 'copyCut' && !globalData.selectText) item.style.display = 'none';
|
219
|
-
if (itemEvent === 'copyAll' && !globalData.inputValue) item.style.display = 'none';
|
220
|
-
if (itemEvent === 'copyPaste' && !globalData.isReadClipboard) item.style.display = 'none';
|
221
|
-
}
|
222
|
-
break;
|
223
|
-
case 'seletctText':
|
224
|
-
if (!!globalData.selectText) item.style.display = 'block';
|
225
|
-
break;
|
226
|
-
case 'elementCheck':
|
227
|
-
if (globalData.isLink || globalData.isMediaLink) item.style.display = 'block';
|
228
|
-
break;
|
229
|
-
case 'elementImage':
|
230
|
-
if (globalData.isImage) item.style.display = 'block';
|
231
|
-
break;
|
232
|
-
case 'articlePage':
|
233
|
-
if (globalData.isArticle) item.style.display = 'block';
|
234
|
-
break;
|
235
|
-
default:
|
236
|
-
item.style.display = nodeName === 'A'
|
237
|
-
? globalData.isArticle && !globalData.statusCheck && rightMenuConfig.options.articleShowLink
|
238
|
-
? 'block'
|
239
|
-
: 'none'
|
240
|
-
: 'block';
|
241
|
-
break;
|
242
|
-
}
|
243
|
-
} else if (nodeName === 'A' || RightMenus.defaultGroup.every(item => { return groupName !== item })) {
|
244
|
-
item.style.display = 'block';
|
245
|
-
}
|
246
|
-
})
|
247
|
-
|
248
|
-
// 执行外部事件
|
249
|
-
volantis.mouseEvent = event;
|
250
|
-
volantis.rightmenu.method.handle.start()
|
251
|
-
|
252
|
-
// 过滤 HR 元素
|
253
|
-
let elementHrItem = { item: null, hide: true };
|
254
|
-
_rightMenuListWithHr.forEach((item) => {
|
255
|
-
if (item.nodeName === "HR") {
|
256
|
-
item.style.display = 'block';
|
257
|
-
if (!elementHrItem.item) {
|
258
|
-
elementHrItem.item = item;
|
259
|
-
return;
|
260
|
-
}
|
261
|
-
if (elementHrItem.hide || elementHrItem.item.nextElementSibling.nodeName === "hr") {
|
262
|
-
elementHrItem.item.style.display = 'none';
|
263
|
-
}
|
264
|
-
elementHrItem.item = item;
|
265
|
-
elementHrItem.hide = true;
|
266
|
-
} else {
|
267
|
-
if (item.style.display === 'block' && elementHrItem.hide) {
|
268
|
-
elementHrItem.hide = false;
|
269
|
-
}
|
270
|
-
}
|
271
|
-
})
|
272
|
-
if (!!elementHrItem.item && elementHrItem.hide) elementHrItem.item.style.display = 'none';
|
273
|
-
}
|
274
|
-
|
275
|
-
/**
|
276
|
-
* 元素状态判断/全局数据设置
|
277
|
-
* @param {*} event
|
278
|
-
*/
|
279
|
-
fn.globalDataSet = (event) => {
|
280
|
-
globalData = Object.assign({}, globalDataBackup);
|
281
|
-
globalData.mouseEvent = event;
|
282
|
-
globalData.selectText = window.getSelection().toString();
|
283
|
-
|
284
|
-
// 判断是否为输入框
|
285
|
-
if (event.target.tagName.toLowerCase() === 'input' || event.target.tagName.toLowerCase() === 'textarea') {
|
286
|
-
globalData.isInputBox = true;
|
287
|
-
globalData.inputValue = event.target.value;
|
288
|
-
}
|
289
|
-
|
290
|
-
// 判断是否允许读取剪切板
|
291
|
-
if (globalData.isInputBox && window.clipboardRead === false) {
|
292
|
-
globalData.isReadClipboard = false;
|
293
|
-
}
|
294
|
-
|
295
|
-
// 判断是否包含链接
|
296
|
-
if (!!event.target.href && RightMenus.urlRegx.test(event.target.href)) {
|
297
|
-
globalData.isLink = true;
|
298
|
-
globalData.linkUrl = event.target.href;
|
299
|
-
}
|
300
|
-
|
301
|
-
// 判断是否包含媒体链接
|
302
|
-
if (!!event.target.currentSrc && RightMenus.urlRegx.test(event.target.currentSrc)) {
|
303
|
-
globalData.isMediaLink = true;
|
304
|
-
globalData.mediaLinkUrl = event.target.currentSrc;
|
305
|
-
}
|
306
|
-
|
307
|
-
// 判断是否为图片地址
|
308
|
-
if (globalData.isMediaLink && RightMenus.imgRegx.test(globalData.mediaLinkUrl)) {
|
309
|
-
globalData.isImage = true;
|
310
|
-
}
|
311
|
-
|
312
|
-
// 判断是否为文章页面
|
313
|
-
if (!!(document.querySelector('#post.article') || null)) {
|
314
|
-
globalData.isArticle = true;
|
315
|
-
globalData.pathName = window.location.pathname;
|
316
|
-
}
|
317
|
-
|
318
|
-
// 判断是否显示音乐控制器
|
319
|
-
if (volantis.GLOBAL_CONFIG.plugins.aplayer?.enable
|
320
|
-
&& typeof RightMenuAplayer !== 'undefined'
|
321
|
-
&& RightMenuAplayer.APlayer.player !== undefined) {
|
322
|
-
if (rightMenuConfig.options.musicAlwaysShow
|
323
|
-
|| RightMenuAplayer.APlayer.status === 'play'
|
324
|
-
|| RightMenuAplayer.APlayer.status === 'undefined') {
|
325
|
-
globalData.isShowMusic = true;
|
326
|
-
}
|
327
|
-
}
|
328
|
-
|
329
|
-
// 设定校验状态
|
330
|
-
if (!!globalData.selectText || globalData.isInputBox || globalData.isLink || globalData.isMediaLink) {
|
331
|
-
globalData.statusCheck = true;
|
332
|
-
}
|
333
|
-
}
|
334
|
-
|
335
|
-
/**
|
336
|
-
* 全局右键监听函数
|
337
|
-
*/
|
338
|
-
fn.contextmenu = () => {
|
339
|
-
window.document.oncontextmenu = (event) => {
|
340
|
-
if (event.ctrlKey || document.body.offsetWidth <= 500) {
|
341
|
-
fn.hideMenu();
|
342
|
-
return true;
|
343
|
-
}
|
344
|
-
return fn.menuPosition(event);
|
345
|
-
}
|
346
|
-
|
347
|
-
_rightMenuWrapper.oncontextmenu = (event) => {
|
348
|
-
event.stopPropagation();
|
349
|
-
event.preventDefault();
|
350
|
-
return false;
|
351
|
-
}
|
352
|
-
|
353
|
-
window.removeEventListener('blur', fn.hideMenu);
|
354
|
-
window.addEventListener('blur', fn.hideMenu);
|
355
|
-
document.body.removeEventListener('click', fn.hideMenu);
|
356
|
-
document.body.addEventListener('click', fn.hideMenu);
|
357
|
-
}
|
358
|
-
|
359
|
-
/**
|
360
|
-
* 菜单项事件处理函数
|
361
|
-
*/
|
362
|
-
fn.menuEvent = () => {
|
363
|
-
_rightMenuList.forEach(item => {
|
364
|
-
let eventName = item.firstElementChild.getAttribute('data-event');
|
365
|
-
const id = item.firstElementChild.getAttribute('id');
|
366
|
-
const groupName = item.firstElementChild.getAttribute('data-group');
|
367
|
-
if (item.firstElementChild.nodeName === "A") return;
|
368
|
-
item.addEventListener('click', () => {
|
369
|
-
try {
|
370
|
-
if (RightMenus.defaultEvent.every(item => { return eventName !== item })) {
|
371
|
-
if (groupName === 'seletctText') {
|
372
|
-
RightMenusFunction[id](globalData.selectText)
|
373
|
-
} else if (groupName === 'elementCheck') {
|
374
|
-
RightMenusFunction[id](globalData.isLink ? globalData.linkUrl : globalData.mediaLinkUrl)
|
375
|
-
} else if (groupName === 'elementImage') {
|
376
|
-
RightMenusFunction[id](globalData.mediaLinkUrl)
|
377
|
-
} else {
|
378
|
-
RightMenusFunction[id]()
|
379
|
-
}
|
380
|
-
} else {
|
381
|
-
fn[eventName]()
|
382
|
-
}
|
383
|
-
} catch (error) {
|
384
|
-
if (volantis.GLOBAL_CONFIG.debug === "rightMenus") {
|
385
|
-
console.error({
|
386
|
-
id: id,
|
387
|
-
error: error,
|
388
|
-
globalData: globalData,
|
389
|
-
groupName: groupName,
|
390
|
-
eventName: eventName
|
391
|
-
});
|
392
|
-
}
|
393
|
-
if (RightMenus.messageRightMenu) {
|
394
|
-
VolantisApp.message('错误提示', error, {
|
395
|
-
icon: rightMenuConfig.options.iconPrefix + ' fa-exclamation-square red',
|
396
|
-
time: '15000'
|
397
|
-
});
|
398
|
-
}
|
399
|
-
}
|
400
|
-
})
|
401
|
-
})
|
402
|
-
|
403
|
-
if (_forward && _toggle && _forward) {
|
404
|
-
_backward.onclick = (e) => {
|
405
|
-
e.preventDefault();
|
406
|
-
e.stopPropagation();
|
407
|
-
RightMenuAplayer.aplayerBackward();
|
408
|
-
}
|
409
|
-
_toggle.onclick = (e) => {
|
410
|
-
e.preventDefault();
|
411
|
-
e.stopPropagation();
|
412
|
-
RightMenuAplayer.aplayerToggle();
|
413
|
-
}
|
414
|
-
_forward.onclick = (e) => {
|
415
|
-
e.preventDefault();
|
416
|
-
e.stopPropagation();
|
417
|
-
RightMenuAplayer.aplayerForward();
|
418
|
-
}
|
419
|
-
}
|
420
|
-
}
|
421
|
-
|
422
|
-
/**
|
423
|
-
* 隐藏菜单显示
|
424
|
-
*/
|
425
|
-
fn.hideMenu = () => {
|
426
|
-
_rightMenuWrapper.style.display = null;
|
427
|
-
_rightMenuWrapper.style.left = null;
|
428
|
-
_rightMenuWrapper.style.top = null;
|
429
|
-
}
|
430
|
-
|
431
|
-
/**
|
432
|
-
* 右键菜单覆盖提示
|
433
|
-
*/
|
434
|
-
fn.menuNotic = () => {
|
435
|
-
const NoticeRightMenu = localStorage.getItem('NoticeRightMenu') === 'true';
|
436
|
-
if (RightMenus.messageRightMenu && !NoticeRightMenu)
|
437
|
-
VolantisApp.message('右键菜单', '唤醒原系统菜单请使用:<kbd>Ctrl</kbd> + <kbd>右键</kbd>', {
|
438
|
-
icon: rightMenuConfig.options.iconPrefix + ' fa-exclamation-square red',
|
439
|
-
displayMode: 1,
|
440
|
-
time: 9000
|
441
|
-
}, () => {
|
442
|
-
localStorage.setItem('NoticeRightMenu', 'true')
|
443
|
-
});
|
444
|
-
}
|
445
|
-
|
446
|
-
fn.copyText = () => {
|
447
|
-
VolantisApp.utilWriteClipText(globalData.selectText)
|
448
|
-
.then(() => {
|
449
|
-
if (RightMenus.messageRightMenu) {
|
450
|
-
VolantisApp.messageCopyright();
|
451
|
-
}
|
452
|
-
}).catch(e => {
|
453
|
-
if (RightMenus.messageRightMenu) {
|
454
|
-
VolantisApp.message('系统提示', e, {
|
455
|
-
icon: rightMenuConfig.options.iconPrefix + ' fa-exclamation-square red',
|
456
|
-
displayMode: 1,
|
457
|
-
time: 9000
|
458
|
-
});
|
459
|
-
}
|
460
|
-
})
|
461
|
-
}
|
462
|
-
|
463
|
-
fn.copyLink = () => {
|
464
|
-
VolantisApp.utilWriteClipText(globalData.linkUrl || globalData.mediaLinkUrl)
|
465
|
-
.then(() => {
|
466
|
-
if (RightMenus.messageRightMenu) {
|
467
|
-
VolantisApp.messageCopyright();
|
468
|
-
}
|
469
|
-
}).catch(e => {
|
470
|
-
if (RightMenus.messageRightMenu) {
|
471
|
-
VolantisApp.message('系统提示', e, {
|
472
|
-
icon: rightMenuConfig.options.iconPrefix + ' fa-exclamation-square red',
|
473
|
-
displayMode: 1,
|
474
|
-
time: 9000
|
475
|
-
});
|
476
|
-
}
|
477
|
-
})
|
478
|
-
}
|
479
|
-
|
480
|
-
fn.copyAll = () => {
|
481
|
-
globalData.mouseEvent.target.select();
|
482
|
-
}
|
483
|
-
|
484
|
-
fn.copyPaste = async () => {
|
485
|
-
const result = await RightMenus.readClipboard() || '';
|
486
|
-
if (RightMenus.messageRightMenu && window.clipboardRead === false) {
|
487
|
-
VolantisApp.message('系统提示', '未授予剪切板读取权限!');
|
488
|
-
} else if (RightMenus.messageRightMenu && result === '') {
|
489
|
-
VolantisApp.message('系统提示', '仅支持复制文本内容!');
|
490
|
-
} else {
|
491
|
-
RightMenus.insertAtCaret(globalData.mouseEvent.target, result);
|
492
|
-
}
|
493
|
-
}
|
494
|
-
|
495
|
-
fn.copyCut = () => {
|
496
|
-
const statrPos = globalData.mouseEvent.target.selectionStart;
|
497
|
-
const endPos = globalData.mouseEvent.target.selectionEnd;
|
498
|
-
const inputStr = globalData.inputValue;
|
499
|
-
fn.copyText(globalData.selectText);
|
500
|
-
globalData.mouseEvent.target.value = inputStr.substring(0, statrPos) + inputStr.substring(endPos, inputStr.length);
|
501
|
-
globalData.mouseEvent.target.selectionStart = statrPos;
|
502
|
-
globalData.mouseEvent.target.selectionEnd = statrPos;
|
503
|
-
globalData.mouseEvent.target.focus();
|
504
|
-
}
|
505
|
-
|
506
|
-
fn.copyImg = () => {
|
507
|
-
if (volantis.GLOBAL_CONFIG.plugins.message.rightmenu.notice) {
|
508
|
-
VolantisApp.message('系统提示', '复制中,请等待。', {
|
509
|
-
icon: rightMenuConfig.options.iconPrefix + ' fa-images'
|
510
|
-
})
|
511
|
-
}
|
512
|
-
RightMenus.writeClipImg(globalData.mediaLinkUrl, e => {
|
513
|
-
if (RightMenus.messageRightMenu) {
|
514
|
-
VolantisApp.hideMessage();
|
515
|
-
VolantisApp.message('系统提示', '图片复制成功!', {
|
516
|
-
icon: rightMenuConfig.options.iconPrefix + ' fa-images'
|
517
|
-
});
|
518
|
-
}
|
519
|
-
}, (e) => {
|
520
|
-
console.error(e);
|
521
|
-
if (RightMenus.messageRightMenu) {
|
522
|
-
VolantisApp.hideMessage();
|
523
|
-
VolantisApp.message('系统提示', '复制失败:' + e, {
|
524
|
-
icon: rightMenuConfig.options.iconPrefix + ' fa-exclamation-square red',
|
525
|
-
time: 9000
|
526
|
-
});
|
527
|
-
}
|
528
|
-
})
|
529
|
-
}
|
530
|
-
|
531
|
-
fn.printMode = () => {
|
532
|
-
if (window.location.pathname === globalData.pathName) {
|
533
|
-
if (RightMenus.messageRightMenu) {
|
534
|
-
const message = '是否打印当前页面?<br><em style="font-size: 80%">建议打印时勾选背景图形</em><br>'
|
535
|
-
VolantisApp.question('', message, { time: 9000 }, () => { fn.printHtml() })
|
536
|
-
} else {
|
537
|
-
fn.printHtml()
|
538
|
-
}
|
539
|
-
}
|
540
|
-
}
|
541
|
-
|
542
|
-
fn.printHtml = () => {
|
543
|
-
if (volantis.isReadModel) fn.readMode();
|
544
|
-
DOMController.setAttribute('details', 'open', 'true');
|
545
|
-
DOMController.removeList([
|
546
|
-
'.cus-article-bkg', '.iziToast-overlay', '.iziToast-wrapper', '.prev-next',
|
547
|
-
'footer', '#l_header', '#l_cover', '#l_side', '#comments', '#s-top', '#BKG',
|
548
|
-
'#rightmenu-wrapper', '.nav-tabs', '.parallax-mirror', '.new-meta-item.share', 'div.footer'
|
549
|
-
]);
|
550
|
-
DOMController.setStyleList([
|
551
|
-
['body', 'backgroundColor', 'unset'], ['#l_main', 'width', '100%'], ['#post', 'boxShadow', 'none'],
|
552
|
-
['#post', 'background', 'none'], ['#post', 'padding', '0'], ['h1', 'textAlign', 'center'],
|
553
|
-
['h1', 'fontWeight', '600'], ['h1', 'fontSize', '2rem'], ['h1', 'marginBottom', '20px'],
|
554
|
-
['.tab-pane', 'display', 'block'], ['.tab-content', 'borderTop', 'none'], ['.highlight>table pre', 'whiteSpace', 'pre-wrap'],
|
555
|
-
['.highlight>table pre', 'wordBreak', 'break-all'], ['.fancybox img', 'height', 'auto'], ['.fancybox img', 'weight', 'auto']
|
556
|
-
]);
|
557
|
-
setTimeout(() => {
|
558
|
-
window.print();
|
559
|
-
document.body.innerHTML = '';
|
560
|
-
window.location.reload();
|
561
|
-
}, 50);
|
562
|
-
}
|
563
|
-
|
564
|
-
fn.readMode = () => {
|
565
|
-
if (typeof ScrollReveal === 'function') ScrollReveal().clean('#comments');
|
566
|
-
DOMController.fadeToggleList([
|
567
|
-
document.querySelector('#l_header'), document.querySelector('footer'),
|
568
|
-
document.querySelector('#s-top'), document.querySelector('.article-meta#bottom'),
|
569
|
-
document.querySelector('.prev-next'), document.querySelector('#l_side'),
|
570
|
-
document.querySelector('#comments')
|
571
|
-
]);
|
572
|
-
DOMController.toggleClassList([
|
573
|
-
[document.querySelector('#l_main'), 'common_read'], [document.querySelector('#l_main'), 'common_read_main'],
|
574
|
-
[document.querySelector('#l_body'), 'common_read'], [document.querySelector('#safearea'), 'common_read'],
|
575
|
-
[document.querySelector('#pjax-container'), 'common_read'], [document.querySelector('#read_bkg'), 'common_read_hide'],
|
576
|
-
[document.querySelector('h1'), 'common_read_h1'], [document.querySelector('#post'), 'post_read'],
|
577
|
-
[document.querySelector('#l_cover'), 'read_cover'], [document.querySelector('.widget.toc-wrapper'), 'post_read']
|
578
|
-
]);
|
579
|
-
DOMController.setStyle('.copyright.license', 'margin', '15px 0');
|
580
|
-
volantis.isReadModel = volantis.isReadModel === undefined ? true : !volantis.isReadModel;
|
581
|
-
if (volantis.isReadModel) {
|
582
|
-
if (RightMenus.messageRightMenu) VolantisApp.message('系统提示', '阅读模式已开启,您可以点击屏幕空白处退出。', {
|
583
|
-
backgroundColor: 'var(--color-read-post)',
|
584
|
-
icon: rightMenuConfig.options.iconPrefix + ' fa-book-reader',
|
585
|
-
displayMode: 1,
|
586
|
-
time: 5000
|
587
|
-
});
|
588
|
-
document.querySelector('#l_body').removeEventListener('click', fn.readMode);
|
589
|
-
document.querySelector('#l_body').addEventListener('click', (event) => {
|
590
|
-
if (DOMController.hasClass(event.target, 'common_read')) {
|
591
|
-
fn.readMode();
|
592
|
-
}
|
593
|
-
});
|
594
|
-
} else {
|
595
|
-
document.querySelector('#l_body').removeEventListener('click', fn.readMode);
|
596
|
-
document.querySelector('#post').removeEventListener('click', fn.readMode);
|
597
|
-
DOMController.setStyle('.prev-next', 'display', 'flex');
|
598
|
-
DOMController.setStyle('.copyright.license', 'margin', '15px -40px');
|
599
|
-
}
|
600
|
-
}
|
601
|
-
|
602
|
-
return {
|
603
|
-
init: fn.initEvent,
|
604
|
-
hideMenu: fn.hideMenu,
|
605
|
-
readMode: fn.readMode
|
606
|
-
}
|
607
|
-
})()
|
608
|
-
|
609
|
-
Object.freeze(RightMenus);
|
610
|
-
volantis.requestAnimationFrame(() => {
|
611
|
-
if (document.readyState !== 'loading') {
|
612
|
-
RightMenus.initialMenu();
|
613
|
-
} else {
|
614
|
-
document.addEventListener("DOMContentLoaded", function () {
|
615
|
-
RightMenus.initialMenu();
|
616
|
-
})
|
617
|
-
}
|
618
|
-
});
|
1
|
+
"use strict";function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _regeneratorRuntime(){_regeneratorRuntime=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,n){return e[t]=n}}function l(e,t,n,r){var i=t&&t.prototype instanceof y?t:y,a=Object.create(i.prototype),c=new C(r||[]);return o(a,"_invoke",{value:_(e,n,c)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var p="suspendedStart",m="suspendedYield",h="executing",g="completed",f={};function y(){}function v(){}function b(){}var M={};s(M,a,(function(){return this}));var w=Object.getPrototypeOf,x=w&&w(w(O([])));x&&x!==n&&r.call(x,a)&&(M=x);var k=b.prototype=y.prototype=Object.create(M);function L(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function R(e,t){function n(o,i,a,c){var u=d(e[o],e,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==_typeof(l)&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,c)}),(function(e){n("throw",e,a,c)})):t.resolve(l).then((function(e){s.value=e,a(s)}),(function(e){return n("throw",e,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function _(t,n,r){var o=p;return function(i,a){if(o===h)throw new Error("Generator is already running");if(o===g){if("throw"===i)throw a;return{value:e,done:!0}}for(r.method=i,r.arg=a;;){var c=r.delegate;if(c){var u=E(c,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(o===p)throw o=g,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);o=h;var s=d(t,n,r);if("normal"===s.type){if(o=r.done?g:m,s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(o=g,r.method="throw",r.arg=s.arg)}}}function E(t,n){var r=n.method,o=t.iterator[r];if(o===e)return n.delegate=null,"throw"===r&&t.iterator["return"]&&(n.method="return",n.arg=e,E(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var i=d(o,t.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,f;var a=i.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,f):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,f)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function C(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function O(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function n(){for(;++o<t.length;)if(r.call(t,o))return n.value=t[o],n.done=!1,n;return n.value=e,n.done=!0,n};return i.next=i}}throw new TypeError(_typeof(t)+" is not iterable")}return v.prototype=b,o(k,"constructor",{value:b,configurable:!0}),o(b,"constructor",{value:v,configurable:!0}),v.displayName=s(b,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,b):(e.__proto__=b,s(e,u,"GeneratorFunction")),e.prototype=Object.create(k),e},t.awrap=function(e){return{__await:e}},L(R.prototype),s(R.prototype,c,(function(){return this})),t.AsyncIterator=R,t.async=function(e,n,r,o,i){void 0===i&&(i=Promise);var a=new R(l(e,n,r,o),i);return t.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},L(k),s(k,u,"Generator"),s(k,a,(function(){return this})),s(k,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function o(){for(;n.length;){var e=n.pop();if(e in t)return o.value=e,o.done=!1,o}return o.done=!0,o}},t.values=O,C.prototype={constructor:C,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(A),!t)for(var n in this)"t"===n.charAt(0)&&r.call(this,n)&&!isNaN(+n.slice(1))&&(this[n]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var n=this;function o(r,o){return c.type="throw",c.arg=t,n.next=r,o&&(n.method="next",n.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),A(n),f}},"catch":function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;A(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:O(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),f}},t}function asyncGeneratorStep(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(s){return void n(s)}c.done?t(u):Promise.resolve(u).then(r,o)}function _asyncToGenerator(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function a(e){asyncGeneratorStep(i,r,o,a,c,"next",e)}function c(e){asyncGeneratorStep(i,r,o,a,c,"throw",e)}a(undefined)}))}}var RightMenus={defaultEvent:["copyText","copyLink","copyPaste","copyAll","copyCut","copyImg","printMode","readMode"],defaultGroup:["navigation","inputBox","seletctText","elementCheck","elementImage","articlePage"],messageRightMenu:volantis.GLOBAL_CONFIG.plugins.message.enable&&volantis.GLOBAL_CONFIG.plugins.message.rightmenu.enable,corsAnywhere:volantis.GLOBAL_CONFIG.plugins.rightmenus.options.corsAnywhere,urlRegx:/^((https|http)?:\/\/)+[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,imgRegx:/\.(jpe?g|png|webp|svg|gif|jifi)(-|_|!|\?|\/)?.*$/,initialMenu:function(){RightMenus.fun.init(),volantis.pjax.send((function(){RightMenus.fun.hideMenu(),volantis.isReadModel&&RightMenus.fun.readMode()}))},readClipboard:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function t(){var e,n;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,navigator.permissions.query({name:"clipboard-read"});case 2:n=t.sent,t.t0=n.state,t.next="granted"===t.t0||"prompt"===t.t0?6:10;break;case 6:return t.next=8,navigator.clipboard.readText();case 8:return e=t.sent,t.abrupt("break",12);case 10:return window.clipboardRead=!1,t.abrupt("break",12);case 12:return t.abrupt("return",e);case 13:case"end":return t.stop()}}),t)})));return function(){return e.apply(this,arguments)}}(),writeClipText:function(e){return navigator.clipboard.writeText(e).then((function(){return Promise.resolve()}))["catch"]((function(e){return Promise.reject(e)}))},writeClipImg:function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function t(e,n,r){var o;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:(o=new Image).crossOrigin="Anonymous",o.addEventListener("load",(function(){var e=document.createElement("canvas"),t=e.getContext("2d");e.width=o.width,e.height=o.height,t.drawImage(o,0,0),e.toBlob((function(e){navigator.clipboard.write([new ClipboardItem({"image/png":e})]).then((function(e){n(e)}))["catch"]((function(e){r(e)}))}),"image/png")}),!1),o.src="".concat(e,"?(lll¬ω¬)");case 4:case"end":return t.stop()}}),t)})));return function(t,n,r){return e.apply(this,arguments)}}(),insertAtCaret:function(e,t){var n=e.selectionStart,r=e.selectionEnd;if(document.selection)e.focus(),document.selection.createRange().text=t,e.focus();else if(n||"0"==n){var o=e.scrollTop;e.value=e.value.substring(0,n)+t+e.value.substring(r,e.value.length),e.focus(),e.selectionStart=n+t.length,e.selectionEnd=n+t.length,e.scrollTop=o}else e.value+=t,e.focus()}};RightMenus.fun=function(){var e=volantis.GLOBAL_CONFIG.plugins.rightmenus,t={},n=document.getElementById("rightmenu-wrapper"),r=document.getElementById("rightmenu-content"),o=document.querySelectorAll("#rightmenu-content li.menuLoad-Content"),i=document.querySelectorAll("#rightmenu-content li, #rightmenu-content hr, #menuMusic"),a=document.getElementById("read_bkg"),c=document.getElementById("menuMusic"),u=document.querySelector("#menuMusic .backward"),s=document.querySelector("#menuMusic .toggle"),l=document.querySelector("#menuMusic .forward"),d={mouseEvent:null,isInputBox:!1,selectText:"",inputValue:"",isLink:!1,linkUrl:"",isMediaLink:!1,mediaLinkUrl:"",isImage:!1,isArticle:!1,pathName:"",isReadClipboard:!0,isShowMusic:!1,statusCheck:!1},p=Object.assign({},d);return t.initEvent=function(){t.elementAppend(),t.contextmenu(),t.menuEvent()},t.elementAppend=function(){a&&a.parentNode.removeChild(a);var e=document.createElement("div");e.className="common_read_bkg common_read_hide",e.id="read_bkg",window.document.body.appendChild(e)},t.menuPosition=function(e){try{var o=e.clientX,i=e.clientY,a=document.documentElement.clientWidth||document.body.clientWidth,c=document.documentElement.clientHeight||document.body.clientHeight;n.style.display="block",t.menuControl(e);var u=r.offsetWidth,s=r.offsetHeight,l=o+u>a?o-u+10:o,d=i+s>c?i-s+10:i;d=i+s>c&&d<s&&i<s?d+(c-s-d-10):d,n.style.left="".concat(l,"px"),n.style.top="".concat(d,"px"),volantis.GLOBAL_CONFIG.plugins.message.rightmenu.notice&&t.menuNotic()}catch(p){return console.error(p),t.hideMenu(),!0}return!1},t.menuControl=function(n){t.globalDataSet(n),c&&(c.style.display=d.isShowMusic?"block":"none"),o.forEach((function(t){t.style.display="none";var n=t.firstElementChild.nodeName,r=t.firstElementChild.getAttribute("data-group"),o=t.firstElementChild.getAttribute("data-event");if(d.statusCheck||d.isArticle)switch(r){case"inputBox":d.isInputBox&&(t.style.display="block","copyCut"!==o||d.selectText||(t.style.display="none"),"copyAll"!==o||d.inputValue||(t.style.display="none"),"copyPaste"!==o||d.isReadClipboard||(t.style.display="none"));break;case"seletctText":d.selectText&&(t.style.display="block");break;case"elementCheck":(d.isLink||d.isMediaLink)&&(t.style.display="block");break;case"elementImage":d.isImage&&(t.style.display="block");break;case"articlePage":d.isArticle&&(t.style.display="block");break;default:t.style.display="A"===n?d.isArticle&&!d.statusCheck&&e.options.articleShowLink?"block":"none":"block"}else("A"===n||RightMenus.defaultGroup.every((function(e){return r!==e})))&&(t.style.display="block")})),volantis.mouseEvent=n,volantis.rightmenu.method.handle.start();var r={item:null,hide:!0};i.forEach((function(e){if("HR"===e.nodeName){if(e.style.display="block",!r.item)return void(r.item=e);(r.hide||"hr"===r.item.nextElementSibling.nodeName)&&(r.item.style.display="none"),r.item=e,r.hide=!0}else"block"===e.style.display&&r.hide&&(r.hide=!1)})),r.item&&r.hide&&(r.item.style.display="none")},t.globalDataSet=function(t){var n;(d=Object.assign({},p)).mouseEvent=t,d.selectText=window.getSelection().toString(),"input"!==t.target.tagName.toLowerCase()&&"textarea"!==t.target.tagName.toLowerCase()||(d.isInputBox=!0,d.inputValue=t.target.value),d.isInputBox&&!1===window.clipboardRead&&(d.isReadClipboard=!1),t.target.href&&RightMenus.urlRegx.test(t.target.href)&&(d.isLink=!0,d.linkUrl=t.target.href),t.target.currentSrc&&RightMenus.urlRegx.test(t.target.currentSrc)&&(d.isMediaLink=!0,d.mediaLinkUrl=t.target.currentSrc),d.isMediaLink&&RightMenus.imgRegx.test(d.mediaLinkUrl)&&(d.isImage=!0),document.querySelector("#post.article")&&(d.isArticle=!0,d.pathName=window.location.pathname),null!==(n=volantis.GLOBAL_CONFIG.plugins.aplayer)&&void 0!==n&&n.enable&&"undefined"!=typeof RightMenuAplayer&&RightMenuAplayer.APlayer.player!==undefined&&(e.options.musicAlwaysShow||"play"===RightMenuAplayer.APlayer.status||"undefined"===RightMenuAplayer.APlayer.status)&&(d.isShowMusic=!0),(d.selectText||d.isInputBox||d.isLink||d.isMediaLink)&&(d.statusCheck=!0)},t.contextmenu=function(){window.document.oncontextmenu=function(e){return e.ctrlKey||document.body.offsetWidth<=500?(t.hideMenu(),!0):t.menuPosition(e)},n.oncontextmenu=function(e){return e.stopPropagation(),e.preventDefault(),!1},window.removeEventListener("blur",t.hideMenu),window.addEventListener("blur",t.hideMenu),document.body.removeEventListener("click",t.hideMenu),document.body.addEventListener("click",t.hideMenu)},t.menuEvent=function(){o.forEach((function(n){var r=n.firstElementChild.getAttribute("data-event"),o=n.firstElementChild.getAttribute("id"),i=n.firstElementChild.getAttribute("data-group");"A"!==n.firstElementChild.nodeName&&n.addEventListener("click",(function(){try{RightMenus.defaultEvent.every((function(e){return r!==e}))?"seletctText"===i?RightMenusFunction[o](d.selectText):"elementCheck"===i?RightMenusFunction[o](d.isLink?d.linkUrl:d.mediaLinkUrl):"elementImage"===i?RightMenusFunction[o](d.mediaLinkUrl):RightMenusFunction[o]():t[r]()}catch(n){"rightMenus"===volantis.GLOBAL_CONFIG.debug&&console.error({id:o,error:n,globalData:d,groupName:i,eventName:r}),RightMenus.messageRightMenu&&VolantisApp.message("错误提示",n,{icon:e.options.iconPrefix+" fa-exclamation-square red",time:"15000"})}}))})),l&&s&&l&&(u.onclick=function(e){e.preventDefault(),e.stopPropagation(),RightMenuAplayer.aplayerBackward()},s.onclick=function(e){e.preventDefault(),e.stopPropagation(),RightMenuAplayer.aplayerToggle()},l.onclick=function(e){e.preventDefault(),e.stopPropagation(),RightMenuAplayer.aplayerForward()})},t.hideMenu=function(){n.style.display=null,n.style.left=null,n.style.top=null},t.menuNotic=function(){var t="true"===localStorage.getItem("NoticeRightMenu");RightMenus.messageRightMenu&&!t&&VolantisApp.message("右键菜单","唤醒原系统菜单请使用:<kbd>Ctrl</kbd> + <kbd>右键</kbd>",{icon:e.options.iconPrefix+" fa-exclamation-square red",displayMode:1,time:9e3},(function(){localStorage.setItem("NoticeRightMenu","true")}))},t.copyText=function(){VolantisApp.utilWriteClipText(d.selectText).then((function(){RightMenus.messageRightMenu&&VolantisApp.messageCopyright()}))["catch"]((function(t){RightMenus.messageRightMenu&&VolantisApp.message("系统提示",t,{icon:e.options.iconPrefix+" fa-exclamation-square red",displayMode:1,time:9e3})}))},t.copyLink=function(){VolantisApp.utilWriteClipText(d.linkUrl||d.mediaLinkUrl).then((function(){RightMenus.messageRightMenu&&VolantisApp.messageCopyright()}))["catch"]((function(t){RightMenus.messageRightMenu&&VolantisApp.message("系统提示",t,{icon:e.options.iconPrefix+" fa-exclamation-square red",displayMode:1,time:9e3})}))},t.copyAll=function(){d.mouseEvent.target.select()},t.copyPaste=_asyncToGenerator(_regeneratorRuntime().mark((function m(){var e;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,RightMenus.readClipboard();case 2:if(t.t0=t.sent,t.t0){t.next=5;break}t.t0="";case 5:e=t.t0,RightMenus.messageRightMenu&&!1===window.clipboardRead?VolantisApp.message("系统提示","未授予剪切板读取权限!"):RightMenus.messageRightMenu&&""===e?VolantisApp.message("系统提示","仅支持复制文本内容!"):RightMenus.insertAtCaret(d.mouseEvent.target,e);case 7:case"end":return t.stop()}}),m)}))),t.copyCut=function(){var e=d.mouseEvent.target.selectionStart,n=d.mouseEvent.target.selectionEnd,r=d.inputValue;t.copyText(d.selectText),d.mouseEvent.target.value=r.substring(0,e)+r.substring(n,r.length),d.mouseEvent.target.selectionStart=e,d.mouseEvent.target.selectionEnd=e,d.mouseEvent.target.focus()},t.copyImg=function(){volantis.GLOBAL_CONFIG.plugins.message.rightmenu.notice&&VolantisApp.message("系统提示","复制中,请等待。",{icon:e.options.iconPrefix+" fa-images"}),RightMenus.writeClipImg(d.mediaLinkUrl,(function(t){RightMenus.messageRightMenu&&(VolantisApp.hideMessage(),VolantisApp.message("系统提示","图片复制成功!",{icon:e.options.iconPrefix+" fa-images"}))}),(function(t){console.error(t),RightMenus.messageRightMenu&&(VolantisApp.hideMessage(),VolantisApp.message("系统提示","复制失败:"+t,{icon:e.options.iconPrefix+" fa-exclamation-square red",time:9e3}))}))},t.printMode=function(){if(window.location.pathname===d.pathName)if(RightMenus.messageRightMenu){VolantisApp.question("",'是否打印当前页面?<br><em style="font-size: 80%">建议打印时勾选背景图形</em><br>',{time:9e3},(function(){t.printHtml()}))}else t.printHtml()},t.printHtml=function(){volantis.isReadModel&&t.readMode(),DOMController.setAttribute("details","open","true"),DOMController.removeList([".cus-article-bkg",".iziToast-overlay",".iziToast-wrapper",".prev-next","footer","#l_header","#l_cover","#l_side","#comments","#s-top","#BKG","#rightmenu-wrapper",".nav-tabs",".parallax-mirror",".new-meta-item.share","div.footer"]),DOMController.setStyleList([["body","backgroundColor","unset"],["#l_main","width","100%"],["#post","boxShadow","none"],["#post","background","none"],["#post","padding","0"],["h1","textAlign","center"],["h1","fontWeight","600"],["h1","fontSize","2rem"],["h1","marginBottom","20px"],[".tab-pane","display","block"],[".tab-content","borderTop","none"],[".highlight>table pre","whiteSpace","pre-wrap"],[".highlight>table pre","wordBreak","break-all"],[".fancybox img","height","auto"],[".fancybox img","weight","auto"]]),setTimeout((function(){window.print(),document.body.innerHTML="",window.location.reload()}),50)},t.readMode=function(){"function"==typeof ScrollReveal&&ScrollReveal().clean("#comments"),DOMController.fadeToggleList([document.querySelector("#l_header"),document.querySelector("footer"),document.querySelector("#s-top"),document.querySelector(".article-meta#bottom"),document.querySelector(".prev-next"),document.querySelector("#l_side"),document.querySelector("#comments")]),DOMController.toggleClassList([[document.querySelector("#l_main"),"common_read"],[document.querySelector("#l_main"),"common_read_main"],[document.querySelector("#l_body"),"common_read"],[document.querySelector("#safearea"),"common_read"],[document.querySelector("#pjax-container"),"common_read"],[document.querySelector("#read_bkg"),"common_read_hide"],[document.querySelector("h1"),"common_read_h1"],[document.querySelector("#post"),"post_read"],[document.querySelector("#l_cover"),"read_cover"],[document.querySelector(".widget.toc-wrapper"),"post_read"]]),DOMController.setStyle(".copyright.license","margin","15px 0"),volantis.isReadModel=volantis.isReadModel===undefined||!volantis.isReadModel,volantis.isReadModel?(RightMenus.messageRightMenu&&VolantisApp.message("系统提示","阅读模式已开启,您可以点击屏幕空白处退出。",{backgroundColor:"var(--color-read-post)",icon:e.options.iconPrefix+" fa-book-reader",displayMode:1,time:5e3}),document.querySelector("#l_body").removeEventListener("click",t.readMode),document.querySelector("#l_body").addEventListener("click",(function(e){DOMController.hasClass(e.target,"common_read")&&t.readMode()}))):(document.querySelector("#l_body").removeEventListener("click",t.readMode),document.querySelector("#post").removeEventListener("click",t.readMode),DOMController.setStyle(".prev-next","display","flex"),DOMController.setStyle(".copyright.license","margin","15px -40px"))},{init:t.initEvent,hideMenu:t.hideMenu,readMode:t.readMode}}(),Object.freeze(RightMenus),volantis.requestAnimationFrame((function(){"loading"!==document.readyState?RightMenus.initialMenu():document.addEventListener("DOMContentLoaded",(function(){RightMenus.initialMenu()}))}));
|
2
|
+
//# sourceMappingURL=../../maps/js/plugins/rightMenus.js.map
|