MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 19: | Line 19: | ||
}); | }); | ||
var sidebarMenu = $('<div class | var topnav = $('<div>', { | ||
id: 'handwiki-topnav' | |||
}); | |||
var sidebarMenu = $('<div>', { | |||
class: 'handwiki-dropdown' | |||
}); | |||
var sidebarButton = $('<div>', { | |||
class: 'handwiki-dropdown-button', | |||
text: 'Sidebar ▾' | |||
}); | |||
var sidebarContent = $('<div class | var sidebarContent = $('<div>', { | ||
class: 'handwiki-dropdown-content' | |||
}); | |||
sidebarLinks.forEach(function (link) { | sidebarLinks.forEach(function (link) { | ||
sidebarContent.append( | sidebarContent.append( | ||
$('< | $('<a>', { | ||
href: link.href, | |||
text: link.text | |||
}) | |||
); | ); | ||
}); | }); | ||
sidebarMenu.append(sidebarButton); | |||
sidebarMenu.append(sidebarContent); | sidebarMenu.append(sidebarContent); | ||
var secondMenu = $('<div class | var secondMenu = $('<div>', { | ||
class: 'handwiki-dropdown' | |||
}); | |||
var secondButton = $('<div>', { | |||
class: 'handwiki-dropdown-button', | |||
text: 'Quantum ▾' | |||
}); | |||
var secondContent = $('<div>', { | |||
class: 'handwiki-dropdown-content' | |||
}); | |||
secondContent.append($('<a>', { | |||
href: '/index.php/Book:Quantum_Collection', | |||
text: 'Quantum Collection' | |||
})); | |||
secondContent.append($('<a>', { | |||
href: '/index.php/Book:Quantum_Collection/Matter_(by_scale)', | |||
text: 'Matter by scale' | |||
})); | |||
secondContent.append($('<a>', { | |||
href: '/index.php/Book:Quantum_Collection/Methods_and_tools', | |||
text: 'Methods and tools' | |||
})); | |||
secondContent.append($('<a>', { | |||
href: '/index.php/Special:RecentChanges', | |||
text: 'Recent changes' | |||
})); | |||
secondContent.append($('<a>', { | |||
secondContent.append( | href: '/index.php/Special:SpecialPages', | ||
text: 'Special pages' | |||
})); | |||
secondMenu.append(secondButton); | |||
secondMenu.append(secondContent); | secondMenu.append(secondContent); | ||
topnav.append(sidebarMenu); | topnav.append(sidebarMenu); | ||
topnav.append(secondMenu); | topnav.append(secondMenu); | ||
$('#content, .mw-body').first(). | $('#content, .mw-body').first().prepend(topnav); | ||
}); | }); | ||
}); | }); | ||
Revision as of 16:55, 9 May 2026
mw.loader.using('mediawiki.util', function () {
$(function () {
if ($('#handwiki-topnav').length) {
return;
}
var sidebarLinks = [];
$('#mw-panel a').each(function () {
var text = $(this).text().trim();
var href = $(this).attr('href');
if (text && href) {
sidebarLinks.push({
text: text,
href: href
});
}
});
var topnav = $('<div>', {
id: 'handwiki-topnav'
});
var sidebarMenu = $('<div>', {
class: 'handwiki-dropdown'
});
var sidebarButton = $('<div>', {
class: 'handwiki-dropdown-button',
text: 'Sidebar ▾'
});
var sidebarContent = $('<div>', {
class: 'handwiki-dropdown-content'
});
sidebarLinks.forEach(function (link) {
sidebarContent.append(
$('<a>', {
href: link.href,
text: link.text
})
);
});
sidebarMenu.append(sidebarButton);
sidebarMenu.append(sidebarContent);
var secondMenu = $('<div>', {
class: 'handwiki-dropdown'
});
var secondButton = $('<div>', {
class: 'handwiki-dropdown-button',
text: 'Quantum ▾'
});
var secondContent = $('<div>', {
class: 'handwiki-dropdown-content'
});
secondContent.append($('<a>', {
href: '/index.php/Book:Quantum_Collection',
text: 'Quantum Collection'
}));
secondContent.append($('<a>', {
href: '/index.php/Book:Quantum_Collection/Matter_(by_scale)',
text: 'Matter by scale'
}));
secondContent.append($('<a>', {
href: '/index.php/Book:Quantum_Collection/Methods_and_tools',
text: 'Methods and tools'
}));
secondContent.append($('<a>', {
href: '/index.php/Special:RecentChanges',
text: 'Recent changes'
}));
secondContent.append($('<a>', {
href: '/index.php/Special:SpecialPages',
text: 'Special pages'
}));
secondMenu.append(secondButton);
secondMenu.append(secondContent);
topnav.append(sidebarMenu);
topnav.append(secondMenu);
$('#content, .mw-body').first().prepend(topnav);
});
});