Index: trunk/extensions/Push/includes/ext.push.tab.js |
— | — | @@ -5,7 +5,7 @@ |
6 | 6 | * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
7 | 7 | */ |
8 | 8 | |
9 | | -(function($) { $( document ).ready( function() { |
| 9 | +(function( $ ) { $( document ).ready( function() { |
10 | 10 | |
11 | 11 | // Compatibility with pre-RL code. |
12 | 12 | // Messages will have been loaded into wgPushMessages. |
— | — | @@ -23,6 +23,8 @@ |
24 | 24 | } |
25 | 25 | } |
26 | 26 | |
| 27 | + mw = mediaWiki; |
| 28 | + |
27 | 29 | var pages; |
28 | 30 | var targetData = []; |
29 | 31 | |
— | — | @@ -32,7 +34,7 @@ |
33 | 35 | |
34 | 36 | $('.push-button').click(function() { |
35 | 37 | this.disabled = true; |
36 | | - this.innerHTML = mediaWiki.msg( 'push-button-pushing' ); |
| 38 | + this.innerHTML = mw.msg( 'push-button-pushing' ); |
37 | 39 | |
38 | 40 | var errorDiv = $( '#targeterrors' + $(this).attr( 'targetid' ) ); |
39 | 41 | errorDiv.fadeOut( 'fast' ); |
— | — | @@ -55,7 +57,7 @@ |
56 | 58 | |
57 | 59 | $('#push-all-button').click(function() { |
58 | 60 | this.disabled = true; |
59 | | - this.innerHTML = mediaWiki.msg( 'push-button-pushing' ); |
| 61 | + this.innerHTML = mw.msg( 'push-button-pushing' ); |
60 | 62 | $.each($(".push-button"), function(i,v) { |
61 | 63 | $(v).click(); |
62 | 64 | }); |
— | — | @@ -116,7 +118,7 @@ |
117 | 119 | } |
118 | 120 | |
119 | 121 | if ( files.length > 0 ) { |
120 | | - $('#txtFileList').text( '(' + mediaWiki.msg( 'push-tab-embedded-files' ) + ' ' ); |
| 122 | + $('#txtFileList').text( '(' + mw.msg( 'push-tab-embedded-files' ) + ' ' ); |
121 | 123 | |
122 | 124 | for ( i in files ) { |
123 | 125 | if ( i > 0 ) $('#txtFileList').append( ', ' ); |
— | — | @@ -126,7 +128,7 @@ |
127 | 129 | $('#txtFileList').append( ')' ); |
128 | 130 | } |
129 | 131 | else { |
130 | | - $('#txtFileList').text( mediaWiki.msg( 'push-tab-no-embedded-files' ) ); |
| 132 | + $('#txtFileList').text( mw.msg( 'push-tab-no-embedded-files' ) ); |
131 | 133 | } |
132 | 134 | } |
133 | 135 | } |
— | — | @@ -173,7 +175,7 @@ |
174 | 176 | var revision = remotePage.revisions[0]; |
175 | 177 | var dateTime = revision.timestamp.split( 'T' ); |
176 | 178 | |
177 | | - var message = mediaWiki.msg( |
| 179 | + var message = mw.msg( |
178 | 180 | 'push-tab-last-edit', |
179 | 181 | revision.user, |
180 | 182 | dateTime[0], |
— | — | @@ -182,7 +184,7 @@ |
183 | 185 | } |
184 | 186 | else { |
185 | 187 | $( '#targetlink' + targetId ).attr( {'class': 'new'} ); |
186 | | - var message = mediaWiki.msg( 'push-tab-not-created' ); |
| 188 | + var message = mw.msg( 'push-tab-not-created' ); |
187 | 189 | } |
188 | 190 | |
189 | 191 | infoDiv.text( message ); |
— | — | @@ -218,7 +220,7 @@ |
219 | 221 | |
220 | 222 | if ( overideTemplates.length > 0 ) { |
221 | 223 | $( '#targettemplateconflicts' + targetId ) |
222 | | - .text( mediaWiki.msg( 'push-tab-template-override', overideTemplates.join( ', ' ) ) ) |
| 224 | + .text( mw.msg( 'push-tab-template-override', overideTemplates.join( ', ' ) ) ) |
223 | 225 | .fadeIn( 'slow' ); |
224 | 226 | } |
225 | 227 | else { |
— | — | @@ -241,7 +243,7 @@ |
242 | 244 | |
243 | 245 | if ( overideFiles.length > 0 ) { |
244 | 246 | $( '#targetfileconflicts' + targetId ) |
245 | | - .text( mediaWiki.msg( 'push-tab-files-override', overideFiles.join( ', ' ) ) ) |
| 247 | + .text( mw.msg( 'push-tab-files-override', overideFiles.join( ', ' ) ) ) |
246 | 248 | .fadeIn( 'slow' ); |
247 | 249 | } |
248 | 250 | else { |
— | — | @@ -267,14 +269,14 @@ |
268 | 270 | handleError( sender, targetUrl, data.error ); |
269 | 271 | } |
270 | 272 | else if ( data.length > 0 && data[0].edit && data[0].edit.captcha ) { |
271 | | - handleError( sender, targetUrl, { info: mediaWiki.msg( 'push-err-captacha', targetName ) } ); |
| 273 | + handleError( sender, targetUrl, { info: mw.msg( 'push-err-captacha', targetName ) } ); |
272 | 274 | } |
273 | 275 | else { |
274 | 276 | if ( $('#checkIncFiles').length != 0 && $('#checkIncFiles').attr('checked') ) { |
275 | 277 | setButtonToImgPush( sender, targetUrl, targetName ); |
276 | 278 | } |
277 | 279 | else { |
278 | | - sender.innerHTML = mediaWiki.msg( 'push-button-completed' ); |
| 280 | + sender.innerHTML = mw.msg( 'push-button-completed' ); |
279 | 281 | setTimeout( function() {reEnableButton( sender, targetUrl, targetName );}, 1000 ); |
280 | 282 | } |
281 | 283 | } |
— | — | @@ -282,40 +284,50 @@ |
283 | 285 | ); |
284 | 286 | } |
285 | 287 | |
286 | | - function setButtonToImgPush( button, targetUrl, targetName ) { |
287 | | - button.innerHTML = mediaWiki.msg( 'push-button-pushing-files' ); |
288 | | - initiateImagePush( button, targetUrl, targetName ); |
| 288 | + function handleFilePushingCompletion( sender, targetUrl, targetName ) { |
| 289 | + sender.innerHTML = mw.msg( 'push-button-completed' ); |
| 290 | + |
| 291 | + setTimeout( function() { |
| 292 | + reEnableButton( sender, targetUrl, targetName ); |
| 293 | + }, 1000 ); |
289 | 294 | } |
290 | 295 | |
291 | | - function initiateImagePush( sender, targetUrl, targetName ) { |
| 296 | + function setButtonToImgPush( button, targetUrl, targetName ) { |
| 297 | + button.innerHTML = mw.msg( 'push-button-pushing-files' ); |
| 298 | + |
292 | 299 | var images = window.wgPushPageFiles.concat( window.wgPushTemplateFiles ); |
| 300 | + var currentFile = images.pop(); |
293 | 301 | |
| 302 | + initiateImagePush( button, targetUrl, targetName, images, currentFile, handleFilePushingCompletion ); |
| 303 | + } |
| 304 | + |
| 305 | + function initiateImagePush( sender, targetUrl, targetName, images, fileName, callback ) { |
294 | 306 | $.getJSON( |
295 | 307 | wgScriptPath + '/api.php', |
296 | 308 | { |
297 | 309 | 'action': 'pushimages', |
298 | 310 | 'format': 'json', |
299 | | - 'images': images.join( '|' ), |
| 311 | + 'images': fileName, |
300 | 312 | 'targets': targetUrl |
301 | 313 | }, |
302 | 314 | function( data ) { |
303 | 315 | var fail = false; |
304 | 316 | |
305 | 317 | if ( data.error ) { |
306 | | - data.error.info = mediaWiki.msg( 'push-tab-err-filepush', data.error.info ); |
| 318 | + data.error.info = mw.msg( 'push-tab-err-filepush', data.error.info ); |
307 | 319 | handleError( sender, targetUrl, data.error ); |
308 | 320 | fail = true; |
309 | 321 | } |
310 | 322 | else { |
311 | 323 | for ( i in data ) { |
312 | 324 | if ( data[i].error ) { |
313 | | - data[i].error.info = mediaWiki.msg( 'push-tab-err-filepush', data[i].error.info ); |
| 325 | + data[i].error.info = mw.msg( 'push-tab-err-filepush', data[i].error.info ); |
314 | 326 | handleError( sender, targetUrl, data[i].error ); |
315 | 327 | fail = true; |
316 | 328 | break; |
317 | 329 | } |
318 | 330 | else if ( !data[i].upload ) { |
319 | | - data[i].error.info = mediaWiki.msg( 'push-tab-err-filepush-unknown' ); |
| 331 | + data[i].error.info = mw.msg( 'push-tab-err-filepush-unknown' ); |
320 | 332 | handleError( sender, targetUrl, data[i].error ); |
321 | 333 | fail = true; |
322 | 334 | break; |
— | — | @@ -324,15 +336,20 @@ |
325 | 337 | } |
326 | 338 | |
327 | 339 | if ( !fail ) { |
328 | | - sender.innerHTML = mediaWiki.msg( 'push-button-completed' ); |
329 | | - setTimeout( function() {reEnableButton( sender, targetUrl, targetName );}, 1000 ); |
| 340 | + if ( images.length > 0 ) { |
| 341 | + var currentFile = images.pop(); |
| 342 | + initiateImagePush( sender, targetUrl, targetName, images, currentFile, callback ); |
| 343 | + } |
| 344 | + else { |
| 345 | + callback( sender, targetUrl, targetName ); |
| 346 | + } |
330 | 347 | } |
331 | 348 | } |
332 | 349 | ); |
333 | 350 | } |
334 | 351 | |
335 | 352 | function reEnableButton( button, targetUrl, targetName ) { |
336 | | - button.innerHTML = mediaWiki.msg( 'push-button-text' ); |
| 353 | + button.innerHTML = mw.msg( 'push-button-text' ); |
337 | 354 | button.disabled = false; |
338 | 355 | |
339 | 356 | getRemoteArticleInfo( $(button).attr( 'targetid' ), $(button).attr( 'pushtarget' ) ); |
— | — | @@ -352,7 +369,7 @@ |
353 | 370 | |
354 | 371 | if ( !hasDisabled ) { |
355 | 372 | pushAllButton.attr( "disabled", false ); |
356 | | - pushAllButton.text( mediaWiki.msg( 'push-button-all' ) ); |
| 373 | + pushAllButton.text( mw.msg( 'push-button-all' ) ); |
357 | 374 | } |
358 | 375 | } |
359 | 376 | } |
— | — | @@ -361,14 +378,14 @@ |
362 | 379 | var errorDiv = $( '#targeterrors' + $(sender).attr( 'targetid' ) ); |
363 | 380 | |
364 | 381 | if ( error.code && error.code == 'uploaddisabled' ) { |
365 | | - error.info = mediaWiki.msg( 'push-tab-err-uploaddisabled' ); |
| 382 | + error.info = mw.msg( 'push-tab-err-uploaddisabled' ); |
366 | 383 | } |
367 | 384 | |
368 | 385 | errorDiv.text( error.info ); |
369 | 386 | errorDiv.fadeIn( 'slow' ); |
370 | 387 | |
371 | | - sender.innerHTML = mediaWiki.msg( 'push-button-failed' ); |
| 388 | + sender.innerHTML = mw.msg( 'push-button-failed' ); |
372 | 389 | setTimeout( function() {reEnableButton( sender );}, 2500 ); |
373 | 390 | } |
374 | 391 | |
375 | | -} ); })(jQuery); |
| 392 | +} ); })( jQuery ); |