User:Kiokurashi/common.js: Difference between revisions

From IdleOn MMO Wiki
imported>Kiokurashi
(Blanked the page)
imported>Kiokurashi
No edit summary
Line 1: Line 1:


$(document).ready(function() {
//assign custom sidebar collapsible classes
    $("#site-navigation > .sidebar-inner > div > h3").addClass("sidebar-collapsible");
$("#site-navigation > .sidebar-inner > div > div.mw-portlet-body").addClass("sidebar-collapsible-content");
$("#site-navigation > .sidebar-inner").html("<div id=\"sidebar-collapsible-toggle\">Expand All</div>" + $("#site-navigation > .sidebar-inner").html())
//hide content except for the ones specified as expanded
var expandedContentTitles = ['Navigation', 'Featured', 'Episodes', 'Other Tales', 'Story Chapters', 'Symphonies - Collabs'];
$(".sidebar-collapsible-content").each(function() {
if (!expandedContentTitles.includes(this.previousSibling.textContent)) {
$(this.previousSibling).css("background-image", "url('https://upload.wikimedia.org/wikipedia/commons/b/bc/Vector_right_arrow_link.png')");
this.style.display = "none";
} else {
$(this.previousSibling).css("background-image", "url('https://upload.wikimedia.org/wikipedia/commons/2/27/Vector_down_arrow_link.png')");
}
});
// on section title click, show/hide contents and toggle between cute little right/down arrow
$(".sidebar-collapsible").click(function() {
if(this.nextSibling.style.display != "none") {
this.nextSibling.style.display = "none";
$(this).css("background-image", "url('https://upload.wikimedia.org/wikipedia/commons/b/bc/Vector_right_arrow_link.png')");
} else {
this.nextSibling.style.display = "";
$(this).css("background-image", "url('https://upload.wikimedia.org/wikipedia/commons/2/27/Vector_down_arrow_link.png')");
}
});
   
    $("#sidebar-collapsible-toggle").click(function() {
if($("#sidebar-collapsible-toggle").text() == "Expand All") {
$(".sidebar-collapsible-content").css('display', '');
$("#sidebar-collapsible-toggle").text("Close All");
$(".sidebar-collapsible").css("background-image", "url('https://upload.wikimedia.org/wikipedia/commons/2/27/Vector_down_arrow_link.png')");
} else {
$(".sidebar-collapsible-content").css('display', 'none');
$("#sidebar-collapsible-toggle").text("Expand All");
$(".sidebar-collapsible").css("background-image", "url('https://upload.wikimedia.org/wikipedia/commons/b/bc/Vector_right_arrow_link.png')");
}
});
});

Revision as of 20:20, 1 November 2021

$(document).ready(function() {
	//assign custom sidebar collapsible classes
    $("#site-navigation > .sidebar-inner > div > h3").addClass("sidebar-collapsible");
	$("#site-navigation > .sidebar-inner > div > div.mw-portlet-body").addClass("sidebar-collapsible-content");
	$("#site-navigation > .sidebar-inner").html("<div id=\"sidebar-collapsible-toggle\">Expand All</div>" + $("#site-navigation > .sidebar-inner").html())
	
	//hide content except for the ones specified as expanded
	var expandedContentTitles = ['Navigation', 'Featured', 'Episodes', 'Other Tales', 'Story Chapters', 'Symphonies - Collabs'];
	$(".sidebar-collapsible-content").each(function() {
		if (!expandedContentTitles.includes(this.previousSibling.textContent)) {
			$(this.previousSibling).css("background-image", "url('https://upload.wikimedia.org/wikipedia/commons/b/bc/Vector_right_arrow_link.png')");
			this.style.display = "none";
		} else {
			$(this.previousSibling).css("background-image", "url('https://upload.wikimedia.org/wikipedia/commons/2/27/Vector_down_arrow_link.png')");
		}
	});

	// on section title click, show/hide contents and toggle between cute little right/down arrow
	$(".sidebar-collapsible").click(function() {
		if(this.nextSibling.style.display != "none") {
			this.nextSibling.style.display = "none";
			$(this).css("background-image", "url('https://upload.wikimedia.org/wikipedia/commons/b/bc/Vector_right_arrow_link.png')");
		} else {
			this.nextSibling.style.display = "";
			$(this).css("background-image", "url('https://upload.wikimedia.org/wikipedia/commons/2/27/Vector_down_arrow_link.png')");
		}
	});
    
    $("#sidebar-collapsible-toggle").click(function() {
		if($("#sidebar-collapsible-toggle").text() == "Expand All") {
			$(".sidebar-collapsible-content").css('display', '');
			$("#sidebar-collapsible-toggle").text("Close All");
			$(".sidebar-collapsible").css("background-image", "url('https://upload.wikimedia.org/wikipedia/commons/2/27/Vector_down_arrow_link.png')");
		} else {
			$(".sidebar-collapsible-content").css('display', 'none');
			$("#sidebar-collapsible-toggle").text("Expand All");
			$(".sidebar-collapsible").css("background-image", "url('https://upload.wikimedia.org/wikipedia/commons/b/bc/Vector_right_arrow_link.png')");
		}
	});
});