feat: add new shortcode (#179)

pull/239/head
Seaton Jiang 2020-06-21 21:24:48 +08:00
parent e861f6e9a6
commit 38dda0822d
8 changed files with 88 additions and 6 deletions

View File

@ -865,8 +865,8 @@ button:focus {
.k-main .details .article h1 { .k-main .details .article h1 {
padding-bottom: 4.8px; padding-bottom: 4.8px;
/* border-bottom: 1px solid #eaecef; */ /* border-bottom: 1px solid #eaecef; */
line-height: 38px;
font-size: 30px; font-size: 30px;
line-height: 38px;
} }
.k-main .details .article .content h2 { .k-main .details .article .content h2 {
@ -1156,6 +1156,44 @@ button:focus {
font-size: 13px; font-size: 13px;
} }
.k-main .details .article .content .accordion {
margin-bottom: 16px;
border: 1px solid #e5e8ed;
}
.k-main .details .article .content .accordion .acheader {
position: relative;
padding: 5px 15px;
background: #f7f8fa;
}
.k-main .details .article .content .accordion .acheader span {
font-weight: 600;
font-size: 17px;
}
.k-main .details .article .content .accordion .acheader .icon {
position: absolute;
right: 15px;
font-size: 17px;
}
.k-main .details .article .content .accordion.active .icon {
-webkit-transition: 0.3s;
transition: 0.3s;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
}
.k-main .details .article .content .accordion .contents {
display: none;
border-top: 1px solid #e6e6e6;
}
.k-main .details .article .content .accordion .contents .inner {
padding: 5px 15px;
}
@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {
.k-main .details .article .header { .k-main .details .article .header {
padding: 0 16px 12px; padding: 0 16px 12px;
@ -1472,11 +1510,11 @@ button:focus {
.k-main .details .comments .comment .info .author_name { .k-main .details .comments .comment .info .author_name {
display: inline-block; display: inline-block;
margin-top: 3px;
color: #252525; color: #252525;
font-weight: 600; font-weight: 600;
font-size: 14px;
margin-top: 3px;
font-style: normal; font-style: normal;
font-size: 14px;
line-height: 1.375; line-height: 1.375;
} }

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -223,6 +223,22 @@
}) })
tinymce.PluginManager.add('reply', tinymce.plugins.reply) tinymce.PluginManager.add('reply', tinymce.plugins.reply)
tinymce.create('tinymce.plugins.accordion', {
init: function (ed, url) {
ed.addButton('accordion', {
title: '展开收缩',
image: url + '/images/accordion.png',
onclick: function () {
ed.selection.setContent('[accordion title="标题内容"]' + ed.selection.getContent() + '[/accordion]')
}
})
},
createControl: function (n, cm) {
return null
},
})
tinymce.PluginManager.add('accordion', tinymce.plugins.accordion)
tinymce.create('tinymce.plugins.music', { tinymce.create('tinymce.plugins.music', {
init: function (ed, url) { init: function (ed, url) {
ed.addButton('music', { ed.addButton('music', {

View File

@ -123,11 +123,25 @@
}) })
} }
var accordionConfig = function () {
$(document).on('click', '.acheader', function (event) {
var $this = $(this)
$this.closest('.accordion').find('.contents').slideToggle(300)
if ($this.closest('.accordion').hasClass('active')) {
$this.closest('.accordion').removeClass('active')
} else {
$this.closest('.accordion').addClass('active')
}
event.preventDefault()
})
}
var consoleConfig = function () { var consoleConfig = function () {
console.log('\n Kratos v' + KRATOS_VERSION + '\n\n https://github.com/Vtrois/Kratos \n\n') console.log('\n Kratos v' + KRATOS_VERSION + '\n\n https://github.com/Vtrois/Kratos \n\n')
} }
$(function () { $(function () {
accordionConfig()
navbarConfig() navbarConfig()
tooltipConfig() tooltipConfig()
gotopConfig() gotopConfig()

View File

@ -1 +1 @@
function grin(t){var o;if(t=" "+t+" ",!document.getElementById("comment")||"textarea"!=document.getElementById("comment").type)return!1;if(o=document.getElementById("comment"),document.selection)o.focus(),sel=document.selection.createRange(),sel.text=t,o.focus();else if(o.selectionStart||"0"==o.selectionStart){var e=o.selectionStart,a=o.selectionEnd,n=a;o.value=o.value.substring(0,e)+t+o.value.substring(a,o.value.length),n+=t.length,o.focus(),o.selectionStart=n,o.selectionEnd=n}else o.value+=t,o.focus()}(function(){"use strict";var t="3.0.10",o=function(){$("#navbutton").on("click",function(){$(".navbar-toggler").toggleClass("nav-close")})},e=function(){$(function(){$('[data-toggle="tooltip"]').tooltip()})},a=function(){$(window).on("load",function(){var t=$(window);t.scrollTop()>200?$(".gotop").addClass("active"):$(".gotop").removeClass("active"),t.scroll(function(){t.scrollTop()>200?$(".gotop").addClass("active"):$(".gotop").removeClass("active")})}),$(".gotop").on("click",function(t){return t.preventDefault(),$("html, body").animate({scrollTop:$("html").offset().top},500),!1})},n=function(){$(".search").on("click",function(t){$(".search-form").animate({width:"200px"},200),$(".search-form input").css("display","block"),$(document).one("click",function(){$(".search-form").animate({width:"0"},100),$(".search-form input").hide()}),t.stopPropagation()}),$(".search-form").on("click",function(t){t.stopPropagation()})},i=function(){$(".wechat").mouseout(function(){$(".wechat-pic")[0].style.display="none"}),$(".wechat").mouseover(function(){$(".wechat-pic")[0].style.display="block"})},s=function(){$("#addsmile").on("click",function(t){return $(".smile").toggleClass("open"),$(document).one("click",function(){$(".smile").toggleClass("open")}),t.stopPropagation(),!1})},c=function(){$.fn.postLike=function(){if($(this).hasClass("done"))return layer.msg(kratos.repeat,function(){}),!1;$(this).addClass("done"),layer.msg(kratos.thanks);var t=$(this).data("id"),o=$(this).data("action"),e={action:"love",um_id:t,um_action:o};return $.post(kratos.site+"/wp-admin/admin-ajax.php",e,function(t){}),!1},$(document).on("click",".btn-thumbs",function(){$(this).postLike()})},l=function(){$("#donate").on("click",function(){layer.open({type:1,area:["300px","370px"],title:kratos.donate,resize:!1,scrollbar:!1,content:'<div class="donate-box"><div class="meta-pay text-center my-2"><strong>'+kratos.scan+'</strong></div><div class="qr-pay text-center"><img class="pay-img" id="alipay_qr" src="'+kratos.alipay+'"><img class="pay-img d-none" id="wechat_qr" src="'+kratos.wechat+'"></div><div class="choose-pay text-center mt-2"><input id="alipay" type="radio" name="pay-method" checked><label for="alipay" class="pay-button"><img src="'+kratos.directory+'/assets/img/payment/alipay.png"></label><input id="wechatpay" type="radio" name="pay-method"><label for="wechatpay" class="pay-button"><img src="'+kratos.directory+'/assets/img/payment/wechat.png"></label></div></div>'}),$(".choose-pay input[type='radio']").click(function(){var t=$(this).attr("id");"alipay"==t&&($(".qr-pay #alipay_qr").removeClass("d-none"),$(".qr-pay #wechat_qr").addClass("d-none")),"wechatpay"==t&&($(".qr-pay #alipay_qr").addClass("d-none"),$(".qr-pay #wechat_qr").removeClass("d-none"))})})},r=function(){console.log("\n Kratos v"+t+"\n\n https://github.com/Vtrois/Kratos \n\n")};$(function(){o(),e(),a(),n(),i(),s(),c(),l(),r()})})(); function grin(t){var o;if(t=" "+t+" ",!document.getElementById("comment")||"textarea"!=document.getElementById("comment").type)return!1;if(o=document.getElementById("comment"),document.selection)o.focus(),sel=document.selection.createRange(),sel.text=t,o.focus();else if(o.selectionStart||"0"==o.selectionStart){var e=o.selectionStart,a=o.selectionEnd,n=a;o.value=o.value.substring(0,e)+t+o.value.substring(a,o.value.length),n+=t.length,o.focus(),o.selectionStart=n,o.selectionEnd=n}else o.value+=t,o.focus()}(function(){"use strict";var t="3.0.10",o=function(){$("#navbutton").on("click",function(){$(".navbar-toggler").toggleClass("nav-close")})},e=function(){$(function(){$('[data-toggle="tooltip"]').tooltip()})},a=function(){$(window).on("load",function(){var t=$(window);t.scrollTop()>200?$(".gotop").addClass("active"):$(".gotop").removeClass("active"),t.scroll(function(){t.scrollTop()>200?$(".gotop").addClass("active"):$(".gotop").removeClass("active")})}),$(".gotop").on("click",function(t){return t.preventDefault(),$("html, body").animate({scrollTop:$("html").offset().top},500),!1})},n=function(){$(".search").on("click",function(t){$(".search-form").animate({width:"200px"},200),$(".search-form input").css("display","block"),$(document).one("click",function(){$(".search-form").animate({width:"0"},100),$(".search-form input").hide()}),t.stopPropagation()}),$(".search-form").on("click",function(t){t.stopPropagation()})},c=function(){$(".wechat").mouseout(function(){$(".wechat-pic")[0].style.display="none"}),$(".wechat").mouseover(function(){$(".wechat-pic")[0].style.display="block"})},s=function(){$("#addsmile").on("click",function(t){return $(".smile").toggleClass("open"),$(document).one("click",function(){$(".smile").toggleClass("open")}),t.stopPropagation(),!1})},i=function(){$.fn.postLike=function(){if($(this).hasClass("done"))return layer.msg(kratos.repeat,function(){}),!1;$(this).addClass("done"),layer.msg(kratos.thanks);var t=$(this).data("id"),o=$(this).data("action"),e={action:"love",um_id:t,um_action:o};return $.post(kratos.site+"/wp-admin/admin-ajax.php",e,function(t){}),!1},$(document).on("click",".btn-thumbs",function(){$(this).postLike()})},l=function(){$("#donate").on("click",function(){layer.open({type:1,area:["300px","370px"],title:kratos.donate,resize:!1,scrollbar:!1,content:'<div class="donate-box"><div class="meta-pay text-center my-2"><strong>'+kratos.scan+'</strong></div><div class="qr-pay text-center"><img class="pay-img" id="alipay_qr" src="'+kratos.alipay+'"><img class="pay-img d-none" id="wechat_qr" src="'+kratos.wechat+'"></div><div class="choose-pay text-center mt-2"><input id="alipay" type="radio" name="pay-method" checked><label for="alipay" class="pay-button"><img src="'+kratos.directory+'/assets/img/payment/alipay.png"></label><input id="wechatpay" type="radio" name="pay-method"><label for="wechatpay" class="pay-button"><img src="'+kratos.directory+'/assets/img/payment/wechat.png"></label></div></div>'}),$(".choose-pay input[type='radio']").click(function(){var t=$(this).attr("id");"alipay"==t&&($(".qr-pay #alipay_qr").removeClass("d-none"),$(".qr-pay #wechat_qr").addClass("d-none")),"wechatpay"==t&&($(".qr-pay #alipay_qr").addClass("d-none"),$(".qr-pay #wechat_qr").removeClass("d-none"))})})},r=function(){$(document).on("click",".acheader",function(t){var o=$(this);o.closest(".accordion").find(".contents").slideToggle(300),o.closest(".accordion").hasClass("active")?o.closest(".accordion").removeClass("active"):o.closest(".accordion").addClass("active"),t.preventDefault()})},d=function(){console.log("\n Kratos v"+t+"\n\n https://github.com/Vtrois/Kratos \n\n")};$(function(){r(),o(),e(),a(),n(),c(),s(),i(),l(),d()})})();

View File

@ -216,6 +216,17 @@ function reply($atts, $content = null)
} }
add_shortcode('reply', 'reply'); add_shortcode('reply', 'reply');
function accordion($atts, $content=null, $code=""){
extract(shortcode_atts(array("title"=>__('标题内容','kratos')),$atts));
$return = '<div class="accordion"><div class="acheader"><div class="icon"><i class="fa fa-plus"></i></div><span>';
$return .= $title;
$return .= '</span></div><div class="contents"><div class="inner">';
$return .= do_shortcode($content);
$return .= '</div></div></div>';
return $return;
}
add_shortcode('accordion','accordion');
add_action('init', 'more_button'); add_action('init', 'more_button');
function more_button() function more_button()
{ {
@ -245,6 +256,7 @@ function register_button($buttons)
array_push($buttons, " ", "striped"); array_push($buttons, " ", "striped");
array_push($buttons, " ", "bdbtn"); array_push($buttons, " ", "bdbtn");
array_push($buttons, " ", "reply"); array_push($buttons, " ", "reply");
array_push($buttons, " ", "accordion");
array_push($buttons, " ", "music"); array_push($buttons, " ", "music");
array_push($buttons, " ", "vqq"); array_push($buttons, " ", "vqq");
array_push($buttons, " ", "youtube"); array_push($buttons, " ", "youtube");
@ -268,6 +280,7 @@ function add_plugin($plugin_array)
$plugin_array['striped'] = ASSET_PATH . '/assets/js/buttons/more.js'; $plugin_array['striped'] = ASSET_PATH . '/assets/js/buttons/more.js';
$plugin_array['bdbtn'] = ASSET_PATH . '/assets/js/buttons/more.js'; $plugin_array['bdbtn'] = ASSET_PATH . '/assets/js/buttons/more.js';
$plugin_array['reply'] = ASSET_PATH . '/assets/js/buttons/more.js'; $plugin_array['reply'] = ASSET_PATH . '/assets/js/buttons/more.js';
$plugin_array['accordion'] = ASSET_PATH . '/assets/js/buttons/more.js';
$plugin_array['music'] = ASSET_PATH . '/assets/js/buttons/more.js'; $plugin_array['music'] = ASSET_PATH . '/assets/js/buttons/more.js';
$plugin_array['vqq'] = ASSET_PATH . '/assets/js/buttons/more.js'; $plugin_array['vqq'] = ASSET_PATH . '/assets/js/buttons/more.js';
$plugin_array['youtube'] = ASSET_PATH . '/assets/js/buttons/more.js'; $plugin_array['youtube'] = ASSET_PATH . '/assets/js/buttons/more.js';

View File

@ -3,7 +3,7 @@ msgid ""
msgstr "" msgstr ""
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n" "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
"Project-Id-Version: Kratos\n" "Project-Id-Version: Kratos\n"
"POT-Creation-Date: 2020-06-21 11:42+0800\n" "POT-Creation-Date: 2020-06-21 21:24+0800\n"
"PO-Revision-Date: 2020-02-14 23:32+0800\n" "PO-Revision-Date: 2020-02-14 23:32+0800\n"
"Last-Translator: \n" "Last-Translator: \n"
"Language-Team: \n" "Language-Team: \n"
@ -834,6 +834,7 @@ msgstr ""
#: inc/theme-shortcode.php:105 inc/theme-shortcode.php:117 #: inc/theme-shortcode.php:105 inc/theme-shortcode.php:117
#: inc/theme-shortcode.php:129 inc/theme-shortcode.php:141 #: inc/theme-shortcode.php:129 inc/theme-shortcode.php:141
#: inc/theme-shortcode.php:220
msgid "标题内容" msgid "标题内容"
msgstr "" msgstr ""