mirror of
https://github.com/mashirozx/sakura.git
synced 2024-12-12 09:54:35 +08:00
自动加载
This commit is contained in:
parent
ce31befb4e
commit
7918e830a2
@ -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>') ?>
|
||||
|
@ -1431,27 +1431,54 @@ var home = location.href,
|
||||
},
|
||||
XLS: function () {
|
||||
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
|
||||
var load_post_timer;
|
||||
$(window).scroll(function () {
|
||||
var htmlHeight=document.body.scrollHeight;
|
||||
var clientHeight=$(this).height() + 1;
|
||||
var scrollTop=document.documentElement.scrollTop;
|
||||
var page_next = $('#pagination a').attr("href");
|
||||
var load_key = document.getElementById("add_post_time");
|
||||
if(scrollTop+clientHeight > htmlHeight){
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
$('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'),
|
||||
|
21
options.php
21
options.php
@ -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'),
|
||||
|
Loading…
Reference in New Issue
Block a user