MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 8: | Line 8: | ||
homeTab.style.display = 'inline-block'; | homeTab.style.display = 'inline-block'; | ||
} | } | ||
}); | |||
mw.hook('wikipage.content').add(function($content) { | |||
$content.find('#toc li').has('ul').each(function() { | |||
var $li = $(this); | |||
if ($li.children('.fandom-toc-toggle').length === 0) { | |||
// Insert a purple clickable arrow before the link | |||
$li.prepend('<span class="fandom-toc-toggle" style="cursor:pointer; display:inline-block; width: 16px; text-align:center; color:#a862ea; margin-right:4px; font-size:10px; transition: transform 0.2s;">▼</span>'); | |||
} | |||
}); | |||
$content.find('.fandom-toc-toggle').off('click').on('click', function(e) { | |||
e.preventDefault(); | |||
e.stopPropagation(); | |||
var $toggle = $(this); | |||
var $sublist = $toggle.siblings('ul'); | |||
$sublist.slideToggle(200, function() { | |||
if ($sublist.is(':visible')) { | |||
$toggle.css('transform', 'rotate(0deg)'); | |||
} else { | |||
$toggle.css('transform', 'rotate(-90deg)'); | |||
} | |||
}); | |||
}); | |||
}); | }); | ||
Revision as of 16:39, 27 April 2026
/* Any JavaScript here will be loaded for all users on every page load. */
$(function() {
var homeTab = document.querySelector('#ca-talk a');
if (homeTab) {
homeTab.setAttribute('href', 'https://wiki.jcraft-eoe.com/index.php?title=Main_Page');
// Ensure the link is physically clickable
homeTab.style.pointerEvents = 'auto';
homeTab.style.display = 'inline-block';
}
});
mw.hook('wikipage.content').add(function($content) {
$content.find('#toc li').has('ul').each(function() {
var $li = $(this);
if ($li.children('.fandom-toc-toggle').length === 0) {
// Insert a purple clickable arrow before the link
$li.prepend('<span class="fandom-toc-toggle" style="cursor:pointer; display:inline-block; width: 16px; text-align:center; color:#a862ea; margin-right:4px; font-size:10px; transition: transform 0.2s;">▼</span>');
}
});
$content.find('.fandom-toc-toggle').off('click').on('click', function(e) {
e.preventDefault();
e.stopPropagation();
var $toggle = $(this);
var $sublist = $toggle.siblings('ul');
$sublist.slideToggle(200, function() {
if ($sublist.is(':visible')) {
$toggle.css('transform', 'rotate(0deg)');
} else {
$toggle.css('transform', 'rotate(-90deg)');
}
});
});
});