From a723ff8e66e88f0e98b893275b8f7b1bbc990514 Mon Sep 17 00:00:00 2001 From: Markerov Date: Mon, 27 Oct 2014 16:49:17 +0800 Subject: Display inline image when it starts loading, Rewrote inline-expanding.js to display full image as soon as it starts loading. Modified expand-all-images.js to work with the new change Moved max-width to style.css --- js/inline-expanding.js | 51 ++++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 22 deletions(-) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 4d0cb03d..6692e8a1 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -18,13 +18,23 @@ 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].childNodes[0].className.match(/post-image/) && !link[i].className.match(/file/)) { - link[i].childNodes[0].style.maxWidth = '98%'; link[i].onclick = function(e) { + var img; + var loadImage = function(img, thumb) { + if (img.naturalWidth) { + thumb.style.display = 'none'; + img.style.display = ''; + } + else { + return thumb.parentNode.timeout = setTimeout(loadImage, 30, img, thumb); + } + }; + if (this.childNodes[0].className == 'hidden') return false; - if (e.which == 2 || e.metaKey) + if (e.which == 2 || e.ctrlKey) //open in new tab return true; - if (!this.dataset.src) { + if (!this.dataset.expanded) { this.parentNode.removeAttribute('style'); this.dataset.expanded = 'true'; @@ -33,29 +43,26 @@ onready(function(){ this.childNodes[0].style.display = 'block'; } - 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; - } + + img = document.createElement('img'); + img.className = 'full-image'; + img.setAttribute('src', this.href); + img.setAttribute('alt', 'Fullsized image'); + img.style.display = 'none'; + this.appendChild(img); + + this.timeout = loadImage(img, this.childNodes[0]); } else { + clearTimeout(this.timeout); if (~this.parentNode.className.indexOf('multifile')) this.parentNode.style.width = (parseInt(this.dataset.width)+40)+'px'; - this.childNodes[0].src = this.dataset.src; - this.childNodes[0].style.width = this.dataset.width; - this.childNodes[0].style.height = this.dataset.height; + + this.childNodes[0].style.opacity = ''; + this.childNodes[0].style.display = ''; + this.removeChild(this.childNodes[1]); delete this.dataset.expanded; - delete this.dataset.src; - delete this.childNodes[0].style.opacity; delete this.childNodes[0].style.filter; if (localStorage.no_animated_gif === 'true' && typeof unanimate_gif === 'function') { @@ -63,10 +70,10 @@ onready(function(){ } } return false; - } + }; } } - } + }; if (window.jQuery) { $('div[id^="thread_"]').each(inline_expand_post); -- cgit v1.3 From 4767a6317899ab627eec72bfadcd4252a9277a54 Mon Sep 17 00:00:00 2001 From: Markerov Date: Mon, 27 Oct 2014 16:57:03 +0800 Subject: renamed 'this.childNodes[0]' to thumb --- js/inline-expanding.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 6692e8a1..c19937ed 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -20,6 +20,7 @@ onready(function(){ if (typeof link[i] == "object" && link[i].childNodes && typeof link[i].childNodes[0] !== 'undefined' && link[i].childNodes[0].src && link[i].childNodes[0].className.match(/post-image/) && !link[i].className.match(/file/)) { link[i].onclick = function(e) { var img; + var thumb = this.childNodes[0]; var loadImage = function(img, thumb) { if (img.naturalWidth) { thumb.style.display = 'none'; @@ -30,7 +31,7 @@ onready(function(){ } }; - if (this.childNodes[0].className == 'hidden') + if (thumb.className == 'hidden') return false; if (e.which == 2 || e.ctrlKey) //open in new tab return true; @@ -38,13 +39,13 @@ onready(function(){ this.parentNode.removeAttribute('style'); this.dataset.expanded = 'true'; - if (this.childNodes[0].tagName === 'CANVAS') { - this.removeChild(this.childNodes[0]); - this.childNodes[0].style.display = 'block'; + if (thumb.tagName === 'CANVAS') { + this.removeChild(thumb); + thumb.style.display = 'block'; } - this.childNodes[0].style.opacity = '0.4'; - this.childNodes[0].style.filter = 'alpha(opacity=40)'; + thumb.style.opacity = '0.4'; + thumb.style.filter = 'alpha(opacity=40)'; img = document.createElement('img'); img.className = 'full-image'; @@ -53,20 +54,20 @@ onready(function(){ img.style.display = 'none'; this.appendChild(img); - this.timeout = loadImage(img, this.childNodes[0]); + this.timeout = loadImage(img, thumb); } else { clearTimeout(this.timeout); if (~this.parentNode.className.indexOf('multifile')) this.parentNode.style.width = (parseInt(this.dataset.width)+40)+'px'; - this.childNodes[0].style.opacity = ''; - this.childNodes[0].style.display = ''; - this.removeChild(this.childNodes[1]); + thumb.style.opacity = ''; + thumb.style.display = ''; + this.removeChild(thumb.nextSibling); delete this.dataset.expanded; - delete this.childNodes[0].style.filter; + delete thumb.style.filter; if (localStorage.no_animated_gif === 'true' && typeof unanimate_gif === 'function') { - unanimate_gif(this.childNodes[0]); + unanimate_gif(thumb); } } return false; -- cgit v1.3 From bc2257be087ff037c9d84f685df6f064a26efff7 Mon Sep 17 00:00:00 2001 From: Markerov Date: Tue, 28 Oct 2014 23:35:58 +0800 Subject: scroll to thumb scroll up to image if its top is out of view when shrunk. Requires jQuery --- js/inline-expanding.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index c19937ed..cf8cab81 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -7,7 +7,7 @@ * Copyright (c) 2013-2014 Marcin Ɓabanowski * * Usage: - * // $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/inline-expanding.js'; * */ @@ -19,8 +19,11 @@ 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].childNodes[0].className.match(/post-image/) && !link[i].className.match(/file/)) { link[i].onclick = function(e) { - var img; + var img, post_body, still_open; var thumb = this.childNodes[0]; + var padding = 5; + var boardlist = $('.boardlist')[0]; + var loadImage = function(img, thumb) { if (img.naturalWidth) { thumb.style.display = 'none'; @@ -57,6 +60,25 @@ onready(function(){ this.timeout = loadImage(img, thumb); } else { clearTimeout(this.timeout); + + //scroll to thumb if not triggered by 'shrink all image' + if (e.target.className == 'full-image') { + post_body = $(e.target).parentsUntil('form > div').last(); + still_open = post_body.find('.post-image').filter(function(){return $(this).parent().attr('data-expanded') == 'true'}).length; + + //deal with differnt boards' menu styles + if ($(boardlist).css('position') == 'fixed') + padding += boardlist.getBoundingClientRect().height; + + if (still_open > 1) { + if (e.target.getBoundingClientRect().top - padding < 0) + $('body').scrollTop($(e.target).parent().parent().offset().top - padding); + } else { + if (post_body[0].getBoundingClientRect().top - padding < 0) + $('body').scrollTop(post_body.offset().top - padding); + } + } + if (~this.parentNode.className.indexOf('multifile')) this.parentNode.style.width = (parseInt(this.dataset.width)+40)+'px'; -- cgit v1.3 From fd2b41c1f0d1a2d091f8ee66880b230301b823cc Mon Sep 17 00:00:00 2001 From: Markerov Date: Sat, 29 Nov 2014 11:01:30 +0800 Subject: Fix bug with inline expansion with Unanimate Gif Issue #273 --- js/inline-expanding.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index cf8cab81..8da66898 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -19,7 +19,7 @@ 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].childNodes[0].className.match(/post-image/) && !link[i].className.match(/file/)) { link[i].onclick = function(e) { - var img, post_body, still_open; + var img, post_body, still_open, canvas; var thumb = this.childNodes[0]; var padding = 5; var boardlist = $('.boardlist')[0]; @@ -43,8 +43,10 @@ onready(function(){ this.dataset.expanded = 'true'; if (thumb.tagName === 'CANVAS') { - this.removeChild(thumb); - thumb.style.display = 'block'; + canvas = thumb; + thumb = thumb.nextSibling; + this.removeChild(canvas); + canvas.style.display = 'block'; } thumb.style.opacity = '0.4'; -- cgit v1.3 From 63491b0b9a4a9325bb8f68d0c5763ac3cda68c89 Mon Sep 17 00:00:00 2001 From: topkek Date: Tue, 9 Dec 2014 02:04:53 +0000 Subject: Scroll to thumbnail when shrinking an expanded image --- js/inline-expanding.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 8da66898..05300138 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -74,10 +74,10 @@ onready(function(){ if (still_open > 1) { if (e.target.getBoundingClientRect().top - padding < 0) - $('body').scrollTop($(e.target).parent().parent().offset().top - padding); + $(document).scrollTop($(e.target).parent().parent().offset().top - padding); } else { if (post_body[0].getBoundingClientRect().top - padding < 0) - $('body').scrollTop(post_body.offset().top - padding); + $(document).scrollTop(post_body.offset().top - padding); } } -- cgit v1.3 From c3146e17948a422f1d40537bb021a7ef53e78c6b Mon Sep 17 00:00:00 2001 From: Markerov Date: Mon, 12 Jan 2015 11:41:54 +0800 Subject: image throttler initial commit --- js/inline-expanding.js | 164 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 132 insertions(+), 32 deletions(-) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 05300138..74fe6c5a 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -13,30 +13,104 @@ */ onready(function(){ + 'use strict'; + + var DEFAULT_MAX = 5; // default maximum image loads var inline_expand_post = function() { var link = this.getElementsByTagName('a'); + var loadingQueue = (function () { + var MAX_IMAGES = localStorage.inline_expand_max || DEFAULT_MAX; // maximum number of images to load concurrently, 0 to disable + var loading = 0; // number of images that is currently loading + var waiting = []; // waiting queue + + var enqueue = function (ele) { + waiting.push(ele); + }; + var dequeue = function () { + return waiting.shift(); + }; + var update = function() { + var ele; + while (loading < MAX_IMAGES || MAX_IMAGES === 0) { + ele = dequeue(); + if (ele) { + ++loading; + ele.deferred.resolve(); + } else { + return; + } + } + }; + return { + remove: function (ele) { + var i = waiting.indexOf(ele); + if (i > -1) { + waiting.splice(i, 1); + } + if (ele.dataset.imageLoading === 'true') { + ele.dataset.imageLoading = 'false'; + clearTimeout(ele.timeout); + --loading; + } + }, + add: function (ele) { + ele.deferred = $.Deferred(); + ele.deferred.done(function () { + var $loadstart = $.Deferred(); + var thumb = ele.childNodes[0]; + var img = ele.childNodes[1]; + + var onLoadStart = function (img) { + if (img.naturalWidth) { + $loadstart.resolve(img, thumb); + } else { + return (ele.timeout = setTimeout(onLoadStart, 30, img)); + } + }; + + $(img).one('load', function () { + $.when($loadstart).done(function () { + // once fully loaded, update the waiting queue + --loading; + ele.dataset.imageLoading = 'false'; + update(); + }); + }); + $loadstart.done(function (img, thumb) { + thumb.style.display = 'none'; + img.style.display = ''; + }); + + img.setAttribute('src', ele.href); + ele.dataset.imageLoading = 'true'; + ele.timeout = onLoadStart(img); + }); + + if (loading < MAX_IMAGES || MAX_IMAGES === 0) { + ++loading; + ele.deferred.resolve(); + } else { + enqueue(ele); + } + + } + }; + })(); + 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].childNodes[0].className.match(/post-image/) && !link[i].className.match(/file/)) { + if (typeof link[i] == "object" && link[i].childNodes && typeof link[i].childNodes[0] !== 'undefined' && + link[i].childNodes[0].src && link[i].childNodes[0].className.match(/post-image/) && !link[i].className.match(/file/)) { link[i].onclick = function(e) { - var img, post_body, still_open, canvas; + var img, post_body, still_open, canvas, scroll; var thumb = this.childNodes[0]; var padding = 5; var boardlist = $('.boardlist')[0]; - var loadImage = function(img, thumb) { - if (img.naturalWidth) { - thumb.style.display = 'none'; - img.style.display = ''; - } - else { - return thumb.parentNode.timeout = setTimeout(loadImage, 30, img, thumb); - } - }; if (thumb.className == 'hidden') return false; - if (e.which == 2 || e.ctrlKey) //open in new tab + if (e.which == 2 || e.ctrlKey) // open in new tab return true; if (!this.dataset.expanded) { this.parentNode.removeAttribute('style'); @@ -54,31 +128,19 @@ onready(function(){ img = document.createElement('img'); img.className = 'full-image'; - img.setAttribute('src', this.href); - img.setAttribute('alt', 'Fullsized image'); img.style.display = 'none'; + img.setAttribute('alt', 'Fullsized image'); this.appendChild(img); - this.timeout = loadImage(img, thumb); + loadingQueue.add(this); } else { - clearTimeout(this.timeout); + loadingQueue.remove(this); - //scroll to thumb if not triggered by 'shrink all image' - if (e.target.className == 'full-image') { - post_body = $(e.target).parentsUntil('form > div').last(); - still_open = post_body.find('.post-image').filter(function(){return $(this).parent().attr('data-expanded') == 'true'}).length; - - //deal with differnt boards' menu styles - if ($(boardlist).css('position') == 'fixed') - padding += boardlist.getBoundingClientRect().height; + scroll = false; - if (still_open > 1) { - if (e.target.getBoundingClientRect().top - padding < 0) - $(document).scrollTop($(e.target).parent().parent().offset().top - padding); - } else { - if (post_body[0].getBoundingClientRect().top - padding < 0) - $(document).scrollTop(post_body.offset().top - padding); - } + // scroll to thumb if not triggered by 'shrink all image' + if (e.target.className == 'full-image') { + scroll = true; } if (~this.parentNode.className.indexOf('multifile')) @@ -86,10 +148,32 @@ onready(function(){ thumb.style.opacity = ''; thumb.style.display = ''; - this.removeChild(thumb.nextSibling); + if (thumb.nextSibling) this.removeChild(thumb.nextSibling); //full image loaded or loading delete this.dataset.expanded; delete thumb.style.filter; + // do the scrolling after page reflow + if (scroll) { + post_body = $(thumb).parentsUntil('form > div').last(); + + // on multifile posts, determin how many other images are still expanded + still_open = post_body.find('.post-image').filter(function(){ + return $(this).parent().attr('data-expanded') == 'true'; + }).length; + + // deal with differnt boards' menu styles + if ($(boardlist).css('position') == 'fixed') + padding += boardlist.getBoundingClientRect().height; + + if (still_open > 0) { + if (thumb.getBoundingClientRect().top - padding < 0) + $(document).scrollTop($(thumb).parent().parent().offset().top - padding); + } else { + if (post_body[0].getBoundingClientRect().top - padding < 0) + $(document).scrollTop(post_body.offset().top - padding); + } + } + if (localStorage.no_animated_gif === 'true' && typeof unanimate_gif === 'function') { unanimate_gif(thumb); } @@ -100,6 +184,22 @@ onready(function(){ } }; + // setting up user option + if (window.Options && Options.get_tab('general')) { + Options.extend_tab('general', ''+ _('Number of simultaneous image downloads (0 to disable): ') + + ''); + $('#inline-expand-max input') + .css('width', '50px') + .val(localStorage.inline_expand_max || DEFAULT_MAX) + .on('change', function (e) { + // validation in case some fucktard tries to enter a negative floating point number + var n = parseInt(e.target.value); + var val = (n<0) ? 0 : n; + + localStorage.inline_expand_max = val; + }); + } + if (window.jQuery) { $('div[id^="thread_"]').each(inline_expand_post); -- cgit v1.3 From 88f6088a429fb73d12805377b43c6b567d03a5db Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Fri, 23 Jan 2015 00:03:37 +0800 Subject: fix Relative Time and Image Throttler --- js/inline-expanding.js | 2 +- js/local-time.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 74fe6c5a..92069689 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -12,7 +12,7 @@ * */ -onready(function(){ +$(document).ready(function(){ 'use strict'; var DEFAULT_MAX = 5; // default maximum image loads diff --git a/js/local-time.js b/js/local-time.js index ac67673c..a821579f 100644 --- a/js/local-time.js +++ b/js/local-time.js @@ -13,7 +13,7 @@ * */ -onready(function(){ +$(document).ready(function(){ 'use strict'; var iso8601 = function(s) { -- cgit v1.3 From 5176377045d25ab00ed4653f980e9a95a17b0e31 Mon Sep 17 00:00:00 2001 From: 8chan Date: Fri, 20 Feb 2015 01:51:06 -0800 Subject: Fix many features for Internet Explorer 9 and 10 Please don't use "dataset" in scripts anymore, it doesn't work in IE9 or 10. Instead use $.data --- js/catalog-search.js | 12 ++++++------ js/expand-all-images.js | 4 ++-- js/hide-images.js | 2 +- js/id_colors.js | 10 +++++----- js/inline-expanding.js | 16 ++++++++-------- js/post-filter.js | 44 ++++++++++++++++++++++---------------------- js/toggle-images.js | 2 +- 7 files changed, 45 insertions(+), 45 deletions(-) (limited to 'js/inline-expanding.js') diff --git a/js/catalog-search.js b/js/catalog-search.js index 17a8edac..ff9af785 100644 --- a/js/catalog-search.js +++ b/js/catalog-search.js @@ -34,16 +34,16 @@ if (active_page == 'catalog') { } function searchToggle() { - var button = $('#catalog_search_button')[0]; + var button = $('#catalog_search_button'); - if (!button.dataset.expanded) { - button.dataset.expanded = '1'; - button.innerText = 'Close'; + if (!button.data('expanded')) { + button.data('expanded', '1'); + button.text('Close'); $('.catalog_search').append(' '); $('#search_field').focus(); } else { - delete button.dataset.expanded; - button.innerText = 'Search'; + button.removeData('expanded'); + button.text('Search'); $('.catalog_search').children().last().remove(); $('div[id="Grid"]>.mix').each(function () { $(this).css('display', 'inline-block'); }); } diff --git a/js/expand-all-images.js b/js/expand-all-images.js index 6d7b4ca0..c110f51c 100644 --- a/js/expand-all-images.js +++ b/js/expand-all-images.js @@ -31,7 +31,7 @@ onready(function(){ if (/^\/player\.php\?/.test($(this).parent().attr('href'))) return; - if (!$(this).parent()[0].dataset.expanded) + if (!$(this).parent().data('expanded')) $(this).parent().click(); }); @@ -43,7 +43,7 @@ onready(function(){ .text(_('Shrink all images')) .click(function(){ $('a img.full-image').each(function() { - if ($(this).parent()[0].dataset.expanded) + if ($(this).parent().data('expanded')) $(this).parent().click(); }); $(this).parent().remove(); diff --git a/js/hide-images.js b/js/hide-images.js index 323a1a1f..4fdad891 100644 --- a/js/hide-images.js +++ b/js/hide-images.js @@ -77,7 +77,7 @@ $(document).ready(function(){ $(this).hide().after(show_link); - if ($(img).parent()[0].dataset.expanded == 'true') { + if ($(img).parent().data('expanded') == 'true') { $(img).parent().click(); } diff --git a/js/id_colors.js b/js/id_colors.js index 17f8b4d9..6335f960 100644 --- a/js/id_colors.js +++ b/js/id_colors.js @@ -1,18 +1,18 @@ if (active_page == 'thread' || active_page == 'index') { $(document).ready(function(){ if (window.Options && Options.get_tab('general')) { - selector = '#color-ids>input'; - event = 'change'; + var selector = '#color-ids>input'; + var e = 'change'; Options.extend_tab("general", ""); } else { - selector = '#color-ids'; - event = 'click'; + var selector = '#color-ids'; + var e = 'click'; $('hr:first').before('') } - $(selector).on(event, function() { + $(selector).on(e, function() { if (localStorage.color_ids === 'true') { localStorage.color_ids = 'false'; } else { diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 92069689..e316fbb7 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -48,8 +48,8 @@ $(document).ready(function(){ if (i > -1) { waiting.splice(i, 1); } - if (ele.dataset.imageLoading === 'true') { - ele.dataset.imageLoading = 'false'; + if ($(ele).data('imageLoading') === 'true') { + $(ele).data('imageLoading', 'false'); clearTimeout(ele.timeout); --loading; } @@ -73,7 +73,7 @@ $(document).ready(function(){ $.when($loadstart).done(function () { // once fully loaded, update the waiting queue --loading; - ele.dataset.imageLoading = 'false'; + $(ele).data('imageLoading', 'false'); update(); }); }); @@ -83,7 +83,7 @@ $(document).ready(function(){ }); img.setAttribute('src', ele.href); - ele.dataset.imageLoading = 'true'; + $(ele).data('imageLoading', 'true'); ele.timeout = onLoadStart(img); }); @@ -112,9 +112,9 @@ $(document).ready(function(){ return false; if (e.which == 2 || e.ctrlKey) // open in new tab return true; - if (!this.dataset.expanded) { + if (!$(this).data('expanded')) { this.parentNode.removeAttribute('style'); - this.dataset.expanded = 'true'; + $(this).data('expanded', 'true'); if (thumb.tagName === 'CANVAS') { canvas = thumb; @@ -144,12 +144,12 @@ $(document).ready(function(){ } if (~this.parentNode.className.indexOf('multifile')) - this.parentNode.style.width = (parseInt(this.dataset.width)+40)+'px'; + this.parentNode.style.width = (parseInt($(this).data('width'))+40)+'px'; thumb.style.opacity = ''; thumb.style.display = ''; if (thumb.nextSibling) this.removeChild(thumb.nextSibling); //full image loaded or loading - delete this.dataset.expanded; + $(this).removeData('expanded'); delete thumb.style.filter; // do the scrolling after page reflow diff --git a/js/post-filter.js b/js/post-filter.js index d5225f45..b3f633f7 100644 --- a/js/post-filter.js +++ b/js/post-filter.js @@ -174,10 +174,10 @@ if (active_page === 'thread' || active_page === 'index') { function hide(ele) { var $ele = $(ele); - if (ele.dataset.hidden == '1') + if ($(ele).data('hidden') === '1') return; - ele.dataset.hidden = '1'; + $(ele).data('hidden', '1'); if ($ele.hasClass('op')) { $ele.parent().find('.body, .files, .video-container').not($ele.children('.reply').children()).hide(); @@ -191,7 +191,7 @@ if (active_page === 'thread' || active_page === 'index') { function show(ele) { var $ele = $(ele); - ele.dataset.hidden = '0'; + $(ele).data('hidden', '0'); if ($ele.hasClass('op')) { $ele.parent().find('.body, .files, .video-container').show(); if (active_page == 'index') $ele.parent().find('.omitted, .reply:not(.hidden), post_no, .mentioned, br').show(); @@ -254,8 +254,8 @@ if (active_page === 'thread' || active_page === 'index') { */ // unhide button - if (ele.dataset.hidden == '1' && ele.dataset.hiddenByUid == '0' && - ele.dataset.hiddenByName == '0' && ele.dataset.hiddenByTrip == '0') { + if ($(ele).data('hidden') == '1' && $(ele).data('hiddenByUid') == '0' && + $(ele).data('hiddenByName') == '0' && $(ele).data('hiddenByTrip') == '0') { $buffer.find('#filter-menu-unhide').click(function () { // if hidden due to post id, remove it from blacklist // otherwise just show this post @@ -267,7 +267,7 @@ if (active_page === 'thread' || active_page === 'index') { } // post id - if (ele.dataset.hiddenByPost == '0') { + if ($(ele).data('hiddenByPost') == '0') { $buffer.find('#filter-menu-add .filter-post').click(function () { blacklist.add.post(pageData.boardId, threadId, postId, false); }); @@ -280,7 +280,7 @@ if (active_page === 'thread' || active_page === 'index') { } // UID - if (pageData.hasUID && ele.dataset.hiddenByUid == '0') { + if (pageData.hasUID && $(ele).data('hiddenByUid') == '0') { $buffer.find('#filter-menu-add .filter-id').click(function () { blacklist.add.uid(pageData.boardId, threadId, postUid, false); }); @@ -304,7 +304,7 @@ if (active_page === 'thread' || active_page === 'index') { } // name - if (!pageData.forcedAnon && ele.dataset.hiddenByName == '0') { + if (!pageData.forcedAnon && $(ele).data('hiddenByName') == '0') { $buffer.find('#filter-menu-add .filter-name').click(function () { blacklist.add.name(postName); }); @@ -323,7 +323,7 @@ if (active_page === 'thread' || active_page === 'index') { } // tripcode - if (!pageData.forcedAnon && ele.dataset.hiddenByTrip == '0' && postTrip !== '') { + if (!pageData.forcedAnon && $(ele).data('hiddenByTrip') == '0' && postTrip !== '') { $buffer.find('#filter-menu-add .filter-trip').click(function () { blacklist.add.trip(postTrip); }); @@ -408,11 +408,11 @@ if (active_page === 'thread' || active_page === 'index') { var hasUID = pageData.hasUID; var forcedAnon = pageData.forcedAnon; - post.dataset.hidden = '0'; - post.dataset.hiddenByUid = '0'; - post.dataset.hiddenByPost = '0'; - post.dataset.hiddenByName = '0'; - post.dataset.hiddenByTrip = '0'; + $post.data('hidden', '0'); + $post.data('hiddenByUid', '0'); + $post.data('hiddenByPost', '0'); + $post.data('hiddenByName', '0'); + $post.data('hiddenByTrip', '0'); // add post with matched UID to localList if (hasUID && @@ -423,7 +423,7 @@ if (active_page === 'thread' || active_page === 'index') { for (i=0; i img.hidden{ opacity: 0.1; background: grey; border: 1px solid #000; } ').appendTo($('head')); var hideImage = function() { - if ($(this).parent()[0].dataset.expanded == 'true') { + if ($(this).parent().data('expanded') == 'true') { $(this).parent().click(); } $(this) -- cgit v1.3 From deefe7225d1992b67912a267cb2bba7ec93d1698 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Tue, 24 Feb 2015 20:34:13 +0800 Subject: Bugfix: scroll to thumbnail on multipost close Indroduced in 7364e85 --- 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 e316fbb7..8405ee6a 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -158,7 +158,7 @@ $(document).ready(function(){ // on multifile posts, determin how many other images are still expanded still_open = post_body.find('.post-image').filter(function(){ - return $(this).parent().attr('data-expanded') == 'true'; + return $(this).parent().data('expanded') == 'true'; }).length; // deal with differnt boards' menu styles -- cgit v1.3 From 3e579ee1d483e3a5b26b980762c7ccbd9e33850a Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Fri, 6 Mar 2015 20:59:47 +0800 Subject: Bugfix: reset multifile container width #371 --- js/inline-expanding.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'js/inline-expanding.js') diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 8405ee6a..78e5dc68 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -113,6 +113,10 @@ $(document).ready(function(){ if (e.which == 2 || e.ctrlKey) // open in new tab return true; if (!$(this).data('expanded')) { + + if (~this.parentNode.className.indexOf('multifile')) + $(this).data('width') = this.parentNode.style.width; + this.parentNode.removeAttribute('style'); $(this).data('expanded', 'true'); @@ -144,7 +148,7 @@ $(document).ready(function(){ } if (~this.parentNode.className.indexOf('multifile')) - this.parentNode.style.width = (parseInt($(this).data('width'))+40)+'px'; + this.parentNode.style.width = $(this).data('width'); thumb.style.opacity = ''; thumb.style.display = ''; -- cgit v1.3 From 84bc3b0f7b7b60ee905167ee6390d4f7d241ca8e Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Sun, 8 Mar 2015 13:06:52 +0800 Subject: I forgot how to jQuery --- 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 78e5dc68..5db95c09 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -115,7 +115,7 @@ $(document).ready(function(){ if (!$(this).data('expanded')) { if (~this.parentNode.className.indexOf('multifile')) - $(this).data('width') = this.parentNode.style.width; + $(this).data('width', this.parentNode.style.width); this.parentNode.removeAttribute('style'); $(this).data('expanded', 'true'); -- cgit v1.3