MediaWiki:NoLicenseWarning.js

/** * NoLicenseWarning * Original author unknown, rewritten by Rail01 */ require( [ 'jquery', 'mw', 'wikia.window' ], function( $, mw, window ) {   // Loading restrictions    if ( mw.config.get( 'wgCanonicalSpecialPageName' ) !== 'Upload' || window.NoLicenseWarningLoaded ) return;    window.NoLicenseWarningLoaded = true;

function showNoLicenseWarning( i18n ) { // User wants to upload an image $( '#mw-upload-form' ).submit( function {           if ( window.NoLicenseWarningDelivered ) {                // User already encountered warning, send form                return true;            } else if ( $( '#wpLicense' ).val === '' ) {                // No license selected, show warning                new BannerNotification( i18n.msg( 'warning-text' ).escape, 'warn' ).show;

// Warning has been delivered window.NoLicenseWarningDelivered = true;

// Decline the form return false; } else { // License is selected, send form return true; }       } );    }

// Load i18n messages mw.hook( 'dev.i18n' ).add( function( i18n ) {       i18n.loadMessages( 'NoLicenseWarning' ).then( showNoLicenseWarning );    } );

// Load dependencies importArticle( {       type: 'script',        article: 'u:dev:MediaWiki:I18n-js/code.js'    } ); } );