Merge branch 'master' into myblog

i18n
xaoxuu 5 years ago
commit a4d868576e
  1. 2
      _config.yml
  2. 1
      layout/_partial/head.ejs
  3. 14
      layout/_partial/scripts.ejs
  4. 82
      layout/_third-party/clipboard.ejs
  5. 18
      layout/_third-party/fancybox.ejs
  6. 76
      source/js/clipboard-use.js
  7. 5
      source/less/_main.less

@ -8,7 +8,7 @@ info:
name: Material X
docs: https://xaoxuu.com/wiki/material-x/
# 主题的CDN地址。如需启用CDN,请在主目录的config中设置,详见文档。
cdn: https://cdn.jsdelivr.net/gh/xaoxuu/cdn-material-x@19.3.24/
cdn: https://cdn.jsdelivr.net/gh/xaoxuu/cdn-material-x@19.3.28/
############################### 主题样式 ###############################

@ -45,6 +45,7 @@
<% } %>
<!-- link -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
<% if (theme.services && theme.services.nodewaves == true) { %>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-waves@0.7.6/dist/waves.min.css">
<% } %>

@ -140,16 +140,15 @@
</script>
<% } %>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<% if (theme.services.cdn == true && config.theme_cdn) { %>
<% if (config.theme_cdn == true) { %>
<%- js([theme.info.cdn + 'js/app.js', theme.info.cdn + 'js/search.js', theme.info.cdn + 'js/clipboard-use.js']) %>
<%- js([theme.info.cdn + 'js/app.js', theme.info.cdn + 'js/search.js']) %>
<% } else if (config.theme_cdn.length > 0) { %>
<%- js([config.theme_cdn + 'js/app.js', config.theme_cdn + 'js/search.js', config.theme_cdn + 'js/clipboard-use.js']) %>
<%- js([config.theme_cdn + 'js/app.js', config.theme_cdn + 'js/search.js']) %>
<% } %>
<% } else { %>
<%- js(['js/app.js', 'js/search.js', 'js/clipboard-use.js']) %>
<%- js(['js/app.js', 'js/search.js']) %>
<% } %>
@ -167,6 +166,13 @@
</script>
<% } %>
<!-- 复制 -->
<%- partial('_third-party/clipboard') %>
<!-- fancybox -->
<%- partial('_third-party/fancybox') %>
<% if (config.import && config.import.script){ %>
<% (config.import.script||[]).forEach(function(item){ %>
<%- item %><% }) %>

@ -0,0 +1,82 @@
<script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
let COPY_SUCCESS = "<%- __('post.copy_success') %>";
let COPY_FAILURE = "<%- __('post.copy_failure') %>";
/*页面载入完成后,创建复制按钮*/
!function (e, t, a) {
/* code */
var initCopyCode = function(){
var copyHtml = '';
copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
copyHtml += ' <i class="fa fa-copy"></i><span>Copy</span>';
copyHtml += '</button>';
$(".highlight .code pre").before(copyHtml);
var clipboard = new ClipboardJS('.btn-copy', {
target: function(trigger) {
return trigger.nextElementSibling;
}
});
clipboard.on('success', function(e) {
//您可以加入成功提示
console.info('Action:', e.action);
console.info('Text:', e.text);
console.info('Trigger:', e.trigger);
success_prompt(COPY_SUCCESS);
e.clearSelection();
});
clipboard.on('error', function(e) {
//您可以加入失败提示
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
fail_prompt(COPY_FAILURE);
});
}
initCopyCode();
}(window, document);
/**
* 弹出式提示框,默认1.5秒自动消失
* @param message 提示信息
* @param style 提示样式,有alert-success、alert-danger、alert-warning、alert-info
* @param time 消失时间
*/
var prompt = function (message, style, time)
{
style = (style === undefined) ? 'alert-success' : style;
time = (time === undefined) ? 1500 : time*1000;
$('<div>')
.appendTo('body')
.addClass('alert ' + style)
.html(message)
.show()
.delay(time)
.fadeOut();
};
// 成功提示
var success_prompt = function(message, time)
{
prompt(message, 'alert-success', time);
};
// 失败提示
var fail_prompt = function(message, time)
{
prompt(message, 'alert-danger', time);
};
// 提醒
var warning_prompt = function(message, time)
{
prompt(message, 'alert-warning', time);
};
// 信息提示
var info_prompt = function(message, time)
{
prompt(message, 'alert-info', time);
};
</script>

@ -0,0 +1,18 @@
<script src="https://cdn.jsdelivr.net/gh/fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script>
<script>
let LAZY_LOAD_IMAGE = "<%- config.lazyload %>";
$(".article-entry").find("img").each(function () {
var element = document.createElement("a");
$(element).attr("data-fancybox", "gallery");
$(element).attr("href", $(this).attr("src"));
/* 图片采用懒加载处理时,
* 一般图片标签内会有个属性名来存放图片的真实地址,比如 data-original,
* 那么此处将原本的属性名src替换为对应属性名data-original,
* 修改如下
*/
if (LAZY_LOAD_IMAGE) {
$(element).attr("href", $(this).attr("data-original"));
}
$(this).wrap(element);
});
</script>

@ -1,76 +0,0 @@
/*页面载入完成后,创建复制按钮*/
!function (e, t, a) {
/* code */
var initCopyCode = function(){
var copyHtml = '';
copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
copyHtml += ' <i class="fa fa-copy"></i><span>Copy</span>';
copyHtml += '</button>';
$(".highlight .code pre").before(copyHtml);
var clipboard = new ClipboardJS('.btn-copy', {
target: function(trigger) {
return trigger.nextElementSibling;
}
});
clipboard.on('success', function(e) {
//您可以加入成功提示
console.info('Action:', e.action);
console.info('Text:', e.text);
console.info('Trigger:', e.trigger);
success_prompt("复制成功");
e.clearSelection();
});
clipboard.on('error', function(e) {
//您可以加入失败提示
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
fail_prompt("复制失败");
});
}
initCopyCode();
}(window, document);
/**
* 弹出式提示框默认1.2秒自动消失
* @param message 提示信息
* @param style 提示样式有alert-successalert-dangeralert-warningalert-info
* @param time 消失时间
*/
var prompt = function (message, style, time)
{
style = (style === undefined) ? 'alert-success' : style;
time = (time === undefined) ? 1200 : time*1000;
$('<div>')
.appendTo('body')
.addClass('alert ' + style)
.html(message)
.show()
.delay(time)
.fadeOut();
};
// 成功提示
var success_prompt = function(message, time)
{
prompt(message, 'alert-success', time);
};
// 失败提示
var fail_prompt = function(message, time)
{
prompt(message, 'alert-danger', time);
};
// 提醒
var warning_prompt = function(message, time)
{
prompt(message, 'alert-warning', time);
};
// 信息提示
var info_prompt = function(message, time)
{
prompt(message, 'alert-info', time);
};

@ -489,8 +489,11 @@
z-index: 99999;
text-align: center;
padding: 24px 36px;
border-radius: @border_radius;
border-radius: @border_radius_code_block;
box-shadow: @boxshadow_card_normal;
font-family: @fontfamily_base;
font-weight: bold;
font-size: @fontsize_base;
&.alert-success {
color: #3c763d;

Loading…
Cancel
Save