MediaWiki:Mobile.js
Jump to navigation
Jump to search
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* Mobile Menu */
var timer = setInterval(function() {
if ($('.menu ul:first').length) {
//console.log("mobile menu exists");
clearInterval(timer);
$.get('/customizations/mobilemenu.htm', function(data){
$('.menu ul:first').after(data);
});
$(".menu").find(".level2").hide(); // hide level2 until level1 is clicked
$(".level1").click(function(event){
$(this).find(".level2").slideToggle(500);
}); // if level1 is clicked, dropdown level2
}
}, 100); // check every 100ms
/* Tooltip */
$(".popup").click(function () {
var $title = $(this).find(".title");
if (!$title.length) {
$(this).append('<span class="title">' + $(this).attr("title") + '</span>');
} else {
$title.remove();
}
});
// Creates action=raw links for JS or CSS gadgets
// Useful for mw.loader.load, which doesn't accept page titles
function rawPageLink( pageName ) {
return mw.config.get( 'wgServer' ) + mw.config.get( 'wgScript' ) + '?title=' + mw.util.wikiUrlencode(pageName) + '&action=raw&ctype=text/javascript';
}
// Overwriting deprecated functions that don't have an exact followup but can be easily mapped:
window.importScript = function ( page ) {
if ( typeof page === 'string' && page.length ) {
mw.loader.load( rawPageLink( page ) );
}
};
/* Palette Hex Codes */
$(document).ready(function() {
$('.palette2').click(function() {
var color = $(this).data('color');
var tempInput = document.createElement("input");
tempInput.style = "position: absolute; left: -1000px; top: -1000px";
tempInput.value = color;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
// Remove any existing notifications
$('.color-notification').remove();
// Create notification
var notification = $('<div class="color-notification">Copied color code: ' + color + '</div>');
notification.css({
'position': 'absolute',
'background-color': 'var(--jjbe3)',
'color': 'white',
'padding': '10px',
'border-radius': '5px',
'z-index': '1000'
});
// Position notification near the clicked color box
var position = $(this).position();
position.top -= $(this).height();
notification.css(position);
$(this).parent().append(notification);
// Fade out and remove notification after 3 seconds
setTimeout(function() {
notification.fadeOut('slow', function() {
notification.remove();
});
}, 3000);
});
});