aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/main.js
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2016-02-16 20:53:38 +0100
committerMario Vavti <mario@mariovavti.com>2016-02-16 20:53:38 +0100
commit45247d1595f4478bf9bb684efd210afbcc36f018 (patch)
tree3c1a2effb8f7bf59999cef3cac7905eeb416ee5c /view/js/main.js
parent3be6ef6bfcf662616b37da85fbeb2a7a08a1bd4e (diff)
downloadvolse-hubzilla-45247d1595f4478bf9bb684efd210afbcc36f018.tar.gz
volse-hubzilla-45247d1595f4478bf9bb684efd210afbcc36f018.tar.bz2
volse-hubzilla-45247d1595f4478bf9bb684efd210afbcc36f018.zip
only prefetch images on update_mode update
Diffstat (limited to 'view/js/main.js')
-rw-r--r--view/js/main.js83
1 files changed, 54 insertions, 29 deletions
diff --git a/view/js/main.js b/view/js/main.js
index f9f88aec6..19f0eb79c 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -617,7 +617,7 @@ 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 bimgcount = bimgs.length;
@@ -631,8 +631,8 @@ function updateConvItems(mode,data) {
} else {
collapseHeight();
}
-*/
- collapseHeight();
+
+ //collapseHeight();
}
@@ -648,7 +648,6 @@ function collapseHeight() {
if(! $(this).hasClass('divmore')) {
//var trigger = $(window).scrollTop() < $(this).offset().top ? true : false;
- var trigger = true;
// check if we will collapse some content above the visible content and compensate the diff later
if($(window).scrollTop() > $(this).offset().top) {
@@ -657,23 +656,23 @@ function collapseHeight() {
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));
- }
+ //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');
+ //}
}
}
});
@@ -683,7 +682,7 @@ function collapseHeight() {
console.log('collapseHeight() - contentHeightDiff: ' + contentHeightDiff + 'px');
if(i){
- var sval = position - cDiff + $(".divgrow-showmore").height();
+ var sval = position - cDiff + ($(".divgrow-showmore").outerHeight() * i);
console.log('collapsed above content count: ' + i);
$(window).scrollTop(sval);
}
@@ -739,22 +738,48 @@ 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') {
+ 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.');
+
+ page_load = false;
+ scroll_next = false;
+ updateConvItems(update_mode,data);
+ $("#page-spinner").spin(false);
+ $("#profile-jot-text-loading").spin(false);
+
+ $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff);
+
+ 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);
+
+ });
+ }
+ else {
page_load = false;
scroll_next = false;
updateConvItems(update_mode,data);
$("#page-spinner").spin(false);
$("#profile-jot-text-loading").spin(false);
- if(update_mode === 'update') {
- $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff);
- }
-
in_progress = false;
// FIXME - the following lines were added so that almost
@@ -771,7 +796,7 @@ function liveUpdate() {
if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,10);
- });
+ }
});
}