Fix a Firefox "scroll to bottom" bug when launching the media modal.
* Records main document scroll position when launching media modal. * Restores position when media modal is closed. * Also locks background document scrolling while media modal is open, preventing inadvertent scrolling there. props koopersmith. fixes #22716 git-svn-id: http://core.svn.wordpress.org/trunk@23029 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
82d51aeeef
commit
bc09152660
|
@ -1866,7 +1866,8 @@
|
|||
_.defaults( this.options, {
|
||||
container: document.body,
|
||||
title: '',
|
||||
propagate: true
|
||||
propagate: true,
|
||||
freeze: document.body
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -1902,23 +1903,47 @@
|
|||
},
|
||||
|
||||
open: function() {
|
||||
if ( this.$el.is(':visible') )
|
||||
var $el = this.$el,
|
||||
options = this.options,
|
||||
$freeze;
|
||||
|
||||
if ( $el.is(':visible') )
|
||||
return this;
|
||||
|
||||
if ( ! this.views.attached )
|
||||
this.attach();
|
||||
|
||||
this.$el.show().focus();
|
||||
// If the `freeze` option is set, record the window's scroll
|
||||
// position and the body's overflow, and then set overflow to hidden.
|
||||
if ( options.freeze ) {
|
||||
$freeze = $( options.freeze );
|
||||
this._freeze = {
|
||||
overflow: $freeze.css('overflow'),
|
||||
scrollTop: $( window ).scrollTop()
|
||||
};
|
||||
$freeze.css( 'overflow', 'hidden' );
|
||||
}
|
||||
|
||||
$el.show().focus();
|
||||
return this.propagate('open');
|
||||
},
|
||||
|
||||
close: function( options ) {
|
||||
var freeze = this._freeze;
|
||||
|
||||
if ( ! this.views.attached || ! this.$el.is(':visible') )
|
||||
return this;
|
||||
|
||||
this.$el.hide();
|
||||
this.propagate('close');
|
||||
|
||||
// If the `freeze` option is set, restore the container's scroll
|
||||
// position and overflow property.
|
||||
if ( freeze ) {
|
||||
$( this.options.freeze ).css( 'overflow', freeze.overflow );
|
||||
$( window ).scrollTop( freeze.scrollTop );
|
||||
}
|
||||
|
||||
if ( options && options.escape )
|
||||
this.propagate('escape');
|
||||
|
||||
|
|
Loading…
Reference in New Issue