Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js |
— | — | @@ -145,7 +145,13 @@ |
146 | 146 | if ( !mw.isDefined( args ) ) { |
147 | 147 | args = []; |
148 | 148 | } |
149 | | - $j( this.div ).find( '.mwe-upwiz-file-status' ).html( gM( msgKey, args ) ).show(); |
| 149 | + // get the status line for our upload |
| 150 | + $statusDiv = $j( this.div ).find( '.mwe-upwiz-file-status' ); |
| 151 | + |
| 152 | + // apply the message and args, but if any anchors were created make sure they link to new windows. |
| 153 | + $statusDiv.msg( msgKey, args ).find( 'a' ).attr( 'target', '_blank' ); |
| 154 | + |
| 155 | + $statusDiv.show(); |
150 | 156 | }, |
151 | 157 | |
152 | 158 | /** |
— | — | @@ -187,9 +193,7 @@ |
188 | 194 | var args = [ code ]; |
189 | 195 | if ( $j.inArray( code, mw.Api.errors ) !== -1 ) { |
190 | 196 | msgKey = 'mwe-upwiz-api-error-' + code; |
191 | | - // args may change base on particular error messages. |
192 | | - // for instance, we are throwing away the extra info right now. Might be nice to surface that in a debug mode |
193 | | - args = []; |
| 197 | + args = $j.makeArray( info ); |
194 | 198 | } |
195 | 199 | this.setStatus( msgKey, args ); |
196 | 200 | }, |
Index: trunk/extensions/UploadWizard/resources/mw.Api.js |
— | — | @@ -156,6 +156,9 @@ |
157 | 157 | /* occurs when POST aborted - jQuery 1.4 can't distinguish abort or lost connection from 200 OK + empty result */ |
158 | 158 | 'ok-but-empty', |
159 | 159 | |
| 160 | + /* really a warning, but we treat it like an error */ |
| 161 | + 'duplicate', |
| 162 | + |
160 | 163 | /* remote errors, defined in API */ |
161 | 164 | 'uploaddisabled', |
162 | 165 | 'nomodule', |
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js |
— | — | @@ -98,7 +98,13 @@ |
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | | - if ( result.upload && result.upload.imageinfo ) { |
| 102 | + if ( result.upload && result.upload.warnings && result.upload.warnings.exists ) { |
| 103 | + var fileTitle = new mw.Title( result.upload.warnings.exists, 'file' ).toString(); |
| 104 | + var fileUri = new mw.Uri( document.URL ); |
| 105 | + fileUri.path = wgScript; |
| 106 | + fileUri.query = { title: fileTitle, action: 'view' }; |
| 107 | + _this.setError( 'duplicate', fileUri.toString() ); |
| 108 | + } else if ( result.upload && result.upload.imageinfo ) { |
103 | 109 | // success |
104 | 110 | _this.state = 'transported'; |
105 | 111 | _this.transportProgress = 1; |
— | — | @@ -133,7 +139,7 @@ |
134 | 140 | if ( result.error ) { |
135 | 141 | code = result.error.code; |
136 | 142 | info = result.error.info; |
137 | | - } |
| 143 | + } |
138 | 144 | _this.setError( code, info ); |
139 | 145 | } |
140 | 146 | |