MediaWiki:Common.js: Difference between revisions
From DM Live - the Depeche Mode live encyclopedia for the masses
Jump to navigationJump to search
Tag: Undo |
No edit summary |
||
Line 48: | Line 48: | ||
}); | }); | ||
}); | }); | ||
// only run on the real Main Page | |||
if ( mw.config.get('wgPageName') === 'Main_Page' ) { | |||
// 1) hide the normal chrome | |||
$('head').append(` | |||
<style> | |||
.navigation, | |||
#column-one, | |||
#siteNotice, | |||
#footer { | |||
display: none !important; | |||
} | |||
#column-content { | |||
margin: 0 !important; | |||
width: 100% !important; | |||
} | |||
</style> | |||
`); | |||
// 2) load your CSS and scope it only to Main_Page | |||
$.get(mw.util.wikiUrl('MediaWiki:HomepageDraft.css','action=raw')) | |||
.done(function(css){ | |||
$('head').append('<style>'+css+'</style>'); | |||
}); | |||
// 3) replace the wiki content with your HTML draft | |||
$('#mw-content-text').empty(); | |||
$.get(mw.util.wikiUrl('MediaWiki:HomepageDraft.html','action=raw')) | |||
.done(function(html){ | |||
// inject the raw HTML you stored | |||
$('#mw-content-text').append(html); | |||
}); | |||
} |
Revision as of 19:15, 27 May 2025
/* <pre> */ /* Any JavaScript here will be loaded for all users on every page load. */ // Start of custom navbar js (function($) { // Begin jQuery $(function() { // DOM ready // If a link has a dropdown, add sub menu toggle. $('nav ul li a:not(:only-child)').click(function(e) { $(this).siblings('.nav-dropdown').toggle(); // Close one dropdown when selecting another $('.nav-dropdown').not($(this).siblings()).hide(); e.stopPropagation(); }); // Clicking away from dropdown will remove the dropdown class $('html').click(function() { $('.nav-dropdown').hide(); }); // Toggle open and close nav styles on click $('#nav-toggle').click(function() { $('nav ul').slideToggle(); }); // Hamburger to X toggle $('#nav-toggle').on('click', function() { this.classList.toggle('active'); }); }); // end DOM ready })(jQuery); // end jQuery // End of custom navbar // Collapsible menus... $(function() { var b = $("#toggle-button"); var w = $("#toggle"); var l = $("#toggle-content"); w.height(l.outerHeight(true)); b.click(function() { if(w.hasClass('open')) { w.removeClass('open'); w.height(0); } else { w.addClass('open'); w.height(l.outerHeight(true)); } }); }); // only run on the real Main Page if ( mw.config.get('wgPageName') === 'Main_Page' ) { // 1) hide the normal chrome $('head').append(` <style> .navigation, #column-one, #siteNotice, #footer { display: none !important; } #column-content { margin: 0 !important; width: 100% !important; } </style> `); // 2) load your CSS and scope it only to Main_Page $.get(mw.util.wikiUrl('MediaWiki:HomepageDraft.css','action=raw')) .done(function(css){ $('head').append('<style>'+css+'</style>'); }); // 3) replace the wiki content with your HTML draft $('#mw-content-text').empty(); $.get(mw.util.wikiUrl('MediaWiki:HomepageDraft.html','action=raw')) .done(function(html){ // inject the raw HTML you stored $('#mw-content-text').append(html); }); }