mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-05 12:56:22 -07:00
Apply thumbnail expansion and inline post preview events to AJAX-loaded posts
This commit is contained in:
parent
62c81a3245
commit
db4d3b0977
3 changed files with 21 additions and 9 deletions
|
@ -66,6 +66,8 @@ function updateThreadHTML() {
|
||||||
}).append($post);
|
}).append($post);
|
||||||
$replyContainer.appendTo(`div#${post.resto}.thread`);
|
$replyContainer.appendTo(`div#${post.resto}.thread`);
|
||||||
addPostDropdown($post);
|
addPostDropdown($post);
|
||||||
|
prepareThumbnails($post);
|
||||||
|
initPostPreviews($post);
|
||||||
numAdded++;
|
numAdded++;
|
||||||
}
|
}
|
||||||
if(numAdded === 0) return;
|
if(numAdded === 0) return;
|
||||||
|
@ -156,17 +158,22 @@ export function initPostPreviews($post = null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function prepareThumbnails() {
|
/**
|
||||||
// set thumbnails to expand when clicked
|
* Sets thumbnails to expand when clicked. If a parent is provided, prepareThumbnails will only
|
||||||
$("a.upload-container").on("click", function(e) {
|
* be applied to that parent
|
||||||
|
* @param {JQuery<HTMLElement>} $post the post (if set) to prepare the thumbnails for
|
||||||
|
*/
|
||||||
|
export function prepareThumbnails($parent = null) {
|
||||||
|
let $container = $parent === null ? $("a.upload-container") : $parent.find("a")
|
||||||
|
$container.on("click", function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let a = $(this);
|
let $a = $(this);
|
||||||
let thumb = a.find("img.upload");
|
let thumb = $a.find("img.upload");
|
||||||
let thumbURL = thumb.attr("src");
|
let thumbURL = thumb.attr("src");
|
||||||
let uploadURL = thumb.attr("alt");
|
let uploadURL = thumb.attr("alt");
|
||||||
thumb.removeAttr("width").removeAttr("height");
|
thumb.removeAttr("width").removeAttr("height");
|
||||||
|
|
||||||
var fileInfoElement = a.prevAll(".file-info:first");
|
var fileInfoElement = $a.prevAll(".file-info:first");
|
||||||
|
|
||||||
if(videoTestRE.test(thumbURL + uploadURL)) {
|
if(videoTestRE.test(thumbURL + uploadURL)) {
|
||||||
// Upload is a video
|
// Upload is a video
|
||||||
|
@ -243,9 +250,14 @@ export function stopThreadWatcher() {
|
||||||
clearInterval(threadWatcherInterval);
|
clearInterval(threadWatcherInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function resetThreadWatcherInterval() {
|
||||||
|
stopThreadWatcher();
|
||||||
|
threadWatcherInterval = setInterval(updateThread, getNumberStorageVal("watcherseconds", 10) * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
$(() => {
|
$(() => {
|
||||||
let pageThread = getPageThread();
|
let pageThread = getPageThread();
|
||||||
if(pageThread.op >= 1) {
|
if(pageThread.op >= 1) {
|
||||||
threadWatcherInterval = setInterval(updateThread, getNumberStorageVal("watcherseconds", 10) * 1000);
|
resetThreadWatcherInterval();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue