5 * Fired after an edit was successfully saved.
7 * Does not fire for null edits.
11 * @param {Object} [data] Optional data
12 * @param {string|jQuery|Array} [data.message] Message that listeners
13 * should use when displaying notifications. String for plain text,
14 * use array or jQuery object to pass actual nodes.
15 * @param {string|mw.user} [data.user=mw.user] User that made the edit.
19 * After the listener for #postEdit removes the notification.
21 * @event postEdit_afterRemoval
25 var postEdit = mw.config.get( 'wgPostEdit' );
27 function showConfirmation( data ) {
28 var $container, $popup, $content, timeoutId;
30 function fadeOutConfirmation() {
31 $popup.addClass( 'postedit-faded' );
32 setTimeout( function () {
34 mw.hook( 'postEdit.afterRemoval' ).fire();
40 if ( data.message === undefined ) {
41 data.message = $.parseHTML( mw.message( 'postedit-confirmation-saved', data.user || mw.user ).escaped() );
44 $content = $( '<div>' ).addClass( 'postedit-icon postedit-icon-checkmark postedit-content' );
45 if ( typeof data.message === 'string' ) {
46 $content.text( data.message );
47 } else if ( typeof data.message === 'object' ) {
48 $content.append( data.message );
51 $popup = $( '<div>' ).addClass( 'postedit mw-notification' ).append( $content )
53 clearTimeout( timeoutId );
54 fadeOutConfirmation();
57 $container = $( '<div>' ).addClass( 'postedit-container' ).append( $popup );
58 timeoutId = setTimeout( fadeOutConfirmation, 3000 );
60 $( 'body' ).prepend( $container );
63 mw.hook( 'postEdit' ).add( showConfirmation );
66 mw.hook( 'postEdit' ).fire( {
67 // The following messages can be used here:
68 // postedit-confirmation-saved
69 // postedit-confirmation-created
70 // postedit-confirmation-restored
72 'postedit-confirmation-' + postEdit,
78 }( mediaWiki, jQuery ) );