MediaWiki:Gadget-alertMessage.js

Nota: dopo aver pubblicato, potrebbe essere necessario pulire la cache del proprio browser per vedere i cambiamenti.

  • Firefox / Safari: tieni premuto il tasto delle maiuscole Shift e fai clic su Ricarica, oppure premi Ctrl-F5 o Ctrl-R (⌘-R su Mac)
  • Google Chrome: premi Ctrl-Shift-R (⌘-Shift-R su un Mac)
  • Internet Explorer / Edge: tieni premuto il tasto Ctrl e fai clic su Aggiorna, oppure premi Ctrl-F5
  • Opera: premi Ctrl-F5.
mw.alertMessage = function (title, text) {
	if (text === undefined) {
		text = title;
		title = undefined;
	}
	
	var id = Math.random().toString(36).substring(5);
	var box = '<div class="alert-message" id="' + id + '">'
	+ '<button class="button alert-message-close">x</button>';
	
	if (title)
		box += '<strong>' + title + '</strong><br>' ;
		
	box += text + '</div>';
	$('#bodyContent').append(box);
	$('.alert-message-close').click(function() {
		$('.alert-message-close').parents('.alert-message').remove();
	});
	
	$("#" + id).fadeTo(3000, 500).slideUp(500, function() {
    	$("#" + id).slideUp(500).remove();
	});
};