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;
+ cookieVal, $div, id;
function removeConfirmation() {
$div.remove();
mw.hook( 'postEdit' ).add( showConfirmation );
- if ( config.wgAction === 'view' && cookieVal ) {
- mw.config.set( 'wgPostEdit', true );
-
- 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,
- mw.user
- )
- } );
- mw.cookie.set( cookieKey, null );
+ // Only when viewing wiki pages, that exist
+ // (E.g. not on special pages or non-view actions)
+ if ( config.wgCurRevisionId && config.wgAction === 'view' ) {
+ cookieVal = mw.cookie.get( cookieKey );
+ if ( cookieVal ) {
+ mw.config.set( 'wgPostEdit', true );
+
+ 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,
+ mw.user
+ )
+ } );
+
+ mw.cookie.set( cookieKey, null );
+ }
}
}( mediaWiki, jQuery ) );