Toggle display of plupload overlays when the select files button is hidden. see #22732.

git-svn-id: https://develop.svn.wordpress.org/trunk@23053 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Daryl Koopersmith 2012-12-05 00:45:21 +00:00
parent f824b1a921
commit eae68af55c
2 changed files with 60 additions and 0 deletions

View File

@ -2085,6 +2085,31 @@
}
},
dispose: function() {
if ( this.disposing )
return media.View.prototype.dispose.apply( this, arguments );
// Run remove on `dispose`, so we can be sure to refresh the
// uploader with a view-less DOM. Track whether we're disposing
// so we don't trigger an infinite loop.
this.disposing = true;
return this.remove();
},
remove: function() {
var result = media.View.prototype.remove.apply( this, arguments );
_.defer( _.bind( this.refresh, this ) );
return result;
},
refresh: function() {
var uploader = this.controller.uploader;
if ( uploader )
uploader.refresh();
},
ready: function() {
var $browser = this.options.$browser,
$placeholder;
@ -2101,6 +2126,7 @@
$placeholder.replaceWith( $browser.show() );
}
this.refresh();
return this;
}
});

View File

@ -293,7 +293,41 @@ window.wp = window.wp || {};
progress: function() {},
complete: function() {},
refresh: function() {
var node, enabled, container;
if ( this.browser ) {
node = this.browser[0];
while ( node ) {
if ( node === document.body ) {
enabled = true;
break;
}
node = node.parentNode;
}
this.uploader.disableBrowse( ! enabled );
// Toggle all auto-created file containers.
this._container().toggle( enabled );
}
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;
}
});