From f549a8baa67923d2346fefd3cfb548c59569108f Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 5 Dec 2012 21:21:17 +0000 Subject: [PATCH] Fix uploads in IE9 Props koopersmith fixes #22762 git-svn-id: https://develop.svn.wordpress.org/trunk@23079 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/js/plupload/wp-plupload.js | 46 ++++++++++++++------------ 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/wp-includes/js/plupload/wp-plupload.js b/wp-includes/js/plupload/wp-plupload.js index 3a6c42728b..88a84edfc4 100644 --- a/wp-includes/js/plupload/wp-plupload.js +++ b/wp-includes/js/plupload/wp-plupload.js @@ -293,41 +293,45 @@ window.wp = window.wp || {}; progress: function() {}, complete: function() {}, refresh: function() { - var node, enabled, container; + var node, attached, container, id; if ( this.browser ) { node = this.browser[0]; + // Check if the browser node is in the DOM. while ( node ) { if ( node === document.body ) { - enabled = true; + attached = true; break; } node = node.parentNode; } - this.uploader.disableBrowse( ! enabled ); - // Toggle all auto-created file containers. - this._container().toggle( enabled ); + // If the browser node is not attached to the DOM, use a + // temporary container to house it, as the browser button + // shims require the button to exist in the DOM at all times. + if ( ! attached ) { + id = 'wp-uploader-browser-' + this.uploader.id; + + container = $( '#' + id ); + if ( ! container.length ) { + container = $('
', { + id: 'wp-uploader-browser-' + this.uploader.id, + css: { + position: 'fixed', + top: '-1000px', + left: '-1000px', + height: 0, + width: 0 + } + }).appendTo('body'); + } + + container.append( this.browser ); + } } this.uploader.refresh(); - }, - - _container: function() { - var runtime = this.uploader.runtime; - - if ( this._$container && this._$container.length ) - return this._$container; - - if ( 'html4' === runtime ) - return $('[target="' + this.uploader.id + '_iframe"]'); - - if ( 'html5' !== runtime && 'flash' !== runtime && 'silverlight' !== runtime ) - return $(); - - this._$container = $( '#' + this.uploader.id + '_' + runtime + '_container' ); - return this._$container; } });