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