Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardDeed.js |
— | — | @@ -308,8 +308,10 @@ |
309 | 309 | |
310 | 310 | |
311 | 311 | /** |
| 312 | + * Interface widget to choose among various deeds -- for instance, if own work, or not own work, or other such cases. |
312 | 313 | * @param selector where to put this deed chooser |
313 | | - * @param isPlural whether this chooser applies to multiple files (changes messaging mostly) |
| 314 | + * @param deeds Array of UploadWizardDeed |
| 315 | + * @param uploadCount whether this chooser applies to multiple files (changes messaging mostly) |
314 | 316 | */ |
315 | 317 | mw.UploadWizardDeedChooser = function( selector, deeds, uploadCount ) { |
316 | 318 | var _this = this; |
— | — | @@ -326,16 +328,14 @@ |
327 | 329 | |
328 | 330 | $j.each( deeds, function (i, deed) { |
329 | 331 | var id = _this.name + '-' + deed.name; |
330 | | - |
331 | 332 | var $deedInterface = $j( |
332 | 333 | '<div class="mwe-upwiz-deed mwe-upwiz-deed-' + deed.name + '">' |
333 | 334 | + '<div class="mwe-upwiz-deed-option-title">' |
334 | 335 | + '<span class="mwe-upwiz-deed-header">' |
335 | | - + '<input id="' + id +'" name="' + _this.name + '" type="radio" value="' + deed.name + '">' |
336 | | - + '<label for="' + id + '" class="mwe-upwiz-deed-name">' |
337 | | - + gM( 'mwe-upwiz-source-' + deed.name, _this.uploadCount ) |
338 | | - + '</label>' |
339 | | - + '</input>' |
| 336 | + + '<input id="' + id +'" name="' + _this.name + '" type="radio" value="' + deed.name + ' /">' |
| 337 | + + '<label for="' + id + '" class="mwe-upwiz-deed-name">' |
| 338 | + + gM( 'mwe-upwiz-source-' + deed.name, _this.uploadCount ) |
| 339 | + + '</label>' |
340 | 340 | + '</span>' |
341 | 341 | + '</div>' |
342 | 342 | + '<div class="mwe-upwiz-deed-form">' |
— | — | @@ -347,17 +347,19 @@ |
348 | 348 | deed.setFormFields( $deedInterface.find( '.mwe-upwiz-deed-form' ) ); |
349 | 349 | |
350 | 350 | $deedInterface.find( 'span.mwe-upwiz-deed-header input' ).click( function() { |
351 | | - if ( $j( this ).is(':checked' ) ) { |
| 351 | + if ( $j( this ).is( ':checked' ) ) { |
352 | 352 | _this.choose( deed ); |
353 | | - _this.showDeed( $deedInterface ); |
| 353 | + _this.selectDeedInterface( $deedInterface ); |
354 | 354 | } |
355 | 355 | } ); |
356 | 356 | |
357 | 357 | } ); |
358 | 358 | |
| 359 | + // deselect all deeds |
| 360 | + _this.deselectDeedInterface( this.$selector.find( '.mwe-upwiz-deed' ) ); |
| 361 | + |
| 362 | + // set the "value" to be the null deed; which will cause an error if the data is submitted. |
359 | 363 | _this.choose( mw.UploadWizardNullDeed ); |
360 | | - _this.showDeedChoice(); |
361 | | - |
362 | 364 | |
363 | 365 | }; |
364 | 366 | |
— | — | @@ -423,37 +425,36 @@ |
424 | 426 | } |
425 | 427 | }, |
426 | 428 | |
427 | | - /** |
428 | | - * Go back to original source choice. |
429 | | - */ |
430 | | - showDeedChoice: function() { |
431 | | - var $allDeeds = this.$selector.find( '.mwe-upwiz-deed' ); |
432 | | - this.deselectDeed( $allDeeds ); |
433 | | - // $allDeeds.fadeTo( 'fast', 1.0 ); //maskSafeShow(); |
434 | | - }, |
435 | | - |
436 | 429 | /** |
437 | 430 | * From the deed choices, make a choice fade to the background a bit, hide the extended form |
438 | 431 | */ |
439 | | - deselectDeed: function( $deedSelector ) { |
| 432 | + deselectDeedInterface: function( $deedSelector ) { |
440 | 433 | $deedSelector.removeClass( 'selected' ); |
441 | | - // $deedSelector.find( 'a.mwe-upwiz-macro-deeds-return' ).hide(); |
442 | | - $deedSelector.find( '.mwe-upwiz-deed-form' ).slideUp( 500 ); //.maskSafeHide(); |
| 434 | + $j.each( $deedSelector.find( '.mwe-upwiz-deed-form' ), function( i, form ) { |
| 435 | + var $form = $j( form ); |
| 436 | + if ( $form.parents().is( ':hidden' ) ) { |
| 437 | + $form.hide(); |
| 438 | + } else { |
| 439 | + $form.slideUp( 500 ); |
| 440 | + } |
| 441 | + } ); |
443 | 442 | }, |
444 | 443 | |
445 | 444 | /** |
446 | 445 | * From the deed choice page, show a particular deed |
447 | 446 | */ |
448 | | - showDeed: function( $deedSelector ) { |
| 447 | + selectDeedInterface: function( $deedSelector ) { |
449 | 448 | var $otherDeeds = $deedSelector.siblings().filter( '.mwe-upwiz-deed' ); |
450 | | - this.deselectDeed( $otherDeeds ); |
451 | | - // $siblings.fadeTo( 'fast', 0.5 ) // maskSafeHide(); |
452 | | - |
453 | | - $deedSelector |
454 | | - .addClass('selected') |
455 | | - .fadeTo( 'fast', 1.0 ) |
456 | | - .find( '.mwe-upwiz-deed-form' ).slideDown( 500 ); // maskSafeShow(); |
457 | | - // $deedSelector.find( 'a.mwe-upwiz-macro-deeds-return' ).show(); |
| 449 | + this.deselectDeedInterface( $otherDeeds ); |
| 450 | + $deedSelector.addClass( 'selected' ).fadeTo( 'fast', 1.0 ); |
| 451 | + $j.each( $deedSelector.find( '.mwe-upwiz-deed-form' ), function( i, form ) { |
| 452 | + var $form = $j( form ); |
| 453 | + if ( $form.is( ':hidden' ) ) { |
| 454 | + // if the form was hidden, set things up so a slide-down works |
| 455 | + $form.show().slideUp( 0 ); |
| 456 | + } |
| 457 | + $form.slideDown( 500 ); |
| 458 | + } ); |
458 | 459 | } |
459 | 460 | |
460 | 461 | }; |