From c0a45ba1237fd54c0d5050d3a70abdea022ff6c3 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sat, 27 Jul 2013 00:14:43 -0400 Subject: Allow hide-images.js, toggle-images.js and inline-expanding.js to work together --- js/inline-expanding.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index f6714d7f..2e924f05 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -3,7 +3,7 @@ * https://github.com/savetheinternet/Tinyboard/blob/master/js/inline-expanding.js * * Released under the MIT license - * Copyright (c) 2012 Michael Save + * Copyright (c) 2012-2013 Michael Save * * Usage: * $config['additional_javascript'][] = 'js/inline-expanding.js'; @@ -13,30 +13,37 @@ onready(function(){ var link = document.getElementsByTagName('a'); - for(var i = 0; i < link.length; i++) { - if(typeof link[i] == "object" && link[i].childNodes[0].src && link[i].className != 'file') { + 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') { link[i].childNodes[0].style.maxWidth = '95%'; link[i].childNodes[0].style.maxHeight = '95%'; link[i].onclick = function(e) { - if(e.which == 2) { + if (this.childNodes[0].className == 'hidden') + return false; + if (e.which == 2) return true; - } - if(!this.tag) { - this.tag = this.childNodes[0].src; + if (!this.dataset.src) { + this.dataset.expanded = 'true'; + this.dataset.src= this.childNodes[0].src; + this.dataset.width = this.childNodes[0].style.width; + this.dataset.height = this.childNodes[0].style.height; this.childNodes[0].src = this.href; this.childNodes[0].style.width = 'auto'; this.childNodes[0].style.height = 'auto'; this.childNodes[0].style.opacity = '0.4'; this.childNodes[0].style.filter = 'alpha(opacity=40)'; this.childNodes[0].onload = function() { - this.style.opacity = '1'; - this.style.filter = ''; + this.style.opacity = ''; + delete this.style.filter; } } else { - this.childNodes[0].src = this.tag; - this.childNodes[0].style.width = 'auto'; - this.childNodes[0].style.height = 'auto'; - this.tag = ''; + this.childNodes[0].src = this.dataset.src; + this.childNodes[0].style.width = this.dataset.width; + this.childNodes[0].style.height = this.dataset.height; + delete this.dataset.expanded; + delete this.dataset.src; + delete this.childNodes[0].style.opacity; + delete this.childNodes[0].style.filter; } return false; } -- 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/inline-expanding.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 07ea457aa53729212e345eb0907b932f3939a3d9 Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 27 Jul 2013 02:19:58 -0400 Subject: inline-expanding.js: missed preventing default action; shouldn't open new window when unwanted anymore --- js/inline-expanding.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 1849b078..0f7b7229 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -46,6 +46,7 @@ onready(function(){ delete this.childNodes[0].style.opacity; delete this.childNodes[0].style.filter; } + return false; } } } -- cgit v1.3 From 54714595f7ce2cdbd88de1c536e0ddc97ca71529 Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 27 Jul 2013 02:19:58 -0400 Subject: js/inline-expanding.js: Allow to work with auto-reload.js, etc. (jQuery is still optional) Conflicts: js/inline-expanding.js --- js/inline-expanding.js | 79 +++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 33 deletions(-) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 2e924f05..06d3f76f 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -6,49 +6,62 @@ * Copyright (c) 2012-2013 Michael Save * * Usage: + * // $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/inline-expanding.js'; * */ onready(function(){ - var link = document.getElementsByTagName('a'); + 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 && 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; - if (e.which == 2) - return true; - if (!this.dataset.src) { - this.dataset.expanded = 'true'; - this.dataset.src= this.childNodes[0].src; - this.dataset.width = this.childNodes[0].style.width; - this.dataset.height = this.childNodes[0].style.height; - this.childNodes[0].src = this.href; - this.childNodes[0].style.width = 'auto'; - this.childNodes[0].style.height = 'auto'; - this.childNodes[0].style.opacity = '0.4'; - this.childNodes[0].style.filter = 'alpha(opacity=40)'; - this.childNodes[0].onload = function() { - this.style.opacity = ''; - delete this.style.filter; + 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%'; + link[i].onclick = function(e) { + if (this.childNodes[0].className == 'hidden') + return false; + if (e.which == 2) + return true; + if (!this.dataset.src) { + this.dataset.expanded = 'true'; + this.dataset.src= this.childNodes[0].src; + this.dataset.width = this.childNodes[0].style.width; + this.dataset.height = this.childNodes[0].style.height; + this.childNodes[0].src = this.href; + this.childNodes[0].style.width = 'auto'; + this.childNodes[0].style.height = 'auto'; + this.childNodes[0].style.opacity = '0.4'; + this.childNodes[0].style.filter = 'alpha(opacity=40)'; + this.childNodes[0].onload = function() { + this.style.opacity = ''; + delete this.style.filter; + } + } else { + this.childNodes[0].src = this.dataset.src; + this.childNodes[0].style.width = this.dataset.width; + this.childNodes[0].style.height = this.dataset.height; + delete this.dataset.expanded; + delete this.dataset.src; + delete this.childNodes[0].style.opacity; + delete this.childNodes[0].style.filter; } - } else { - this.childNodes[0].src = this.dataset.src; - this.childNodes[0].style.width = this.dataset.width; - this.childNodes[0].style.height = this.dataset.height; - delete this.dataset.expanded; - delete this.dataset.src; - delete this.childNodes[0].style.opacity; - delete this.childNodes[0].style.filter; + return false; } - return false; } - } } + + 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); + }); + } else { + inline_expand_post.call(document); + } + }); -- cgit v1.3 From 91bb3182da63e64d45ab8ac26735e090db928f15 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Tue, 30 Jul 2013 19:07:28 -0400 Subject: ⌘+click should open image in new tab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/inline-expanding.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 06d3f76f..20383f04 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -21,7 +21,7 @@ onready(function(){ link[i].onclick = function(e) { if (this.childNodes[0].className == 'hidden') return false; - if (e.which == 2) + if (e.which == 2 || e.metaKey) return true; if (!this.dataset.src) { this.dataset.expanded = 'true'; -- 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/inline-expanding.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 5bf0e7f7e76cd3610e0aa692e0c433aca594ee51 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Thu, 1 Aug 2013 00:27:54 -0400 Subject: Better/fixed jQuery styling and slightly improved js/inline-expanding.js accuracy (when jQuery is enabled) --- js/inline-expanding.js | 3 +++ templates/header.html | 30 ++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 8 deletions(-) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index e529a395..61085b0d 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -17,6 +17,9 @@ onready(function(){ 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') { + if (window.jQuery && !$(link).prev().hasClass('fileinfo')) { + continue; + } link[i].childNodes[0].style.maxWidth = '95%'; link[i].onclick = function(e) { if (this.childNodes[0].className == 'hidden') diff --git a/templates/header.html b/templates/header.html index 3791296f..c1230f0e 100644 --- a/templates/header.html +++ b/templates/header.html @@ -13,17 +13,31 @@ {% endif %} {% endif %} {% if config.recaptcha %}{% endif %} \ No newline at end of file -- cgit v1.3