r112248 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112247‎ | r112248 | r112249 >
Date:22:04, 23 February 2012
Author:brion
Status:reverted
Tags:gerritmigration 
Comment:
Another stab at bug 34601: UploadWizard positioning issues with hidden file input control

Uses a timer interval to reposition the file control every half second.
This should resolve issues with initial layout as well as layout changing when the page resizes.
Doesn't seem to explode anything else in my testing.
Modified paths:
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizard.js (modified) (history)
  • /trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js (modified) (history)

Diff [purge]

Index: trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js
@@ -460,28 +460,45 @@
461461 * @param selector jquery-compatible selector, for a single element
462462 */
463463 moveFileInputToCover: function( selector ) {
464 - var $covered = $j( selector );
 464+ var _this = this;
 465+ var update = function() {
 466+ var $covered = $j( selector );
465467
466 - this.fileCtrlContainer
467 - .css( $covered.position() )
468 - .css( 'marginTop', $covered.css( 'marginTop' ) )
469 - .css( 'marginRight', $covered.css( 'marginRight' ) )
470 - .css( 'marginBottom', $covered.css( 'marginBottom' ) )
471 - .css( 'marginLeft', $covered.css( 'marginLeft' ) )
472 - .width( $covered.outerWidth() )
473 - .height( $covered.outerHeight() );
 468+ _this.fileCtrlContainer
 469+ .css( $covered.position() )
 470+ .css( 'marginTop', $covered.css( 'marginTop' ) )
 471+ .css( 'marginRight', $covered.css( 'marginRight' ) )
 472+ .css( 'marginBottom', $covered.css( 'marginBottom' ) )
 473+ .css( 'marginLeft', $covered.css( 'marginLeft' ) )
 474+ .width( $covered.outerWidth() )
 475+ .height( $covered.outerHeight() );
474476
475 - this.fileCtrlContainer.css( { 'z-index': 1 } );
 477+ _this.fileCtrlContainer.css( { 'z-index': 1 } );
476478
477 - // shift the file input over with negative margins,
478 - // internal to the overflow-containing div, so the div shows all button
479 - // and none of the textfield-like input
480 - this.$fileInputCtrl.css( {
481 - 'margin-left': '-' + ~~( this.$fileInputCtrl.width() - $covered.outerWidth() - 10 ) + 'px',
482 - 'margin-top' : '-' + ~~( this.$fileInputCtrl.height() - $covered.outerHeight() - 10 ) + 'px'
483 - } );
 479+ // shift the file input over with negative margins,
 480+ // internal to the overflow-containing div, so the div shows all button
 481+ // and none of the textfield-like input
 482+ _this.$fileInputCtrl.css( {
 483+ 'margin-left': '-' + ~~( _this.$fileInputCtrl.width() - $covered.outerWidth() - 10 ) + 'px',
 484+ 'margin-top' : '-' + ~~( _this.$fileInputCtrl.height() - $covered.outerHeight() - 10 ) + 'px'
 485+ } );
 486+ }
484487
 488+ if (this.moveFileInputInterval) {
 489+ window.clearInterval(this.moveFileInputInterval);
 490+ }
 491+ this.moveFileInputInterval = window.setInterval(function() {
 492+ update();
 493+ }, 500);
 494+ update();
 495+ },
485496
 497+ hideFileInput: function() {
 498+ if (this.moveFileInputInterval) {
 499+ window.clearInterval(this.moveFileInputInterval);
 500+ }
 501+ this.moveFileInputInterval = null;
 502+ // Should we actually hide it?
486503 },
487504
488505 /**
Index: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
@@ -414,10 +414,6 @@
415415
416416 // we explicitly move the file input to cover the upload button
417417 upload.ui.moveFileInputToCover( '#mwe-upwiz-add-file' );
418 - // do it again in case the layout didn't update immediately
419 - setTimeout(function() {
420 - upload.ui.moveFileInputToCover( '#mwe-upwiz-add-file' );
421 - }, 50);
422418
423419 // we bind to the ui div since unbind doesn't work for non-DOM objects
424420
@@ -750,6 +746,7 @@
751747 } else {
752748 $j( '#mwe-upwiz-add-file' ).button( 'option', 'disabled', true );
753749 $j( _this.uploadToAdd.ui.div ).hide();
 750+ _this.uploadToAdd.ui.hideFileInput();
754751 }
755752
756753

Follow-up revisions

RevisionCommit summaryAuthorDate
r112256MFT r112248, r112250, r112253reedy22:32, 23 February 2012
r113049MFT r112229, r112248, r112253, r112260, r112758reedy17:46, 5 March 2012
r114400Revert r112166, r112229, r112248, r113584, r113591, r114349: unreviewed revis...catrope20:21, 21 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r112166Semi-wild stab at bug 34601: 'drop media file to donate here' sometimes silen...brion23:50, 22 February 2012
r112229May or may not help with bug 34601 UW mispositioned file control - still can'...brion19:28, 23 February 2012

Status & tagging log