diff options
Diffstat (limited to 'view/js')
-rw-r--r-- | view/js/autocomplete.js | 2 | ||||
-rw-r--r-- | view/js/main.js | 156 | ||||
-rw-r--r-- | view/js/mod_connections.js | 7 | ||||
-rw-r--r-- | view/js/mod_register.js | 21 |
4 files changed, 130 insertions, 56 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_register.js b/view/js/mod_register.js index 95bc7bbbb..8430b4655 100644 --- a/view/js/mod_register.js +++ b/view/js/mod_register.js @@ -26,4 +26,25 @@ $(document).ready(function() { zFormError("#register-password2-feedback", false); } }); + + + $("#newchannel-name").blur(function() { + $("#name-spinner").spin('small'); + var zreg_name = $("#newchannel-name").val(); + $.get("new_channel/autofill.json?f=&name=" + encodeURIComponent(zreg_name),function(data) { + $("#newchannel-nickname").val(data); + zFormError("#newchannel-name-feedback",data.error); + $("#name-spinner").spin(false); + }); + }); + $("#newchannel-nickname").blur(function() { + $("#nick-spinner").spin('small'); + var zreg_nick = $("#newchannel-nickname").val(); + $.get("new_channel/checkaddr.json?f=&nick=" + encodeURIComponent(zreg_nick),function(data) { + $("#newchannel-nickname").val(data); + zFormError("#newchannel-nickname-feedback",data.error); + $("#nick-spinner").spin(false); + }); + }); + });
\ No newline at end of file |