提交 26155b79 编写于 作者: EvanOne(文一)'s avatar EvanOne(文一)

feat: Add the copy button in copyright of posts

上级 2f11fd75
......@@ -30,6 +30,9 @@ else if (hexo-config('img_horizonal_align') == 'right')
span
margin: 0 .1rem
&-copyright
position: relative
&-tags
margin-bottom: 1rem
......
......@@ -11,7 +11,8 @@ $(document).ready(function test () {
var codeHeader = $(`
<figcaption class="custom">
<span>${lang}</span>
</figcaption>`)[0];
</figcaption>
`)[0];
item.insertBefore(codeHeader, $(item).children().first()[0]);
}
......@@ -20,14 +21,27 @@ $(document).ready(function test () {
var $copyIcon = $(`
<div class="copy-button">
<i class="fa fa-clipboard"></i>
</div>`);
</div>
`);
var COPY_BUTTON_WRAPPER = `
figure.highlight figcaption,
.post-footer-copyright
`;
$('figure.highlight figcaption').append($copyIcon);
// Add a copy button to the selected elements.
$(COPY_BUTTON_WRAPPER).append($copyIcon);
$('.copy-button').on('click', function () {
var container = null;
var codeContainer =
$(this).parent('figcaption').parent('figure').find('td.code')[0];
if (Stun.utils.copyText(codeContainer)) {
if (codeContainer) { // Copy code.
container = codeContainer;
} else { // Copy text.
container = $(this).parent()[0];
}
if (Stun.utils.copyText(container)) {
Stun.utils.popAlert('success', CONFIG.notification.copy_success);
} else {
Stun.utils.popAlert('error', CONFIG.notification.copy_error);
......
......@@ -151,8 +151,7 @@ $(document).ready(function () {
isAnime = false;
isMaxH = false;
}
}
);
});
} else if (!isMaxH && !isAnime && $(window).height() <
$('#footer')[0].getBoundingClientRect().top) {
isAnime = true;
......@@ -165,8 +164,7 @@ $(document).ready(function () {
isAnime = false;
isMaxH = true;
}
}
);
});
}
}
......
......@@ -138,6 +138,7 @@ Stun.utils = Stun.$u = {
}
document.body.removeChild(input);
} catch (e) {
console.log(e);
return false;
}
},
......@@ -241,4 +242,5 @@ Stun.utils = Stun.$u = {
$(document).ready(function () {
Stun.utils.addContainerToTable();
Stun.utils.adjustImageSize();
Stun.utils.copyText()
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册