MediaWiki:Common.js
MediaWiki interface page
More actions
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/**
* Pre-select and hide the "This is my own work" checkbox
* in the VisualEditor media upload dialog.
*
* The dialog calls clear() each time it opens, which explicitly resets
* ownWorkCheckbox to false, so we must wrap both renderUploadForm and clear.
*/
mw.loader.using( 'mediawiki.ForeignStructuredUpload.BookletLayout' ).done( function () {
var BookletLayout = mw.ForeignStructuredUpload &&
mw.ForeignStructuredUpload.BookletLayout;
if ( !BookletLayout ) {
return;
}
function enforceOwnWork( booklet ) {
if ( booklet.ownWorkCheckbox ) {
booklet.ownWorkCheckbox.setSelected( true );
booklet.ownWorkCheckbox.$element
.closest( '.oo-ui-fieldLayout' )
.hide();
}
// Hide the "not own work" message that appears when the checkbox is unchecked
if ( booklet.messageLabel ) {
booklet.messageLabel.toggle( false );
}
}
var origRender = BookletLayout.prototype.renderUploadForm;
BookletLayout.prototype.renderUploadForm = function () {
var form = origRender.call( this );
enforceOwnWork( this );
return form;
};
// clear() is called when the dialog opens and resets ownWorkCheckbox to false.
// Re-enforce own-work state after the reset.
var origClear = BookletLayout.prototype.clear;
BookletLayout.prototype.clear = function () {
origClear.call( this );
enforceOwnWork( this );
};
} );