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(
53 $( '<span>' ).addClass( 'postedit-close' ).text( '×' )
54 ).click( function () {
55 clearTimeout( timeoutId
);
56 fadeOutConfirmation();
59 $container
= $( '<div>' ).addClass( 'postedit-container' ).append( $popup
);
60 timeoutId
= setTimeout( fadeOutConfirmation
, 3000 );
62 $( 'body' ).prepend( $container
);
65 mw
.hook( 'postEdit' ).add( showConfirmation
);
68 mw
.hook( 'postEdit' ).fire( {
69 // The following messages can be used here:
70 // postedit-confirmation-saved
71 // postedit-confirmation-created
72 // postedit-confirmation-restored
74 'postedit-confirmation-' + postEdit
,
80 }( mediaWiki
, jQuery
) );