MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 5: | Line 5: | ||
} | } | ||
var | var topnav = $('<div>', { | ||
id: 'handwiki-topnav' | |||
}); | |||
function makeMenu(buttonText, extraClass) { | |||
var | var menu = $('<div>', { | ||
class: 'handwiki-dropdown ' + extraClass | |||
}); | |||
var button = $('<div>', { | |||
class: 'handwiki-dropdown-button', | |||
text: buttonText | |||
}); | |||
var content = $('<div>', { | |||
class: 'handwiki-dropdown-content' | |||
}); | |||
menu.append(button); | |||
menu.append(content); | |||
return { | |||
menu: menu, | |||
content: content | |||
} | }; | ||
} | |||
function addSection(content, title) { | |||
content.append($('<div>', { | |||
class: 'handwiki-menu-section', | |||
text: title | |||
})); | |||
} | |||
function addLink(content, href, text, bold) { | |||
content.append( | |||
$('<a>', { | $('<a>', { | ||
href: | href: href, | ||
text: | text: text, | ||
class: bold ? 'handwiki-menu-bold' : '' | |||
}) | }) | ||
); | ); | ||
}); | } | ||
var portal = makeMenu('Portal ▾', 'handwiki-portal-menu'); | |||
portal.content.append($('<div>', { | |||
class: 'handwiki-menu-title', | |||
text: 'Encyclopedia of Knowledge' | |||
})); | |||
portal.content.append($('<div>', { | |||
class: 'handwiki-menu-band', | |||
text: 'Portals' | |||
})); | |||
addLink(portal.content, '/index.php/Main_Page', 'Main page', true); | |||
addLink(portal.content, '/index.php/Portal:Data_analysis', 'Data analysis', false); | |||
addLink(portal.content, '/index.php/Portal:Mathematics', 'Mathematics', false); | |||
addSection(portal.content, 'Natural Sciences'); | |||
addLink(portal.content, '/index.php/Portal:Astronomy_%26_Space', 'Astronomy & Space', false); | |||
addLink(portal.content, '/index.php/Portal:Biology', 'Biology', false); | |||
addLink(portal.content, '/index.php/Portal:Computer_concepts', 'Computer concepts', false); | |||
addLink(portal.content, '/index.php/Portal:Chemistry', 'Chemistry', false); | |||
addLink(portal.content, '/index.php/Portal:Physics', 'Physics', false); | |||
addLink(portal.content, '/index.php/Portal:Earth_studies', 'Earth studies', false); | |||
addLink(portal.content, '/index.php/Portal:Unsolved_problems', 'Unsolved problems', false); | |||
addSection(portal.content, 'Humanities'); | |||
addLink(portal.content, '/index.php/Portal:History', 'History', false); | |||
addLink(portal.content, '/index.php/Portal:Philosophy', 'Philosophy', false); | |||
addLink(portal.content, '/index.php/Portal:Social_studies', 'Social studies', false); | |||
addLink(portal.content, '/index.php/Portal:Religion', 'Religion', false); | |||
addLink(portal.content, '/index.php/Portal:Medicine', 'Medicine', false); | |||
addSection(portal.content, 'Technology & Finance'); | |||
addLink(portal.content, '/index.php/Portal:Engineering_%26_Tech', 'Engineering & Tech', false); | |||
addLink(portal.content, '/index.php/Portal:Software_programs', 'Software programs', false); | |||
addLink(portal.content, '/index.php/Portal:Business_and_economics', 'Business and economics', false); | |||
addLink(portal.content, '/index.php/Portal:Finance', 'Finance', false); | |||
var sources = makeMenu('Sources ▾', 'handwiki-sources-menu'); | |||
sources.content.append($('<div>', { | |||
class: 'handwiki-menu-title', | |||
text: ' | text: 'Sources' | ||
})); | })); | ||
sources.content.append($('<div>', { | |||
class: 'handwiki-menu-band handwiki-menu-band-orange', | |||
text: ' | text: 'Quantum Collection' | ||
})); | })); | ||
addLink(sources.content, '/index.php/Book:Quantum_Collection', 'Quantum Collection', true); | |||
addLink(sources.content, '/index.php/Book:Quantum_Collection/Matter_(by_scale)', 'Matter by scale', false); | |||
addLink(sources.content, '/index.php/Book:Quantum_Collection/Methods_and_tools', 'Methods and tools', false); | |||
addSection(sources.content, 'Wiki sources'); | |||
addLink(sources.content, '/index.php/Special:RecentChanges', 'Recent changes', false); | |||
addLink(sources.content, '/index.php/Special:Random', 'Random page', false); | |||
addLink(sources.content, '/index.php/Special:SpecialPages', 'Special pages', false); | |||
addLink(sources.content, '/index.php/Special:Upload', 'Upload file', false); | |||
topnav.append( | topnav.append(portal.menu); | ||
topnav.append( | topnav.append(sources.menu); | ||
$('body').append(topnav); | $('body').append(topnav); | ||
}); | }); | ||
}); | }); | ||
Revision as of 17:30, 9 May 2026
mw.loader.using('mediawiki.util', function () {
$(function () {
if ($('#handwiki-topnav').length) {
return;
}
var topnav = $('<div>', {
id: 'handwiki-topnav'
});
function makeMenu(buttonText, extraClass) {
var menu = $('<div>', {
class: 'handwiki-dropdown ' + extraClass
});
var button = $('<div>', {
class: 'handwiki-dropdown-button',
text: buttonText
});
var content = $('<div>', {
class: 'handwiki-dropdown-content'
});
menu.append(button);
menu.append(content);
return {
menu: menu,
content: content
};
}
function addSection(content, title) {
content.append($('<div>', {
class: 'handwiki-menu-section',
text: title
}));
}
function addLink(content, href, text, bold) {
content.append(
$('<a>', {
href: href,
text: text,
class: bold ? 'handwiki-menu-bold' : ''
})
);
}
var portal = makeMenu('Portal ▾', 'handwiki-portal-menu');
portal.content.append($('<div>', {
class: 'handwiki-menu-title',
text: 'Encyclopedia of Knowledge'
}));
portal.content.append($('<div>', {
class: 'handwiki-menu-band',
text: 'Portals'
}));
addLink(portal.content, '/index.php/Main_Page', 'Main page', true);
addLink(portal.content, '/index.php/Portal:Data_analysis', 'Data analysis', false);
addLink(portal.content, '/index.php/Portal:Mathematics', 'Mathematics', false);
addSection(portal.content, 'Natural Sciences');
addLink(portal.content, '/index.php/Portal:Astronomy_%26_Space', 'Astronomy & Space', false);
addLink(portal.content, '/index.php/Portal:Biology', 'Biology', false);
addLink(portal.content, '/index.php/Portal:Computer_concepts', 'Computer concepts', false);
addLink(portal.content, '/index.php/Portal:Chemistry', 'Chemistry', false);
addLink(portal.content, '/index.php/Portal:Physics', 'Physics', false);
addLink(portal.content, '/index.php/Portal:Earth_studies', 'Earth studies', false);
addLink(portal.content, '/index.php/Portal:Unsolved_problems', 'Unsolved problems', false);
addSection(portal.content, 'Humanities');
addLink(portal.content, '/index.php/Portal:History', 'History', false);
addLink(portal.content, '/index.php/Portal:Philosophy', 'Philosophy', false);
addLink(portal.content, '/index.php/Portal:Social_studies', 'Social studies', false);
addLink(portal.content, '/index.php/Portal:Religion', 'Religion', false);
addLink(portal.content, '/index.php/Portal:Medicine', 'Medicine', false);
addSection(portal.content, 'Technology & Finance');
addLink(portal.content, '/index.php/Portal:Engineering_%26_Tech', 'Engineering & Tech', false);
addLink(portal.content, '/index.php/Portal:Software_programs', 'Software programs', false);
addLink(portal.content, '/index.php/Portal:Business_and_economics', 'Business and economics', false);
addLink(portal.content, '/index.php/Portal:Finance', 'Finance', false);
var sources = makeMenu('Sources ▾', 'handwiki-sources-menu');
sources.content.append($('<div>', {
class: 'handwiki-menu-title',
text: 'Sources'
}));
sources.content.append($('<div>', {
class: 'handwiki-menu-band handwiki-menu-band-orange',
text: 'Quantum Collection'
}));
addLink(sources.content, '/index.php/Book:Quantum_Collection', 'Quantum Collection', true);
addLink(sources.content, '/index.php/Book:Quantum_Collection/Matter_(by_scale)', 'Matter by scale', false);
addLink(sources.content, '/index.php/Book:Quantum_Collection/Methods_and_tools', 'Methods and tools', false);
addSection(sources.content, 'Wiki sources');
addLink(sources.content, '/index.php/Special:RecentChanges', 'Recent changes', false);
addLink(sources.content, '/index.php/Special:Random', 'Random page', false);
addLink(sources.content, '/index.php/Special:SpecialPages', 'Special pages', false);
addLink(sources.content, '/index.php/Special:Upload', 'Upload file', false);
topnav.append(portal.menu);
topnav.append(sources.menu);
$('body').append(topnav);
});
});