diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js
index 60ad65ee48..da23cb4629 100644
|
|
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
4248 | 4248 | tagName: 'div', |
4249 | 4249 | template: wp.template('media-modal'), |
4250 | 4250 | |
4251 | | attributes: { |
4252 | | tabindex: 0 |
4253 | | }, |
4254 | | |
4255 | 4251 | events: { |
4256 | 4252 | 'click .media-modal-backdrop, .media-modal-close': 'escapeHandler', |
4257 | 4253 | 'keydown': 'keydown' |
… |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
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({ |
… |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
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') ) { |
… |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
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 | |
… |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
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 | |
… |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
4366 | 4353 | * @returns {wp.media.view.Modal} Returns itself to allow chaining |
4367 | 4354 | */ |
4368 | 4355 | close: function( options ) { |
4369 | | var freeze = this._freeze; |
4370 | | |
4371 | 4356 | if ( ! this.views.attached || ! this.$el.is(':visible') ) { |
4372 | 4357 | return this; |
4373 | 4358 | } |
… |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
4387 | 4372 | |
4388 | 4373 | this.propagate('close'); |
4389 | 4374 | |
4390 | | // If the `freeze` option is set, restore the container's scroll position. |
4391 | | if ( freeze ) { |
4392 | | $( window ).scrollTop( freeze.scrollTop ); |
4393 | | } |
4394 | | |
4395 | 4375 | if ( options && options.escape ) { |
4396 | 4376 | this.propagate('escape'); |
4397 | 4377 | } |
diff --git src/wp-includes/js/media/views/modal.js src/wp-includes/js/media/views/modal.js
index f31a59d6d4..cfe11ec941 100644
|
|
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
17 | 17 | tagName: 'div', |
18 | 18 | template: wp.template('media-modal'), |
19 | 19 | |
20 | | attributes: { |
21 | | tabindex: 0 |
22 | | }, |
23 | | |
24 | 20 | events: { |
25 | 21 | 'click .media-modal-backdrop, .media-modal-close': 'escapeHandler', |
26 | 22 | 'keydown': 'keydown' |
… |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
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({ |
… |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
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') ) { |
… |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
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 | |
… |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
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 | |
… |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
135 | 122 | * @returns {wp.media.view.Modal} Returns itself to allow chaining |
136 | 123 | */ |
137 | 124 | close: function( options ) { |
138 | | var freeze = this._freeze; |
139 | | |
140 | 125 | if ( ! this.views.attached || ! this.$el.is(':visible') ) { |
141 | 126 | return this; |
142 | 127 | } |
… |
… |
Modal = wp.media.View.extend(/** @lends wp.media.view.Modal.prototype */{ |
156 | 141 | |
157 | 142 | this.propagate('close'); |
158 | 143 | |
159 | | // If the `freeze` option is set, restore the container's scroll position. |
160 | | if ( freeze ) { |
161 | | $( window ).scrollTop( freeze.scrollTop ); |
162 | | } |
163 | | |
164 | 144 | if ( options && options.escape ) { |
165 | 145 | this.propagate('escape'); |
166 | 146 | } |
diff --git src/wp-includes/media-template.php src/wp-includes/media-template.php
index 4f2f302e0e..0dbba580f4 100644
|
|
function wp_print_media_templates() { |
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> |