From 3bf9dc9f181174e2cf946d2bff75300758951d72 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 13 Jan 2016 01:17:02 -0800 Subject: more work on auto channel creation during register --- view/js/mod_register.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'view/js') 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 -- cgit v1.2.3 From 588d022fbb8490f0531b7e44a6af0b596409dc38 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 14 Jan 2016 23:23:12 +0100 Subject: provide some info about our contacts - status (archived, hidden, etc.), public forum (like in directory) and show since when we are connected --- view/js/autocomplete.js | 2 +- view/js/mod_connections.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'view/js') 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/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(); } }); -- cgit v1.2.3 From d7abacb7b2737699d983862aa03628ee3d758545 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 30 Jan 2016 00:30:49 +0100 Subject: it is not perfect but it still may ease the collapsing of items above the viewport a little... --- view/js/main.js | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 3 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index d670b704a..3906953f6 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -630,14 +630,29 @@ function updateConvItems(mode,data) { } else { collapseHeight(); } + } +var contentHeightDiff = 0; function collapseHeight() { + var origContentHeight = parseInt($("#region_2").height()); + var cDiff = 0; + var i = 0; $(".wall-item-content, .directory-collapse").each(function() { - var orgHeight = $(this).outerHeight(true); - if(orgHeight > divmore_height + 10) { + var orgHeight = parseInt($(this).height()); + if(orgHeight > divmore_height) { if(! $(this).hasClass('divmore')) { + + // check if we will collapse some content above the visible content and compensate the diff later + if(($(this).offset().top + orgHeight - $(window).scrollTop()) < 50) { + diff = orgHeight - divmore_height; + //console.log('diff: ' + diff); + + cDiff = cDiff + diff; + i++; + } + $(this).readmore({ speed: 0, heightMargin: 50, @@ -653,9 +668,38 @@ function collapseHeight() { } }); $(this).addClass('divmore'); + } } }); + + var collapsedContentHeight = parseInt($("#region_2").height()); + contentHeightDiff = origContentHeight - collapsedContentHeight; + + if(i){ + + var position = $(window).scrollTop(); + + //console.log('cDiff: ' + cDiff); + + //console.log('position: ' + position); + + //console.log('origContentHeight: ' + origContentHeight); + + //console.log('collapsedContentHeight: ' + collapsedContentHeight); + + //console.log('contentHeightDiff: ' + contentHeightDiff); + + var sval = position - cDiff + (i*3); // i*3 is possibly some border or margin/padding which might not be calculated correct + + //console.log('sval: ' + sval); + console.log('collapsed above content count: ' + i); + + $(window).scrollTop(sval); + + //var nposition = $(document).scrollTop(); + //console.log('nposition: ' + nposition); + } } function liveUpdate() { @@ -708,7 +752,7 @@ function liveUpdate() { $("#profile-jot-text-loading").spin(false); if(update_mode === 'update') { - $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight); + $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff); } in_progress = false; -- cgit v1.2.3 From da198fdda50389d79f1c792d6e11369ec869a88e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 30 Jan 2016 01:28:01 +0100 Subject: more on collapsing --- view/js/main.js | 73 ++++++++++++++++----------------------------------------- 1 file changed, 20 insertions(+), 53 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 3906953f6..a37c23cf0 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}); @@ -624,7 +625,7 @@ function updateConvItems(mode,data) { bimgs.load(function() { bimgcount--; if (! bimgcount) { - collapseHeight(); + collapseHeight(true); } }); } else { @@ -633,42 +634,29 @@ function updateConvItems(mode,data) { } - -var contentHeightDiff = 0; -function collapseHeight() { +function collapseHeight(below=false) { var origContentHeight = parseInt($("#region_2").height()); - var cDiff = 0; - var i = 0; $(".wall-item-content, .directory-collapse").each(function() { var orgHeight = parseInt($(this).height()); if(orgHeight > divmore_height) { if(! $(this).hasClass('divmore')) { - - // check if we will collapse some content above the visible content and compensate the diff later - if(($(this).offset().top + orgHeight - $(window).scrollTop()) < 50) { - diff = orgHeight - divmore_height; - //console.log('diff: ' + diff); - - cDiff = cDiff + diff; - i++; - } - - $(this).readmore({ - speed: 0, - heightMargin: 50, - collapsedHeight: divmore_height, - moreLink: '' + aStr.divgrowmore + '', - lessLink: '' + aStr.divgrowless + '', - 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 } ); + if((below=true) && ($(window).scrollTop() + ($(window).height() - divmore_height) < $(this).offset().top)) { + $(this).readmore({ + speed: 0, + heightMargin: 50, + collapsedHeight: divmore_height, + moreLink: '' + aStr.divgrowmore + '', + lessLink: '' + aStr.divgrowless + '', + 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 } ); + } } } - } - }); - $(this).addClass('divmore'); - + }); + $(this).addClass('divmore'); + } } } }); @@ -676,30 +664,7 @@ function collapseHeight() { var collapsedContentHeight = parseInt($("#region_2").height()); contentHeightDiff = origContentHeight - collapsedContentHeight; - if(i){ - var position = $(window).scrollTop(); - - //console.log('cDiff: ' + cDiff); - - //console.log('position: ' + position); - - //console.log('origContentHeight: ' + origContentHeight); - - //console.log('collapsedContentHeight: ' + collapsedContentHeight); - - //console.log('contentHeightDiff: ' + contentHeightDiff); - - var sval = position - cDiff + (i*3); // i*3 is possibly some border or margin/padding which might not be calculated correct - - //console.log('sval: ' + sval); - console.log('collapsed above content count: ' + i); - - $(window).scrollTop(sval); - - //var nposition = $(document).scrollTop(); - //console.log('nposition: ' + nposition); - } } function liveUpdate() { @@ -751,6 +716,8 @@ function liveUpdate() { $("#page-spinner").spin(false); $("#profile-jot-text-loading").spin(false); + console.log('contentHeightDiff: ' + contentHeightDiff); + if(update_mode === 'update') { $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff); } -- cgit v1.2.3 From b6543beca2f0e5e353b497099e3fa6b29bf47233 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 30 Jan 2016 01:34:27 +0100 Subject: do not make a difference if there are images or not for now --- view/js/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index a37c23cf0..16f6b9213 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -625,7 +625,7 @@ function updateConvItems(mode,data) { bimgs.load(function() { bimgcount--; if (! bimgcount) { - collapseHeight(true); + collapseHeight(); } }); } else { @@ -634,13 +634,13 @@ function updateConvItems(mode,data) { } -function collapseHeight(below=false) { +function collapseHeight() { var origContentHeight = parseInt($("#region_2").height()); $(".wall-item-content, .directory-collapse").each(function() { var orgHeight = parseInt($(this).height()); if(orgHeight > divmore_height) { if(! $(this).hasClass('divmore')) { - if((below=true) && ($(window).scrollTop() + ($(window).height() - divmore_height) < $(this).offset().top)) { + if($(window).scrollTop() + ($(window).height() - divmore_height) < $(this).offset().top) { $(this).readmore({ speed: 0, heightMargin: 50, -- cgit v1.2.3 From 0405a49df19663d92a8e660a4193dbf2f582f04d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 30 Jan 2016 13:47:58 +0100 Subject: fix a slight regression --- view/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 16f6b9213..220898efd 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -637,7 +637,7 @@ function updateConvItems(mode,data) { function collapseHeight() { var origContentHeight = parseInt($("#region_2").height()); $(".wall-item-content, .directory-collapse").each(function() { - var orgHeight = parseInt($(this).height()); + var orgHeight = parseInt($(this).css('height')); if(orgHeight > divmore_height) { if(! $(this).hasClass('divmore')) { if($(window).scrollTop() + ($(window).height() - divmore_height) < $(this).offset().top) { -- cgit v1.2.3 From f1245206ceadd60fec4bd00948c115f74ad6dbd7 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 2 Feb 2016 12:40:40 +0100 Subject: change aside width to reflect recent widget style changes --- view/js/main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 220898efd..2b13acc3d 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -640,7 +640,10 @@ function collapseHeight() { var orgHeight = parseInt($(this).css('height')); if(orgHeight > divmore_height) { if(! $(this).hasClass('divmore')) { - if($(window).scrollTop() + ($(window).height() - divmore_height) < $(this).offset().top) { + + var trigger = $(window).scrollTop() + ($(window).height() - divmore_height) < $(this).offset().top ? true : false; + + if(trigger) { $(this).readmore({ speed: 0, heightMargin: 50, -- cgit v1.2.3 From 48963f62f974ce4f2d8e26c344b65e87f704e4d6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 8 Feb 2016 22:19:38 +0100 Subject: avoid collapsing only above the viewport --- view/js/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 2b13acc3d..d1bf34699 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -641,7 +641,7 @@ function collapseHeight() { if(orgHeight > divmore_height) { if(! $(this).hasClass('divmore')) { - var trigger = $(window).scrollTop() + ($(window).height() - divmore_height) < $(this).offset().top ? true : false; + var trigger = $(window).scrollTop() < $(this).offset().top ? true : false; if(trigger) { $(this).readmore({ @@ -653,7 +653,7 @@ function collapseHeight() { 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)); } } } -- cgit v1.2.3 From 0b487122f6463b5918207cde99b7ba3ad55d5bcc Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 12 Feb 2016 11:00:50 +0100 Subject: tryout: introduce loading of images before rendering content and provide some detailed logging in js-console --- view/js/main.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index d1bf34699..f75f1f095 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,6 +631,8 @@ function updateConvItems(mode,data) { } else { collapseHeight(); } +*/ + collapseHeight(); } @@ -666,6 +668,7 @@ function collapseHeight() { var collapsedContentHeight = parseInt($("#region_2").height()); contentHeightDiff = origContentHeight - collapsedContentHeight; + console.log('collapseHeight() - contentHeightDiff: ' + contentHeightDiff + 'px'); } @@ -712,15 +715,24 @@ function liveUpdate() { var orgHeight = $("#region_2").height(); } + + var dstart = new Date(); + console.log('LOADING data...'); $.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.'); + page_load = false; scroll_next = false; updateConvItems(update_mode,data); $("#page-spinner").spin(false); $("#profile-jot-text-loading").spin(false); - console.log('contentHeightDiff: ' + contentHeightDiff); - if(update_mode === 'update') { $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff); } @@ -740,6 +752,9 @@ function liveUpdate() { updateCountsOnly = true; if(timer) clearTimeout(timer); timer = setTimeout(NavUpdate,10); + + }); + }); } -- cgit v1.2.3 From afb86aa90896c04101e384edcb4fef6514fbefcc Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 15 Feb 2016 22:20:55 +0100 Subject: clean up some unused stuff and start loading content a bit earlier --- view/js/main.js | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index f75f1f095..cf367ec87 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1231,21 +1231,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 +1242,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; -- cgit v1.2.3 From 3be6ef6bfcf662616b37da85fbeb2a7a08a1bd4e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 16 Feb 2016 14:42:13 +0100 Subject: since we preload images now we also can collapse and calculate posts above the viewport --- view/js/main.js | 68 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 25 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index cf367ec87..f9f88aec6 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -638,12 +638,24 @@ function updateConvItems(mode,data) { 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; + //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) { + diff = orgHeight - divmore_height; + cDiff = cDiff + diff; + i++; + } if(trigger) { $(this).readmore({ @@ -670,6 +682,12 @@ function collapseHeight() { contentHeightDiff = origContentHeight - collapsedContentHeight; console.log('collapseHeight() - contentHeightDiff: ' + contentHeightDiff + 'px'); + if(i){ + var sval = position - cDiff + $(".divgrow-showmore").height(); + console.log('collapsed above content count: ' + i); + $(window).scrollTop(sval); + } + } @@ -724,34 +742,34 @@ function liveUpdate() { 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.'); + 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); + 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); - } + if(update_mode === 'update') { + $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff); + } - in_progress = 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); + // 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); }); -- cgit v1.2.3 From 45247d1595f4478bf9bb684efd210afbcc36f018 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 16 Feb 2016 20:53:38 +0100 Subject: only prefetch images on update_mode update --- view/js/main.js | 83 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 29 deletions(-) (limited to 'view/js') 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: '' + aStr.divgrowmore + '', - lessLink: '' + aStr.divgrowless + '', - 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: '' + aStr.divgrowmore + '', + lessLink: '' + aStr.divgrowless + '', + 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); - }); + } }); } -- cgit v1.2.3 From 679fb7d0d2ce56d1e67c9aa08441c95828d96463 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 16 Feb 2016 20:58:10 +0100 Subject: content -> viewport --- view/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 19f0eb79c..1fb61ebab 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -683,7 +683,7 @@ function collapseHeight() { if(i){ var sval = position - cDiff + ($(".divgrow-showmore").outerHeight() * i); - console.log('collapsed above content count: ' + i); + console.log('collapsed above vieport count: ' + i); $(window).scrollTop(sval); } -- cgit v1.2.3 From 0eb0256502f4091858f3773c92fd63b83eb9a5a9 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 16 Feb 2016 21:02:28 +0100 Subject: typo --- view/js/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 1fb61ebab..2ae542ed8 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -683,7 +683,7 @@ function collapseHeight() { if(i){ var sval = position - cDiff + ($(".divgrow-showmore").outerHeight() * i); - console.log('collapsed above vieport count: ' + i); + console.log('collapsed above viewport count: ' + i); $(window).scrollTop(sval); } -- cgit v1.2.3 From 364972a2925ee9545364e53b79d5a3d50149119d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 16 Feb 2016 21:29:09 +0100 Subject: Thats probably better but there are still edge cases... --- view/js/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 2ae542ed8..ca2f3bbcb 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -650,7 +650,7 @@ function collapseHeight() { //var trigger = $(window).scrollTop() < $(this).offset().top ? true : false; // check if we will collapse some content above the visible content and compensate the diff later - if($(window).scrollTop() > $(this).offset().top) { + if(($(this).offset().top + orgHeight - $(window).scrollTop()) < 50) { diff = orgHeight - divmore_height; cDiff = cDiff + diff; i++; @@ -753,7 +753,7 @@ function liveUpdate() { $("#page-spinner").spin(false); $("#profile-jot-text-loading").spin(false); - $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff); + //$(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff); in_progress = false; -- cgit v1.2.3 From b8c7b2f81df61e5068366cbdb0f18940ff5d4bf1 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 17 Feb 2016 11:07:47 +0100 Subject: more refinement on collapsing --- view/js/main.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index ca2f3bbcb..6bc7d9e91 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -648,9 +648,12 @@ function collapseHeight() { 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 + orgHeight - $(window).scrollTop()) < 50) { + 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++; @@ -753,7 +756,8 @@ function liveUpdate() { $("#page-spinner").spin(false); $("#profile-jot-text-loading").spin(false); - //$(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff); + // adjust scroll position if new content was added above viewport + $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff); in_progress = false; -- cgit v1.2.3 From ddbe3c7426a551420bb6ead09984333e956b3a58 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 17 Feb 2016 12:32:12 +0100 Subject: make always preload images before rendering the page a display setting --- view/js/main.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 6bc7d9e91..04b317914 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -618,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) { @@ -632,8 +632,6 @@ function updateConvItems(mode,data) { collapseHeight(); } - //collapseHeight(); - } function collapseHeight() { @@ -742,8 +740,7 @@ function liveUpdate() { var dready = new Date(); console.log('DATA ready in: ' + (dready - dstart)/1000 + ' seconds.'); - - if(update_mode === 'update') { + if(update_mode === 'update' || preloadImages) { console.log('LOADING images...'); $('.wall-item-body, .wall-photo-item',data).imagesLoaded( function() { @@ -757,7 +754,9 @@ function liveUpdate() { $("#profile-jot-text-loading").spin(false); // adjust scroll position if new content was added above viewport - $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff); + if(update_mode === 'update') { + $(window).scrollTop($(window).scrollTop() + $("#region_2").height() - orgHeight + contentHeightDiff); + } in_progress = false; -- cgit v1.2.3 From 02e82e496e3ec8dbd8264248ad8550dd5e335cba Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 19 Feb 2016 22:28:21 +0100 Subject: pimp up mod new_channel --- view/js/mod_new_channel.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'view/js') diff --git a/view/js/mod_new_channel.js b/view/js/mod_new_channel.js index c4d5408f2..58573f736 100644 --- a/view/js/mod_new_channel.js +++ b/view/js/mod_new_channel.js @@ -1,19 +1,20 @@ $(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); + $("#id_nickname").val(data); zFormError("#newchannel-name-feedback",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); + $("#id_nickname").val(data); zFormError("#newchannel-nickname-feedback",data.error); $("#nick-spinner").spin(false); }); -- cgit v1.2.3 From dd6e3d873d2ff04cb2549530fa838ad58b06cdbc Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 22 Feb 2016 13:04:48 +0100 Subject: some work on mod/register --- view/js/mod_new_channel.js | 10 ++++++-- view/js/mod_register.js | 58 +++++++++++++++++++++++++--------------------- 2 files changed, 40 insertions(+), 28 deletions(-) (limited to 'view/js') diff --git a/view/js/mod_new_channel.js b/view/js/mod_new_channel.js index 58573f736..17b354a4b 100644 --- a/view/js/mod_new_channel.js +++ b/view/js/mod_new_channel.js @@ -5,7 +5,10 @@ var zreg_name = $("#id_name").val(); $.get("new_channel/autofill.json?f=&name=" + encodeURIComponent(zreg_name),function(data) { $("#id_nickname").val(data); - zFormError("#newchannel-name-feedback",data.error); + if(data.error) { + $("#help_name").html(""); + zFormError("#help_name",data.error); + } $("#name-spinner").spin(false); }); }); @@ -15,7 +18,10 @@ var zreg_nick = $("#id_nickname").val(); $.get("new_channel/checkaddr.json?f=&nick=" + encodeURIComponent(zreg_nick),function(data) { $("#id_nickname").val(data); - zFormError("#newchannel-nickname-feedback",data.error); + 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 +}); -- cgit v1.2.3 From 30cf56bdb505ffa50bb7416ec8623fb97418d358 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 20 Mar 2016 01:45:56 +0100 Subject: make >>indicate group members<< in acl selector work again on group > show or group > dont show is selected --- view/js/acl.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'view/js') diff --git a/view/js/acl.js b/view/js/acl.js index 6d94b4987..70440b572 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -231,14 +231,15 @@ ACL.prototype.update_view = function() { } $(that.group_uids[id]).each(function(i, v) { if(uclass == "grouphide") - $("#c"+v).removeClass("groupshow"); + // we need attr selection here because the id can include an @ (diaspora/friendica xchans) + $('[id="c' + v + '"]').removeClass("groupshow"); if(uclass !== "") { - var cls = $("#c"+v).attr('class'); + var cls = $('[id="c' + v + '"]').attr('class'); if( cls === undefined) return true; var hiding = cls.indexOf('grouphide'); if(hiding == -1) - $("#c"+v).addClass(uclass); + $('[id="c' + v + '"]').addClass(uclass); } }); break; @@ -277,7 +278,7 @@ ACL.prototype.populate = function(data) { $(data.items).each(function(){ html = "
"+that.item_tpl+"
"; html = html.format(this.photo, this.name, this.type, this.xid, '', this.self, this.link, this.taggable); - if (this.uids !== undefined) that.group_uids[this.id] = this.uids; + if (this.uids !== undefined) that.group_uids[this.xid] = this.uids; //console.log(html); that.list_content.append(html); }); @@ -287,4 +288,4 @@ ACL.prototype.populate = function(data) { $(el).removeAttr("data-src"); }); that.update_view(); -}; \ No newline at end of file +}; -- cgit v1.2.3 From 1ddb43b0d32ab0dadb3fabc1ed79c96c4365eb77 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 20 Mar 2016 23:07:39 +0100 Subject: an attempt to visualize the supremacy of dont show over show in the acl selector --- view/js/acl.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'view/js') diff --git a/view/js/acl.js b/view/js/acl.js index 70440b572..65f1009ed 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -121,8 +121,10 @@ ACL.prototype.on_button_show = function(event) { event.stopImmediatePropagation(); event.stopPropagation(); - that.set_allow($(this).parent().attr('id')); - that.on_submit(); + if(!$(this).parent().hasClass("grouphide")) { + that.set_allow($(this).parent().attr('id')); + that.on_submit(); + } return false; }; @@ -245,12 +247,15 @@ ACL.prototype.update_view = function() { break; case "c": if (that.allow_cid.indexOf(id)>=0){ - btshow.removeClass("btn-default").addClass("btn-success"); - bthide.removeClass("btn-danger").addClass("btn-default"); + if(!$(this).hasClass("grouphide") ) { + btshow.removeClass("btn-default").addClass("btn-success"); + bthide.removeClass("btn-danger").addClass("btn-default"); + } } if (that.deny_cid.indexOf(id)>=0){ btshow.removeClass("btn-success").addClass("btn-default"); bthide.removeClass("btn-default").addClass("btn-danger"); + $(this).removeClass("groupshow"); } } }); -- cgit v1.2.3 From 5462453bf2bde50166c68f90b08d24826dd07ba8 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 Mar 2016 14:31:55 +0200 Subject: some work on mod chat --- view/js/mod_chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/mod_chat.js b/view/js/mod_chat.js index 6c432742f..0d47e3e77 100644 --- a/view/js/mod_chat.js +++ b/view/js/mod_chat.js @@ -15,4 +15,4 @@ $(document).ready(function() { $('#jot-public').show(); } }).trigger('change'); -}); \ No newline at end of file +}); -- cgit v1.2.3 From 90a5ba01a35aeb3629ebe76069e68c64b913a4d5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 31 Mar 2016 23:13:40 +0200 Subject: make fullscreen mode available for other modules and some cleanup --- view/js/main.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 04b317914..d6d1238d4 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1451,3 +1451,16 @@ function zid(s) { return s; } + +function makeFullScreen(full) { + if(typeof full=='undefined' || full == true) { + $('#fullscreen, aside').hide(); + $('#inline').show(); + $('.generic-content-wrapper').addClass('fullscreen'); + } + else { + $('#fullscreen, aside').show(); + $('#inline').hide(); + $('.generic-content-wrapper').removeClass('fullscreen'); + } +} -- cgit v1.2.3 From 50d9b2934742ad9fb0dc8354d405789e3c14cd00 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Apr 2016 00:16:39 +0200 Subject: slightly change the way fullscreen works and bring it to mod mail --- view/js/main.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index d6d1238d4..4e99bf1aa 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1454,13 +1454,15 @@ function zid(s) { function makeFullScreen(full) { if(typeof full=='undefined' || full == true) { - $('#fullscreen, aside').hide(); - $('#inline').show(); + $('#fullscreen-btn, header, nav, aside').hide(); + $('main').css({'width': '100%', 'max-width': 'none'}); + $('#inline-btn').show(); $('.generic-content-wrapper').addClass('fullscreen'); } else { - $('#fullscreen, aside').show(); - $('#inline').hide(); + $('#fullscreen-btn, header, nav, aside').show(); + $('main').removeAttr('style'); + $('#inline-btn').hide(); $('.generic-content-wrapper').removeClass('fullscreen'); } } -- cgit v1.2.3 From 60bb8f25f7bd1e857f8e70769b83f9c75521db29 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Apr 2016 08:56:51 +0200 Subject: move fullscreen js code to redbasic.js where it belongs to --- view/js/main.js | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index 4e99bf1aa..04b317914 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1451,18 +1451,3 @@ function zid(s) { return s; } - -function makeFullScreen(full) { - if(typeof full=='undefined' || full == true) { - $('#fullscreen-btn, header, nav, aside').hide(); - $('main').css({'width': '100%', 'max-width': 'none'}); - $('#inline-btn').show(); - $('.generic-content-wrapper').addClass('fullscreen'); - } - else { - $('#fullscreen-btn, header, nav, aside').show(); - $('main').removeAttr('style'); - $('#inline-btn').hide(); - $('.generic-content-wrapper').removeClass('fullscreen'); - } -} -- cgit v1.2.3 From ec651f219e10c71a493e0cd2b4737077aee826dc Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 4 Apr 2016 17:12:23 +0200 Subject: a simple autocomplete for bbcode or comanche - partly implemented --- view/js/autocomplete.js | 40 ++++++++++++++++++++++++++++++++++++++++ view/js/main.js | 2 ++ 2 files changed, 42 insertions(+) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 437425a0e..b6e81eb8c 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -197,3 +197,43 @@ function submit_form(e) { a.on('textComplete:select', function(e, value, strategy) { onselect(value); }); }; })( jQuery ); + +(function( $ ) { + $.fn.bbco_autocomplete = function(type) { + + if(type=='bbcode') { + var open_close_elements = ['b', 'i', 'u', 's', 'quote', 'code', 'spoiler', 'map', 'observer']; + var open_elements = ['observer.photo', 'observer.name', 'observer.url']; + + var elements = open_close_elements.concat(open_elements); + } + + if(type=='comanche') { + var elements = ['region', 'widget', 'var', 'template', 'css', 'js']; + } + + bbco = { + match: /\[(\w*)$/, + search: function (term, callback) { + callback($.map(elements, function (element) { + return element.indexOf(term) === 0 ? element : null; + })); + }, + index: 1, + replace: function (element) { + if(open_elements.indexOf(element) < 0) { + return ['\[' + element + '\]', '\[/' + element + '\]']; + } + else { + return '\[' + element + '\] '; + } + } + }; + + this.attr('autocomplete','off'); + var a = this.textcomplete([bbco], {className:'acpopup', zIndex:1020}); + + a.on('textComplete:select', function(e, value, strategy) { value; }); + }; +})( jQuery ); + diff --git a/view/js/main.js b/view/js/main.js index 04b317914..ba476b576 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -617,6 +617,8 @@ 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 = ((preloadImages) ? false : $(".wall-item-body img").not(function() { return this.complete; })); var bimgcount = bimgs.length; -- cgit v1.2.3 From deaf0e99fdd4edb1cccbcf721d34821927c50f3c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 5 Apr 2016 15:27:45 +0200 Subject: expand list of bbcode in autocomplete --- view/js/autocomplete.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index b6e81eb8c..a990ad187 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -202,14 +202,17 @@ function submit_form(e) { $.fn.bbco_autocomplete = function(type) { if(type=='bbcode') { - var open_close_elements = ['b', 'i', 'u', 's', 'quote', 'code', 'spoiler', 'map', 'observer']; - var open_elements = ['observer.photo', 'observer.name', 'observer.url']; + var open_close_elements = ['b', 'i', 'u', 's', 'quote', 'code', 'spoiler', 'map', 'nobb', 'list', 'ul', 'ol', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer',]; + var open_elements = ['observer.baseurl', 'observer.address', 'observer.photo', 'observer.name', 'observer.webname', 'observer.url', '*', 'hr', ]; var elements = open_close_elements.concat(open_elements); } if(type=='comanche') { - var elements = ['region', 'widget', 'var', 'template', 'css', 'js']; + var open_close_elements = ['region', 'widget', 'var', 'template', 'css', 'js']; + var open_elements = []; + + var elements = open_close_elements.concat(open_elements); } bbco = { -- cgit v1.2.3 From bd29551f9aec4c463c02a3c57a5d6d94c9ee318d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 5 Apr 2016 16:59:32 +0200 Subject: fix contextual help --- view/js/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index a990ad187..b4879d464 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -202,7 +202,7 @@ function submit_form(e) { $.fn.bbco_autocomplete = function(type) { if(type=='bbcode') { - var open_close_elements = ['b', 'i', 'u', 's', 'quote', 'code', 'spoiler', 'map', 'nobb', 'list', 'ul', 'ol', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer',]; + var open_close_elements = ['b', 'i', 'u', 's', 'quote', 'code', 'spoiler', 'map', 'nobb', 'list', 'ul', 'ol', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer']; var open_elements = ['observer.baseurl', 'observer.address', 'observer.photo', 'observer.name', 'observer.webname', 'observer.url', '*', 'hr', ]; var elements = open_close_elements.concat(open_elements); -- cgit v1.2.3 From 1eb6067c31f10c8da262fd8aef8d740b94d85137 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Tue, 5 Apr 2016 14:46:16 -0400 Subject: Improve (un)ordered list autocompletion for list construction --- view/js/autocomplete.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index b4879d464..3e7e08b35 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -202,7 +202,7 @@ function submit_form(e) { $.fn.bbco_autocomplete = function(type) { if(type=='bbcode') { - var open_close_elements = ['b', 'i', 'u', 's', 'quote', 'code', 'spoiler', 'map', 'nobb', 'list', 'ul', 'ol', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer']; + var open_close_elements = ['b', 'i', 'u', 's', 'quote', 'code', 'spoiler', 'map', 'nobb', 'li', 'list', 'ul', 'ol', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer']; var open_elements = ['observer.baseurl', 'observer.address', 'observer.photo', 'observer.name', 'observer.webname', 'observer.url', '*', 'hr', ]; var elements = open_close_elements.concat(open_elements); @@ -225,7 +225,11 @@ function submit_form(e) { index: 1, replace: function (element) { if(open_elements.indexOf(element) < 0) { + if(element === 'ol' || element === 'ul') { + return ['\[' + element + '\]' + '\n\[li\]', '\[/li\]\n' + '\[/' + element + '\]']; + } else { return ['\[' + element + '\]', '\[/' + element + '\]']; + } } else { return '\[' + element + '\] '; -- cgit v1.2.3 From 97ccbf1bfb95be412393bed207a26fd8d0cbf512 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 6 Apr 2016 22:18:59 +0200 Subject: adjust the regex to also work with asteriks and use the simpler syntax for lists --- view/js/autocomplete.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 3e7e08b35..5f67476df 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -216,7 +216,7 @@ function submit_form(e) { } bbco = { - match: /\[(\w*)$/, + match: /\[(\w*\**)$/, search: function (term, callback) { callback($.map(elements, function (element) { return element.indexOf(term) === 0 ? element : null; @@ -225,11 +225,12 @@ function submit_form(e) { index: 1, replace: function (element) { if(open_elements.indexOf(element) < 0) { - if(element === 'ol' || element === 'ul') { - return ['\[' + element + '\]' + '\n\[li\]', '\[/li\]\n' + '\[/' + element + '\]']; - } else { - return ['\[' + element + '\]', '\[/' + element + '\]']; - } + if(element === 'list' || element === 'ol' || element === 'ul') { + return ['\[' + element + '\]' + '\n\[*\] ', '\n\[/' + element + '\]']; + } + else { + return ['\[' + element + '\]', '\[/' + element + '\]']; + } } else { return '\[' + element + '\] '; -- cgit v1.2.3 From e41082dcccdb46da7ef425f399cf4dd06dff9b6c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 7 Apr 2016 00:46:45 +0200 Subject: automate bbcode list creation even further --- view/js/autocomplete.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 5f67476df..36551dc42 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -100,6 +100,56 @@ function submit_form(e) { $(e).parents('form').submit(); } +function getWord(text, caretPos) { + var index = text.indexOf(caretPos); + var postText = text.substring(caretPos, caretPos+8); + if ((postText.indexOf("[/list]") > 0) || postText.indexOf("[/ul]") > 0 || postText.indexOf("[/ol]") > 0) { + return postText; + } +} + +function getCaretPosition(ctrl) { + var CaretPos = 0; // IE Support + if (document.selection) { + ctrl.focus(); + var Sel = document.selection.createRange(); + Sel.moveStart('character', -ctrl.value.length); + CaretPos = Sel.text.length; + } + // Firefox support + else if (ctrl.selectionStart || ctrl.selectionStart == '0') + CaretPos = ctrl.selectionStart; + return (CaretPos); +} + +function setCaretPosition(ctrl, pos){ + if(ctrl.setSelectionRange) { + ctrl.focus(); + ctrl.setSelectionRange(pos,pos); + } + else if (ctrl.createTextRange) { + var range = ctrl.createTextRange(); + range.collapse(true); + range.moveEnd('character', pos); + range.moveStart('character', pos); + range.select(); + } +} + +function listNewLineAutocomplete(id) { + var text = document.getElementById(id); + var caretPos = getCaretPosition(text) + var word = getWord(text.value, caretPos); + if (word != null) { + var textBefore = text.value.substring(0, caretPos); + var textAfter = text.value.substring(caretPos, text.length); + $('#' + id).val(textBefore + '\r\n[*] ' + textAfter); + setCaretPosition(text, caretPos + 5); + return true; + } +} + + /** * jQuery plugin 'editor_autocomplete' */ @@ -242,6 +292,13 @@ function submit_form(e) { var a = this.textcomplete([bbco], {className:'acpopup', zIndex:1020}); a.on('textComplete:select', function(e, value, strategy) { value; }); + $(this).keypress(function(e){ + if (e.keyCode == 13) { + x = listNewLineAutocomplete(this.id); + if(x) + e.preventDefault(); + } + }); }; })( jQuery ); -- cgit v1.2.3 From 58324473a98db0d9f792c733c157daed5f1c5130 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 7 Apr 2016 11:16:30 +0200 Subject: move li back in the list since it will be used far less than list --- view/js/autocomplete.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 36551dc42..8eb46d83d 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -252,7 +252,7 @@ function listNewLineAutocomplete(id) { $.fn.bbco_autocomplete = function(type) { if(type=='bbcode') { - var open_close_elements = ['b', 'i', 'u', 's', 'quote', 'code', 'spoiler', 'map', 'nobb', 'li', 'list', 'ul', 'ol', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer']; + var open_close_elements = ['b', 'i', 'u', 's', 'quote', 'code', 'spoiler', 'map', 'nobb', 'list', 'ul', 'ol', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer']; var open_elements = ['observer.baseurl', 'observer.address', 'observer.photo', 'observer.name', 'observer.webname', 'observer.url', '*', 'hr', ]; var elements = open_close_elements.concat(open_elements); -- cgit v1.2.3 From e419b2c18c246eb79c3261ba4255761724efd477 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 7 Apr 2016 11:34:38 +0200 Subject: some more autocompletion for bbcode tables - leave it open if we wanna use th or td though --- view/js/autocomplete.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 8eb46d83d..91b779316 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -278,6 +278,9 @@ function listNewLineAutocomplete(id) { if(element === 'list' || element === 'ol' || element === 'ul') { return ['\[' + element + '\]' + '\n\[*\] ', '\n\[/' + element + '\]']; } + else if(element === 'table') { + return ['\[' + element + '\]' + '\n\[tr\]', '\[/tr\]\n\[/' + element + '\]']; + } else { return ['\[' + element + '\]', '\[/' + element + '\]']; } -- cgit v1.2.3 From cf84ff334444c09269fd77cf06dac44828bc9bae Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 7 Apr 2016 23:03:55 +0200 Subject: translate the most common bbcodes to their *real name*. finally we should probably use an array for each bbcode containing the bbcode the real name and possibly a template for use as a peview in the dropdown --- view/js/autocomplete.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 91b779316..0ba291004 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -149,6 +149,16 @@ function listNewLineAutocomplete(id) { } } +function string2bb(element) { + if(element == 'bold') return 'b'; + else if(element == 'italic') return 'i'; + else if(element == 'underline') return 'u'; + else if(element == 'overline') return 'o'; + else if(element == 'strike') return 's'; + else if(element == 'superscript') return 'sup'; + else if(element == 'subscript') return 'sub'; + else return element; +} /** * jQuery plugin 'editor_autocomplete' @@ -252,7 +262,7 @@ function listNewLineAutocomplete(id) { $.fn.bbco_autocomplete = function(type) { if(type=='bbcode') { - var open_close_elements = ['b', 'i', 'u', 's', 'quote', 'code', 'spoiler', 'map', 'nobb', 'list', 'ul', 'ol', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer']; + var open_close_elements = ['bold', 'italic', 'underline', 'overline', 'strike', 'superscript', 'subscript', 'quote', 'code', 'spoiler', 'map', 'nobb', 'list', 'ul', 'ol', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer']; var open_elements = ['observer.baseurl', 'observer.address', 'observer.photo', 'observer.name', 'observer.webname', 'observer.url', '*', 'hr', ]; var elements = open_close_elements.concat(open_elements); @@ -274,6 +284,7 @@ function listNewLineAutocomplete(id) { }, index: 1, replace: function (element) { + element = string2bb(element); if(open_elements.indexOf(element) < 0) { if(element === 'list' || element === 'ol' || element === 'ul') { return ['\[' + element + '\]' + '\n\[*\] ', '\n\[/' + element + '\]']; @@ -295,6 +306,7 @@ function listNewLineAutocomplete(id) { var a = this.textcomplete([bbco], {className:'acpopup', zIndex:1020}); a.on('textComplete:select', function(e, value, strategy) { value; }); + $(this).keypress(function(e){ if (e.keyCode == 13) { x = listNewLineAutocomplete(this.id); -- cgit v1.2.3 From 7690dca67b6574cd5b6ffcc59b1c8c6b2df5d54e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 9 Apr 2016 09:24:14 +0200 Subject: enable bbcode autocomplete for other places --- view/js/mod_chat.js | 3 +++ view/js/mod_events.js | 3 +-- view/js/mod_mail.js | 1 + view/js/mod_photos.js | 2 ++ view/js/mod_profiles.js | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) (limited to 'view/js') diff --git a/view/js/mod_chat.js b/view/js/mod_chat.js index 0d47e3e77..f9d2a599c 100644 --- a/view/js/mod_chat.js +++ b/view/js/mod_chat.js @@ -15,4 +15,7 @@ $(document).ready(function() { $('#jot-public').show(); } }).trigger('change'); + + $('#chatText').bbco_autocomplete('bbcode'); + }); diff --git a/view/js/mod_events.js b/view/js/mod_events.js index 0b7b3d24c..74b811dd6 100644 --- a/view/js/mod_events.js +++ b/view/js/mod_events.js @@ -3,9 +3,8 @@ */ $(document).ready( function() { - enableDisableFinishDate(); - + $('#comment-edit-text-desc, #comment-edit-text-loc').bbco_autocomplete('bbcode'); }); function enableDisableFinishDate() { diff --git a/view/js/mod_mail.js b/view/js/mod_mail.js index 561df7229..3e55c8aeb 100644 --- a/view/js/mod_mail.js +++ b/view/js/mod_mail.js @@ -3,4 +3,5 @@ $(document).ready(function() { $("#recip-complete").val(data.xid); }); $(".autotime").timeago() + $('#prvmail-text').bbco_autocomplete('bbcode'); }); diff --git a/view/js/mod_photos.js b/view/js/mod_photos.js index d371c3f2f..34e2e3f25 100644 --- a/view/js/mod_photos.js +++ b/view/js/mod_photos.js @@ -11,6 +11,8 @@ $(document).ready(function() { $("#photo-edit-newtag").val('@' + data.name); }); + $('#id_body').bbco_autocomplete('bbcode'); + $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() { var selstr; $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() { diff --git a/view/js/mod_profiles.js b/view/js/mod_profiles.js index aad2ca902..a7754e0c5 100644 --- a/view/js/mod_profiles.js +++ b/view/js/mod_profiles.js @@ -1,3 +1,4 @@ $(document).ready(function() { $('form').areYouSure(); // Warn user about unsaved settings + $('textarea').bbco_autocomplete('bbcode'); }); -- cgit v1.2.3 From e2b4d33627d5f4cf5f68eb087059d86c78eec41e Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 9 Apr 2016 12:16:42 +0200 Subject: some work on comanche autocomplete --- view/js/autocomplete.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 0ba291004..a4a1fdf51 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -269,7 +269,14 @@ function string2bb(element) { } if(type=='comanche') { - var open_close_elements = ['region', 'widget', 'var', 'template', 'css', 'js']; + var open_close_elements = ['region', 'layout', 'template', 'theme', 'widget', 'block', 'menu', 'var', 'css', 'js', 'authored', 'comment', 'webpage']; + var open_elements = []; + + var elements = open_close_elements.concat(open_elements); + } + + if(type=='comanche-block') { + var open_close_elements = ['menu', 'var']; var open_elements = []; var elements = open_close_elements.concat(open_elements); -- cgit v1.2.3 From 5cb3143c0448834f7bd164320bec15ef2a030c52 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 10 Apr 2016 21:30:35 -0700 Subject: issue #331 use timeago.js for reshared publish date instead of relative_date() which does not play well with other networks. --- view/js/main.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'view/js') diff --git a/view/js/main.js b/view/js/main.js index ba476b576..799ae82bc 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -491,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() { @@ -502,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; }); @@ -529,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() { @@ -540,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(); } }); @@ -573,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; }); @@ -1048,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; }); } }, @@ -1078,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; }); } }, -- cgit v1.2.3 From 571c72f85334cef380098782cce3da91f7a9b238 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 12 Apr 2016 11:55:50 +0200 Subject: improve bbco autocomplete to not execute listNewLineAutocomplete() many times after many ajax page reloads --- view/js/autocomplete.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'view/js') diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index a4a1fdf51..59e3600b3 100644 --- a/view/js/autocomplete.js +++ b/view/js/autocomplete.js @@ -314,9 +314,10 @@ function string2bb(element) { a.on('textComplete:select', function(e, value, strategy) { value; }); - $(this).keypress(function(e){ + a.keypress(function(e){ + e.stopImmediatePropagation(); if (e.keyCode == 13) { - x = listNewLineAutocomplete(this.id); + var x = listNewLineAutocomplete(this.id); if(x) e.preventDefault(); } -- cgit v1.2.3