Merge branch 'LQDJudge:master' into master
This commit is contained in:
commit
49a186f72f
13 changed files with 132 additions and 90 deletions
|
@ -118,8 +118,11 @@
|
|||
};
|
||||
|
||||
$('.actionbar-comment').on('click', function() {
|
||||
$('#comment-section').show();
|
||||
$('#write-comment').click();
|
||||
if ($('#comment-section').css('display') == 'none') {
|
||||
$('#comment-section').show();
|
||||
} else {
|
||||
$('#write-comment').click();
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script>
|
||||
window.page = {{page_obj.number}};
|
||||
window.has_next_page = {{1 if page_obj.has_next() else 0}};
|
||||
window.has_next_page = {{1 if has_next_page else 0}};
|
||||
window.loading_page = false;
|
||||
$(function() {
|
||||
function getQueryParams() {
|
||||
|
@ -14,30 +14,44 @@
|
|||
return queryParams;
|
||||
}
|
||||
|
||||
function loadNextPage() {
|
||||
window.loading_page = true;
|
||||
var params = {
|
||||
"only_content": 1,
|
||||
"page": window.page + 1,
|
||||
};
|
||||
|
||||
params = Object.assign({}, getQueryParams(), params);
|
||||
|
||||
$.get("{{feed_content_url}}", params)
|
||||
.done(function(data) {
|
||||
$(".has_next").remove();
|
||||
$(".middle-content").append(data);
|
||||
window.loading_page = false;
|
||||
window.has_next_page = parseInt($(".has_next").attr("value"));
|
||||
window.page++;
|
||||
MathJax.typeset($('.middle-content')[0]);
|
||||
onWindowReady();
|
||||
activateBlogBoxOnClick();
|
||||
})
|
||||
}
|
||||
|
||||
$(window).on("scroll", function() {
|
||||
if (window.loading_page || !window.has_next_page) return;
|
||||
var distanceFromBottom = $(document).height() - ($(window).scrollTop() + $(window).height());
|
||||
if (distanceFromBottom < 500) {
|
||||
window.loading_page = true;
|
||||
var params = {
|
||||
"only_content": 1,
|
||||
"page": window.page + 1,
|
||||
};
|
||||
var isDesktop = window.matchMedia('(min-width: 800px)').matches;
|
||||
|
||||
params = Object.assign({}, getQueryParams(), params);
|
||||
|
||||
$.get("{{feed_content_url}}", params)
|
||||
.done(function(data) {
|
||||
$(".has_next").remove();
|
||||
$(".middle-content").append(data);
|
||||
window.loading_page = false;
|
||||
window.has_next_page = parseInt($(".has_next").attr("value"));
|
||||
window.page++;
|
||||
MathJax.typeset($('.middle-content')[0]);
|
||||
onWindowReady();
|
||||
activateBlogBoxOnClick();
|
||||
})
|
||||
if (isDesktop && distanceFromBottom < 500) {
|
||||
loadNextPage();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("click", ".view-next-page", () => {
|
||||
if (window.loading_page || !window.has_next_page) return;
|
||||
var isDesktop = window.matchMedia('(min-width: 800px)').matches;
|
||||
if (isDesktop) return;
|
||||
$(".view-next-page").remove();
|
||||
loadNextPage();
|
||||
});
|
||||
});
|
||||
</script>
|
|
@ -1 +1,4 @@
|
|||
<div class="has_next" style="display: none;" value="{{1 if has_next_page else 0}}"></div>
|
||||
<div class="has_next" style="display: none;" value="{{1 if has_next_page else 0}}"></div>
|
||||
{% if has_next_page %}
|
||||
<button class="view-next-page btn-green small">{{_('View more')}}</button>
|
||||
{% endif %}
|
Loading…
Add table
Add a link
Reference in a new issue