Ticket #22716: 22716.2.diff
File 22716.2.diff, 1.6 KB (added by , 13 years ago) |
---|
-
wp-includes/js/media-views.js
1861 1861 _.defaults( this.options, { 1862 1862 container: document.body, 1863 1863 title: '', 1864 propagate: true 1864 propagate: true, 1865 freeze: document.body 1865 1866 }); 1866 1867 }, 1867 1868 … … 1897 1898 }, 1898 1899 1899 1900 open: function() { 1900 if ( this.$el.is(':visible') ) 1901 var $el = this.$el, 1902 options = this.options, 1903 $freeze; 1904 1905 if ( $el.is(':visible') ) 1901 1906 return this; 1902 1907 1903 1908 if ( ! this.views.attached ) 1904 1909 this.attach(); 1905 1910 1906 this.$el.show().focus(); 1911 // If the `freeze` option is set, record the window's scroll 1912 // position and the body's overflow, and then set overflow to hidden. 1913 if ( options.freeze ) { 1914 $freeze = $( options.freeze ); 1915 this._freeze = { 1916 overflow: $freeze.css('overflow'), 1917 scrollTop: $( window ).scrollTop() 1918 }; 1919 $freeze.css( 'overflow', 'hidden' ); 1920 } 1921 1922 $el.show().focus(); 1907 1923 return this.propagate('open'); 1908 1924 }, 1909 1925 1910 1926 close: function( options ) { 1927 var freeze = this._freeze; 1928 1911 1929 if ( ! this.views.attached || ! this.$el.is(':visible') ) 1912 1930 return this; 1913 1931 1914 1932 this.$el.hide(); 1915 1933 this.propagate('close'); 1916 1934 1935 // If the `freeze` option is set, restore the container's scroll 1936 // position and overflow property. 1937 if ( freeze ) { 1938 $( this.options.freeze ).css( 'overflow', freeze.overflow ); 1939 $( window ).scrollTop( freeze.scrollTop ); 1940 } 1941 1917 1942 if ( options && options.escape ) 1918 1943 this.propagate('escape'); 1919 1944