aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/main.js
diff options
context:
space:
mode:
authorPaolo Tacconi <p.tacconi@giunti.it>2016-04-15 09:22:27 +0200
committerPaolo Tacconi <p.tacconi@giunti.it>2016-04-15 09:22:27 +0200
commitc38c79d71c8ef70ef649f83e322f1984b75ee2dd (patch)
tree958fcd22f04546f40b6ac68bb58cfe1a1b1fb7f6 /view/js/main.js
parent1806da0851dd5cf5978b19d12783ae3101a11257 (diff)
parent45a854762b451dafb882bc56efce054b64420627 (diff)
downloadvolse-hubzilla-c38c79d71c8ef70ef649f83e322f1984b75ee2dd.tar.gz
volse-hubzilla-c38c79d71c8ef70ef649f83e322f1984b75ee2dd.tar.bz2
volse-hubzilla-c38c79d71c8ef70ef649f83e322f1984b75ee2dd.zip
Merge branch 'redmatrix-master'
Diffstat (limited to 'view/js/main.js')
-rw-r--r--view/js/main.js165
1 files changed, 113 insertions, 52 deletions
diff --git a/view/js/main.js b/view/js/main.js
index d670b704a..799ae82bc 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -248,6 +248,7 @@ var updateCountsOnly = false;
var divmore_height = 400;
var last_filestorage_id = null;
var mediaPlaying = false;
+var contentHeightDiff = 0;
$(function() {
$.ajaxSetup({cache: false});
@@ -490,6 +491,7 @@ function updateConvItems(mode,data) {
if(isVisible)
showHideComments(itmId);
$("> .wall-item-outside-wrapper .autotime, > .thread-wrapper .autotime",this).timeago();
+ $("> .shared_header .autotime",this).timeago();
}
else {
$('img',this).each(function() {
@@ -501,6 +503,7 @@ function updateConvItems(mode,data) {
if(isVisible)
showHideComments(itmId);
$("> .wall-item-outside-wrapper .autotime, > .thread-wrapper .autotime",this).timeago();
+ $("> .shared_header .autotime",this).timeago();
}
prev = ident;
});
@@ -528,6 +531,7 @@ function updateConvItems(mode,data) {
if(isVisible)
showHideComments(itmId);
$("> .wall-item-outside-wrapper .autotime, > .thread-wrapper .autotime",this).timeago();
+ $("> .shared_header .autotime",this).timeago();
}
else {
$('img',this).each(function() {
@@ -539,6 +543,7 @@ function updateConvItems(mode,data) {
if(isVisible)
showHideComments(itmId);
$("> .wall-item-outside-wrapper .autotime, > .thread-wrapper .autotime",this).timeago();
+ $("> .shared_header .autotime",this).timeago();
}
});
@@ -572,6 +577,7 @@ function updateConvItems(mode,data) {
if(isVisible)
showHideComments(itmId);
$("> .wall-item-outside-wrapper .autotime, > .thread-wrapper .autotime",this).timeago();
+ $("> .shared_header .autotime",this).timeago();
}
prev = ident;
});
@@ -616,8 +622,10 @@ function updateConvItems(mode,data) {
/* autocomplete @nicknames */
$(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl?f=&n=1");
+ /* autocomplete bbcode */
+ $(".comment-edit-form textarea").bbco_autocomplete('bbcode');
- 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) {
@@ -630,32 +638,64 @@ function updateConvItems(mode,data) {
} else {
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 = $(this).outerHeight(true);
- if(orgHeight > divmore_height + 10) {
+ var orgHeight = parseInt($(this).css('height'));
+ if(orgHeight > divmore_height) {
if(! $(this).hasClass('divmore')) {
+
+ //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,
+ 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 ) {
- $('html, body').animate( { scrollTop: $(window).scrollTop() - (orgHeight - divmore_height) }, {duration: 0 } );
+ $(window).scrollTop($(window).scrollTop() - (orgHeight - divmore_height));
}
}
}
});
$(this).addClass('divmore');
+ //}
}
}
});
+
+ var collapsedContentHeight = parseInt($("#region_2").height());
+ 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);
+ }
+
+
}
function liveUpdate() {
@@ -700,32 +740,74 @@ function liveUpdate() {
var orgHeight = $("#region_2").height();
}
+
+ var dstart = new Date();
+ console.log('LOADING data...');
$.get(update_url, function(data) {
- page_load = false;
- scroll_next = false;
- updateConvItems(update_mode,data);
- $("#page-spinner").spin(false);
- $("#profile-jot-text-loading").spin(false);
+ var dready = new Date();
+ console.log('DATA ready in: ' + (dready - dstart)/1000 + ' seconds.');
+
+ if(update_mode === 'update' || preloadImages) {
+ 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);
+
+ // adjust scroll position if new content was added above viewport
+ if(update_mode === 'update') {
+ $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff);
+ }
+
+ in_progress = false;
- if(update_mode === 'update') {
- $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight);
+ // 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);
- 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);
});
}
@@ -971,6 +1053,7 @@ function preview_comment(id) {
function(data) {
if(data.preview) {
$("#comment-edit-preview-" + id).html(data.preview);
+ $("#comment-edit-preview-" + id + " .autotime").timeago();
$("#comment-edit-preview-" + id + " a").click(function() { return false; });
}
},
@@ -1001,6 +1084,7 @@ function preview_post() {
function(data) {
if(data.preview) {
$("#jot-preview-content").html(data.preview);
+ $("#jot-preview-content .autotime").timeago();
$("#jot-preview-content" + " a").click(function() { return false; });
}
},
@@ -1202,21 +1286,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;
@@ -1226,18 +1297,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;