Merge "PHPUnit now recognizes extension parser tests"
[mediawiki.git] / resources / mediawiki.action / mediawiki.action.view.postEdit.js
blobe7a3e3c871b103329edaba0936ae60d754f032d0
1 ( function ( mw, $ ) {
2         'use strict';
4         var config = mw.config.get( [ 'wgAction', 'wgCookiePrefix', 'wgCurRevisionId' ] ),
5                 // This should match EditPage::POST_EDIT_COOKIE_KEY_PREFIX:
6                 cookieKey = config.wgCookiePrefix + 'PostEditRevision' + config.wgCurRevisionId,
7                 div, id;
9         if ( config.wgAction !== 'view' || $.cookie( cookieKey ) !== '1' ) {
10                 return;
11         }
13         $.cookie( cookieKey, null, { path: '/' } );
14         mw.config.set( 'wgPostEdit', true );
16         function removeConfirmation() {
17                 div.parentNode.removeChild( div );
18                 mw.hook( 'postEdit.afterRemoval' ).fire();
19         }
21         function fadeOutConfirmation() {
22                 clearTimeout( id );
23                 div.firstChild.className = 'postedit postedit-faded';
24                 setTimeout( removeConfirmation, 500 );
25                 return false;
26         }
28         function showConfirmation() {
29                 div = document.createElement( 'div' );
30                 div.className = 'postedit-container';
31                 div.innerHTML =
32                         '<div class="postedit">' +
33                                 '<div class="postedit-icon postedit-icon-checkmark">' +
34                                         mw.message( 'postedit-confirmation', mw.user ).escaped() +
35                                 '</div>' +
36                                 '<a href="#" class="postedit-close">&times;</a>' +
37                         '</div>';
38                 id = setTimeout( fadeOutConfirmation, 3000 );
39                 div.firstChild.lastChild.onclick = fadeOutConfirmation;
40                 document.body.insertBefore( div, document.body.firstChild );
41         }
43         mw.hook( 'postEdit' ).add( showConfirmation ).fire();
45 } ( mediaWiki, jQuery ) );