aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/main.js
diff options
context:
space:
mode:
authorHaakon Meland Eriksen <haakon.eriksen@far.no>2016-02-18 20:33:25 +0100
committerHaakon Meland Eriksen <haakon.eriksen@far.no>2016-02-18 20:33:25 +0100
commitcc264b2d60049a844fe17322fbcb367712a7071f (patch)
treef1f069a49dd186d4cf21c37a25fb794d6d53e6f2 /view/js/main.js
parentb77c5ae61e5a208daf4b9431a730db874c487e32 (diff)
parent33c34984e647f48452d53b93b635f6f517a0f392 (diff)
downloadvolse-hubzilla-cc264b2d60049a844fe17322fbcb367712a7071f.tar.gz
volse-hubzilla-cc264b2d60049a844fe17322fbcb367712a7071f.tar.bz2
volse-hubzilla-cc264b2d60049a844fe17322fbcb367712a7071f.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'view/js/main.js')
-rw-r--r--view/js/main.js167
1 files changed, 95 insertions, 72 deletions
diff --git a/view/js/main.js b/view/js/main.js
index f75f1f095..04b317914 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -617,8 +617,8 @@ function updateConvItems(mode,data) {
/* autocomplete @nicknames */
$(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl?f=&n=1");
-/*
- var bimgs = $(".wall-item-body img").not(function() { return this.complete; });
+
+ var bimgs = ((preloadImages) ? false : $(".wall-item-body img").not(function() { return this.complete; }));
var bimgcount = bimgs.length;
if (bimgcount) {
@@ -631,37 +631,49 @@ function updateConvItems(mode,data) {
} else {
collapseHeight();
}
-*/
- collapseHeight();
}
function collapseHeight() {
var origContentHeight = parseInt($("#region_2").height());
+ var cDiff = 0;
+ var i = 0;
+ var position = $(window).scrollTop();
+
$(".wall-item-content, .directory-collapse").each(function() {
var orgHeight = parseInt($(this).css('height'));
if(orgHeight > divmore_height) {
if(! $(this).hasClass('divmore')) {
- var trigger = $(window).scrollTop() < $(this).offset().top ? true : false;
-
- if(trigger) {
- $(this).readmore({
- speed: 0,
- heightMargin: 50,
- collapsedHeight: divmore_height,
- moreLink: '<a href="#" class="divgrow-showmore">' + aStr.divgrowmore + '</a>',
- lessLink: '<a href="#" class="divgrow-showmore">' + aStr.divgrowless + '</a>',
- beforeToggle: function(trigger, element, expanded) {
- if(expanded) {
- if((($(element).offset().top + divmore_height) - $(window).scrollTop()) < 65 ) {
- $(window).scrollTop($(window).scrollTop() - (orgHeight - divmore_height));
- }
+ //var trigger = $(window).scrollTop() < $(this).offset().top ? true : false;
+ //console.log($(this).offset().top + divmore_height - $(window).scrollTop() + cDiff - ($(".divgrow-showmore").outerHeight() * i));
+
+ // check if we will collapse some content above the visible content and compensate the diff later
+ if($(this).offset().top + divmore_height - $(window).scrollTop() + cDiff - ($(".divgrow-showmore").outerHeight() * i) < 65) {
+ //$(this).css('color', 'red');
+ //console.log($(this).offset().top + divmore_height + ' / ' + $(window).scrollTop());
+ diff = orgHeight - divmore_height;
+ cDiff = cDiff + diff;
+ i++;
+ }
+
+ //if(trigger) {
+ $(this).readmore({
+ speed: 0,
+ heightMargin: 50,
+ collapsedHeight: divmore_height,
+ moreLink: '<a href="#" class="divgrow-showmore">' + aStr.divgrowmore + '</a>',
+ lessLink: '<a href="#" class="divgrow-showmore">' + aStr.divgrowless + '</a>',
+ beforeToggle: function(trigger, element, expanded) {
+ if(expanded) {
+ if((($(element).offset().top + divmore_height) - $(window).scrollTop()) < 65 ) {
+ $(window).scrollTop($(window).scrollTop() - (orgHeight - divmore_height));
}
}
- });
- $(this).addClass('divmore');
- }
+ }
+ });
+ $(this).addClass('divmore');
+ //}
}
}
});
@@ -670,6 +682,12 @@ function collapseHeight() {
contentHeightDiff = origContentHeight - collapsedContentHeight;
console.log('collapseHeight() - contentHeightDiff: ' + contentHeightDiff + 'px');
+ if(i){
+ var sval = position - cDiff + ($(".divgrow-showmore").outerHeight() * i);
+ console.log('collapsed above viewport count: ' + i);
+ $(window).scrollTop(sval);
+ }
+
}
@@ -721,39 +739,67 @@ function liveUpdate() {
$.get(update_url, function(data) {
var dready = new Date();
console.log('DATA ready in: ' + (dready - dstart)/1000 + ' seconds.');
- console.log('LOADING images...');
- $('.wall-item-body, .wall-photo-item',data).imagesLoaded( function() {
- var iready = new Date();
- console.log('IMAGES ready in: ' + (iready - dready)/1000 + ' seconds.');
+ if(update_mode === 'update' || preloadImages) {
+ console.log('LOADING images...');
- page_load = false;
- scroll_next = false;
- updateConvItems(update_mode,data);
- $("#page-spinner").spin(false);
- $("#profile-jot-text-loading").spin(false);
+ $('.wall-item-body, .wall-photo-item',data).imagesLoaded( function() {
+ var iready = new Date();
+ console.log('IMAGES ready in: ' + (iready - dready)/1000 + ' seconds.');
- if(update_mode === 'update') {
- $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff);
- }
+ page_load = false;
+ scroll_next = false;
+ updateConvItems(update_mode,data);
+ $("#page-spinner").spin(false);
+ $("#profile-jot-text-loading").spin(false);
- in_progress = false;
+ // adjust scroll position if new content was added above viewport
+ if(update_mode === 'update') {
+ $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff);
+ }
- // FIXME - the following lines were added so that almost
- // immediately after we update the posts on the page, we
- // re-check and update the notification counts.
- // As it turns out this causes a bit of an inefficiency
- // as we're pinging twice for every update, once before
- // and once after. A btter way to do this is to rewrite
- // NavUpdate and perhaps LiveUpdate so that we check for
- // post updates first and only call the notification ping
- // once.
+ in_progress = false;
- updateCountsOnly = true;
- if(timer) clearTimeout(timer);
- timer = setTimeout(NavUpdate,10);
+ // FIXME - the following lines were added so that almost
+ // immediately after we update the posts on the page, we
+ // re-check and update the notification counts.
+ // As it turns out this causes a bit of an inefficiency
+ // as we're pinging twice for every update, once before
+ // and once after. A btter way to do this is to rewrite
+ // NavUpdate and perhaps LiveUpdate so that we check for
+ // post updates first and only call the notification ping
+ // once.
- });
+ updateCountsOnly = true;
+ if(timer) clearTimeout(timer);
+ timer = setTimeout(NavUpdate,10);
+
+ });
+ }
+ else {
+ page_load = false;
+ scroll_next = false;
+ updateConvItems(update_mode,data);
+ $("#page-spinner").spin(false);
+ $("#profile-jot-text-loading").spin(false);
+
+ in_progress = false;
+
+ // FIXME - the following lines were added so that almost
+ // immediately after we update the posts on the page, we
+ // re-check and update the notification counts.
+ // As it turns out this causes a bit of an inefficiency
+ // as we're pinging twice for every update, once before
+ // and once after. A btter way to do this is to rewrite
+ // NavUpdate and perhaps LiveUpdate so that we check for
+ // post updates first and only call the notification ping
+ // once.
+
+ updateCountsOnly = true;
+ if(timer) clearTimeout(timer);
+ timer = setTimeout(NavUpdate,10);
+
+ }
});
}
@@ -1231,21 +1277,8 @@ function zFormError(elm,x) {
$(window).scroll(function () {
if(typeof buildCmd == 'function') {
// This is a content page with items and/or conversations
- $('#more').hide();
- $('#no-more').hide();
-
- if($(window).scrollTop() + $(window).height() > $(document).height() - 200) {
- $('#more').css("top","400");
- $('#more').show();
- }
-
- if($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
-// if($(window).scrollTop() > $(document).height() - ($(window).height() * 1.5 )) {
-
+ if($(window).scrollTop() + $(window).height() > $(document).height() - 300) {
if((pageHasMoreContent) && (! loadingPage)) {
- $('#more').hide();
- $('#no-more').hide();
-
next_page++;
scroll_next = true;
loadingPage = true;
@@ -1255,18 +1288,8 @@ $(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($(window).scrollTop() > ($(document).height() - $(window).height() * 1.5 )) {
+ if($(window).scrollTop() + $(window).height() > $(document).height() - 300) {
if((pageHasMoreContent) && (! loadingPage) && (! justifiedGalleryActive)) {
- $('#more').hide();
- $('#no-more').hide();
-
next_page++;
scroll_next = true;
loadingPage = true;