MediaWiki:Gadget-ImprovedUploadForm.js
Jump to navigation
Jump to search
Note: After saving, 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)
- Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/** * Enhancements for Special:Upload * * See also [[MediaWiki:Upload.js]] & [[MediaWiki:UploadForm.js]] * */ // <nowiki> /* global jQuery, mediaWiki, importScript */ /* eslint one-var:0, vars-on-top:0, camelcase:0, curly:0, space-in-parens:0, indent:0 */ // extends: wikimedia (function ($, mw) { 'use strict'; function enableNewUploadForm() { if (mw.user.options.get('gadget-OldUploadForm') === '1') window.UploadForm_forcebasic = true; // Set UploadForm_forcebasic, while taking JSconfig cookies into account. if (window.UploadForm_forcebasic === undefined) { window.UploadForm_forcebasic = (!window.JSconfig || window.JSconfig.keys.UploadForm_newlayout === undefined) ? false : (!window.JSconfig.keys.UploadForm_newlayout); } var isNlWLM = mw.util.getParamValue('uselang') === 'nlwikilovesmonuments'; // honor JSConfig user settings if (!isNlWLM && !(window.JSconfig && window.JSconfig.keys.UploadForm_loadform) && window.UploadForm_forcebasic) return; // Add loading spinner, as UploadForm will be first installed after document ready. if ($.createSpinner && !window.UploadForm) { $('#mw-upload-form').prepend($.createSpinner({ id: 'UploadLoadingSpinner', size: 'large', type: 'block' })); // Max appearance window.setTimeout(function () { $.removeSpinner('UploadLoadingSpinner'); }, 2800); } importScript('MediaWiki:UploadForm.js'); // Load additional enhancements for a special upload form (request by User:Multichill) if (isNlWLM) importScript('MediaWiki:UploadFormNlWikiLovesMonuments.js'); } if (mw.config.get('wgCanonicalSpecialPageName') === 'Upload' && mw.util.getParamValue('uploadformstyle') !== 'plain') { // (Un)comment the following line (the call to enableNewUploadForm) to globally enable/disable // new upload form. Leave the line *above* (the include of MediaWiki:Upload.js) untouched; // that script provides useful default behavior if the new upload form is disabled or // redirects to the old form in case an error occurs. mw.loader.using(['jquery.spinner', 'jquery.accessKeyLabel'], enableNewUploadForm); // Adding banner to the Upload Wizard for Special:Upload pages which having no button yet or are not // in the default navbar. Currently some forms in non pupular languages are not fully functional // eg. licenses missing, no intro, etc. if (!document.getElementById('commons-upwiz-advertising-button') && !document.getElementById('noupwizjsbutton') && mw.config.get('wgUserLanguage').length < 8 && mw.util.getParamValue('wpForReUpload') !== '1') { var oldUF = 'You are using the old upload form. Try the <b><a href="/wiki/Special:UploadWizard">Upload Wizard</a></b> instead.'; oldUF = '<div id="su-nointro" style="padding:0.3em 1em;background:#EEF;font-size:large;margin:0 0 0.5em 0;border:2px solid #ACF;text-align:center;position:relative;">' + oldUF + '</div>'; $(oldUF).insertBefore('#uploadtext'); } } }(jQuery, mediaWiki)); // </nowiki>