https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112248

Revision: 112248
Author:   brion
Date:     2012-02-23 22:04:18 +0000 (Thu, 23 Feb 2012)
Log Message:
-----------
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
    trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js

Modified: trunk/extensions/UploadWizard/resources/mw.UploadWizard.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.UploadWizard.js  2012-02-23 
22:03:43 UTC (rev 112247)
+++ trunk/extensions/UploadWizard/resources/mw.UploadWizard.js  2012-02-23 
22:04:18 UTC (rev 112248)
@@ -414,10 +414,6 @@
 
                // we explicitly move the file input to cover the upload button
                upload.ui.moveFileInputToCover( '#mwe-upwiz-add-file' );
-               // do it again in case the layout didn't update immediately
-               setTimeout(function() {
-                       upload.ui.moveFileInputToCover( '#mwe-upwiz-add-file' );
-               }, 50);
 
                // we bind to the ui div since unbind doesn't work for non-DOM 
objects
 
@@ -750,6 +746,7 @@
                } else {
                        $j( '#mwe-upwiz-add-file' ).button( 'option', 
'disabled', true );
                        $j( _this.uploadToAdd.ui.div ).hide();
+                       _this.uploadToAdd.ui.hideFileInput();
                }
 
 

Modified: 
trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js
===================================================================
--- trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js   
2012-02-23 22:03:43 UTC (rev 112247)
+++ trunk/extensions/UploadWizard/resources/mw.UploadWizardUploadInterface.js   
2012-02-23 22:04:18 UTC (rev 112248)
@@ -460,28 +460,45 @@
         * @param selector jquery-compatible selector, for a single element
         */
        moveFileInputToCover: function( selector ) {
-               var $covered = $j( selector ); 
+               var _this = this;
+               var update = function() {
+                       var $covered = $j( selector );
 
-               this.fileCtrlContainer
-                       .css( $covered.position() )
-                       .css( 'marginTop', $covered.css( 'marginTop' ) )
-                       .css( 'marginRight', $covered.css( 'marginRight' ) )
-                       .css( 'marginBottom', $covered.css( 'marginBottom' ) )
-                       .css( 'marginLeft', $covered.css( 'marginLeft' ) )
-                       .width( $covered.outerWidth() )
-                       .height( $covered.outerHeight() ); 
+                       _this.fileCtrlContainer
+                               .css( $covered.position() )
+                               .css( 'marginTop', $covered.css( 'marginTop' ) )
+                               .css( 'marginRight', $covered.css( 
'marginRight' ) )
+                               .css( 'marginBottom', $covered.css( 
'marginBottom' ) )
+                               .css( 'marginLeft', $covered.css( 'marginLeft' 
) )
+                               .width( $covered.outerWidth() )
+                               .height( $covered.outerHeight() );
 
-               this.fileCtrlContainer.css( { 'z-index': 1 } );
+                       _this.fileCtrlContainer.css( { 'z-index': 1 } );
 
-               // shift the file input over with negative margins, 
-               // internal to the overflow-containing div, so the div shows 
all button
-               // and none of the textfield-like input
-               this.$fileInputCtrl.css( {
-                       'margin-left': '-' + ~~( this.$fileInputCtrl.width() - 
$covered.outerWidth() - 10 ) + 'px',
-                       'margin-top' : '-' + ~~( this.$fileInputCtrl.height() - 
$covered.outerHeight() - 10 ) + 'px'
-               } );
+                       // shift the file input over with negative margins,
+                       // internal to the overflow-containing div, so the div 
shows all button
+                       // and none of the textfield-like input
+                       _this.$fileInputCtrl.css( {
+                               'margin-left': '-' + ~~( 
_this.$fileInputCtrl.width() - $covered.outerWidth() - 10 ) + 'px',
+                               'margin-top' : '-' + ~~( 
_this.$fileInputCtrl.height() - $covered.outerHeight() - 10 ) + 'px'
+                       } );
+               }
 
+               if (this.moveFileInputInterval) {
+                       window.clearInterval(this.moveFileInputInterval);
+               }
+               this.moveFileInputInterval = window.setInterval(function() {
+                       update();
+               }, 500);
+               update();
+       },
 
+       hideFileInput: function() {
+               if (this.moveFileInputInterval) {
+                       window.clearInterval(this.moveFileInputInterval);
+               }
+               this.moveFileInputInterval = null;
+               // Should we actually hide it?
        },
 
        /**


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to