7 * @param {Object} [data] Optional data
8 * @param {string|jQuery|Array} [data.message] Message that listeners
9 * should use when displaying notifications. String for plain text,
10 * use array or jQuery object to pass actual nodes.
11 * @param {string|mw.user} [data.user=mw.user] User that made the edit.
15 * After the listener for #postEdit removes the notification.
17 * @event postEdit_afterRemoval
21 var config
= mw
.config
.get( [ 'wgAction', 'wgCookiePrefix', 'wgCurRevisionId' ] ),
22 // This should match EditPage::POST_EDIT_COOKIE_KEY_PREFIX:
23 cookieKey
= config
.wgCookiePrefix
+ 'PostEditRevision' + config
.wgCurRevisionId
,
26 function showConfirmation( data
) {
28 if ( data
.message
=== undefined ) {
29 data
.message
= $.parseHTML( mw
.message( 'postedit-confirmation', data
.user
|| mw
.user
).escaped() );
33 '<div class="postedit-container">' +
34 '<div class="postedit">' +
35 '<div class="postedit-icon postedit-icon-checkmark postedit-content"></div>' +
36 '<a href="#" class="postedit-close">×</a>' +
41 if ( typeof data
.message
=== 'string' ) {
42 $div
.find( '.postedit-content' ).text( data
.message
);
43 } else if ( typeof data
.message
=== 'object' ) {
44 $div
.find( '.postedit-content' ).append( data
.message
);
48 .click( fadeOutConfirmation
)
51 id
= setTimeout( fadeOutConfirmation
, 3000 );
54 function fadeOutConfirmation() {
56 $div
.find( '.postedit' ).addClass( 'postedit postedit-faded' );
57 setTimeout( removeConfirmation
, 500 );
62 function removeConfirmation() {
64 mw
.hook( 'postEdit.afterRemoval' ).fire();
67 mw
.hook( 'postEdit' ).add( showConfirmation
);
69 if ( config
.wgAction
=== 'view' && $.cookie( cookieKey
) === '1' ) {
70 $.cookie( cookieKey
, null, { path
: '/' } );
71 mw
.config
.set( 'wgPostEdit', true );
73 mw
.hook( 'postEdit' ).fire();
76 } ( mediaWiki
, jQuery
) );