Merge pull request #100 from spirit1431007/pr-branch

bug fix&自动加载
This commit is contained in:
Mashiro 2019-08-17 23:52:36 +08:00 committed by GitHub
commit 3f30e88768
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 4 deletions

View File

@ -952,6 +952,8 @@ function rt_add_link_target( $content ){
foreach( $bits as $key=>$bit ){ foreach( $bits as $key=>$bit ){
// fix the target="_blank" bug after the link // fix the target="_blank" bug after the link
if ( strpos( $bit, 'href' ) === false ) continue; if ( strpos( $bit, 'href' ) === false ) continue;
// fix the target="_blank" bug in the codeblock
if ( strpos( preg_replace('/code([\s\S]*?)\/code[\s]*/m','temp',$content), $bit ) === false ) continue;
// find the end of each link // find the end of each link
$pos = strpos( $bit, '>' ); $pos = strpos( $bit, '>' );
// check if there is an end (only fails with malformed markup) // check if there is an end (only fails with malformed markup)

View File

@ -65,6 +65,7 @@ get_header();
</main><!-- #main --> </main><!-- #main -->
<?php if ( akina_option('pagenav_style') == 'ajax') { ?> <?php if ( akina_option('pagenav_style') == 'ajax') { ?>
<div id="pagination"><?php next_posts_link('Previous'); ?></div> <div id="pagination"><?php next_posts_link('Previous'); ?></div>
<div id="add_post"><span id="add_post_time" style="visibility: hidden;" title="<?php echo akina_option('auto_load_post',''); ?>" ></span></div>
<?php }else{ ?> <?php }else{ ?>
<nav class="navigator"> <nav class="navigator">
<?php previous_posts_link('<i class="iconfont icon-back"></i>') ?><?php next_posts_link('<i class="iconfont icon-right"></i>') ?> <?php previous_posts_link('<i class="iconfont icon-back"></i>') ?><?php next_posts_link('<i class="iconfont icon-right"></i>') ?>

View File

@ -1321,7 +1321,7 @@ var home = location.href,
AH: function () { AH: function () {
if (Poi.windowheight == 'auto') { if (Poi.windowheight == 'auto') {
if ($('h1.main-title').length > 0) { if ($('h1.main-title').length > 0) {
var _height = $(window).height(); var _height = $(window).height()+"px";
$('#centerbg').css({ $('#centerbg').css({
'height': _height 'height': _height
}); });
@ -1431,27 +1431,53 @@ var home = location.href,
}, },
XLS: function () { XLS: function () {
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body'); $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
var load_post_timer;
var intersectionObserver = new IntersectionObserver(function (entries) {
if (entries[0].intersectionRatio <= 0) return;
var page_next = $('#pagination a').attr("href");
var load_key = document.getElementById("add_post_time");
if(page_next!=undefined && load_key ){
var load_time = document.getElementById("add_post_time").title;
if(load_time !="233"){
console.log("%c 自动加载时倒计时 %c","background:#9a9da2; color:#ffffff; border-radius:4px;","","",load_time);
load_post_timer=setTimeout(function(){load_post();},load_time*1000);
}
}
});
intersectionObserver.observe(
document.querySelector('.footer-device')
);
$('body').on('click', '#pagination a', function () { $('body').on('click', '#pagination a', function () {
$(this).addClass("loading").text(""); clearTimeout(load_post_timer);
load_post();
return false;
});
function load_post() {
$('#pagination a').addClass("loading").text("");
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: $(this).attr("href") + "#main", url: $('#pagination a').attr("href") + "#main",
success: function (data) { success: function (data) {
result = $(data).find("#main .post"); result = $(data).find("#main .post");
nextHref = $(data).find("#pagination a").attr("href"); nextHref = $(data).find("#pagination a").attr("href");
$("#main").append(result.fadeIn(500)); $("#main").append(result.fadeIn(500));
$("#pagination a").removeClass("loading").text("Previous"); $("#pagination a").removeClass("loading").text("Previous");
$('#add_post span').removeClass("loading").text("");
lazyload(); lazyload();
mashiro_global.post_list_show_animation.ini(50); mashiro_global.post_list_show_animation.ini(50);
if (nextHref != undefined) { if (nextHref != undefined) {
$("#pagination a").attr("href", nextHref); $("#pagination a").attr("href", nextHref);
//加载完成上滑
var tempScrollTop = $(window).scrollTop();
$(window).scrollTop(tempScrollTop);
$body.animate({ scrollTop: tempScrollTop + 300 }, 666)
} else { } else {
$("#pagination").html("<span>很高兴你翻到这里,但是真的没有了...</span>"); $("#pagination").html("<span>很高兴你翻到这里,但是真的没有了...</span>");
} }
} }
}); });
return false; return false;
}); }
}, },
XCS: function () { XCS: function () {
var __cancel = jQuery('#cancel-comment-reply-link'), var __cancel = jQuery('#cancel-comment-reply-link'),

View File

@ -259,6 +259,27 @@ function optionsframework_options() {
'np' => __('上一页和下一页', '') 'np' => __('上一页和下一页', '')
)); ));
$options[] = array(
'name' => __('自动加载下一页', 'options_framework_theme'),
'desc' => __('(秒)设置自动加载下一页时间,默认不自动加载', 'options_framework_theme'),
'id' => 'auto_load_post',
'std' => '233',
'type' => 'select',
'options'=>array(
'0'=> __('0秒',''),
'1'=> __('1秒',''),
'2'=> __('2秒',''),
'3'=> __('3秒',''),
'4'=> __('4秒',''),
'5'=> __('5秒',''),
'6'=> __('6秒',''),
'7'=> __('7秒',''),
'8'=> __('8秒',''),
'9'=> __('9秒',''),
'10'=> __('10秒',''),
'233'=> __('233秒,即不倒计时自动加载',''),
));
$options[] = array( $options[] = array(
'name' => __('博主描述', 'options_framework_theme'), 'name' => __('博主描述', 'options_framework_theme'),
'desc' => __('一段自我描述的话', 'options_framework_theme'), 'desc' => __('一段自我描述的话', 'options_framework_theme'),