/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 3);
/******/ })
/************************************************************************/
/******/ ({
/***/ "+B8m":
/***/ (function(module, exports) {
var AttachmentDisplay = wp.media.view.Settings.AttachmentDisplay,
EmbedImage;
/**
* wp.media.view.EmbedImage
*
* @memberOf wp.media.view
*
* @class
* @augments wp.media.view.Settings.AttachmentDisplay
* @augments wp.media.view.Settings
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
EmbedImage = AttachmentDisplay.extend(/** @lends wp.media.view.EmbedImage.prototype */{
className: 'embed-media-settings',
template: wp.template('embed-image-settings'),
initialize: function() {
/**
* Call `initialize` directly on parent class with passed arguments
*/
AttachmentDisplay.prototype.initialize.apply( this, arguments );
this.listenTo( this.model, 'change:url', this.updateImage );
},
updateImage: function() {
this.$('img').attr( 'src', this.model.get('url') );
}
});
module.exports = EmbedImage;
/***/ }),
/***/ "+mQJ":
/***/ (function(module, exports) {
var View = wp.media.View,
$ = jQuery,
l10n = wp.media.view.l10n,
EmbedUrl;
/**
* wp.media.view.EmbedUrl
*
* @memberOf wp.media.view
*
* @class
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
EmbedUrl = View.extend(/** @lends wp.media.view.EmbedUrl.prototype */{
tagName: 'span',
className: 'embed-url',
events: {
'input': 'url'
},
initialize: function() {
this.$input = $( '' )
.attr( 'aria-label', l10n.insertFromUrlTitle )
.val( this.model.get('url') );
this.input = this.$input[0];
this.spinner = $('')[0];
this.$el.append([ this.input, this.spinner ]);
this.listenTo( this.model, 'change:url', this.render );
if ( this.model.get( 'url' ) ) {
_.delay( _.bind( function () {
this.model.trigger( 'change:url' );
}, this ), 500 );
}
},
/**
* @return {wp.media.view.EmbedUrl} Returns itself to allow chaining.
*/
render: function() {
var $input = this.$input;
if ( $input.is(':focus') ) {
return;
}
this.input.value = this.model.get('url') || 'http://';
/**
* Call `render` directly on parent class with passed arguments
*/
View.prototype.render.apply( this, arguments );
return this;
},
url: function( event ) {
var url = event.target.value || '';
this.model.set( 'url', url.trim() );
}
});
module.exports = EmbedUrl;
/***/ }),
/***/ "04Ix":
/***/ (function(module, exports) {
var _n = wp.i18n._n,
sprintf = wp.i18n.sprintf,
Selection;
/**
* wp.media.view.Selection
*
* @memberOf wp.media.view
*
* @class
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
Selection = wp.media.View.extend(/** @lends wp.media.view.Selection.prototype */{
tagName: 'div',
className: 'media-selection',
template: wp.template('media-selection'),
events: {
'click .edit-selection': 'edit',
'click .clear-selection': 'clear'
},
initialize: function() {
_.defaults( this.options, {
editable: false,
clearable: true
});
/**
* @member {wp.media.view.Attachments.Selection}
*/
this.attachments = new wp.media.view.Attachments.Selection({
controller: this.controller,
collection: this.collection,
selection: this.collection,
model: new Backbone.Model()
});
this.views.set( '.selection-view', this.attachments );
this.collection.on( 'add remove reset', this.refresh, this );
this.controller.on( 'content:activate', this.refresh, this );
},
ready: function() {
this.refresh();
},
refresh: function() {
// If the selection hasn't been rendered, bail.
if ( ! this.$el.children().length ) {
return;
}
var collection = this.collection,
editing = 'edit-selection' === this.controller.content.mode();
// If nothing is selected, display nothing.
this.$el.toggleClass( 'empty', ! collection.length );
this.$el.toggleClass( 'one', 1 === collection.length );
this.$el.toggleClass( 'editing', editing );
this.$( '.count' ).text(
/* translators: %s: Number of selected media attachments. */
sprintf( _n( '%s item selected', '%s items selected', collection.length ), collection.length )
);
},
edit: function( event ) {
event.preventDefault();
if ( this.options.editable ) {
this.options.editable.call( this, this.collection );
}
},
clear: function( event ) {
event.preventDefault();
this.collection.reset();
// Move focus to the modal.
this.controller.modal.focusManager.focus();
}
});
module.exports = Selection;
/***/ }),
/***/ "1S4+":
/***/ (function(module, exports) {
var $ = jQuery,
AttachmentFilters;
/**
* wp.media.view.AttachmentFilters
*
* @memberOf wp.media.view
*
* @class
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
AttachmentFilters = wp.media.View.extend(/** @lends wp.media.view.AttachmentFilters.prototype */{
tagName: 'select',
className: 'attachment-filters',
id: 'media-attachment-filters',
events: {
change: 'change'
},
keys: [],
initialize: function() {
this.createFilters();
_.extend( this.filters, this.options.filters );
// Build `' ).val( value ).html( filter.text )[0],
priority: filter.priority || 50
};
}, this ).sortBy('priority').pluck('el').value() );
this.listenTo( this.model, 'change', this.select );
this.select();
},
/**
* @abstract
*/
createFilters: function() {
this.filters = {};
},
/**
* When the selected filter changes, update the Attachment Query properties to match.
*/
change: function() {
var filter = this.filters[ this.el.value ];
if ( filter ) {
this.model.set( filter.props );
}
},
select: function() {
var model = this.model,
value = 'all',
props = model.toJSON();
_.find( this.filters, function( filter, id ) {
var equal = _.all( filter.props, function( prop, key ) {
return prop === ( _.isUndefined( props[ key ] ) ? null : props[ key ] );
});
if ( equal ) {
return value = id;
}
});
this.$el.val( value );
}
});
module.exports = AttachmentFilters;
/***/ }),
/***/ "2AvB":
/***/ (function(module, exports) {
var Settings = wp.media.view.Settings,
AttachmentDisplay;
/**
* wp.media.view.Settings.AttachmentDisplay
*
* @memberOf wp.media.view.Settings
*
* @class
* @augments wp.media.view.Settings
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
AttachmentDisplay = Settings.extend(/** @lends wp.media.view.Settings.AttachmentDisplay.prototype */{
className: 'attachment-display-settings',
template: wp.template('attachment-display-settings'),
initialize: function() {
var attachment = this.options.attachment;
_.defaults( this.options, {
userSettings: false
});
// Call 'initialize' directly on the parent class.
Settings.prototype.initialize.apply( this, arguments );
this.listenTo( this.model, 'change:link', this.updateLinkTo );
if ( attachment ) {
attachment.on( 'change:uploading', this.render, this );
}
},
dispose: function() {
var attachment = this.options.attachment;
if ( attachment ) {
attachment.off( null, null, this );
}
/**
* call 'dispose' directly on the parent class
*/
Settings.prototype.dispose.apply( this, arguments );
},
/**
* @return {wp.media.view.AttachmentDisplay} Returns itself to allow chaining.
*/
render: function() {
var attachment = this.options.attachment;
if ( attachment ) {
_.extend( this.options, {
sizes: attachment.get('sizes'),
type: attachment.get('type')
});
}
/**
* call 'render' directly on the parent class
*/
Settings.prototype.render.call( this );
this.updateLinkTo();
return this;
},
updateLinkTo: function() {
var linkTo = this.model.get('link'),
$input = this.$('.link-to-custom'),
attachment = this.options.attachment;
if ( 'none' === linkTo || 'embed' === linkTo || ( ! attachment && 'custom' !== linkTo ) ) {
$input.closest( '.setting' ).addClass( 'hidden' );
return;
}
if ( attachment ) {
if ( 'post' === linkTo ) {
$input.val( attachment.get('link') );
} else if ( 'file' === linkTo ) {
$input.val( attachment.get('url') );
} else if ( ! this.model.get('linkUrl') ) {
$input.val('http://');
}
$input.prop( 'readonly', 'custom' !== linkTo );
}
$input.closest( '.setting' ).removeClass( 'hidden' );
if ( $input.length ) {
$input[0].scrollIntoView();
}
}
});
module.exports = AttachmentDisplay;
/***/ }),
/***/ "2NU8":
/***/ (function(module, exports) {
var View = wp.media.View,
Toolbar;
/**
* wp.media.view.Toolbar
*
* A toolbar which consists of a primary and a secondary section. Each sections
* can be filled with views.
*
* @memberOf wp.media.view
*
* @class
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
Toolbar = View.extend(/** @lends wp.media.view.Toolbar.prototype */{
tagName: 'div',
className: 'media-toolbar',
initialize: function() {
var state = this.controller.state(),
selection = this.selection = state.get('selection'),
library = this.library = state.get('library');
this._views = {};
// The toolbar is composed of two `PriorityList` views.
this.primary = new wp.media.view.PriorityList();
this.secondary = new wp.media.view.PriorityList();
this.primary.$el.addClass('media-toolbar-primary search-form');
this.secondary.$el.addClass('media-toolbar-secondary');
this.views.set([ this.secondary, this.primary ]);
if ( this.options.items ) {
this.set( this.options.items, { silent: true });
}
if ( ! this.options.silent ) {
this.render();
}
if ( selection ) {
selection.on( 'add remove reset', this.refresh, this );
}
if ( library ) {
library.on( 'add remove reset', this.refresh, this );
}
},
/**
* @return {wp.media.view.Toolbar} Returns itsef to allow chaining
*/
dispose: function() {
if ( this.selection ) {
this.selection.off( null, null, this );
}
if ( this.library ) {
this.library.off( null, null, this );
}
/**
* call 'dispose' directly on the parent class
*/
return View.prototype.dispose.apply( this, arguments );
},
ready: function() {
this.refresh();
},
/**
* @param {string} id
* @param {Backbone.View|Object} view
* @param {Object} [options={}]
* @return {wp.media.view.Toolbar} Returns itself to allow chaining.
*/
set: function( id, view, options ) {
var list;
options = options || {};
// Accept an object with an `id` : `view` mapping.
if ( _.isObject( id ) ) {
_.each( id, function( view, id ) {
this.set( id, view, { silent: true });
}, this );
} else {
if ( ! ( view instanceof Backbone.View ) ) {
view.classes = [ 'media-button-' + id ].concat( view.classes || [] );
view = new wp.media.view.Button( view ).render();
}
view.controller = view.controller || this.controller;
this._views[ id ] = view;
list = view.options.priority < 0 ? 'secondary' : 'primary';
this[ list ].set( id, view, options );
}
if ( ! options.silent ) {
this.refresh();
}
return this;
},
/**
* @param {string} id
* @return {wp.media.view.Button}
*/
get: function( id ) {
return this._views[ id ];
},
/**
* @param {string} id
* @param {Object} options
* @return {wp.media.view.Toolbar} Returns itself to allow chaining.
*/
unset: function( id, options ) {
delete this._views[ id ];
this.primary.unset( id, options );
this.secondary.unset( id, options );
if ( ! options || ! options.silent ) {
this.refresh();
}
return this;
},
refresh: function() {
var state = this.controller.state(),
library = state.get('library'),
selection = state.get('selection');
_.each( this._views, function( button ) {
if ( ! button.model || ! button.options || ! button.options.requires ) {
return;
}
var requires = button.options.requires,
disabled = false;
// Prevent insertion of attachments if any of them are still uploading.
if ( selection && selection.models ) {
disabled = _.some( selection.models, function( attachment ) {
return attachment.get('uploading') === true;
});
}
if ( requires.selection && selection && ! selection.length ) {
disabled = true;
} else if ( requires.library && library && ! library.length ) {
disabled = true;
}
button.model.set( 'disabled', disabled );
});
}
});
module.exports = Toolbar;
/***/ }),
/***/ "2jku":
/***/ (function(module, exports) {
/**
* wp.media.view.Attachment.Library
*
* @memberOf wp.media.view.Attachment
*
* @class
* @augments wp.media.view.Attachment
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
var Library = wp.media.view.Attachment.extend(/** @lends wp.media.view.Attachment.Library.prototype */{
buttons: {
check: true
}
});
module.exports = Library;
/***/ }),
/***/ 3:
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__("tg/Y");
/***/ }),
/***/ "3nJM":
/***/ (function(module, exports) {
var $ = jQuery;
/**
* wp.media.view.FocusManager
*
* @memberOf wp.media.view
*
* @class
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
var FocusManager = wp.media.View.extend(/** @lends wp.media.view.FocusManager.prototype */{
events: {
'keydown': 'focusManagementMode'
},
/**
* Initializes the Focus Manager.
*
* @param {Object} options The Focus Manager options.
*
* @since 5.3.0
*
* @return {void}
*/
initialize: function( options ) {
this.mode = options.mode || 'constrainTabbing';
this.tabsAutomaticActivation = options.tabsAutomaticActivation || false;
},
/**
* Determines which focus management mode to use.
*
* @since 5.3.0
*
* @param {Object} event jQuery event object.
*
* @return {void}
*/
focusManagementMode: function( event ) {
if ( this.mode === 'constrainTabbing' ) {
this.constrainTabbing( event );
}
if ( this.mode === 'tabsNavigation' ) {
this.tabsNavigation( event );
}
},
/**
* Gets all the tabbable elements.
*
* @since 5.3.0
*
* @return {Object} A jQuery collection of tabbable elements.
*/
getTabbables: function() {
// Skip the file input added by Plupload.
return this.$( ':tabbable' ).not( '.moxie-shim input[type="file"]' );
},
/**
* Moves focus to the modal dialog.
*
* @since 3.5.0
*
* @return {void}
*/
focus: function() {
this.$( '.media-modal' ).trigger( 'focus' );
},
/**
* Constrains navigation with the Tab key within the media view element.
*
* @since 4.0.0
*
* @param {Object} event A keydown jQuery event.
*
* @return {void}
*/
constrainTabbing: function( event ) {
var tabbables;
// Look for the tab key.
if ( 9 !== event.keyCode ) {
return;
}
tabbables = this.getTabbables();
// Keep tab focus within media modal while it's open.
if ( tabbables.last()[0] === event.target && ! event.shiftKey ) {
tabbables.first().focus();
return false;
} else if ( tabbables.first()[0] === event.target && event.shiftKey ) {
tabbables.last().focus();
return false;
}
},
/**
* Hides from assistive technologies all the body children.
*
* Sets an `aria-hidden="true"` attribute on all the body children except
* the provided element and other elements that should not be hidden.
*
* The reason why we use `aria-hidden` is that `aria-modal="true"` is buggy
* in Safari 11.1 and support is spotty in other browsers. Also, `aria-modal="true"`
* prevents the `wp.a11y.speak()` ARIA live regions to work as they're outside
* of the modal dialog and get hidden from assistive technologies.
*
* @since 5.2.3
*
* @param {Object} visibleElement The jQuery object representing the element that should not be hidden.
*
* @return {void}
*/
setAriaHiddenOnBodyChildren: function( visibleElement ) {
var bodyChildren,
self = this;
if ( this.isBodyAriaHidden ) {
return;
}
// Get all the body children.
bodyChildren = document.body.children;
// Loop through the body children and hide the ones that should be hidden.
_.each( bodyChildren, function( element ) {
// Don't hide the modal element.
if ( element === visibleElement[0] ) {
return;
}
// Determine the body children to hide.
if ( self.elementShouldBeHidden( element ) ) {
element.setAttribute( 'aria-hidden', 'true' );
// Store the hidden elements.
self.ariaHiddenElements.push( element );
}
} );
this.isBodyAriaHidden = true;
},
/**
* Unhides from assistive technologies all the body children.
*
* Makes visible again to assistive technologies all the body children
* previously hidden and stored in this.ariaHiddenElements.
*
* @since 5.2.3
*
* @return {void}
*/
removeAriaHiddenFromBodyChildren: function() {
_.each( this.ariaHiddenElements, function( element ) {
element.removeAttribute( 'aria-hidden' );
} );
this.ariaHiddenElements = [];
this.isBodyAriaHidden = false;
},
/**
* Determines if the passed element should not be hidden from assistive technologies.
*
* @since 5.2.3
*
* @param {Object} element The DOM element that should be checked.
*
* @return {boolean} Whether the element should not be hidden from assistive technologies.
*/
elementShouldBeHidden: function( element ) {
var role = element.getAttribute( 'role' ),
liveRegionsRoles = [ 'alert', 'status', 'log', 'marquee', 'timer' ];
/*
* Don't hide scripts, elements that already have `aria-hidden`, and
* ARIA live regions.
*/
return ! (
element.tagName === 'SCRIPT' ||
element.hasAttribute( 'aria-hidden' ) ||
element.hasAttribute( 'aria-live' ) ||
liveRegionsRoles.indexOf( role ) !== -1
);
},
/**
* Whether the body children are hidden from assistive technologies.
*
* @since 5.2.3
*/
isBodyAriaHidden: false,
/**
* Stores an array of DOM elements that should be hidden from assistive
* technologies, for example when the media modal dialog opens.
*
* @since 5.2.3
*/
ariaHiddenElements: [],
/**
* Holds the jQuery collection of ARIA tabs.
*
* @since 5.3.0
*/
tabs: $(),
/**
* Sets up tabs in an ARIA tabbed interface.
*
* @since 5.3.0
*
* @param {Object} event jQuery event object.
*
* @return {void}
*/
setupAriaTabs: function() {
this.tabs = this.$( '[role="tab"]' );
// Set up initial attributes.
this.tabs.attr( {
'aria-selected': 'false',
tabIndex: '-1'
} );
// Set up attributes on the initially active tab.
this.tabs.filter( '.active' )
.removeAttr( 'tabindex' )
.attr( 'aria-selected', 'true' );
},
/**
* Enables arrows navigation within the ARIA tabbed interface.
*
* @since 5.3.0
*
* @param {Object} event jQuery event object.
*
* @return {void}
*/
tabsNavigation: function( event ) {
var orientation = 'horizontal',
keys = [ 32, 35, 36, 37, 38, 39, 40 ];
// Return if not Spacebar, End, Home, or Arrow keys.
if ( keys.indexOf( event.which ) === -1 ) {
return;
}
// Determine navigation direction.
if ( this.$el.attr( 'aria-orientation' ) === 'vertical' ) {
orientation = 'vertical';
}
// Make Up and Down arrow keys do nothing with horizontal tabs.
if ( orientation === 'horizontal' && [ 38, 40 ].indexOf( event.which ) !== -1 ) {
return;
}
// Make Left and Right arrow keys do nothing with vertical tabs.
if ( orientation === 'vertical' && [ 37, 39 ].indexOf( event.which ) !== -1 ) {
return;
}
this.switchTabs( event, this.tabs );
},
/**
* Switches tabs in the ARIA tabbed interface.
*
* @since 5.3.0
*
* @param {Object} event jQuery event object.
*
* @return {void}
*/
switchTabs: function( event ) {
var key = event.which,
index = this.tabs.index( $( event.target ) ),
newIndex;
switch ( key ) {
// Space bar: Activate current targeted tab.
case 32: {
this.activateTab( this.tabs[ index ] );
break;
}
// End key: Activate last tab.
case 35: {
event.preventDefault();
this.activateTab( this.tabs[ this.tabs.length - 1 ] );
break;
}
// Home key: Activate first tab.
case 36: {
event.preventDefault();
this.activateTab( this.tabs[ 0 ] );
break;
}
// Left and up keys: Activate previous tab.
case 37:
case 38: {
event.preventDefault();
newIndex = ( index - 1 ) < 0 ? this.tabs.length - 1 : index - 1;
this.activateTab( this.tabs[ newIndex ] );
break;
}
// Right and down keys: Activate next tab.
case 39:
case 40: {
event.preventDefault();
newIndex = ( index + 1 ) === this.tabs.length ? 0 : index + 1;
this.activateTab( this.tabs[ newIndex ] );
break;
}
}
},
/**
* Sets a single tab to be focusable and semantically selected.
*
* @since 5.3.0
*
* @param {Object} tab The tab DOM element.
*
* @return {void}
*/
activateTab: function( tab ) {
if ( ! tab ) {
return;
}
// The tab is a DOM element: no need for jQuery methods.
tab.focus();
// Handle automatic activation.
if ( this.tabsAutomaticActivation ) {
tab.removeAttribute( 'tabindex' );
tab.setAttribute( 'aria-selected', 'true' );
tab.click();
return;
}
// Handle manual activation.
$( tab ).on( 'click', function() {
tab.removeAttribute( 'tabindex' );
tab.setAttribute( 'aria-selected', 'true' );
} );
}
});
module.exports = FocusManager;
/***/ }),
/***/ "4jjk":
/***/ (function(module, exports) {
var l10n = wp.media.view.l10n,
Uploaded;
/**
* wp.media.view.AttachmentFilters.Uploaded
*
* @memberOf wp.media.view.AttachmentFilters
*
* @class
* @augments wp.media.view.AttachmentFilters
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
Uploaded = wp.media.view.AttachmentFilters.extend(/** @lends wp.media.view.AttachmentFilters.Uploaded.prototype */{
createFilters: function() {
var type = this.model.get('type'),
types = wp.media.view.settings.mimeTypes,
uid = window.userSettings ? parseInt( window.userSettings.uid, 10 ) : 0,
text;
if ( types && type ) {
text = types[ type ];
}
this.filters = {
all: {
text: text || l10n.allMediaItems,
props: {
uploadedTo: null,
orderby: 'date',
order: 'DESC',
author: null
},
priority: 10
},
uploaded: {
text: l10n.uploadedToThisPost,
props: {
uploadedTo: wp.media.view.settings.post.id,
orderby: 'menuOrder',
order: 'ASC',
author: null
},
priority: 20
},
unattached: {
text: l10n.unattached,
props: {
uploadedTo: 0,
orderby: 'menuOrder',
order: 'ASC',
author: null
},
priority: 50
}
};
if ( uid ) {
this.filters.mine = {
text: l10n.mine,
props: {
orderby: 'date',
order: 'DESC',
author: uid
},
priority: 50
};
}
}
});
module.exports = Uploaded;
/***/ }),
/***/ "4tHu":
/***/ (function(module, exports) {
var l10n = wp.media.view.l10n,
EditImage;
/**
* wp.media.controller.EditImage
*
* A state for editing (cropping, etc.) an image.
*
* @memberOf wp.media.controller
*
* @class
* @augments wp.media.controller.State
* @augments Backbone.Model
*
* @param {object} attributes The attributes hash passed to the state.
* @param {wp.media.model.Attachment} attributes.model The attachment.
* @param {string} [attributes.id=edit-image] Unique identifier.
* @param {string} [attributes.title=Edit Image] Title for the state. Displays in the media menu and the frame's title region.
* @param {string} [attributes.content=edit-image] Initial mode for the content region.
* @param {string} [attributes.toolbar=edit-image] Initial mode for the toolbar region.
* @param {string} [attributes.menu=false] Initial mode for the menu region.
* @param {string} [attributes.url] Unused. @todo Consider removal.
*/
EditImage = wp.media.controller.State.extend(/** @lends wp.media.controller.EditImage.prototype */{
defaults: {
id: 'edit-image',
title: l10n.editImage,
menu: false,
toolbar: 'edit-image',
content: 'edit-image',
url: ''
},
/**
* Activates a frame for editing a featured image.
*
* @since 3.9.0
*
* @return {void}
*/
activate: function() {
this.frame.on( 'toolbar:render:edit-image', _.bind( this.toolbar, this ) );
},
/**
* Deactivates a frame for editing a featured image.
*
* @since 3.9.0
*
* @return {void}
*/
deactivate: function() {
this.frame.off( 'toolbar:render:edit-image' );
},
/**
* Adds a toolbar with a back button.
*
* When the back button is pressed it checks whether there is a previous state.
* In case there is a previous state it sets that previous state otherwise it
* closes the frame.
*
* @since 3.9.0
*
* @return {void}
*/
toolbar: function() {
var frame = this.frame,
lastState = frame.lastState(),
previous = lastState && lastState.id;
frame.toolbar.set( new wp.media.view.Toolbar({
controller: frame,
items: {
back: {
style: 'primary',
text: l10n.back,
priority: 20,
click: function() {
if ( previous ) {
frame.setState( previous );
} else {
frame.close();
}
}
}
}
}) );
}
});
module.exports = EditImage;
/***/ }),
/***/ "6B7g":
/***/ (function(module, exports) {
var Select = wp.media.view.MediaFrame.Select,
Library = wp.media.controller.Library,
l10n = wp.media.view.l10n,
Post;
/**
* wp.media.view.MediaFrame.Post
*
* The frame for manipulating media on the Edit Post page.
*
* @memberOf wp.media.view.MediaFrame
*
* @class
* @augments wp.media.view.MediaFrame.Select
* @augments wp.media.view.MediaFrame
* @augments wp.media.view.Frame
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
* @mixes wp.media.controller.StateMachine
*/
Post = Select.extend(/** @lends wp.media.view.MediaFrame.Post.prototype */{
initialize: function() {
this.counts = {
audio: {
count: wp.media.view.settings.attachmentCounts.audio,
state: 'playlist'
},
video: {
count: wp.media.view.settings.attachmentCounts.video,
state: 'video-playlist'
}
};
_.defaults( this.options, {
multiple: true,
editing: false,
state: 'insert',
metadata: {}
});
// Call 'initialize' directly on the parent class.
Select.prototype.initialize.apply( this, arguments );
this.createIframeStates();
},
/**
* Create the default states.
*/
createStates: function() {
var options = this.options;
this.states.add([
// Main states.
new Library({
id: 'insert',
title: l10n.insertMediaTitle,
priority: 20,
toolbar: 'main-insert',
filterable: 'all',
library: wp.media.query( options.library ),
multiple: options.multiple ? 'reset' : false,
editable: true,
// If the user isn't allowed to edit fields,
// can they still edit it locally?
allowLocalEdits: true,
// Show the attachment display settings.
displaySettings: true,
// Update user settings when users adjust the
// attachment display settings.
displayUserSettings: true
}),
new Library({
id: 'gallery',
title: l10n.createGalleryTitle,
priority: 40,
toolbar: 'main-gallery',
filterable: 'uploaded',
multiple: 'add',
editable: false,
library: wp.media.query( _.defaults({
type: 'image'
}, options.library ) )
}),
// Embed states.
new wp.media.controller.Embed( { metadata: options.metadata } ),
new wp.media.controller.EditImage( { model: options.editImage } ),
// Gallery states.
new wp.media.controller.GalleryEdit({
library: options.selection,
editing: options.editing,
menu: 'gallery'
}),
new wp.media.controller.GalleryAdd(),
new Library({
id: 'playlist',
title: l10n.createPlaylistTitle,
priority: 60,
toolbar: 'main-playlist',
filterable: 'uploaded',
multiple: 'add',
editable: false,
library: wp.media.query( _.defaults({
type: 'audio'
}, options.library ) )
}),
// Playlist states.
new wp.media.controller.CollectionEdit({
type: 'audio',
collectionType: 'playlist',
title: l10n.editPlaylistTitle,
SettingsView: wp.media.view.Settings.Playlist,
library: options.selection,
editing: options.editing,
menu: 'playlist',
dragInfoText: l10n.playlistDragInfo,
dragInfo: false
}),
new wp.media.controller.CollectionAdd({
type: 'audio',
collectionType: 'playlist',
title: l10n.addToPlaylistTitle
}),
new Library({
id: 'video-playlist',
title: l10n.createVideoPlaylistTitle,
priority: 60,
toolbar: 'main-video-playlist',
filterable: 'uploaded',
multiple: 'add',
editable: false,
library: wp.media.query( _.defaults({
type: 'video'
}, options.library ) )
}),
new wp.media.controller.CollectionEdit({
type: 'video',
collectionType: 'playlist',
title: l10n.editVideoPlaylistTitle,
SettingsView: wp.media.view.Settings.Playlist,
library: options.selection,
editing: options.editing,
menu: 'video-playlist',
dragInfoText: l10n.videoPlaylistDragInfo,
dragInfo: false
}),
new wp.media.controller.CollectionAdd({
type: 'video',
collectionType: 'playlist',
title: l10n.addToVideoPlaylistTitle
})
]);
if ( wp.media.view.settings.post.featuredImageId ) {
this.states.add( new wp.media.controller.FeaturedImage() );
}
},
bindHandlers: function() {
var handlers, checkCounts;
Select.prototype.bindHandlers.apply( this, arguments );
this.on( 'activate', this.activate, this );
// Only bother checking media type counts if one of the counts is zero.
checkCounts = _.find( this.counts, function( type ) {
return type.count === 0;
} );
if ( typeof checkCounts !== 'undefined' ) {
this.listenTo( wp.media.model.Attachments.all, 'change:type', this.mediaTypeCounts );
}
this.on( 'menu:create:gallery', this.createMenu, this );
this.on( 'menu:create:playlist', this.createMenu, this );
this.on( 'menu:create:video-playlist', this.createMenu, this );
this.on( 'toolbar:create:main-insert', this.createToolbar, this );
this.on( 'toolbar:create:main-gallery', this.createToolbar, this );
this.on( 'toolbar:create:main-playlist', this.createToolbar, this );
this.on( 'toolbar:create:main-video-playlist', this.createToolbar, this );
this.on( 'toolbar:create:featured-image', this.featuredImageToolbar, this );
this.on( 'toolbar:create:main-embed', this.mainEmbedToolbar, this );
handlers = {
menu: {
'default': 'mainMenu',
'gallery': 'galleryMenu',
'playlist': 'playlistMenu',
'video-playlist': 'videoPlaylistMenu'
},
content: {
'embed': 'embedContent',
'edit-image': 'editImageContent',
'edit-selection': 'editSelectionContent'
},
toolbar: {
'main-insert': 'mainInsertToolbar',
'main-gallery': 'mainGalleryToolbar',
'gallery-edit': 'galleryEditToolbar',
'gallery-add': 'galleryAddToolbar',
'main-playlist': 'mainPlaylistToolbar',
'playlist-edit': 'playlistEditToolbar',
'playlist-add': 'playlistAddToolbar',
'main-video-playlist': 'mainVideoPlaylistToolbar',
'video-playlist-edit': 'videoPlaylistEditToolbar',
'video-playlist-add': 'videoPlaylistAddToolbar'
}
};
_.each( handlers, function( regionHandlers, region ) {
_.each( regionHandlers, function( callback, handler ) {
this.on( region + ':render:' + handler, this[ callback ], this );
}, this );
}, this );
},
activate: function() {
// Hide menu items for states tied to particular media types if there are no items.
_.each( this.counts, function( type ) {
if ( type.count < 1 ) {
this.menuItemVisibility( type.state, 'hide' );
}
}, this );
},
mediaTypeCounts: function( model, attr ) {
if ( typeof this.counts[ attr ] !== 'undefined' && this.counts[ attr ].count < 1 ) {
this.counts[ attr ].count++;
this.menuItemVisibility( this.counts[ attr ].state, 'show' );
}
},
// Menus.
/**
* @param {wp.Backbone.View} view
*/
mainMenu: function( view ) {
view.set({
'library-separator': new wp.media.View({
className: 'separator',
priority: 100,
attributes: {
role: 'presentation'
}
})
});
},
menuItemVisibility: function( state, visibility ) {
var menu = this.menu.get();
if ( visibility === 'hide' ) {
menu.hide( state );
} else if ( visibility === 'show' ) {
menu.show( state );
}
},
/**
* @param {wp.Backbone.View} view
*/
galleryMenu: function( view ) {
var lastState = this.lastState(),
previous = lastState && lastState.id,
frame = this;
view.set({
cancel: {
text: l10n.cancelGalleryTitle,
priority: 20,
click: function() {
if ( previous ) {
frame.setState( previous );
} else {
frame.close();
}
// Move focus to the modal after canceling a Gallery.
this.controller.modal.focusManager.focus();
}
},
separateCancel: new wp.media.View({
className: 'separator',
priority: 40
})
});
},
playlistMenu: function( view ) {
var lastState = this.lastState(),
previous = lastState && lastState.id,
frame = this;
view.set({
cancel: {
text: l10n.cancelPlaylistTitle,
priority: 20,
click: function() {
if ( previous ) {
frame.setState( previous );
} else {
frame.close();
}
// Move focus to the modal after canceling an Audio Playlist.
this.controller.modal.focusManager.focus();
}
},
separateCancel: new wp.media.View({
className: 'separator',
priority: 40
})
});
},
videoPlaylistMenu: function( view ) {
var lastState = this.lastState(),
previous = lastState && lastState.id,
frame = this;
view.set({
cancel: {
text: l10n.cancelVideoPlaylistTitle,
priority: 20,
click: function() {
if ( previous ) {
frame.setState( previous );
} else {
frame.close();
}
// Move focus to the modal after canceling a Video Playlist.
this.controller.modal.focusManager.focus();
}
},
separateCancel: new wp.media.View({
className: 'separator',
priority: 40
})
});
},
// Content.
embedContent: function() {
var view = new wp.media.view.Embed({
controller: this,
model: this.state()
}).render();
this.content.set( view );
},
editSelectionContent: function() {
var state = this.state(),
selection = state.get('selection'),
view;
view = new wp.media.view.AttachmentsBrowser({
controller: this,
collection: selection,
selection: selection,
model: state,
sortable: true,
search: false,
date: false,
dragInfo: true,
AttachmentView: wp.media.view.Attachments.EditSelection
}).render();
view.toolbar.set( 'backToLibrary', {
text: l10n.returnToLibrary,
priority: -100,
click: function() {
this.controller.content.mode('browse');
// Move focus to the modal when jumping back from Edit Selection to Add Media view.
this.controller.modal.focusManager.focus();
}
});
// Browse our library of attachments.
this.content.set( view );
// Trigger the controller to set focus.
this.trigger( 'edit:selection', this );
},
editImageContent: function() {
var image = this.state().get('image'),
view = new wp.media.view.EditImage( { model: image, controller: this } ).render();
this.content.set( view );
// After creating the wrapper view, load the actual editor via an Ajax call.
view.loadEditor();
},
// Toolbars.
/**
* @param {wp.Backbone.View} view
*/
selectionStatusToolbar: function( view ) {
var editable = this.state().get('editable');
view.set( 'selection', new wp.media.view.Selection({
controller: this,
collection: this.state().get('selection'),
priority: -40,
// If the selection is editable, pass the callback to
// switch the content mode.
editable: editable && function() {
this.controller.content.mode('edit-selection');
}
}).render() );
},
/**
* @param {wp.Backbone.View} view
*/
mainInsertToolbar: function( view ) {
var controller = this;
this.selectionStatusToolbar( view );
view.set( 'insert', {
style: 'primary',
priority: 80,
text: l10n.insertIntoPost,
requires: { selection: true },
/**
* @ignore
*
* @fires wp.media.controller.State#insert
*/
click: function() {
var state = controller.state(),
selection = state.get('selection');
controller.close();
state.trigger( 'insert', selection ).reset();
}
});
},
/**
* @param {wp.Backbone.View} view
*/
mainGalleryToolbar: function( view ) {
var controller = this;
this.selectionStatusToolbar( view );
view.set( 'gallery', {
style: 'primary',
text: l10n.createNewGallery,
priority: 60,
requires: { selection: true },
click: function() {
var selection = controller.state().get('selection'),
edit = controller.state('gallery-edit'),
models = selection.where({ type: 'image' });
edit.set( 'library', new wp.media.model.Selection( models, {
props: selection.props.toJSON(),
multiple: true
}) );
// Jump to Edit Gallery view.
this.controller.setState( 'gallery-edit' );
// Move focus to the modal after jumping to Edit Gallery view.
this.controller.modal.focusManager.focus();
}
});
},
mainPlaylistToolbar: function( view ) {
var controller = this;
this.selectionStatusToolbar( view );
view.set( 'playlist', {
style: 'primary',
text: l10n.createNewPlaylist,
priority: 100,
requires: { selection: true },
click: function() {
var selection = controller.state().get('selection'),
edit = controller.state('playlist-edit'),
models = selection.where({ type: 'audio' });
edit.set( 'library', new wp.media.model.Selection( models, {
props: selection.props.toJSON(),
multiple: true
}) );
// Jump to Edit Audio Playlist view.
this.controller.setState( 'playlist-edit' );
// Move focus to the modal after jumping to Edit Audio Playlist view.
this.controller.modal.focusManager.focus();
}
});
},
mainVideoPlaylistToolbar: function( view ) {
var controller = this;
this.selectionStatusToolbar( view );
view.set( 'video-playlist', {
style: 'primary',
text: l10n.createNewVideoPlaylist,
priority: 100,
requires: { selection: true },
click: function() {
var selection = controller.state().get('selection'),
edit = controller.state('video-playlist-edit'),
models = selection.where({ type: 'video' });
edit.set( 'library', new wp.media.model.Selection( models, {
props: selection.props.toJSON(),
multiple: true
}) );
// Jump to Edit Video Playlist view.
this.controller.setState( 'video-playlist-edit' );
// Move focus to the modal after jumping to Edit Video Playlist view.
this.controller.modal.focusManager.focus();
}
});
},
featuredImageToolbar: function( toolbar ) {
this.createSelectToolbar( toolbar, {
text: l10n.setFeaturedImage,
state: this.options.state
});
},
mainEmbedToolbar: function( toolbar ) {
toolbar.view = new wp.media.view.Toolbar.Embed({
controller: this
});
},
galleryEditToolbar: function() {
var editing = this.state().get('editing');
this.toolbar.set( new wp.media.view.Toolbar({
controller: this,
items: {
insert: {
style: 'primary',
text: editing ? l10n.updateGallery : l10n.insertGallery,
priority: 80,
requires: { library: true },
/**
* @fires wp.media.controller.State#update
*/
click: function() {
var controller = this.controller,
state = controller.state();
controller.close();
state.trigger( 'update', state.get('library') );
// Restore and reset the default state.
controller.setState( controller.options.state );
controller.reset();
}
}
}
}) );
},
galleryAddToolbar: function() {
this.toolbar.set( new wp.media.view.Toolbar({
controller: this,
items: {
insert: {
style: 'primary',
text: l10n.addToGallery,
priority: 80,
requires: { selection: true },
/**
* @fires wp.media.controller.State#reset
*/
click: function() {
var controller = this.controller,
state = controller.state(),
edit = controller.state('gallery-edit');
edit.get('library').add( state.get('selection').models );
state.trigger('reset');
controller.setState('gallery-edit');
// Move focus to the modal when jumping back from Add to Gallery to Edit Gallery view.
this.controller.modal.focusManager.focus();
}
}
}
}) );
},
playlistEditToolbar: function() {
var editing = this.state().get('editing');
this.toolbar.set( new wp.media.view.Toolbar({
controller: this,
items: {
insert: {
style: 'primary',
text: editing ? l10n.updatePlaylist : l10n.insertPlaylist,
priority: 80,
requires: { library: true },
/**
* @fires wp.media.controller.State#update
*/
click: function() {
var controller = this.controller,
state = controller.state();
controller.close();
state.trigger( 'update', state.get('library') );
// Restore and reset the default state.
controller.setState( controller.options.state );
controller.reset();
}
}
}
}) );
},
playlistAddToolbar: function() {
this.toolbar.set( new wp.media.view.Toolbar({
controller: this,
items: {
insert: {
style: 'primary',
text: l10n.addToPlaylist,
priority: 80,
requires: { selection: true },
/**
* @fires wp.media.controller.State#reset
*/
click: function() {
var controller = this.controller,
state = controller.state(),
edit = controller.state('playlist-edit');
edit.get('library').add( state.get('selection').models );
state.trigger('reset');
controller.setState('playlist-edit');
// Move focus to the modal when jumping back from Add to Audio Playlist to Edit Audio Playlist view.
this.controller.modal.focusManager.focus();
}
}
}
}) );
},
videoPlaylistEditToolbar: function() {
var editing = this.state().get('editing');
this.toolbar.set( new wp.media.view.Toolbar({
controller: this,
items: {
insert: {
style: 'primary',
text: editing ? l10n.updateVideoPlaylist : l10n.insertVideoPlaylist,
priority: 140,
requires: { library: true },
click: function() {
var controller = this.controller,
state = controller.state(),
library = state.get('library');
library.type = 'video';
controller.close();
state.trigger( 'update', library );
// Restore and reset the default state.
controller.setState( controller.options.state );
controller.reset();
}
}
}
}) );
},
videoPlaylistAddToolbar: function() {
this.toolbar.set( new wp.media.view.Toolbar({
controller: this,
items: {
insert: {
style: 'primary',
text: l10n.addToVideoPlaylist,
priority: 140,
requires: { selection: true },
click: function() {
var controller = this.controller,
state = controller.state(),
edit = controller.state('video-playlist-edit');
edit.get('library').add( state.get('selection').models );
state.trigger('reset');
controller.setState('video-playlist-edit');
// Move focus to the modal when jumping back from Add to Video Playlist to Edit Video Playlist view.
this.controller.modal.focusManager.focus();
}
}
}
}) );
}
});
module.exports = Post;
/***/ }),
/***/ "72mI":
/***/ (function(module, exports) {
var View = wp.media.View,
mediaTrash = wp.media.view.settings.mediaTrash,
l10n = wp.media.view.l10n,
$ = jQuery,
AttachmentsBrowser,
infiniteScrolling = wp.media.view.settings.infiniteScrolling,
__ = wp.i18n.__,
sprintf = wp.i18n.sprintf;
/**
* wp.media.view.AttachmentsBrowser
*
* @memberOf wp.media.view
*
* @class
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*
* @param {object} [options] The options hash passed to the view.
* @param {boolean|string} [options.filters=false] Which filters to show in the browser's toolbar.
* Accepts 'uploaded' and 'all'.
* @param {boolean} [options.search=true] Whether to show the search interface in the
* browser's toolbar.
* @param {boolean} [options.date=true] Whether to show the date filter in the
* browser's toolbar.
* @param {boolean} [options.display=false] Whether to show the attachments display settings
* view in the sidebar.
* @param {boolean|string} [options.sidebar=true] Whether to create a sidebar for the browser.
* Accepts true, false, and 'errors'.
*/
AttachmentsBrowser = View.extend(/** @lends wp.media.view.AttachmentsBrowser.prototype */{
tagName: 'div',
className: 'attachments-browser',
initialize: function() {
_.defaults( this.options, {
filters: false,
search: true,
date: true,
display: false,
sidebar: true,
AttachmentView: wp.media.view.Attachment.Library
});
this.controller.on( 'toggle:upload:attachment', this.toggleUploader, this );
this.controller.on( 'edit:selection', this.editSelection );
// In the Media Library, the sidebar is used to display errors before the attachments grid.
if ( this.options.sidebar && 'errors' === this.options.sidebar ) {
this.createSidebar();
}
/*
* In the grid mode (the Media Library), place the Inline Uploader before
* other sections so that the visual order and the DOM order match. This way,
* the Inline Uploader in the Media Library is right after the "Add New"
* button, see ticket #37188.
*/
if ( this.controller.isModeActive( 'grid' ) ) {
this.createUploader();
/*
* Create a multi-purpose toolbar. Used as main toolbar in the Media Library
* and also for other things, for example the "Drag and drop to reorder" and
* "Suggested dimensions" info in the media modal.
*/
this.createToolbar();
} else {
this.createToolbar();
this.createUploader();
}
// Add a heading before the attachments list.
this.createAttachmentsHeading();
// Create the attachments wrapper view.
this.createAttachmentsWrapperView();
if ( ! infiniteScrolling ) {
this.$el.addClass( 'has-load-more' );
this.createLoadMoreView();
}
// For accessibility reasons, place the normal sidebar after the attachments, see ticket #36909.
if ( this.options.sidebar && 'errors' !== this.options.sidebar ) {
this.createSidebar();
}
this.updateContent();
if ( ! infiniteScrolling ) {
this.updateLoadMoreView();
}
if ( ! this.options.sidebar || 'errors' === this.options.sidebar ) {
this.$el.addClass( 'hide-sidebar' );
if ( 'errors' === this.options.sidebar ) {
this.$el.addClass( 'sidebar-for-errors' );
}
}
this.collection.on( 'add remove reset', this.updateContent, this );
if ( ! infiniteScrolling ) {
this.collection.on( 'add remove reset', this.updateLoadMoreView, this );
}
// The non-cached or cached attachments query has completed.
this.collection.on( 'attachments:received', this.announceSearchResults, this );
},
/**
* Updates the `wp.a11y.speak()` ARIA live region with a message to communicate
* the number of search results to screen reader users. This function is
* debounced because the collection updates multiple times.
*
* @since 5.3.0
*
* @return {void}
*/
announceSearchResults: _.debounce( function() {
var count,
/* translators: Accessibility text. %d: Number of attachments found in a search. */
mediaFoundHasMoreResultsMessage = __( 'Number of media items displayed: %d. Click load more for more results.' );
if ( infiniteScrolling ) {
/* translators: Accessibility text. %d: Number of attachments found in a search. */
mediaFoundHasMoreResultsMessage = __( 'Number of media items displayed: %d. Scroll the page for more results.' );
}
if ( this.collection.mirroring.args.s ) {
count = this.collection.length;
if ( 0 === count ) {
wp.a11y.speak( l10n.noMediaTryNewSearch );
return;
}
if ( this.collection.hasMore() ) {
wp.a11y.speak( mediaFoundHasMoreResultsMessage.replace( '%d', count ) );
return;
}
wp.a11y.speak( l10n.mediaFound.replace( '%d', count ) );
}
}, 200 ),
editSelection: function( modal ) {
// When editing a selection, move focus to the "Go to library" button.
modal.$( '.media-button-backToLibrary' ).focus();
},
/**
* @return {wp.media.view.AttachmentsBrowser} Returns itself to allow chaining.
*/
dispose: function() {
this.options.selection.off( null, null, this );
View.prototype.dispose.apply( this, arguments );
return this;
},
createToolbar: function() {
var LibraryViewSwitcher, Filters, toolbarOptions,
showFilterByType = -1 !== $.inArray( this.options.filters, [ 'uploaded', 'all' ] );
toolbarOptions = {
controller: this.controller
};
if ( this.controller.isModeActive( 'grid' ) ) {
toolbarOptions.className = 'media-toolbar wp-filter';
}
/**
* @member {wp.media.view.Toolbar}
*/
this.toolbar = new wp.media.view.Toolbar( toolbarOptions );
this.views.add( this.toolbar );
this.toolbar.set( 'spinner', new wp.media.view.Spinner({
priority: -20
}) );
if ( showFilterByType || this.options.date ) {
/*
* Create a h2 heading before the select elements that filter attachments.
* This heading is visible in the modal and visually hidden in the grid.
*/
this.toolbar.set( 'filters-heading', new wp.media.view.Heading( {
priority: -100,
text: l10n.filterAttachments,
level: 'h2',
className: 'media-attachments-filter-heading'
}).render() );
}
if ( showFilterByType ) {
// "Filters" is a