Ticket #39859: 39859.3.diff
| File 39859.3.diff, 5.1 KB (added by , 8 years ago) |
|---|
-
src/wp-includes/js/media/views/modal.js
17 17 tagName: 'div', 18 18 template: wp.template('media-modal'), 19 19 20 attributes: {21 tabindex: 022 },23 24 20 events: { 25 21 'click .media-modal-backdrop, .media-modal-close': 'escapeHandler', 26 22 'keydown': 'keydown' … … 32 28 _.defaults( this.options, { 33 29 container: document.body, 34 30 title: '', 35 propagate: true, 36 freeze: true 31 propagate: true 37 32 }); 38 33 39 34 this.focusManager = new wp.media.view.FocusManager({ … … 88 83 */ 89 84 open: function() { 90 85 var $el = this.$el, 91 options = this.options,92 86 mceEditor; 93 87 94 88 if ( $el.is(':visible') ) { … … 101 95 this.attach(); 102 96 } 103 97 104 // If the `freeze` option is set, record the window's scroll position.105 if ( options.freeze ) {106 this._freeze = {107 scrollTop: $( window ).scrollTop()108 };109 }110 111 98 // Disable page scrolling. 112 99 $( 'body' ).addClass( 'modal-open' ); 113 100 … … 115 102 116 103 // Try to close the onscreen keyboard 117 104 if ( 'ontouchend' in document ) { 118 if ( ( mceEditor = window.tinymce && window.tinymce.activeEditor ) && ! mceEditor.isHidden() && mceEditor.iframeElement ) {105 if ( ( mceEditor = window.tinymce && window.tinymce.activeEditor ) && ! mceEditor.isHidden() && mceEditor.iframeElement ) { 119 106 mceEditor.iframeElement.focus(); 120 107 mceEditor.iframeElement.blur(); 121 108 … … 125 112 } 126 113 } 127 114 128 this.$el.focus(); 115 // Set initial focus on the content instead of this view element, to avoid page scrolling. 116 this.$( '.media-modal' ).focus(); 129 117 130 118 return this.propagate('open'); 131 119 }, … … 135 123 * @returns {wp.media.view.Modal} Returns itself to allow chaining 136 124 */ 137 125 close: function( options ) { 138 var freeze = this._freeze;139 140 126 if ( ! this.views.attached || ! this.$el.is(':visible') ) { 141 127 return this; 142 128 } … … 156 142 157 143 this.propagate('close'); 158 144 159 // If the `freeze` option is set, restore the container's scroll position.160 if ( freeze ) {161 $( window ).scrollTop( freeze.scrollTop );162 }163 164 145 if ( options && options.escape ) { 165 146 this.propagate('escape'); 166 147 } -
src/wp-includes/js/media-views.js
4248 4248 tagName: 'div', 4249 4249 template: wp.template('media-modal'), 4250 4250 4251 attributes: {4252 tabindex: 04253 },4254 4255 4251 events: { 4256 4252 'click .media-modal-backdrop, .media-modal-close': 'escapeHandler', 4257 4253 'keydown': 'keydown' … … 4263 4259 _.defaults( this.options, { 4264 4260 container: document.body, 4265 4261 title: '', 4266 propagate: true, 4267 freeze: true 4262 propagate: true 4268 4263 }); 4269 4264 4270 4265 this.focusManager = new wp.media.view.FocusManager({ … … 4319 4314 */ 4320 4315 open: function() { 4321 4316 var $el = this.$el, 4322 options = this.options,4323 4317 mceEditor; 4324 4318 4325 4319 if ( $el.is(':visible') ) { … … 4332 4326 this.attach(); 4333 4327 } 4334 4328 4335 // If the `freeze` option is set, record the window's scroll position.4336 if ( options.freeze ) {4337 this._freeze = {4338 scrollTop: $( window ).scrollTop()4339 };4340 }4341 4342 4329 // Disable page scrolling. 4343 4330 $( 'body' ).addClass( 'modal-open' ); 4344 4331 … … 4346 4333 4347 4334 // Try to close the onscreen keyboard 4348 4335 if ( 'ontouchend' in document ) { 4349 if ( ( mceEditor = window.tinymce && window.tinymce.activeEditor ) && ! mceEditor.isHidden() && mceEditor.iframeElement ) {4336 if ( ( mceEditor = window.tinymce && window.tinymce.activeEditor ) && ! mceEditor.isHidden() && mceEditor.iframeElement ) { 4350 4337 mceEditor.iframeElement.focus(); 4351 4338 mceEditor.iframeElement.blur(); 4352 4339 … … 4356 4343 } 4357 4344 } 4358 4345 4359 this.$el.focus(); 4346 // Set initial focus on the content instead of this view element, to avoid page scrolling. 4347 this.$( '.media-modal' ).focus(); 4360 4348 4361 4349 return this.propagate('open'); 4362 4350 }, … … 4366 4354 * @returns {wp.media.view.Modal} Returns itself to allow chaining 4367 4355 */ 4368 4356 close: function( options ) { 4369 var freeze = this._freeze;4370 4371 4357 if ( ! this.views.attached || ! this.$el.is(':visible') ) { 4372 4358 return this; 4373 4359 } … … 4387 4373 4388 4374 this.propagate('close'); 4389 4375 4390 // If the `freeze` option is set, restore the container's scroll position.4391 if ( freeze ) {4392 $( window ).scrollTop( freeze.scrollTop );4393 }4394 4395 4376 if ( options && options.escape ) { 4396 4377 this.propagate('escape'); 4397 4378 } -
src/wp-includes/media-template.php
182 182 </script> 183 183 184 184 <script type="text/html" id="tmpl-media-modal"> 185 <div class="<?php echo $class; ?>">185 <div tabindex="0" class="<?php echo $class; ?>"> 186 186 <button type="button" class="media-modal-close"><span class="media-modal-icon"><span class="screen-reader-text"><?php _e( 'Close media panel' ); ?></span></span></button> 187 187 <div class="media-modal-content"></div> 188 188 </div>