This repository has been archived by the owner on Feb 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We call this code, so we should have a local copy of it in the repo to be able to change and fix things.
- Loading branch information
1 parent
d547b12
commit cace168
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* The old mw.util.jsMessage function before https://gerrit.wikimedia.org/r/#/c/17605/, which | ||
* introduced the silly auto-hide function. Also with the original styles. | ||
* Add a little box at the top of the screen to inform the user of | ||
* something, replacing any previous message. | ||
* Calling with no arguments, with an empty string or null will hide the message | ||
* | ||
* @param message {mixed} The DOM-element, jQuery object or HTML-string to be put inside the message box. | ||
* @param className {String} Used in adding a class; should be different for each call | ||
* to allow CSS/JS to hide different boxes. null = no class used. | ||
* @return {Boolean} True on success, false on failure. | ||
*/ | ||
function displayMessage( message, className ){ | ||
if ( !arguments.length || message === '' || message === null ) { | ||
$( '#display-message' ).empty().hide(); | ||
return true; // Emptying and hiding message is intended behaviour, return true | ||
} else { | ||
// We special-case skin structures provided by the software. Skins that | ||
// choose to abandon or significantly modify our formatting can just define | ||
// an mw-js-message div to start with. | ||
var $messageDiv = $( '#display-message' ); | ||
if ( !$messageDiv.length ) { | ||
$messageDiv = $( '<div id="display-message" style="margin:1em;padding:0.5em 2.5%;border:solid 1px #ddd;background-color:#fcfcfc;font-size: 0.8em"></div>' ); | ||
if ( mw.util.$content.length ) { | ||
mw.util.$content.prepend( $messageDiv ); | ||
} else { | ||
return false; | ||
} | ||
} | ||
if ( className ) { | ||
$messageDiv.prop( 'class', 'display-message-' + className ); | ||
} | ||
if ( typeof message === 'object' ) { | ||
$messageDiv.empty(); | ||
$messageDiv.append( message ); | ||
} else { | ||
$messageDiv.html( message ); | ||
} | ||
$messageDiv.slideDown(); | ||
return true; | ||
} | ||
} |