2 * mediawiki.filewarning
4 * @author Mark Holmquist, 2015
8 ( function ( mw, $, oo ) {
9 var warningConfig = mw.config.get( 'wgFileWarning' ),
10 warningMessages = warningConfig.messages,
11 warningLink = warningConfig.link,
12 $origMimetype = $( '.fullMedia .fileInfo .mime-type' ),
13 $mimetype = $origMimetype.clone(),
15 .addClass( 'mediawiki-filewarning-header empty' ),
17 .addClass( 'mediawiki-filewarning-main empty' ),
19 .addClass( 'mediawiki-filewarning-info empty' ),
21 .addClass( 'mediawiki-filewarning-footer empty' ),
22 dialog = new oo.ui.PopupButtonWidget( {
23 classes: [ 'mediawiki-filewarning-anchor' ],
29 classes: [ 'mediawiki-filewarning' ],
32 $content: $header.add( $main ).add( $info ).add( $footer )
36 function loadMessage( $target, message ) {
38 $target.removeClass( 'empty' )
39 .text( mw.message( message ).text() );
43 // The main message must be populated for the dialog to show.
44 if ( warningConfig && warningConfig.messages && warningConfig.messages.main ) {
45 $mimetype.addClass( 'has-warning' );
47 $origMimetype.replaceWith( dialog.$element );
49 if ( warningMessages ) {
50 loadMessage( $main, warningMessages.main );
51 loadMessage( $header, warningMessages.header );
52 loadMessage( $footer, warningMessages.footer );
55 loadMessage( $info, warningMessages.info );
56 $info.attr( 'href', warningLink );
60 // Make OOUI open the dialog, it won't appear until the user
61 // hovers over the warning.
62 dialog.getPopup().toggle( true );
64 // Override toggle handler because we don't need it for this popup
65 // object at all. Sort of nasty, but it gets the job done.
66 dialog.getPopup().toggle = $.noop;
68 }( mediaWiki, jQuery, OO ) );