r92466 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92465‎ | r92466 | r92467 >
Date:20:21, 18 July 2011
Author:neilk
Status:ok
Tags:
Comment:
remove filenameToUrl, mw.Title has same functionality
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -136,7 +136,7 @@
137137 var existsFileName = result.upload.warnings.exists;
138138 try {
139139 code = 'exists';
140 - info = _this.filenameToUrl( existsFileName ).toString();
 140+ info = new mw.Title( existsFileName, 'file' ).getUrl();
141141 } catch ( e ) {
142142 code = 'unknown';
143143 info = 'Warned about existing filename, but filename is unparseable: "' + existsFileName + "'";
@@ -207,7 +207,7 @@
208208 $j.each( duplicates, function( i, filename ) {
209209 var $a = $j( '<a/>' ).append( filename );
210210 try {
211 - var href = _this.filenameToUrl( filename );
 211+ var href = new mw.Title( filename, 'file' ).getUrl();
212212 $a.attr( { 'href': href, 'target': '_blank' } );
213213 } catch ( e ) {
214214 $a.click( function() { alert('could not parse filename=' + filename ); } );
@@ -897,21 +897,6 @@
898898 } ); // close thumbnail click function
899899 },
900900
901 -
902 - /**
903 - * Given a filename like "Foo.jpg", get the URL to that filename, assuming the browser is on the same wiki.
904 - * Candidate for a utility function...
905 - * @param {String} filename
906 - */
907 - filenameToUrl: function( filename ) {
908 - var fileUrl = new mw.Uri( document.URL );
909 - fileUrl.path = wgScript;
910 - var fileTitle = new mw.Title( filename, 'file' );
911 - fileUrl.query = { title: fileTitle, action: 'view' };
912 - return fileUrl;
913 - }
914 -
915 -
916901 };
917902
918903
@@ -1094,7 +1079,7 @@
10951080 _this.prepareAndMoveToDeeds();
10961081 } );
10971082 } );
1098 - $j ( '#mwe-upwiz-stepdiv-file .mwe-upwiz-buttons .mwe-upwiz-button-retry' ).click( function() {
 1083+ $j( '#mwe-upwiz-stepdiv-file .mwe-upwiz-buttons .mwe-upwiz-button-retry' ).click( function() {
10991084 _this.hideFileEndButtons();
11001085 _this.startUploads();
11011086 } );
@@ -1161,7 +1146,7 @@
11621147 _this.removeErrorUploads( finalizeDetails );
11631148 } );
11641149
1165 - $j ( '#mwe-upwiz-stepdiv-details .mwe-upwiz-buttons .mwe-upwiz-button-retry' )
 1150+ $j( '#mwe-upwiz-stepdiv-details .mwe-upwiz-buttons .mwe-upwiz-button-retry' )
11661151 .click( startDetails );
11671152
11681153
@@ -1650,6 +1635,12 @@
16511636 var _this = this;
16521637
16531638 $j.each( _this.uploads, function( i, upload ) {
 1639+ // clear out error states, so we don't end up in an infinite loop
 1640+ if ( upload.state === 'error' ) {
 1641+ upload.state = 'details';
 1642+ }
 1643+
 1644+ // set the "minimized" view of the details to have the right title
16541645 $j( upload.details.submittingDiv )
16551646 .find( '.mwe-upwiz-visible-file-filename-text' )
16561647 .html( upload.title.getMain() );

Status & tagging log