mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-02-08 23:39:46 +01:00
expand.js: format
This commit is contained in:
parent
8302a121e5
commit
3eba0b8721
34
js/expand.js
34
js/expand.js
@ -14,33 +14,34 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
if($('span.omitted').length == 0)
|
if ($('span.omitted').length === 0) {
|
||||||
return; // nothing to expand
|
// Nothing to expand.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var do_expand = function() {
|
let doExpand = function() {
|
||||||
$(this)
|
$(this)
|
||||||
.html($(this).text().replace(_("Click reply to view."), '<a href="javascript:void(0)">'+_("Click to expand")+'</a>.'))
|
.html($(this).text().replace(_("Click reply to view."), '<a href="javascript:void(0)">'+_("Click to expand")+'</a>.'))
|
||||||
.find('a').click(window.expand_fun = function() {
|
.find('a').click(window.expand_fun = function() {
|
||||||
var thread = $(this).parents('[id^="thread_"]');
|
let thread = $(this).parents('[id^="thread_"]');
|
||||||
var id = thread.attr('id').replace(/^thread_/, '');
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: thread.find('p.intro a.post_no:first').attr('href'),
|
url: thread.find('p.intro a.post_no:first').attr('href'),
|
||||||
context: document.body,
|
context: document.body,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var last_expanded = false;
|
let lastExpanded = false;
|
||||||
$(data).find('div.post.reply').each(function() {
|
$(data).find('div.post.reply').each(function() {
|
||||||
thread.find('div.hidden').remove();
|
thread.find('div.hidden').remove();
|
||||||
var post_in_doc = thread.find('#' + $(this).attr('id'));
|
let postInDoc = thread.find('#' + $(this).attr('id'));
|
||||||
if(post_in_doc.length == 0) {
|
if (postInDoc.length === 0) {
|
||||||
if(last_expanded) {
|
if (lastExpanded) {
|
||||||
$(this).addClass('expanded').insertAfter(last_expanded).before('<br class="expanded">');
|
$(this).addClass('expanded').insertAfter(lastExpanded).before('<br class="expanded">');
|
||||||
} else {
|
} else {
|
||||||
$(this).addClass('expanded').insertAfter(thread.find('div.post:first')).after('<br class="expanded">');
|
$(this).addClass('expanded').insertAfter(thread.find('div.post:first')).after('<br class="expanded">');
|
||||||
}
|
}
|
||||||
last_expanded = $(this);
|
lastExpanded = $(this);
|
||||||
$(document).trigger('new_post', this);
|
$(document).trigger('new_post', this);
|
||||||
} else {
|
} else {
|
||||||
last_expanded = post_in_doc;
|
lastExpanded = postInDoc;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -51,19 +52,20 @@ $(document).ready(function(){
|
|||||||
.insertAfter(thread.find('.op div.body, .op span.omitted').last())
|
.insertAfter(thread.find('.op div.body, .op span.omitted').last())
|
||||||
.click(function() {
|
.click(function() {
|
||||||
thread.find('.expanded').remove();
|
thread.find('.expanded').remove();
|
||||||
$(this).parent().find(".omitted:not(.hide-expanded)").css('display', '');
|
let parent = $(this).parent();
|
||||||
$(this).parent().find(".hide-expanded").remove();
|
parent.find(".omitted:not(.hide-expanded)").css('display', '');
|
||||||
|
parent.find(".hide-expanded").remove();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('div.post.op span.omitted').each(do_expand);
|
$('div.post.op span.omitted').each(doExpand);
|
||||||
|
|
||||||
$(document).on("new_post", function(e, post) {
|
$(document).on("new_post", function(e, post) {
|
||||||
if (!$(post).hasClass("reply")) {
|
if (!$(post).hasClass("reply")) {
|
||||||
$(post).find('div.post.op span.omitted').each(do_expand);
|
$(post).find('div.post.op span.omitted').each(doExpand);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user