aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/main.js
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-07-22 22:15:34 -0700
committerfriendica <info@friendica.com>2014-07-22 22:15:34 -0700
commit5c6a251213c7ec28ac113633cdc41f532bb6a7da (patch)
tree47a1874c189268a9d57292edfdca72a577ed4a4a /view/js/main.js
parent9e500494ffcd6f7390e06e3350bb40bcccbb8f35 (diff)
downloadvolse-hubzilla-5c6a251213c7ec28ac113633cdc41f532bb6a7da.tar.gz
volse-hubzilla-5c6a251213c7ec28ac113633cdc41f532bb6a7da.tar.bz2
volse-hubzilla-5c6a251213c7ec28ac113633cdc41f532bb6a7da.zip
some backend JS support for an endless scroll directory
Diffstat (limited to 'view/js/main.js')
-rw-r--r--view/js/main.js71
1 files changed, 68 insertions, 3 deletions
diff --git a/view/js/main.js b/view/js/main.js
index 191f24b59..c803ad538 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -384,6 +384,20 @@
}
+
+function updatePageItems(mode,data) {
+ if(mode === 'append') {
+ $(data).each(function() {
+ $('#page-end').before($(this));
+ });
+
+ if(loadingPage) {
+ loadingPage = false;
+ }
+ }
+}
+
+
function updateConvItems(mode,data) {
if(mode === 'update') {
@@ -560,8 +574,6 @@ function updateConvItems(mode,data) {
-
-
function liveUpdate() {
if((src == null) || (stopped) || (! profile_uid)) { $('.like-rotator').spin(false); return; }
if(($('.comment-edit-text-full').length) || (in_progress)) {
@@ -628,6 +640,37 @@ function updateConvItems(mode,data) {
}
+ function pageUpdate() {
+
+ in_progress = true;
+
+ var update_url;
+ var update_mode;
+
+ if(scroll_next) {
+ bParam_page = next_page;
+ page_load = true;
+ }
+ else {
+ bParam_page = 1;
+ }
+
+ update_url = baseurl + '/directory/?f=&page=' + bParam_page;
+
+ $("#page-spinner").spin('small');
+ update_mode = 'append';
+
+ $.get(update_url,function(data) {
+ page_load = false;
+ scroll_next = false;
+ updatePageItems(update_mode,data);
+ $("#page-spinner").spin(false);
+ in_progress = false;
+ });
+
+ }
+
+
function notify_popup_loader(notifyType) {
/* notifications template */
@@ -1014,6 +1057,7 @@ $(document).ready(function() {
$(window).scroll(function () {
if(typeof buildCmd == 'function') {
+ // This is a content page with items and/or conversations
$('#more').hide();
$('#no-more').hide();
@@ -1026,7 +1070,7 @@ $(window).scroll(function () {
if((pageHasMoreContent) && (! loadingPage)) {
$('#more').hide();
$('#no-more').hide();
- // alert('scroll');
+
next_page++;
scroll_next = true;
loadingPage = true;
@@ -1034,6 +1078,27 @@ $(window).scroll(function () {
}
}
}
+ else {
+ // This is some other kind of page - perhaps a directory
+
+ if($(window).scrollTop() + $(window).height() > $(document).height() - 200) {
+ $('#more').css("top","400");
+ $('#more').show();
+ }
+
+ if($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
+ if((pageHasMoreContent) && (! loadingPage)) {
+ $('#more').hide();
+ $('#no-more').hide();
+
+ next_page++;
+ scroll_next = true;
+ loadingPage = true;
+ pageUpdate();
+ }
+ }
+ }
+
});
var chanviewFullSize = false;