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(
42 mw
.config
.get( 'wgEditSubmitButtonLabelPublish' ) ?
43 'postedit-confirmation-published' :
44 'postedit-confirmation-saved',
49 $content
= $( '<div>' ).addClass( 'postedit-icon postedit-icon-checkmark postedit-content' );
50 if ( typeof data
.message
=== 'string' ) {
51 $content
.text( data
.message
);
52 } else if ( typeof data
.message
=== 'object' ) {
53 $content
.append( data
.message
);
56 $popup
= $( '<div>' ).addClass( 'postedit mw-notification' ).append( $content
)
58 clearTimeout( timeoutId
);
59 fadeOutConfirmation();
62 $container
= $( '<div>' ).addClass( 'postedit-container' ).append( $popup
);
63 timeoutId
= setTimeout( fadeOutConfirmation
, 3000 );
65 $( 'body' ).prepend( $container
);
68 mw
.hook( 'postEdit' ).add( showConfirmation
);
71 mw
.hook( 'postEdit' ).fire( {
72 // The following messages can be used here:
73 // postedit-confirmation-saved
74 // postedit-confirmation-created
75 // postedit-confirmation-restored
77 'postedit-confirmation-' + postEdit
,