From a28b5fc3a1975af863d348d3851b90b3c398baaf Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 26 Jul 2013 22:34:06 -0400 Subject: expand.js: fix a weird bug - thread expand not always worked due to post being loaded in DOM, but not put in a right place in a thread, or so, so check if it has been loaded in a thread instead of if it exists in DOM --- js/expand.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/expand.js') diff --git a/js/expand.js b/js/expand.js index 0e3537a8..1a719fad 100644 --- a/js/expand.js +++ b/js/expand.js @@ -27,7 +27,7 @@ $(document).ready(function(){ success: function(data) { var last_expanded = false; $(data).find('div.post.reply').each(function() { - if($('#' + $(this).attr('id')).length == 0) { + if(thread.find('#' + $(this).attr('id')).length == 0) { if(last_expanded) { $(this).addClass('expanded').insertAfter(last_expanded).before('
'); } else { -- cgit v1.3 From e5bdf63692487e07833bbc4197ae7cd98e5af7e4 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 26 Jul 2013 22:39:00 -0400 Subject: expand.js: fix post order when new posts appear between loading index and expanding --- js/expand.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'js/expand.js') diff --git a/js/expand.js b/js/expand.js index 1a719fad..a737ee7f 100644 --- a/js/expand.js +++ b/js/expand.js @@ -27,7 +27,8 @@ $(document).ready(function(){ success: function(data) { var last_expanded = false; $(data).find('div.post.reply').each(function() { - if(thread.find('#' + $(this).attr('id')).length == 0) { + var post_in_doc = thread.find('#' + $(this).attr('id')); + if(post_in_doc.length == 0) { if(last_expanded) { $(this).addClass('expanded').insertAfter(last_expanded).before('
'); } else { @@ -37,6 +38,9 @@ $(document).ready(function(){ $(document).trigger('new_post', this); } + else { + last_expanded = post_in_doc; + } }); $('' + _('Hide expanded replies') + '.') .insertAfter(thread.find('span.omitted').css('display', 'none')) -- cgit v1.3 From 6bf217941a3342cdcf7768ab5269f7d35b050984 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 26 Jul 2013 22:34:06 -0400 Subject: expand.js: fix a weird bug - thread expand not always worked due to post being loaded in DOM, but not put in a right place in a thread, or so, so check if it has been loaded in a thread instead of if it exists in DOM --- js/expand.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/expand.js') diff --git a/js/expand.js b/js/expand.js index 05aece95..d0b4583c 100644 --- a/js/expand.js +++ b/js/expand.js @@ -27,7 +27,7 @@ $(document).ready(function(){ success: function(data) { var last_expanded = false; $(data).find('div.post.reply').each(function() { - if($('#' + $(this).attr('id')).length == 0) { + if(thread.find('#' + $(this).attr('id')).length == 0) { if(last_expanded) { $(this).addClass('expanded').insertAfter(last_expanded).before('
'); } else { -- cgit v1.3 From d82cd9b7bd03708f4940b4508acd0394713b8869 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 26 Jul 2013 22:39:00 -0400 Subject: expand.js: fix post order when new posts appear between loading index and expanding --- js/expand.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'js/expand.js') diff --git a/js/expand.js b/js/expand.js index d0b4583c..16a0efb2 100644 --- a/js/expand.js +++ b/js/expand.js @@ -27,7 +27,8 @@ $(document).ready(function(){ success: function(data) { var last_expanded = false; $(data).find('div.post.reply').each(function() { - if(thread.find('#' + $(this).attr('id')).length == 0) { + var post_in_doc = thread.find('#' + $(this).attr('id')); + if(post_in_doc.length == 0) { if(last_expanded) { $(this).addClass('expanded').insertAfter(last_expanded).before('
'); } else { @@ -36,6 +37,9 @@ $(document).ready(function(){ last_expanded = $(this); } + else { + last_expanded = post_in_doc; + } }); $('Hide expanded replies.') .insertAfter(thread.find('span.omitted').css('display', 'none')) -- cgit v1.3 From e3cb427feefbbb4fd6a5e76ce77ef80a240941f1 Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 27 Jul 2013 00:57:12 -0400 Subject: ukko: fix javascript interoperation --- js/expand.js | 10 +++++++++- js/hide-threads.js | 12 +++++++++--- js/show-backlinks.js | 7 ++++++- templates/themes/ukko/ukko.js | 3 ++- 4 files changed, 26 insertions(+), 6 deletions(-) (limited to 'js/expand.js') diff --git a/js/expand.js b/js/expand.js index a737ee7f..06151627 100644 --- a/js/expand.js +++ b/js/expand.js @@ -15,7 +15,7 @@ $(document).ready(function(){ if($('div.banner').length != 0) return; // not index - $('div.post.op span.omitted').each(function() { + var do_expand = function() { $(this) .html($(this).text().replace(_("Click reply to view."), ''+_("Click to expand")+'.')) .find('a').click(function() { @@ -52,5 +52,13 @@ $(document).ready(function(){ } }); }); + } + + $('div.post.op span.omitted').each(do_expand); + + $(document).bind("new_post", function(e, post) { + if (!$(post).hasClass("reply")) { + $(post).find('div.post.op span.omitted').each(do_expand); + } }); }); diff --git a/js/hide-threads.js b/js/hide-threads.js index abaa700f..44bd829b 100644 --- a/js/hide-threads.js +++ b/js/hide-threads.js @@ -35,7 +35,7 @@ $(document).ready(function(){ } } - $('div.post.op').each(function() { + var do_hide_threads = function() { var id = $(this).children('p.intro').children('a.post_no:eq(1)').text(); var thread_container = $(this).parent(); @@ -46,7 +46,7 @@ $(document).ready(function(){ } $('[–] ') - .insertBefore(thread_container.find(':first')) + .insertBefore(thread_container.find(':not(h2,h2 *):first')) .click(function() { hidden_data[board][id] = Math.round(Date.now() / 1000); store_data(); @@ -69,9 +69,15 @@ $(document).ready(function(){ hidden_div.remove(); }); - hidden_div.insertAfter(thread_container.find(':first')); + hidden_div.insertAfter(thread_container.find(':not(h2,h2 *):first')); }); if (hidden_data[board][id]) thread_container.find('.hide-thread-link').click(); + } + + $('div.post.op').each(do_hide_threads); + + $(document).bind('new_post', function(e, post) { + do_hide_threads.call($(post).find('div.post.op')[0]); }); }); diff --git a/js/show-backlinks.js b/js/show-backlinks.js index 4ead494b..f23cfc38 100644 --- a/js/show-backlinks.js +++ b/js/show-backlinks.js @@ -48,7 +48,12 @@ onready(function(){ $('div.post.reply').each(showBackLinks); $(document).bind('new_post', function(e, post) { - showBackLinks.call(post); + if ($(post).hasClass("reply")) { + showBackLinks.call(post); + } + else { + $(post).find('div.post.reply').each(showBackLinks); + } }); }); diff --git a/templates/themes/ukko/ukko.js b/templates/themes/ukko/ukko.js index dc8ed382..6566335e 100644 --- a/templates/themes/ukko/ukko.js +++ b/templates/themes/ukko/ukko.js @@ -10,6 +10,7 @@ $(document).ready(function() { if(thread.length > 0) { thread.prepend('

/' + overflow[0].board + '/

'); $('div[id*="thread_"]').last().after(thread.attr('data-board', overflow[0].board).css('display', 'block')); + $(document).trigger('new_post', thread); overflow.shift(); } } else { @@ -25,6 +26,7 @@ $(document).ready(function() { if(thread.length > 0) { thread.prepend('

/' + overflow[0].board + '/

'); $('div[id*="thread_"]').last().after(thread.attr('data-board', overflow[0].board).css('display', 'block')); + $(document).trigger('new_post', thread); overflow.shift(); } @@ -33,5 +35,4 @@ $(document).ready(function() { } } }); - }); -- cgit v1.3 From 880cf25366797affa6279508f3ba8779e3b6da46 Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 27 Jul 2013 01:08:26 -0400 Subject: fix merge --- js/expand.js | 3 --- js/inline-expanding.js | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'js/expand.js') diff --git a/js/expand.js b/js/expand.js index 6b8657bd..06151627 100644 --- a/js/expand.js +++ b/js/expand.js @@ -41,9 +41,6 @@ $(document).ready(function(){ else { last_expanded = post_in_doc; } - else { - last_expanded = post_in_doc; - } }); $('' + _('Hide expanded replies') + '.') .insertAfter(thread.find('span.omitted').css('display', 'none')) diff --git a/js/inline-expanding.js b/js/inline-expanding.js index fb78c222..1849b078 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -16,9 +16,8 @@ onready(function(){ var link = this.getElementsByTagName('a'); for (var i = 0; i < link.length; i++) { - if (typeof link[i] == "object" && link[i].childNodes && link[i].childNodes[0].src && link[i].className != 'file') { + if (typeof link[i] == "object" && link[i].childNodes && typeof link[i].childNodes[0] !== 'undefined' && link[i].childNodes[0].src && link[i].className != 'file') { link[i].childNodes[0].style.maxWidth = '95%'; - link[i].childNodes[0].style.maxHeight = '95%'; link[i].onclick = function(e) { if (this.childNodes[0].className == 'hidden') return false; -- cgit v1.3 From 3bee1ba4fd16263ac4eefdf0bc8c7a3d11d8cccb Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Wed, 31 Jul 2013 00:39:00 -0400 Subject: Issue #61 --- js/expand.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'js/expand.js') diff --git a/js/expand.js b/js/expand.js index 16a0efb2..6e5fa659 100644 --- a/js/expand.js +++ b/js/expand.js @@ -1,9 +1,9 @@ /* - *expand.js + * expand.js * https://github.com/savetheinternet/Tinyboard/blob/master/js/expand.js * * Released under the MIT license - * Copyright (c) 2012 Michael Save + * Copyright (c) 2012-2013 Michael Save * * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; @@ -35,9 +35,8 @@ $(document).ready(function(){ $(this).addClass('expanded').insertAfter(thread.find('div.post:first')).after('
'); } last_expanded = $(this); - - } - else { + $(document).trigger('new_post', this); + } else { last_expanded = post_in_doc; } }); -- cgit v1.3 From 4922828e35eca8b28135a681a6f5d0e9a93641fd Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 3 Jul 2013 01:17:56 -0400 Subject: js i18n: expand.js --- js/expand.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/expand.js') diff --git a/js/expand.js b/js/expand.js index 6e5fa659..d5706643 100644 --- a/js/expand.js +++ b/js/expand.js @@ -17,7 +17,7 @@ $(document).ready(function(){ $('div.post.op span.omitted').each(function() { $(this) - .html($(this).text().replace(/Click reply to view\./, 'Click to expand.')) + .html($(this).text().replace(_("Click reply to view."), ''+_("Click to expand")+'.')) .find('a').click(function() { var thread = $(this).parent().parent().parent(); var id = thread.attr('id').replace(/^thread_/, ''); @@ -40,7 +40,7 @@ $(document).ready(function(){ last_expanded = post_in_doc; } }); - $('Hide expanded replies.') + $('' + _('Hide expanded replies') + '.') .insertAfter(thread.find('span.omitted').css('display', 'none')) .click(function() { thread.find('.expanded').remove(); -- cgit v1.3 From 2868dd7886082cfb11fcbe8f8bee1108a48c81a3 Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 15 Jun 2013 01:39:39 -0400 Subject: javascripts: fixed interactions (BEWARE, inline-expanding.js now requires jquery! fix your configs) Conflicts: js/expand.js js/inline-expanding.js --- js/expand.js | 4 ++-- js/inline-expanding.js | 5 ++--- js/show-backlinks.js | 4 ++++ 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'js/expand.js') diff --git a/js/expand.js b/js/expand.js index d5706643..f2cfdc5e 100644 --- a/js/expand.js +++ b/js/expand.js @@ -14,7 +14,7 @@ $(document).ready(function(){ if($('div.banner').length != 0) return; // not index - + $('div.post.op span.omitted').each(function() { $(this) .html($(this).text().replace(_("Click reply to view."), ''+_("Click to expand")+'.')) @@ -51,4 +51,4 @@ $(document).ready(function(){ }); }); }); -}); +}); \ No newline at end of file diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 20383f04..e529a395 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -14,7 +14,7 @@ onready(function(){ var inline_expand_post = function() { var link = this.getElementsByTagName('a'); - + for (var i = 0; i < link.length; i++) { if (typeof link[i] == "object" && link[i].childNodes && typeof link[i].childNodes[0] !== 'undefined' && link[i].childNodes[0].src && link[i].className != 'file') { link[i].childNodes[0].style.maxWidth = '95%'; @@ -54,7 +54,7 @@ onready(function(){ if (window.jQuery) { $('div[id^="thread_"]').each(inline_expand_post); - + // allow to work with auto-reload.js, etc. $(document).bind('new_post', function(e, post) { inline_expand_post.call(post); @@ -64,4 +64,3 @@ onready(function(){ } }); - diff --git a/js/show-backlinks.js b/js/show-backlinks.js index e6e17e4f..4ead494b 100644 --- a/js/show-backlinks.js +++ b/js/show-backlinks.js @@ -46,5 +46,9 @@ onready(function(){ }; $('div.post.reply').each(showBackLinks); + + $(document).bind('new_post', function(e, post) { + showBackLinks.call(post); + }); }); -- cgit v1.3 From 45ead9803f01c2cb84b11b3747e432737af27595 Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 27 Jul 2013 00:57:12 -0400 Subject: ukko: fix javascript interoperation Conflicts: js/expand.js js/hide-threads.js templates/themes/ukko/ukko.js --- js/expand.js | 13 +++++++++++-- js/hide-threads.js | 12 +++++++++--- js/show-backlinks.js | 7 ++++++- 3 files changed, 26 insertions(+), 6 deletions(-) (limited to 'js/expand.js') diff --git a/js/expand.js b/js/expand.js index f2cfdc5e..07ce9e43 100644 --- a/js/expand.js +++ b/js/expand.js @@ -14,8 +14,9 @@ $(document).ready(function(){ if($('div.banner').length != 0) return; // not index - $('div.post.op span.omitted').each(function() { + + var do_expand = function() { $(this) .html($(this).text().replace(_("Click reply to view."), ''+_("Click to expand")+'.')) .find('a').click(function() { @@ -50,5 +51,13 @@ $(document).ready(function(){ } }); }); + } + + $('div.post.op span.omitted').each(do_expand); + + $(document).bind("new_post", function(e, post) { + if (!$(post).hasClass("reply")) { + $(post).find('div.post.op span.omitted').each(do_expand); + } }); -}); \ No newline at end of file +}); diff --git a/js/hide-threads.js b/js/hide-threads.js index faa1289c..575804b6 100644 --- a/js/hide-threads.js +++ b/js/hide-threads.js @@ -41,11 +41,11 @@ $(document).ready(function(){ hidden_data[board] = {}; // id : timestamp } - $('div.post.op').each(function() { + var do_hide_threads = function() { var id = $(this).children('p.intro').children('a.post_no:eq(1)').text(); var thread_container = $(this).parent(); $('[–] ') - .insertBefore(thread_container.find(':first')) + .insertBefore(thread_container.find(':not(h2,h2 *):first')) .click(function() { hidden_data[board][id] = Math.round(Date.now() / 1000); store_data(); @@ -68,9 +68,15 @@ $(document).ready(function(){ hidden_div.remove(); }); - hidden_div.insertAfter(thread_container.find(':first')); + hidden_div.insertAfter(thread_container.find(':not(h2,h2 *):first')); }); if (hidden_data[board][id]) thread_container.find('.hide-thread-link').click(); + } + + $('div.post.op').each(do_hide_threads); + + $(document).bind('new_post', function(e, post) { + do_hide_threads.call($(post).find('div.post.op')[0]); }); }); diff --git a/js/show-backlinks.js b/js/show-backlinks.js index 4ead494b..f23cfc38 100644 --- a/js/show-backlinks.js +++ b/js/show-backlinks.js @@ -48,7 +48,12 @@ onready(function(){ $('div.post.reply').each(showBackLinks); $(document).bind('new_post', function(e, post) { - showBackLinks.call(post); + if ($(post).hasClass("reply")) { + showBackLinks.call(post); + } + else { + $(post).find('div.post.reply').each(showBackLinks); + } }); }); -- cgit v1.3