]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blobdiff - skins/common/upload.js
MediaWiki 1.17.0
[autoinstalls/mediawiki.git] / skins / common / upload.js
index f40f62e68b47d7712613e256e1b38701aa07e0fa..c877620b3c090800b46dc7f58a5151fa39e3915a 100644 (file)
@@ -1,4 +1,4 @@
-function licenseSelectorCheck() {
+window.licenseSelectorCheck = function() {
        var selector = document.getElementById( "wpLicense" );
        var selection = selector.options[selector.selectedIndex].value;
        if( selector.selectedIndex > 0 ) {
@@ -9,11 +9,11 @@ function licenseSelectorCheck() {
        }
        // We might show a preview
        wgUploadLicenseObj.fetchPreview( selection );
-}
+};
 
-function wgUploadSetup() {
+window.wgUploadSetup = function() {
        // Disable URL box if the URL copy upload source type is not selected
-       var e = document.getElementById( 'wpSourceTypeURL' );
+       var e = document.getElementById( 'wpSourceTypeurl' );
        if( e ) {
                if( !e.checked ) {
                        var ein = document.getElementById( 'wpUploadFileURL' );
@@ -59,12 +59,12 @@ function wgUploadSetup() {
                row.appendChild( td );
        }
        
-       if ( wgAjaxLicensePreview ) {
+       var wpLicense = document.getElementById( 'wpLicense' );
+       if ( wgAjaxLicensePreview && wpLicense ) {
                // License selector check
-               document.getElementById( 'wpLicense' ).onchange = licenseSelectorCheck;
+               wpLicense.onchange = licenseSelectorCheck;
        
                // License selector table row
-               var wpLicense = document.getElementById( 'wpLicense' );
                var wpLicenseRow = wpLicense.parentNode.parentNode;
                var wpLicenseTbody = wpLicenseRow.parentNode;
                
@@ -84,15 +84,14 @@ function wgUploadSetup() {
                document.getElementById( wgUploadSourceIds[i] ).onchange = function (e) {
                        fillDestFilename( this.id );
                };
-}
+};
 
 /**
  * Iterate over all upload source fields and disable all except the selected one.
  * 
- * @param enabledId The id of the selected radio button 
  * @return emptiness
  */
-function toggleUploadInputs() {
+window.toggleUploadInputs = function() {
        // Iterate over all rows with UploadSourceField
        var rows;
        if ( document.getElementsByClassName ) {
@@ -124,9 +123,9 @@ function toggleUploadInputs() {
                                inputs[j].disabled = !isChecked;
                }
        }
-}
+};
 
-var wgUploadWarningObj = {
+window.wgUploadWarningObj = {
        'responseCache' : { '' : ' ' },
        'nameToCheck' : '',
        'typing': false,
@@ -210,9 +209,9 @@ var wgUploadWarningObj = {
                        element.innerHTML = text;
                }
        }
-}
+};
 
-function fillDestFilename(id) {
+window.fillDestFilename = function(id) {
        if (!wgUploadAutoFill) {
                return;
        }
@@ -242,7 +241,7 @@ function fillDestFilename(id) {
        // Clear the filename if it does not have a valid extension.
        // URLs are less likely to have a useful extension, so don't include them in the 
        // extension check.
-       if( wgFileExtensions && id != 'wpUploadFileURL' ) {
+       if( wgStrictFileExtensions && wgFileExtensions && id != 'wpUploadFileURL' ) {
                var found = false;
                if( fname.lastIndexOf( '.' ) != -1 ) {
                        var ext = fname.substr( fname.lastIndexOf( '.' ) + 1 );
@@ -264,16 +263,19 @@ function fillDestFilename(id) {
                        if( e ) e.className = 'error';
 
                        // Clear wpDestFile as well
-                       var e = document.getElementById( 'wpDestFile' )
+                       var e = document.getElementById( 'wpDestFile' );
                        if( e ) e.value = '';
 
                        return false;
                }
        }
 
-       // Capitalise first letter and replace spaces by underscores
-       // FIXME: $wgCapitalizedNamespaces
-       fname = fname.charAt(0).toUpperCase().concat(fname.substring(1,10000)).replace(/ /g, '_');
+       // Replace spaces by underscores
+       fname = fname.replace( / /g, '_' );
+       // Capitalise first letter if needed
+       if ( wgCapitalizeUploads ) {
+               fname = fname.charAt( 0 ).toUpperCase().concat( fname.substring( 1, 10000 ) );
+       }
 
        // Output result
        var destFile = document.getElementById('wpDestFile');
@@ -281,9 +283,9 @@ function fillDestFilename(id) {
                destFile.value = fname;
                wgUploadWarningObj.checkNow(fname) ;
        }
-}
+};
 
-function toggleFilenameFiller() {
+window.toggleFilenameFiller = function() {
        if(!document.getElementById) return;
        var upfield = document.getElementById('wpUploadFile');
        var destName = document.getElementById('wpDestFile').value;
@@ -292,9 +294,9 @@ function toggleFilenameFiller() {
        } else {
                wgUploadAutoFill = false;
        }
-}
+};
 
-var wgUploadLicenseObj = {
+window.wgUploadLicenseObj = {
 
        'responseCache' : { '' : '' },
 
@@ -338,6 +340,6 @@ var wgUploadLicenseObj = {
                        previewPanel.innerHTML = preview;
        }
 
-}
+};
 
 addOnloadHook( wgUploadSetup );