Making a start with $.jsMessage. A more flexible way for messages. Supports grouping...
authorKrinkle <krinkle@users.mediawiki.org>
Fri, 4 Feb 2011 02:17:14 +0000 (02:17 +0000)
committerKrinkle <krinkle@users.mediawiki.org>
Fri, 4 Feb 2011 02:17:14 +0000 (02:17 +0000)
commit11028261537e9b1e763169cca17a12043df754a7
treed5199f32efc1e48704634ff05c06200bae5da271
parent6e1e4e163d6d90ff7a36d999d6407734ce7a0fd5
Making a start with $.jsMessage. A more flexible way for messages. Supports grouping them and making the replacing of previous messages into option (the current jsMsg() function always replaces older messages. Time has shown that there is need for the ability to show older messages as well and grouping to avoid different scripts from erasing or clearing eachother's output (current Commons and a few other wikis have created similar functions to enable keeping previous messages)
* See also bug 26888. Not resolving the bug yet, this plugins needs a little more testing and should then be called from within mw.util.jsMessage with some wiki specific things.

Examples:

// Show a simple message in the default group
$.jsMessage( {
message: 'Hello',
target: 'mw-js-message'
} );

// Add a new message this time stating the defaults
$.jsMessage( {
message: 'World',
group: 'default',
replace: false,
target: 'mw-js-message'
} );

// Post a new message, replacing the previous ones
$.jsMessage( {
message: 'New',
group: 'default',
replace: true,
target: 'mw-js-message'
} );

// Add a messages in a new group (groups separated by a line)
$.jsMessage( {
message: 'A new group',
group: 'something',
target: 'mw-js-message'
} );

// Clear the default group
// See code comments for more info
$.jsMessage( {
message: '',
replace: true,
target: 'mw-js-message'
} );

// Clear the 'something'-group
// Since this leaves no visible groups, the main box will hide (slideUp) right after
$.jsMessage( {
message: '',
group: 'something',
replace: true,
target: 'mw-js-message'
} );

If testing goes well, mw.util.jsMsg(message, className, replace) will call
$.jsMessage( { message: message, group: className, replace: replace, target: $.jsMessage(ge' );
So it's more a backend plugin, not used directly by core modules.
But this way extensions or third party sites can easily re-use this plugin and/or create multiple message boxes
on one page, by calling $.jsMessageNew and giving an id and location for it on the page.
resources/Resources.php
resources/jquery/jquery.jsMessage.css [new file with mode: 0644]
resources/jquery/jquery.jsMessage.js [new file with mode: 0644]
resources/mediawiki.util/mediawiki.util.js