"Krinkle" posted a comment on MediaWiki.r81500.
URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/81500#c32439
Commit summary for MediaWiki.r81500:
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.
Krinkle's comment:
Just a few points:
* This plugin is intended to be generic and not MediaWiki-specific, so there
is't anything other than <code>body</code> to go on
* You shouldn't be putting messages into a parent directly, instead one first
creates a messagebox and writes to it. In case you try to write to a message
box that doesn't exist, it will create it and add it to the body, but that
should almost never happen (unless you design your application in such a way
that the messagebox is positioned by CSS and is supposed to be in the root).
* The default target for the plugin is "<code>#js-messagebox</code>"
* The new equivalent of <code>jsMsg</code> is ''not'' <code>$.messageBox</code>
but <code>mw.util.jsMessage</code>, so do not change scripts from one to
another, that's not how it is designed to work and up until now I haven't seen
that either.
* <code>mw.util.jsMessage</code> currently doesn't make use of messageBox yet,
that's still a todo item.
_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview