* @member mw.hook
*/
- var config = mw.config.get( [ 'wgAction', 'wgCurRevisionId' ] ),
- // This should match EditPage::POST_EDIT_COOKIE_KEY_PREFIX:
- cookieKey = 'PostEditRevision' + config.wgCurRevisionId,
- cookieVal = mw.cookie.get( cookieKey ),
- $div, id;
+ var postEdit = mw.config.get( 'wgPostEdit' );
- function removeConfirmation() {
- $div.remove();
- mw.hook( 'postEdit.afterRemoval' ).fire();
- }
-
- function fadeOutConfirmation() {
- clearTimeout( id );
- $div.find( '.postedit' ).addClass( 'postedit postedit-faded' );
- setTimeout( removeConfirmation, 500 );
+ function showConfirmation( data ) {
+ var $container, $popup, $content, timeoutId;
- return false;
- }
+ function fadeOutConfirmation() {
+ $popup.addClass( 'postedit-faded' );
+ setTimeout( function () {
+ $container.remove();
+ mw.hook( 'postEdit.afterRemoval' ).fire();
+ }, 250 );
+ }
- function showConfirmation( data ) {
data = data || {};
+
if ( data.message === undefined ) {
data.message = $.parseHTML( mw.message( 'postedit-confirmation-saved', data.user || mw.user ).escaped() );
}
- $div = mw.template.get( 'mediawiki.action.view.postEdit', 'postEdit.html' ).render();
-
+ $content = $( '<div>' ).addClass( 'postedit-icon postedit-icon-checkmark postedit-content' );
if ( typeof data.message === 'string' ) {
- $div.find( '.postedit-content' ).text( data.message );
+ $content.text( data.message );
} else if ( typeof data.message === 'object' ) {
- $div.find( '.postedit-content' ).append( data.message );
+ $content.append( data.message );
}
- $div
- .click( fadeOutConfirmation )
- .prependTo( 'body' );
+ $popup = $( '<div>' ).addClass( 'postedit mw-notification' ).append( $content )
+ .click( function () {
+ clearTimeout( timeoutId );
+ fadeOutConfirmation();
+ } );
- id = setTimeout( fadeOutConfirmation, 3000 );
+ $container = $( '<div>' ).addClass( 'postedit-container' ).append( $popup );
+ timeoutId = setTimeout( fadeOutConfirmation, 3000 );
+
+ $( 'body' ).prepend( $container );
}
mw.hook( 'postEdit' ).add( showConfirmation );
- if ( config.wgAction === 'view' && cookieVal ) {
- mw.config.set( 'wgPostEdit', true );
-
+ if ( postEdit ) {
mw.hook( 'postEdit' ).fire( {
// The following messages can be used here:
// postedit-confirmation-saved
// postedit-confirmation-created
// postedit-confirmation-restored
message: mw.msg(
- 'postedit-confirmation-' + cookieVal,
+ 'postedit-confirmation-' + postEdit,
mw.user
)
} );
- mw.cookie.set( cookieKey, null );
}
}( mediaWiki, jQuery ) );