MediaWiki:Common.js/FairUseUpload.js

// 12:16, February 4, 2013 (UTC) /*jshint browser:true jquery:true curly:false smarttabs:true laxbreak:true laxcomma:true */ /*global mediaWiki */ $(document).ready(function {   // Restores normal upload form since the popup one ignores source and license policy.    $('a.wikia-button.upphotos').unbind('click', UploadPhotos.showDialog); }); if (mediaWiki.config.get('wgCanonicalSpecialPageName') === 'Upload' && !(/(?:^\?|&)wpForReUpload=(?:[^0&]|0[^&])/).test(window.location.search)) mediaWiki.loader.using('mediawiki.util', function {   "use strict";    var mw = mediaWiki;    $(function($) { // Overlay the summary with a prompt for the image type. var $textarea = $('#wpUploadDescription'), $prompt = $(document.createElement('div')); // We need a position:relative parent to work with so we'll wrap the contents $textarea.wrap(' '); var $container = $textarea.parent; // Textarea has width:100% so spills its borders $textarea.css({           boxSizing: 'border-box',            MozBoxSizing: 'border-box'        }); $prompt.css({           position: 'absolute',            top: 0,            left: 0,            bottom: 0,            right: 0,            backgroundColor: 'rgba(0,0,0,0.8)'        }).append(' ' + 'Please select a proper license from the dropdown list. ' + ' Anime Image ' + ' Manga Image ' + ' '); $container.append($prompt); // Disable the textarea in case we didn't cover it perfectly $textarea.prop('disabled', true); function unlockUI { $prompt.remove; $textarea.prop('disabled', false).css({               boxSizing: ,                MozBoxSizing:             }).unwrap; // NOTE: If we don't remove prompt then it will be promoted upwards as well }

$prompt.find('.upload-other').click(function(evt) {           evt.preventDefault;        // Manga        $textarea.val('\n' + '\n' + '\n' + '');            unlockUI;        });

//Default $textarea.val('\n' + '\n'); // Anime $prompt.find('.upload-sd-panel').click(function(evt) {           evt.preventDefault;            $textarea.val('\n' + '\n' + '\n' + '');            unlockUI;        }); $prompt.find('.upload-other').click(function(evt) {           evt.preventDefault;            unlockUI;        }); $('input[type="submit"][name="wpUpload"]').after('Preview '); function onPreview { var $modal = $.showModal('Form Preview', ' ' + ' ' +            // Admin dashboard adds crap to WikiaArticle            ' ' + ' '); var $content = $modal.find('.modalContent .WikiaArticle'); $content.parent.css({               maxHeight: $(window).height * 0.75,                paddingRight: (function($) { // Leave room for scroll bar to avoid causing horizontal scroll because of it                   var $x = $(' ' + ' ' + ' ').appendTo('body'); var w = (100 - $x.children.width) + 'px'; $x.remove; return w;               })($)                }); $.ajax({               url: mw.util.wikiScript('api'),                data: {                    // NOTE: We're not setting the page name because who cares? This isn't a full preview.                    //  will come up as "API"                    format: 'json',                    action: 'parse',                    prop: 'text',                    text: $textarea.val + '\n'                },                dataType: 'json',                type: 'POST'            }).done(function(json) {                $content.html(json.parse.text['*']);            }).fail(function(xhr, status, err) {                $content.html(' Server Error: ' + xhr.status + ' ' + err + ' (' + status + ') ');            }); return false; }       $('#sdwPreviewForm').click(onPreview); });   $textarea.closest('form').on('submit.LicenseCheck', function { if (!$('#wpLicense').val) { window.alert(               'You haven\'t selected any license. Unlicensed images would be deleted. Are you sure you want to upload it?'            ); return false; }   }); });