toast
This commit is contained in:
parent
c2889a5e8e
commit
74ca4f723b
|
@ -87,11 +87,11 @@ footer:
|
|||
- icon: '<img src="https://7.dusays.com/2021/02/14/25678f144c438.svg"/>'
|
||||
url: /atom.xml
|
||||
- icon: '<img src="https://7.dusays.com/2021/02/14/08a41b181ce68.svg"/>'
|
||||
url: https://github.com/xaoxuu
|
||||
url: /
|
||||
- icon: '<img src="https://7.dusays.com/2021/02/14/cf1ae151f9e83.svg"/>'
|
||||
url: https://music.163.com/#/user/home?id=63035382
|
||||
url: /
|
||||
- icon: '<img src="https://7.dusays.com/2021/02/14/942ebbf1a4b91.svg"/>'
|
||||
url: /comments/
|
||||
url: /
|
||||
license: '[CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/)'
|
||||
source: #'[GitHub](https://github.com/xaoxuu/hexo-theme-stellar)'
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@ page:
|
|||
filter: "%s's %s has %s articles"
|
||||
wiki: "%s has %s %s in total"
|
||||
|
||||
message:
|
||||
copied: Copied!
|
||||
|
||||
symbol:
|
||||
comma: ", "
|
||||
period: ". "
|
||||
|
|
|
@ -49,6 +49,9 @@ page:
|
|||
filter: '%s的%s共有%s篇文章'
|
||||
wiki: '%s共有%s个%s'
|
||||
|
||||
message:
|
||||
copied: 复制成功
|
||||
|
||||
symbol:
|
||||
comma: ","
|
||||
period: "。"
|
||||
|
|
|
@ -49,6 +49,9 @@ page:
|
|||
filter: '%s的%s共有%s篇文章'
|
||||
wiki: '%s共有%s个%s'
|
||||
|
||||
message:
|
||||
copied: 複製成功
|
||||
|
||||
symbol:
|
||||
comma: ","
|
||||
period: "。"
|
||||
|
|
|
@ -13,7 +13,12 @@ function layoutDiv() {
|
|||
el += '<div class="body"><ul>';
|
||||
page.references.forEach((item, i) => {
|
||||
el += '<li class="post-title">';
|
||||
el += '<a href="' + item.url + '" target="_blank" rel="external nofollow noopener noreferrer">';
|
||||
el += '<a href="' + item.url + '"';
|
||||
if (item.url.includes('://')) {
|
||||
el += ' target="_blank" rel="external nofollow noopener noreferrer">';
|
||||
} else {
|
||||
el += ' rel="noopener noreferrer">';
|
||||
}
|
||||
el += item.title || item.url;
|
||||
el += '</a>';
|
||||
el += '</li>';
|
||||
|
@ -44,9 +49,12 @@ function layoutDiv() {
|
|||
el += '<div class="social-wrap">';
|
||||
theme.article.share.forEach((item, i) => {
|
||||
if (['wechat', 'weibo', 'email', 'link'].includes(item)) {
|
||||
el += '<a class="social share-item ' + item + '" target="_blank" rel="external nofollow noopener noreferrer"';
|
||||
el += '<a class="social share-item ' + item + '"';
|
||||
if (item == 'weibo') {
|
||||
el += ' target="_blank" rel="external nofollow noopener noreferrer"';
|
||||
}
|
||||
if (item == 'wechat') {
|
||||
el += ' onclick="util.toggle_qrcode()"';
|
||||
el += ' onclick="util.toggle("qrcode-wechat")"';
|
||||
} else if (item == 'weibo') {
|
||||
el += ' href="https://service.weibo.com/share/share.php?url=' + page.permalink;
|
||||
el += '&title=' + (page.seo_title || page.title) + ' - ' + config.title;
|
||||
|
@ -61,7 +69,7 @@ function layoutDiv() {
|
|||
el += ' href="mailto:?subject=' + (page.title || page.seo_title) + ' - ' + config.title + '&'
|
||||
el += 'body=' + page.permalink + '"';
|
||||
} else if (item == 'link') {
|
||||
el += ' onclick="util.copy_link()"';
|
||||
el += ' onclick="util.copy("copy-link", "' + __('message.copied') + '")"';
|
||||
}
|
||||
el += '>';
|
||||
if (item == 'wechat') {
|
||||
|
|
|
@ -14,7 +14,14 @@ function layoutFooterDiv() {
|
|||
var el = '<footer class="footer"><div class="social-wrap">';
|
||||
theme.footer.social.forEach(item => {
|
||||
if (item.icon && item.url) {
|
||||
el += '<a class="social" href="' + url_for(item.url) + '" target="_blank" rel="external nofollow noopener noreferrer">' + item.icon + '</a>';
|
||||
el += '<a class="social" href="' + url_for(item.url) + '"';
|
||||
if (item.url.includes('://')) {
|
||||
el += ' target="_blank" rel="external nofollow noopener noreferrer">';
|
||||
} else {
|
||||
el += ' rel="noopener noreferrer">';
|
||||
}
|
||||
el += item.icon;
|
||||
el += '</a>';
|
||||
}
|
||||
});
|
||||
el += '</div></footer>';
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
div.toast
|
||||
max-width: 60%
|
||||
padding: 2rem 3rem
|
||||
line-height: 1.5
|
||||
color: var(--text-p1)
|
||||
font-weight: 500
|
||||
text-align: center
|
||||
border-radius: $border-card
|
||||
background: var(--card)
|
||||
position: fixed
|
||||
top: 50%
|
||||
left: 50%
|
||||
transform: translate(-50%, -50%)
|
||||
z-index: 9
|
||||
box-shadow: $boxshadow-float
|
|
@ -127,22 +127,39 @@ const util = {
|
|||
}
|
||||
},
|
||||
|
||||
copy_link: () => {
|
||||
const el = document.getElementById("copy-link");
|
||||
copy: (id, msg) => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) {
|
||||
el.select();
|
||||
document.execCommand("Copy");
|
||||
hud.toast(msg);
|
||||
}
|
||||
},
|
||||
|
||||
toggle_qrcode: () => {
|
||||
const el = document.getElementById("qrcode-wechat");
|
||||
toggle: (id) => {
|
||||
const el = document.getElementById(id);
|
||||
if (el) {
|
||||
el.classList.toggle("display");
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
const hud = {
|
||||
toast: (msg, duration) => {
|
||||
duration=isNaN(duration)?2000:duration;
|
||||
var el = document.createElement('div');
|
||||
el.classList.add('toast');
|
||||
el.innerHTML = msg;
|
||||
document.body.appendChild(el);
|
||||
setTimeout(function() {
|
||||
var d = 0.5;
|
||||
el.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
|
||||
el.style.opacity = '0';
|
||||
setTimeout(function() { document.body.removeChild(el) }, d * 1000);
|
||||
}, duration);
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
// defines
|
||||
|
||||
|
|
Loading…
Reference in New Issue