aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
Diffstat (limited to 'view/js')
-rw-r--r--view/js/autocomplete.js2
-rw-r--r--view/js/main.js156
-rw-r--r--view/js/mod_connections.js7
-rw-r--r--view/js/mod_new_channel.js23
-rw-r--r--view/js/mod_register.js58
5 files changed, 156 insertions, 90 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 511a7f815..437425a0e 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -196,4 +196,4 @@ function submit_form(e) {
if(typeof onselect !== 'undefined')
a.on('textComplete:select', function(e, value, strategy) { onselect(value); });
};
-})( jQuery ); \ No newline at end of file
+})( jQuery );
diff --git a/view/js/main.js b/view/js/main.js
index d670b704a..04b317914 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});
@@ -617,7 +618,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 bimgs = ((preloadImages) ? false : $(".wall-item-body img").not(function() { return this.complete; }));
var bimgcount = bimgs.length;
if (bimgcount) {
@@ -630,32 +631,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 +733,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);
});
}
@@ -1202,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;
@@ -1226,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;
diff --git a/view/js/mod_connections.js b/view/js/mod_connections.js
index f29d96729..112204a5a 100644
--- a/view/js/mod_connections.js
+++ b/view/js/mod_connections.js
@@ -1,15 +1,16 @@
-$(document).ready(function() {
+$(document).ready(function() {
$("#contacts-search").contact_autocomplete(baseurl + '/acl', 'a', true);
+ $(".autotime").timeago();
});
$("#contacts-search").keyup(function(event){
if(event.keyCode == 13){
- $("#contacts-search-submit").click();
+ $("#contacts-search").click();
}
});
$(".autocomplete-w1 .selected").keyup(function(event){
if(event.keyCode == 13){
- $("#contacts-search-submit").click();
+ $("#contacts-search").click();
}
});
diff --git a/view/js/mod_new_channel.js b/view/js/mod_new_channel.js
index c4d5408f2..17b354a4b 100644
--- a/view/js/mod_new_channel.js
+++ b/view/js/mod_new_channel.js
@@ -1,20 +1,27 @@
$(document).ready(function() {
// $("#id_permissions_role").sSelect();
- $("#newchannel-name").blur(function() {
+ $("#id_name").blur(function() {
$("#name-spinner").spin('small');
- var zreg_name = $("#newchannel-name").val();
+ var zreg_name = $("#id_name").val();
$.get("new_channel/autofill.json?f=&name=" + encodeURIComponent(zreg_name),function(data) {
- $("#newchannel-nickname").val(data);
- zFormError("#newchannel-name-feedback",data.error);
+ $("#id_nickname").val(data);
+ if(data.error) {
+ $("#help_name").html("");
+ zFormError("#help_name",data.error);
+ }
$("#name-spinner").spin(false);
});
});
- $("#newchannel-nickname").blur(function() {
+
+ $("#id_nickname").blur(function() {
$("#nick-spinner").spin('small');
- var zreg_nick = $("#newchannel-nickname").val();
+ var zreg_nick = $("#id_nickname").val();
$.get("new_channel/checkaddr.json?f=&nick=" + encodeURIComponent(zreg_nick),function(data) {
- $("#newchannel-nickname").val(data);
- zFormError("#newchannel-nickname-feedback",data.error);
+ $("#id_nickname").val(data);
+ if(data.error) {
+ $("#help_nickname").html("");
+ zFormError("#help_nickname",data.error);
+ }
$("#nick-spinner").spin(false);
});
});
diff --git a/view/js/mod_register.js b/view/js/mod_register.js
index 8430b4655..f1f3e7f71 100644
--- a/view/js/mod_register.js
+++ b/view/js/mod_register.js
@@ -1,50 +1,56 @@
$(document).ready(function() {
- $("#register-email").blur(function() {
- var zreg_email = $("#register-email").val();
+ $("#id_email").blur(function() {
+ var zreg_email = $("#id_email").val();
$.get("register/email_check.json?f=&email=" + encodeURIComponent(zreg_email), function(data) {
- $("#register-email-feedback").html(data.message);
- zFormError("#register-email-feedback",data.error);
+ $("#help_email").html(data.message);
+ zFormError("#help_email",data.error);
});
});
- $("#register-password").blur(function() {
- if(($("#register-password").val()).length < 6 ) {
- $("#register-password-feedback").html(aStr.pwshort);
- zFormError("#register-password-feedback", true);
+ $("#id_password").blur(function() {
+ if(($("#id_password").val()).length < 6 ) {
+ $("#help_password").html(aStr.pwshort);
+ zFormError("#help_password", true);
}
else {
- $("#register-password-feedback").html("");
- zFormError("#register-password-feedback", false);
+ $("#help_password").html("");
+ zFormError("#help_password", false);
}
});
- $("#register-password2").blur(function() {
- if($("#register-password").val() != $("#register-password2").val()) {
- $("#register-password2-feedback").html(aStr.pwnomatch);
- zFormError("#register-password2-feedback", true);
+ $("#id_password2").blur(function() {
+ if($("#id_password").val() != $("#id_password2").val()) {
+ $("#help_password2").html(aStr.pwnomatch);
+ zFormError("#help_password2", true);
}
else {
- $("#register-password2-feedback").html("");
- zFormError("#register-password2-feedback", false);
+ $("#help_password2").html("");
+ zFormError("#help_password2", false);
}
});
-
- $("#newchannel-name").blur(function() {
+ $("#id_name").blur(function() {
$("#name-spinner").spin('small');
- var zreg_name = $("#newchannel-name").val();
+ var zreg_name = $("#id_name").val();
$.get("new_channel/autofill.json?f=&name=" + encodeURIComponent(zreg_name),function(data) {
- $("#newchannel-nickname").val(data);
- zFormError("#newchannel-name-feedback",data.error);
+ $("#id_nickname").val(data);
+ if(data.error) {
+ $("#help_name").html("");
+ zFormError("#help_name",data.error);
+ }
$("#name-spinner").spin(false);
});
});
- $("#newchannel-nickname").blur(function() {
+
+ $("#id_nickname").blur(function() {
$("#nick-spinner").spin('small');
- var zreg_nick = $("#newchannel-nickname").val();
+ var zreg_nick = $("#id_nickname").val();
$.get("new_channel/checkaddr.json?f=&nick=" + encodeURIComponent(zreg_nick),function(data) {
- $("#newchannel-nickname").val(data);
- zFormError("#newchannel-nickname-feedback",data.error);
+ $("#id_nickname").val(data);
+ if(data.error) {
+ $("#help_nickname").html("");
+ zFormError("#help_nickname",data.error);
+ }
$("#nick-spinner").spin(false);
});
});
-}); \ No newline at end of file
+});