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"/>'
|
- icon: '<img src="https://7.dusays.com/2021/02/14/25678f144c438.svg"/>'
|
||||||
url: /atom.xml
|
url: /atom.xml
|
||||||
- icon: '<img src="https://7.dusays.com/2021/02/14/08a41b181ce68.svg"/>'
|
- 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"/>'
|
- 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"/>'
|
- 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/)'
|
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)'
|
source: #'[GitHub](https://github.com/xaoxuu/hexo-theme-stellar)'
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,9 @@ page:
|
||||||
filter: "%s's %s has %s articles"
|
filter: "%s's %s has %s articles"
|
||||||
wiki: "%s has %s %s in total"
|
wiki: "%s has %s %s in total"
|
||||||
|
|
||||||
|
message:
|
||||||
|
copied: Copied!
|
||||||
|
|
||||||
symbol:
|
symbol:
|
||||||
comma: ", "
|
comma: ", "
|
||||||
period: ". "
|
period: ". "
|
||||||
|
|
|
@ -49,6 +49,9 @@ page:
|
||||||
filter: '%s的%s共有%s篇文章'
|
filter: '%s的%s共有%s篇文章'
|
||||||
wiki: '%s共有%s个%s'
|
wiki: '%s共有%s个%s'
|
||||||
|
|
||||||
|
message:
|
||||||
|
copied: 复制成功
|
||||||
|
|
||||||
symbol:
|
symbol:
|
||||||
comma: ","
|
comma: ","
|
||||||
period: "。"
|
period: "。"
|
||||||
|
|
|
@ -49,6 +49,9 @@ page:
|
||||||
filter: '%s的%s共有%s篇文章'
|
filter: '%s的%s共有%s篇文章'
|
||||||
wiki: '%s共有%s个%s'
|
wiki: '%s共有%s个%s'
|
||||||
|
|
||||||
|
message:
|
||||||
|
copied: 複製成功
|
||||||
|
|
||||||
symbol:
|
symbol:
|
||||||
comma: ","
|
comma: ","
|
||||||
period: "。"
|
period: "。"
|
||||||
|
|
|
@ -13,7 +13,12 @@ function layoutDiv() {
|
||||||
el += '<div class="body"><ul>';
|
el += '<div class="body"><ul>';
|
||||||
page.references.forEach((item, i) => {
|
page.references.forEach((item, i) => {
|
||||||
el += '<li class="post-title">';
|
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 += item.title || item.url;
|
||||||
el += '</a>';
|
el += '</a>';
|
||||||
el += '</li>';
|
el += '</li>';
|
||||||
|
@ -44,9 +49,12 @@ function layoutDiv() {
|
||||||
el += '<div class="social-wrap">';
|
el += '<div class="social-wrap">';
|
||||||
theme.article.share.forEach((item, i) => {
|
theme.article.share.forEach((item, i) => {
|
||||||
if (['wechat', 'weibo', 'email', 'link'].includes(item)) {
|
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') {
|
if (item == 'wechat') {
|
||||||
el += ' onclick="util.toggle_qrcode()"';
|
el += ' onclick="util.toggle("qrcode-wechat")"';
|
||||||
} else if (item == 'weibo') {
|
} else if (item == 'weibo') {
|
||||||
el += ' href="https://service.weibo.com/share/share.php?url=' + page.permalink;
|
el += ' href="https://service.weibo.com/share/share.php?url=' + page.permalink;
|
||||||
el += '&title=' + (page.seo_title || page.title) + ' - ' + config.title;
|
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 += ' href="mailto:?subject=' + (page.title || page.seo_title) + ' - ' + config.title + '&'
|
||||||
el += 'body=' + page.permalink + '"';
|
el += 'body=' + page.permalink + '"';
|
||||||
} else if (item == 'link') {
|
} else if (item == 'link') {
|
||||||
el += ' onclick="util.copy_link()"';
|
el += ' onclick="util.copy("copy-link", "' + __('message.copied') + '")"';
|
||||||
}
|
}
|
||||||
el += '>';
|
el += '>';
|
||||||
if (item == 'wechat') {
|
if (item == 'wechat') {
|
||||||
|
|
|
@ -14,7 +14,14 @@ function layoutFooterDiv() {
|
||||||
var el = '<footer class="footer"><div class="social-wrap">';
|
var el = '<footer class="footer"><div class="social-wrap">';
|
||||||
theme.footer.social.forEach(item => {
|
theme.footer.social.forEach(item => {
|
||||||
if (item.icon && item.url) {
|
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>';
|
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: () => {
|
copy: (id, msg) => {
|
||||||
const el = document.getElementById("copy-link");
|
const el = document.getElementById(id);
|
||||||
if (el) {
|
if (el) {
|
||||||
el.select();
|
el.select();
|
||||||
document.execCommand("Copy");
|
document.execCommand("Copy");
|
||||||
|
hud.toast(msg);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
toggle_qrcode: () => {
|
toggle: (id) => {
|
||||||
const el = document.getElementById("qrcode-wechat");
|
const el = document.getElementById(id);
|
||||||
if (el) {
|
if (el) {
|
||||||
el.classList.toggle("display");
|
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
|
// defines
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue