Merge pull request #100 from spirit1431007/pr-branch

bug fix&自动加载
pull/105/head
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 ){
// fix the target="_blank" bug after the link
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
$pos = strpos( $bit, '>' );
// check if there is an end (only fails with malformed markup)

View File

@ -65,6 +65,7 @@ get_header();
</main><!-- #main -->
<?php if ( akina_option('pagenav_style') == 'ajax') { ?>
<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{ ?>
<nav class="navigator">
<?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 () {
if (Poi.windowheight == 'auto') {
if ($('h1.main-title').length > 0) {
var _height = $(window).height();
var _height = $(window).height()+"px";
$('#centerbg').css({
'height': _height
});
@ -1431,27 +1431,53 @@ var home = location.href,
},
XLS: function () {
$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 () {
$(this).addClass("loading").text("");
clearTimeout(load_post_timer);
load_post();
return false;
});
function load_post() {
$('#pagination a').addClass("loading").text("");
$.ajax({
type: "POST",
url: $(this).attr("href") + "#main",
url: $('#pagination a').attr("href") + "#main",
success: function (data) {
result = $(data).find("#main .post");
nextHref = $(data).find("#pagination a").attr("href");
$("#main").append(result.fadeIn(500));
$("#pagination a").removeClass("loading").text("Previous");
$('#add_post span').removeClass("loading").text("");
lazyload();
mashiro_global.post_list_show_animation.ini(50);
if (nextHref != undefined) {
$("#pagination a").attr("href", nextHref);
//加载完成上滑
var tempScrollTop = $(window).scrollTop();
$(window).scrollTop(tempScrollTop);
$body.animate({ scrollTop: tempScrollTop + 300 }, 666)
} else {
$("#pagination").html("<span>很高兴你翻到这里,但是真的没有了...</span>");
}
}
});
return false;
});
}
},
XCS: function () {
var __cancel = jQuery('#cancel-comment-reply-link'),

View File

@ -258,6 +258,27 @@ function optionsframework_options() {
'ajax' => __('ajax加载', ''),
'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(
'name' => __('博主描述', 'options_framework_theme'),