mirror of
https://github.com/mashirozx/sakura.git
synced 2024-11-22 14:58:14 +08:00
自动加载
This commit is contained in:
parent
ce31befb4e
commit
7918e830a2
@ -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>') ?>
|
||||||
|
@ -1431,27 +1431,54 @@ 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;
|
||||||
|
$(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 () {
|
$('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'),
|
||||||
|
21
options.php
21
options.php
@ -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'),
|
||||||
|
Loading…
Reference in New Issue
Block a user