Merge pull request #201 from mashirozx/issue-199

Close #199
pull/202/head
Spirit 2020-03-21 23:53:52 +08:00 committed by GitHub
commit 5c415480fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 117 additions and 87 deletions

View File

@ -199,9 +199,9 @@ function sakura_scripts()
$movies = akina_option('focus_amv') ? array('url' => akina_option('amv_url'), 'name' => akina_option('amv_title'), 'live' => $mv_live) : 'close'; $movies = akina_option('focus_amv') ? array('url' => akina_option('amv_url'), 'name' => akina_option('amv_title'), 'live' => $mv_live) : 'close';
$auto_height = akina_option('focus_height') ? 'fixed' : 'auto'; $auto_height = akina_option('focus_height') ? 'fixed' : 'auto';
$code_lamp = 'close'; $code_lamp = 'close';
if (wp_is_mobile()) { // if (wp_is_mobile()) {
$auto_height = 'fixed'; // $auto_height = 'fixed';
} // }
//拦截移动端 //拦截移动端
version_compare($GLOBALS['wp_version'], '5.1', '>=') ? $reply_link_version = 'new' : $reply_link_version = 'old'; version_compare($GLOBALS['wp_version'], '5.1', '>=') ? $reply_link_version = 'new' : $reply_link_version = 'old';
wp_localize_script('app', 'Poi', array( wp_localize_script('app', 'Poi', array(

View File

@ -268,21 +268,24 @@ function SMMS_API($image)
*/ */
function cache_search_json() function cache_search_json()
{ {
global $more;
$vowels = array("[", "{", "]", "}", "<", ">", "\r\n", "\r", "\n", "-", "'", '"', '`', " ", ":", ";", '\\', " ", "toc"); $vowels = array("[", "{", "]", "}", "<", ">", "\r\n", "\r", "\n", "-", "'", '"', '`', " ", ":", ";", '\\', " ", "toc");
$regex = <<<EOS $regex = <<<EOS
/<\/?[a-zA-Z]+("[^"]*"|'[^']*'|[^'">])*>|begin[\S\s]*\/begin|hermit[\S\s]*\/hermit|img[\S\s]*\/img|{{.*?}}|:.*?:/m /<\/?[a-zA-Z]+("[^"]*"|'[^']*'|[^'">])*>|begin[\S\s]*\/begin|hermit[\S\s]*\/hermit|img[\S\s]*\/img|{{.*?}}|:.*?:/m
EOS; EOS;
$more = 1;
$posts = new WP_Query('posts_per_page=-1&post_status=publish&post_type=post'); $posts = new WP_Query('posts_per_page=-1&post_status=publish&post_type=post');
while ($posts->have_posts()): $posts->the_post(); while ($posts->have_posts()): $posts->the_post();
$output .= '{"type":"post","link":"' . get_permalink() . '","title":' . json_encode(get_the_title()) . ',"comments":"' . get_comments_number('0', '1', '%') . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', get_the_content()))) . '},'; $output .= '{"type":"post","link":"' . get_permalink() . '","title":' . json_encode(get_the_title()) . ',"comments":"' . get_comments_number('0', '1', '%') . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', apply_filters( 'the_content', get_the_content())))) . '},';
endwhile; endwhile;
wp_reset_postdata(); wp_reset_postdata();
$pages = get_pages(); $pages = new WP_Query('posts_per_page=-1&post_status=publish&post_type=page');
foreach ($pages as $page) { while ($pages->have_posts()): $pages->the_post();
$output .= '{"type":"page","link":"' . get_page_link($page) . '","title":' . json_encode($page->post_title) . ',"comments":"' . $page->comment_count . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', $page->post_content))) . '},'; $output .= '{"type":"page","link":"' . get_permalink() . '","title":' . json_encode(get_the_title()) . ',"comments":"' . get_comments_number('0', '1', '%') . '","text":' . json_encode(str_replace($vowels, " ", preg_replace($regex, ' ', apply_filters( 'the_content', get_the_content())))) . '},';
} endwhile;
wp_reset_postdata();
$tags = get_tags(); $tags = get_tags();
foreach ($tags as $tag) { foreach ($tags as $tag) {

View File

@ -73,6 +73,7 @@ mashiro_option.float_player_on = true;
mashiro_option.cover_api = "<?php echo rest_url('sakura/v1/image/cover'); ?>"; mashiro_option.cover_api = "<?php echo rest_url('sakura/v1/image/cover'); ?>";
mashiro_option.windowheight = /Mobile|Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent) ? 'fixed' : 'auto';
/*End of Initial Variables*/ /*End of Initial Variables*/
</script> </script>
<?php } <?php }

View File

@ -78,10 +78,12 @@ function post_list_show_animation() {
function callback(entries) { function callback(entries) {
entries.forEach((article) => { entries.forEach((article) => {
if (article.target.classList.contains("post-list-show")) { if (article.target.classList.contains("post-list-show")) {
article.target.style.willChange = 'auto';
io.unobserve(article.target) io.unobserve(article.target)
} else { } else {
if (article.isIntersecting) { if (article.isIntersecting) {
article.target.classList.add("post-list-show"); article.target.classList.add("post-list-show");
article.target.style.willChange = 'auto';
io.unobserve(article.target) io.unobserve(article.target)
} }
} }
@ -417,22 +419,15 @@ $(document).ready(function () {
preBG(); preBG();
}); });
}); });
if (document.body.clientWidth <= 860) {
window.onscroll = function () {
scrollFunction()
};
function scrollFunction() { function topFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { if ('scrollBehavior' in document.documentElement.style) {
addComment.I("moblieGoTop").style.display = "block"; window.scrollTo({
} else { top: 0,
addComment.I("moblieGoTop").style.display = "none"; behavior: "smooth"
} })
} } else {
window.scrollSmoothTo(0)
function topFunction() {
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
} }
} }
@ -477,10 +472,20 @@ function timeSeriesReload(flag) {
var al_expand_collapse_click = 0; var al_expand_collapse_click = 0;
$('#al_expand_collapse').click(function () { $('#al_expand_collapse').click(function () {
if (al_expand_collapse_click == 0) { if (al_expand_collapse_click == 0) {
$al_post_list.show(400); $al_post_list.each(function(index){
var $this = $(this),
s = setTimeout(function() {
$this.show(400);
}, 50 * index);
});
al_expand_collapse_click++; al_expand_collapse_click++;
} else if (al_expand_collapse_click == 1) { } else if (al_expand_collapse_click == 1) {
$al_post_list.hide(400); $al_post_list.each(function(index){
var $this = $(this),
h = setTimeout(function() {
$this.hide(400);
}, 50 * index);
});
al_expand_collapse_click--; al_expand_collapse_click--;
} }
}); });
@ -1229,13 +1234,6 @@ var home = location.href,
Siren = { Siren = {
MN: function () { MN: function () {
$('.iconflat').on('click', function () { $('.iconflat').on('click', function () {
if ($("#main-container").hasClass("open")) {
$('.iconflat').css('width', '50px').css('height', '50px');
$('.openNav').css('height', '50px');
} else {
$('.iconflat').css('width', '100%').css('height', '100%');
$('.openNav').css('height', '100%');
}
$('body').toggleClass('navOpen'); $('body').toggleClass('navOpen');
$('#main-container,#mo-nav,.openNav').toggleClass('open'); $('#main-container,#mo-nav,.openNav').toggleClass('open');
}); });
@ -1334,25 +1332,15 @@ var home = location.href,
}); });
}, },
AH: function () { AH: function () {
if (Poi.windowheight == 'auto') { if (Poi.windowheight == 'auto' && mashiro_option.windowheight == 'auto') {
if ($('h1.main-title').length > 0) { if ($('h1.main-title').length > 0) {
var _height = $(window).height() + "px"; var _height = $(window).height() + "px";
$('#centerbg').css({ $('#centerbg').css({
'height': _height 'height': '100vh'
}); });
$('#bgvideo').css({ $('#bgvideo').css({
'min-height': _height 'min-height': '100vh'
}); });
window.resizeFlag = null;
$(window).resize(function () {
//直接resize性能爆炸改成延时
if (resizeFlag = null) {
clearTimeout(resizeFlag);
}
resizeFlag = setTimeout(function () {
Siren.AH();
}, 1000);
})
} }
} else { } else {
$('.headertop').addClass('headertop-bar'); $('.headertop').addClass('headertop-bar');
@ -1547,17 +1535,19 @@ var home = location.href,
}); });
}, },
NH: function () { NH: function () {
var h1 = 0; if(document.body.clientWidth > 860){
$(window).scroll(function () { var h1 = 0;
var s = $(document).scrollTop(), $(window).scroll(function () {
cached = $('.site-header'); var s = $(document).scrollTop(),
if (s == h1) { cached = $('.site-header');
cached.removeClass('yya'); if (s == h1) {
} cached.removeClass('yya');
if (s > h1) { }
cached.addClass('yya'); if (s > h1) {
} cached.addClass('yya');
}
}); });
}
}, },
XLS: function () { XLS: function () {
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body'); $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
@ -1732,6 +1722,7 @@ var home = location.href,
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body'); $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
$('body').on('click', '#comments-navi a', function (e) { $('body').on('click', '#comments-navi a', function (e) {
e.preventDefault(); e.preventDefault();
var path = $(this)[0].pathname;
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: $(this).attr('href'), url: $(this).attr('href'),
@ -1768,36 +1759,43 @@ var home = location.href,
document.body.addEventListener('input', POWERMODE) document.body.addEventListener('input', POWERMODE)
}, },
GT: function () { GT: function () {
var offset = 100, var cwidth = document.body.clientWidth,
offset_opacity = 1200, cheight = window.innerHeight,
scroll_top_duration = 700, pc_to_top = document.querySelector(".cd-top"),
$back_to_top = $('.cd-top'); mb_to_top = document.querySelector("#moblieGoTop"),
$(window).scroll(function () { changeskin = document.querySelector(".changeSkin-gear");
if ($(this).scrollTop() > offset) {
$back_to_top.addClass('cd-is-visible'); $(window).scroll(function() {
$(".changeSkin-gear").css("bottom", "0"); if (cwidth <= 860) {
if ($(window).height() > 950) { if ($(this).scrollTop() > 20) {
$(".cd-top.cd-is-visible").css("top", "0"); mb_to_top.style.transform = "scale(1)";
} else { } else {
$(".cd-top.cd-is-visible").css("top", ($(window).height() - 950) + "px"); mb_to_top.style.transform = "scale(0)";
} }
} else { } else {
$(".changeSkin-gear").css("bottom", "-999px"); if ($(this).scrollTop() > 100) {
$(".cd-top.cd-is-visible").css("top", "-900px"); pc_to_top.classList.add("cd-is-visible");
$back_to_top.removeClass('cd-is-visible cd-fade-out'); changeskin.style.bottom = "0";
} if (cheight > 950) {
if ($(this).scrollTop() > offset_opacity) { pc_to_top.style.top = "0";
$back_to_top.addClass('cd-fade-out'); } else {
pc_to_top.style.top = cheight - 950 + "px";
}
} else {
changeskin.style.bottom = "-999px";
pc_to_top.style.top = "-999px";
pc_to_top.classList.remove("cd-fade-out", "cd-is-visible");
}
if ($(this).scrollTop() > 1200) {
pc_to_top.classList.add("cd-fade-out");
}
} }
}); });
//smooth scroll to top //smooth scroll to top
$back_to_top.on('click', function (event) { pc_to_top.onclick = function() {
event.preventDefault(); topFunction();
$('body,html').animate({ }
scrollTop: 0,
}, scroll_top_duration);
return false;
});
} }
} }
$(function () { $(function () {

View File

@ -5,7 +5,7 @@ Theme URI: https://github.com/mashirozx/Sakura/
Author: Mashiro, Spirit, Louie, Fuzzz Author: Mashiro, Spirit, Louie, Fuzzz
Author URI: http://2heng.xin Author URI: http://2heng.xin
Description: A wonderful branch of theme Akina Description: A wonderful branch of theme Akina
Version: 3.3.6 Version: 3.3.7
License: GNU General Public License v2 or later License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: sakura Text Domain: sakura
@ -1086,6 +1086,7 @@ a:hover {
display: block display: block
} }
.m-nav { .m-nav {
display: none display: none
} }
@ -1142,6 +1143,23 @@ a:hover {
max-width: 100% max-width: 100%
} }
@media(max-width:1200px) {
.site-top .lower nav{
right: calc(-150px - 100%);
position: absolute;
float: right;
animation: searchbox .2s;
min-width: 860px;
z-index: -1
}
.site-top .lower nav.navbar {
right: calc(-50px - 100%);
}
.site-top .lower nav.navbar ul {
background: #fff;
}
}
#show-nav { #show-nav {
position: relative; position: relative;
float: right; float: right;
@ -1443,6 +1461,7 @@ i.iconfont.hotpost {
} }
.post-list-thumb { .post-list-thumb {
will-change: transform;
float: left; float: left;
width: 100%; width: 100%;
height: 300px; height: 300px;
@ -1456,7 +1475,7 @@ i.iconfont.hotpost {
@media (max-width:860px) { @media (max-width:860px) {
.post-list-thumb { .post-list-thumb {
margin: 0; margin: 10px 0 10px;
height: auto height: auto
} }
} }
@ -1870,7 +1889,6 @@ h1.page-title.mb- {
} }
#moblieGoTop { #moblieGoTop {
display: none;
position: fixed; position: fixed;
bottom: 10px; bottom: 10px;
right: 10px; right: 10px;
@ -1884,9 +1902,9 @@ h1.page-title.mb- {
border-radius: 10px; border-radius: 10px;
border-radius: 12px; border-radius: 12px;
box-shadow: 0 0 2px 0 rgba(0, 0, 0, .12), 0 2px 2px 0 rgba(0, 0, 0, .24); box-shadow: 0 0 2px 0 rgba(0, 0, 0, .12), 0 2px 2px 0 rgba(0, 0, 0, .24);
transition: box-shadow .2s ease transform: scale(0);
transition:transform .3s
} }
#moblieGoTop:hover { #moblieGoTop:hover {
background-color: #fff; background-color: #fff;
opacity: .8 opacity: .8
@ -4260,7 +4278,7 @@ i.iconfont.js-toggle-search.iconsearch {
.s-search input { .s-search input {
font-size: 1rem; font-size: 1rem;
background: #none; background: none;
padding: 12px 24px 12px 64px; padding: 12px 24px 12px 64px;
width: 100%; width: 100%;
outline: 0; outline: 0;
@ -4711,6 +4729,11 @@ i.iconfont.js-toggle-search.iconsearch {
margin-top: 0; margin-top: 0;
padding: 0 padding: 0
} }
.wp-smiley {
height: 2em !important;
max-height: 2em !important;
vertical-align: bottom;
}
embed, embed,
iframe, iframe,
@ -6840,9 +6863,9 @@ input[type=radio]:checked:before {
margin-right: 22px margin-right: 22px
} }
@media (max-width:800px) { @media (max-width:860px) {
.changeSkin-gear { .changeSkin-gear {
visibility: hidden visibility: hidden !important
} }
.changeSkin-gear span::before { .changeSkin-gear span::before {
content: "" content: ""
@ -7567,6 +7590,11 @@ a.toc-link {
} }
@media (max-width:860px) { @media (max-width:860px) {
.wp-smiley {
height:20px !important;
max-height:20px !important;
vertical-align:middle
}
.bili-container, .bili-container,
.tieba-container { .tieba-container {
padding-left: 0 padding-left: 0