wp/wp-includes/js/media-grid.js
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
equal deleted inserted replaced
18:be944660c56a 19:3d72ae0968f4
     1 /******/ (function(modules) { // webpackBootstrap
     1 /******/ (function() { // webpackBootstrap
     2 /******/ 	// The module cache
     2 /******/ 	var __webpack_modules__ = ({
     3 /******/ 	var installedModules = {};
     3 
     4 /******/
     4 /***/ 5817:
     5 /******/ 	// The require function
     5 /***/ (function(module) {
     6 /******/ 	function __webpack_require__(moduleId) {
     6 
     7 /******/
     7 var l10n = wp.media.view.l10n,
     8 /******/ 		// Check if module is in cache
     8 	EditAttachmentMetadata;
     9 /******/ 		if(installedModules[moduleId]) {
     9 
    10 /******/ 			return installedModules[moduleId].exports;
    10 /**
    11 /******/ 		}
    11  * wp.media.controller.EditAttachmentMetadata
    12 /******/ 		// Create a new module (and put it into the cache)
    12  *
    13 /******/ 		var module = installedModules[moduleId] = {
    13  * A state for editing an attachment's metadata.
    14 /******/ 			i: moduleId,
    14  *
    15 /******/ 			l: false,
    15  * @memberOf wp.media.controller
    16 /******/ 			exports: {}
    16  *
    17 /******/ 		};
    17  * @class
    18 /******/
    18  * @augments wp.media.controller.State
    19 /******/ 		// Execute the module function
    19  * @augments Backbone.Model
    20 /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
    20  */
    21 /******/
    21 EditAttachmentMetadata = wp.media.controller.State.extend(/** @lends wp.media.controller.EditAttachmentMetadata.prototype */{
    22 /******/ 		// Flag the module as loaded
    22 	defaults: {
    23 /******/ 		module.l = true;
    23 		id:      'edit-attachment',
    24 /******/
    24 		// Title string passed to the frame's title region view.
    25 /******/ 		// Return the exports of the module
    25 		title:   l10n.attachmentDetails,
    26 /******/ 		return module.exports;
    26 		// Region mode defaults.
    27 /******/ 	}
    27 		content: 'edit-metadata',
    28 /******/
    28 		menu:    false,
    29 /******/
    29 		toolbar: false,
    30 /******/ 	// expose the modules object (__webpack_modules__)
    30 		router:  false
    31 /******/ 	__webpack_require__.m = modules;
    31 	}
    32 /******/
    32 });
    33 /******/ 	// expose the module cache
    33 
    34 /******/ 	__webpack_require__.c = installedModules;
    34 module.exports = EditAttachmentMetadata;
    35 /******/
       
    36 /******/ 	// define getter function for harmony exports
       
    37 /******/ 	__webpack_require__.d = function(exports, name, getter) {
       
    38 /******/ 		if(!__webpack_require__.o(exports, name)) {
       
    39 /******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
       
    40 /******/ 		}
       
    41 /******/ 	};
       
    42 /******/
       
    43 /******/ 	// define __esModule on exports
       
    44 /******/ 	__webpack_require__.r = function(exports) {
       
    45 /******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
       
    46 /******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
       
    47 /******/ 		}
       
    48 /******/ 		Object.defineProperty(exports, '__esModule', { value: true });
       
    49 /******/ 	};
       
    50 /******/
       
    51 /******/ 	// create a fake namespace object
       
    52 /******/ 	// mode & 1: value is a module id, require it
       
    53 /******/ 	// mode & 2: merge all properties of value into the ns
       
    54 /******/ 	// mode & 4: return value when already ns object
       
    55 /******/ 	// mode & 8|1: behave like require
       
    56 /******/ 	__webpack_require__.t = function(value, mode) {
       
    57 /******/ 		if(mode & 1) value = __webpack_require__(value);
       
    58 /******/ 		if(mode & 8) return value;
       
    59 /******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
       
    60 /******/ 		var ns = Object.create(null);
       
    61 /******/ 		__webpack_require__.r(ns);
       
    62 /******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
       
    63 /******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
       
    64 /******/ 		return ns;
       
    65 /******/ 	};
       
    66 /******/
       
    67 /******/ 	// getDefaultExport function for compatibility with non-harmony modules
       
    68 /******/ 	__webpack_require__.n = function(module) {
       
    69 /******/ 		var getter = module && module.__esModule ?
       
    70 /******/ 			function getDefault() { return module['default']; } :
       
    71 /******/ 			function getModuleExports() { return module; };
       
    72 /******/ 		__webpack_require__.d(getter, 'a', getter);
       
    73 /******/ 		return getter;
       
    74 /******/ 	};
       
    75 /******/
       
    76 /******/ 	// Object.prototype.hasOwnProperty.call
       
    77 /******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
       
    78 /******/
       
    79 /******/ 	// __webpack_public_path__
       
    80 /******/ 	__webpack_require__.p = "";
       
    81 /******/
       
    82 /******/
       
    83 /******/ 	// Load entry module and return exports
       
    84 /******/ 	return __webpack_require__(__webpack_require__.s = 1);
       
    85 /******/ })
       
    86 /************************************************************************/
       
    87 /******/ ({
       
    88 
       
    89 /***/ 1:
       
    90 /***/ (function(module, exports, __webpack_require__) {
       
    91 
       
    92 module.exports = __webpack_require__("LRQ5");
       
    93 
    35 
    94 
    36 
    95 /***/ }),
    37 /***/ }),
    96 
    38 
    97 /***/ "1lLZ":
    39 /***/ 9525:
    98 /***/ (function(module, exports) {
    40 /***/ (function(module) {
       
    41 
       
    42 /**
       
    43  * wp.media.view.MediaFrame.Manage.Router
       
    44  *
       
    45  * A router for handling the browser history and application state.
       
    46  *
       
    47  * @memberOf wp.media.view.MediaFrame.Manage
       
    48  *
       
    49  * @class
       
    50  * @augments Backbone.Router
       
    51  */
       
    52 var Router = Backbone.Router.extend(/** @lends wp.media.view.MediaFrame.Manage.Router.prototype */{
       
    53 	routes: {
       
    54 		'upload.php?item=:slug&mode=edit': 'editItem',
       
    55 		'upload.php?item=:slug':           'showItem',
       
    56 		'upload.php?search=:query':        'search',
       
    57 		'upload.php':                      'reset'
       
    58 	},
       
    59 
       
    60 	// Map routes against the page URL.
       
    61 	baseUrl: function( url ) {
       
    62 		return 'upload.php' + url;
       
    63 	},
       
    64 
       
    65 	reset: function() {
       
    66 		var frame = wp.media.frames.edit;
       
    67 
       
    68 		if ( frame ) {
       
    69 			frame.close();
       
    70 		}
       
    71 	},
       
    72 
       
    73 	// Respond to the search route by filling the search field and triggering the input event.
       
    74 	search: function( query ) {
       
    75 		jQuery( '#media-search-input' ).val( query ).trigger( 'input' );
       
    76 	},
       
    77 
       
    78 	// Show the modal with a specific item.
       
    79 	showItem: function( query ) {
       
    80 		var media = wp.media,
       
    81 			frame = media.frames.browse,
       
    82 			library = frame.state().get('library'),
       
    83 			item;
       
    84 
       
    85 		// Trigger the media frame to open the correct item.
       
    86 		item = library.findWhere( { id: parseInt( query, 10 ) } );
       
    87 
       
    88 		if ( item ) {
       
    89 			item.set( 'skipHistory', true );
       
    90 			frame.trigger( 'edit:attachment', item );
       
    91 		} else {
       
    92 			item = media.attachment( query );
       
    93 			frame.listenTo( item, 'change', function( model ) {
       
    94 				frame.stopListening( item );
       
    95 				frame.trigger( 'edit:attachment', model );
       
    96 			} );
       
    97 			item.fetch();
       
    98 		}
       
    99 	},
       
   100 
       
   101 	// Show the modal in edit mode with a specific item.
       
   102 	editItem: function( query ) {
       
   103 		this.showItem( query );
       
   104 		wp.media.frames.edit.content.mode( 'edit-details' );
       
   105 	}
       
   106 });
       
   107 
       
   108 module.exports = Router;
       
   109 
       
   110 
       
   111 /***/ }),
       
   112 
       
   113 /***/ 7433:
       
   114 /***/ (function(module) {
       
   115 
       
   116 var Details = wp.media.view.Attachment.Details,
       
   117 	TwoColumn;
       
   118 
       
   119 /**
       
   120  * wp.media.view.Attachment.Details.TwoColumn
       
   121  *
       
   122  * A similar view to media.view.Attachment.Details
       
   123  * for use in the Edit Attachment modal.
       
   124  *
       
   125  * @memberOf wp.media.view.Attachment.Details
       
   126  *
       
   127  * @class
       
   128  * @augments wp.media.view.Attachment.Details
       
   129  * @augments wp.media.view.Attachment
       
   130  * @augments wp.media.View
       
   131  * @augments wp.Backbone.View
       
   132  * @augments Backbone.View
       
   133  */
       
   134 TwoColumn = Details.extend(/** @lends wp.media.view.Attachment.Details.TowColumn.prototype */{
       
   135 	template: wp.template( 'attachment-details-two-column' ),
       
   136 
       
   137 	initialize: function() {
       
   138 		this.controller.on( 'content:activate:edit-details', _.bind( this.editAttachment, this ) );
       
   139 
       
   140 		Details.prototype.initialize.apply( this, arguments );
       
   141 	},
       
   142 
       
   143 	editAttachment: function( event ) {
       
   144 		if ( event ) {
       
   145 			event.preventDefault();
       
   146 		}
       
   147 		this.controller.content.mode( 'edit-image' );
       
   148 	},
       
   149 
       
   150 	/**
       
   151 	 * Noop this from parent class, doesn't apply here.
       
   152 	 */
       
   153 	toggleSelectionHandler: function() {}
       
   154 
       
   155 });
       
   156 
       
   157 module.exports = TwoColumn;
       
   158 
       
   159 
       
   160 /***/ }),
       
   161 
       
   162 /***/ 5562:
       
   163 /***/ (function(module) {
    99 
   164 
   100 var Button = wp.media.view.Button,
   165 var Button = wp.media.view.Button,
   101 	DeleteSelected = wp.media.view.DeleteSelectedButton,
   166 	DeleteSelected = wp.media.view.DeleteSelectedButton,
   102 	DeleteSelectedPermanently;
   167 	DeleteSelectedPermanently;
   103 
   168 
   146 module.exports = DeleteSelectedPermanently;
   211 module.exports = DeleteSelectedPermanently;
   147 
   212 
   148 
   213 
   149 /***/ }),
   214 /***/ }),
   150 
   215 
   151 /***/ "FcM5":
   216 /***/ 471:
   152 /***/ (function(module, exports) {
   217 /***/ (function(module) {
   153 
   218 
   154 var Details = wp.media.view.Attachment.Details,
   219 var Button = wp.media.view.Button,
   155 	TwoColumn;
   220 	l10n = wp.media.view.l10n,
       
   221 	DeleteSelected;
   156 
   222 
   157 /**
   223 /**
   158  * wp.media.view.Attachment.Details.TwoColumn
   224  * wp.media.view.DeleteSelectedButton
   159  *
   225  *
   160  * A similar view to media.view.Attachment.Details
   226  * A button that handles bulk Delete/Trash logic
   161  * for use in the Edit Attachment modal.
   227  *
   162  *
   228  * @memberOf wp.media.view
   163  * @memberOf wp.media.view.Attachment.Details
       
   164  *
   229  *
   165  * @class
   230  * @class
   166  * @augments wp.media.view.Attachment.Details
   231  * @augments wp.media.view.Button
   167  * @augments wp.media.view.Attachment
       
   168  * @augments wp.media.View
   232  * @augments wp.media.View
   169  * @augments wp.Backbone.View
   233  * @augments wp.Backbone.View
   170  * @augments Backbone.View
   234  * @augments Backbone.View
   171  */
   235  */
   172 TwoColumn = Details.extend(/** @lends wp.media.view.Attachment.Details.TowColumn.prototype */{
   236 DeleteSelected = Button.extend(/** @lends wp.media.view.DeleteSelectedButton.prototype */{
   173 	template: wp.template( 'attachment-details-two-column' ),
       
   174 
       
   175 	initialize: function() {
   237 	initialize: function() {
   176 		this.controller.on( 'content:activate:edit-details', _.bind( this.editAttachment, this ) );
   238 		Button.prototype.initialize.apply( this, arguments );
   177 
   239 		if ( this.options.filters ) {
   178 		Details.prototype.initialize.apply( this, arguments );
   240 			this.options.filters.model.on( 'change', this.filterChange, this );
   179 	},
   241 		}
   180 
   242 		this.controller.on( 'selection:toggle', this.toggleDisabled, this );
   181 	editAttachment: function( event ) {
   243 		this.controller.on( 'select:activate', this.toggleDisabled, this );
   182 		if ( event ) {
   244 	},
   183 			event.preventDefault();
   245 
   184 		}
   246 	filterChange: function( model ) {
   185 		this.controller.content.mode( 'edit-image' );
   247 		if ( 'trash' === model.get( 'status' ) ) {
   186 	},
   248 			this.model.set( 'text', l10n.restoreSelected );
   187 
   249 		} else if ( wp.media.view.settings.mediaTrash ) {
   188 	/**
   250 			this.model.set( 'text', l10n.trashSelected );
   189 	 * Noop this from parent class, doesn't apply here.
   251 		} else {
   190 	 */
   252 			this.model.set( 'text', l10n.deletePermanently );
   191 	toggleSelectionHandler: function() {}
   253 		}
   192 
   254 	},
       
   255 
       
   256 	toggleDisabled: function() {
       
   257 		this.model.set( 'disabled', ! this.controller.state().get( 'selection' ).length );
       
   258 	},
       
   259 
       
   260 	render: function() {
       
   261 		Button.prototype.render.apply( this, arguments );
       
   262 		if ( this.controller.isModeActive( 'select' ) ) {
       
   263 			this.$el.addClass( 'delete-selected-button' );
       
   264 		} else {
       
   265 			this.$el.addClass( 'delete-selected-button hidden' );
       
   266 		}
       
   267 		this.toggleDisabled();
       
   268 		return this;
       
   269 	}
   193 });
   270 });
   194 
   271 
   195 module.exports = TwoColumn;
   272 module.exports = DeleteSelected;
   196 
   273 
   197 
   274 
   198 /***/ }),
   275 /***/ }),
   199 
   276 
   200 /***/ "Ffsb":
   277 /***/ 6767:
   201 /***/ (function(module, exports) {
   278 /***/ (function(module) {
   202 
   279 
   203 
   280 
   204 var Button = wp.media.view.Button,
   281 var Button = wp.media.view.Button,
   205 	l10n = wp.media.view.l10n,
   282 	l10n = wp.media.view.l10n,
   206 	SelectModeToggle;
   283 	SelectModeToggle;
   279 module.exports = SelectModeToggle;
   356 module.exports = SelectModeToggle;
   280 
   357 
   281 
   358 
   282 /***/ }),
   359 /***/ }),
   283 
   360 
   284 /***/ "HUrf":
   361 /***/ 9157:
   285 /***/ (function(module, exports) {
   362 /***/ (function(module) {
   286 
   363 
   287 var View = wp.media.View,
   364 var View = wp.media.View,
   288 	EditImage = wp.media.view.EditImage,
   365 	EditImage = wp.media.view.EditImage,
   289 	Details;
   366 	Details;
   290 
   367 
   321 module.exports = Details;
   398 module.exports = Details;
   322 
   399 
   323 
   400 
   324 /***/ }),
   401 /***/ }),
   325 
   402 
   326 /***/ "LRQ5":
   403 /***/ 5169:
   327 /***/ (function(module, exports, __webpack_require__) {
   404 /***/ (function(module) {
       
   405 
       
   406 var Frame = wp.media.view.Frame,
       
   407 	MediaFrame = wp.media.view.MediaFrame,
       
   408 
       
   409 	$ = jQuery,
       
   410 	EditAttachments;
   328 
   411 
   329 /**
   412 /**
   330  * @output wp-includes/js/media-grid.js
   413  * wp.media.view.MediaFrame.EditAttachments
       
   414  *
       
   415  * A frame for editing the details of a specific media item.
       
   416  *
       
   417  * Opens in a modal by default.
       
   418  *
       
   419  * Requires an attachment model to be passed in the options hash under `model`.
       
   420  *
       
   421  * @memberOf wp.media.view.MediaFrame
       
   422  *
       
   423  * @class
       
   424  * @augments wp.media.view.Frame
       
   425  * @augments wp.media.View
       
   426  * @augments wp.Backbone.View
       
   427  * @augments Backbone.View
       
   428  * @mixes wp.media.controller.StateMachine
   331  */
   429  */
   332 
   430 EditAttachments = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.EditAttachments.prototype */{
   333 var media = wp.media;
   431 
   334 
   432 	className: 'edit-attachment-frame',
   335 media.controller.EditAttachmentMetadata = __webpack_require__( "ZJBI" );
   433 	template:  wp.template( 'edit-attachment-frame' ),
   336 media.view.MediaFrame.Manage = __webpack_require__( "lH8y" );
   434 	regions:   [ 'title', 'content' ],
   337 media.view.Attachment.Details.TwoColumn = __webpack_require__( "FcM5" );
   435 
   338 media.view.MediaFrame.Manage.Router = __webpack_require__( "OMfl" );
   436 	events: {
   339 media.view.EditImage.Details = __webpack_require__( "HUrf" );
   437 		'click .left':  'previousMediaItem',
   340 media.view.MediaFrame.EditAttachments = __webpack_require__( "wQX5" );
   438 		'click .right': 'nextMediaItem'
   341 media.view.SelectModeToggleButton = __webpack_require__( "Ffsb" );
   439 	},
   342 media.view.DeleteSelectedButton = __webpack_require__( "nD7t" );
   440 
   343 media.view.DeleteSelectedPermanentlyButton = __webpack_require__( "1lLZ" );
   441 	initialize: function() {
   344 
   442 		Frame.prototype.initialize.apply( this, arguments );
   345 
   443 
   346 /***/ }),
   444 		_.defaults( this.options, {
   347 
   445 			modal: true,
   348 /***/ "OMfl":
   446 			state: 'edit-attachment'
   349 /***/ (function(module, exports) {
   447 		});
   350 
   448 
   351 /**
   449 		this.controller = this.options.controller;
   352  * wp.media.view.MediaFrame.Manage.Router
   450 		this.gridRouter = this.controller.gridRouter;
   353  *
   451 		this.library = this.options.library;
   354  * A router for handling the browser history and application state.
   452 
   355  *
   453 		if ( this.options.model ) {
   356  * @memberOf wp.media.view.MediaFrame.Manage
   454 			this.model = this.options.model;
   357  *
   455 		}
   358  * @class
   456 
   359  * @augments Backbone.Router
   457 		this.bindHandlers();
   360  */
   458 		this.createStates();
   361 var Router = Backbone.Router.extend(/** @lends wp.media.view.MediaFrame.Manage.Router.prototype */{
   459 		this.createModal();
   362 	routes: {
   460 
   363 		'upload.php?item=:slug&mode=edit': 'editItem',
   461 		this.title.mode( 'default' );
   364 		'upload.php?item=:slug':           'showItem',
   462 		this.toggleNav();
   365 		'upload.php?search=:query':        'search',
   463 	},
   366 		'upload.php':                      'reset'
   464 
   367 	},
   465 	bindHandlers: function() {
   368 
   466 		// Bind default title creation.
   369 	// Map routes against the page URL.
   467 		this.on( 'title:create:default', this.createTitle, this );
   370 	baseUrl: function( url ) {
   468 
   371 		return 'upload.php' + url;
   469 		this.on( 'content:create:edit-metadata', this.editMetadataMode, this );
   372 	},
   470 		this.on( 'content:create:edit-image', this.editImageMode, this );
   373 
   471 		this.on( 'content:render:edit-image', this.editImageModeRender, this );
   374 	reset: function() {
   472 		this.on( 'refresh', this.rerender, this );
   375 		var frame = wp.media.frames.edit;
   473 		this.on( 'close', this.detach );
   376 
   474 
   377 		if ( frame ) {
   475 		this.bindModelHandlers();
   378 			frame.close();
   476 		this.listenTo( this.gridRouter, 'route:search', this.close, this );
   379 		}
   477 	},
   380 	},
   478 
   381 
   479 	bindModelHandlers: function() {
   382 	// Respond to the search route by filling the search field and triggering the input event.
   480 		// Close the modal if the attachment is deleted.
   383 	search: function( query ) {
   481 		this.listenTo( this.model, 'change:status destroy', this.close, this );
   384 		jQuery( '#media-search-input' ).val( query ).trigger( 'input' );
   482 	},
   385 	},
   483 
   386 
   484 	createModal: function() {
   387 	// Show the modal with a specific item.
   485 		// Initialize modal container view.
   388 	showItem: function( query ) {
   486 		if ( this.options.modal ) {
   389 		var media = wp.media,
   487 			this.modal = new wp.media.view.Modal({
   390 			frame = media.frames.browse,
   488 				controller:     this,
   391 			library = frame.state().get('library'),
   489 				title:          this.options.title,
   392 			item;
   490 				hasCloseButton: false
   393 
   491 			});
   394 		// Trigger the media frame to open the correct item.
   492 
   395 		item = library.findWhere( { id: parseInt( query, 10 ) } );
   493 			this.modal.on( 'open', _.bind( function () {
   396 
   494 				$( 'body' ).on( 'keydown.media-modal', _.bind( this.keyEvent, this ) );
   397 		if ( item ) {
   495 			}, this ) );
   398 			item.set( 'skipHistory', true );
   496 
   399 			frame.trigger( 'edit:attachment', item );
   497 			// Completely destroy the modal DOM element when closing it.
       
   498 			this.modal.on( 'close', _.bind( function() {
       
   499 				// Remove the keydown event.
       
   500 				$( 'body' ).off( 'keydown.media-modal' );
       
   501 				// Move focus back to the original item in the grid if possible.
       
   502 				$( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).trigger( 'focus' );
       
   503 				this.resetRoute();
       
   504 			}, this ) );
       
   505 
       
   506 			// Set this frame as the modal's content.
       
   507 			this.modal.content( this );
       
   508 			this.modal.open();
       
   509 		}
       
   510 	},
       
   511 
       
   512 	/**
       
   513 	 * Add the default states to the frame.
       
   514 	 */
       
   515 	createStates: function() {
       
   516 		this.states.add([
       
   517 			new wp.media.controller.EditAttachmentMetadata({
       
   518 				model:   this.model,
       
   519 				library: this.library
       
   520 			})
       
   521 		]);
       
   522 	},
       
   523 
       
   524 	/**
       
   525 	 * Content region rendering callback for the `edit-metadata` mode.
       
   526 	 *
       
   527 	 * @param {Object} contentRegion Basic object with a `view` property, which
       
   528 	 *                               should be set with the proper region view.
       
   529 	 */
       
   530 	editMetadataMode: function( contentRegion ) {
       
   531 		contentRegion.view = new wp.media.view.Attachment.Details.TwoColumn({
       
   532 			controller: this,
       
   533 			model:      this.model
       
   534 		});
       
   535 
       
   536 		/**
       
   537 		 * Attach a subview to display fields added via the
       
   538 		 * `attachment_fields_to_edit` filter.
       
   539 		 */
       
   540 		contentRegion.view.views.set( '.attachment-compat', new wp.media.view.AttachmentCompat({
       
   541 			controller: this,
       
   542 			model:      this.model
       
   543 		}) );
       
   544 
       
   545 		// Update browser url when navigating media details, except on load.
       
   546 		if ( this.model && ! this.model.get( 'skipHistory' ) ) {
       
   547 			this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id ) );
       
   548 		}
       
   549 	},
       
   550 
       
   551 	/**
       
   552 	 * Render the EditImage view into the frame's content region.
       
   553 	 *
       
   554 	 * @param {Object} contentRegion Basic object with a `view` property, which
       
   555 	 *                               should be set with the proper region view.
       
   556 	 */
       
   557 	editImageMode: function( contentRegion ) {
       
   558 		var editImageController = new wp.media.controller.EditImage( {
       
   559 			model: this.model,
       
   560 			frame: this
       
   561 		} );
       
   562 		// Noop some methods.
       
   563 		editImageController._toolbar = function() {};
       
   564 		editImageController._router = function() {};
       
   565 		editImageController._menu = function() {};
       
   566 
       
   567 		contentRegion.view = new wp.media.view.EditImage.Details( {
       
   568 			model: this.model,
       
   569 			frame: this,
       
   570 			controller: editImageController
       
   571 		} );
       
   572 
       
   573 		this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id + '&mode=edit' ) );
       
   574 
       
   575 	},
       
   576 
       
   577 	editImageModeRender: function( view ) {
       
   578 		view.on( 'ready', view.loadEditor );
       
   579 	},
       
   580 
       
   581 	toggleNav: function() {
       
   582 		this.$( '.left' ).prop( 'disabled', ! this.hasPrevious() );
       
   583 		this.$( '.right' ).prop( 'disabled', ! this.hasNext() );
       
   584 	},
       
   585 
       
   586 	/**
       
   587 	 * Rerender the view.
       
   588 	 */
       
   589 	rerender: function( model ) {
       
   590 		this.stopListening( this.model );
       
   591 
       
   592 		this.model = model;
       
   593 
       
   594 		this.bindModelHandlers();
       
   595 
       
   596 		// Only rerender the `content` region.
       
   597 		if ( this.content.mode() !== 'edit-metadata' ) {
       
   598 			this.content.mode( 'edit-metadata' );
   400 		} else {
   599 		} else {
   401 			item = media.attachment( query );
   600 			this.content.render();
   402 			frame.listenTo( item, 'change', function( model ) {
   601 		}
   403 				frame.stopListening( item );
   602 
   404 				frame.trigger( 'edit:attachment', model );
   603 		this.toggleNav();
   405 			} );
   604 	},
   406 			item.fetch();
   605 
   407 		}
   606 	/**
   408 	},
   607 	 * Click handler to switch to the previous media item.
   409 
   608 	 */
   410 	// Show the modal in edit mode with a specific item.
   609 	previousMediaItem: function() {
   411 	editItem: function( query ) {
   610 		if ( ! this.hasPrevious() ) {
   412 		this.showItem( query );
   611 			return;
   413 		wp.media.frames.edit.content.mode( 'edit-details' );
   612 		}
       
   613 
       
   614 		this.trigger( 'refresh', this.library.at( this.getCurrentIndex() - 1 ) );
       
   615 		// Move focus to the Previous button. When there are no more items, to the Next button.
       
   616 		this.focusNavButton( this.hasPrevious() ? '.left' : '.right' );
       
   617 	},
       
   618 
       
   619 	/**
       
   620 	 * Click handler to switch to the next media item.
       
   621 	 */
       
   622 	nextMediaItem: function() {
       
   623 		if ( ! this.hasNext() ) {
       
   624 			return;
       
   625 		}
       
   626 
       
   627 		this.trigger( 'refresh', this.library.at( this.getCurrentIndex() + 1 ) );
       
   628 		// Move focus to the Next button. When there are no more items, to the Previous button.
       
   629 		this.focusNavButton( this.hasNext() ? '.right' : '.left' );
       
   630 	},
       
   631 
       
   632 	/**
       
   633 	 * Set focus to the navigation buttons depending on the browsing direction.
       
   634 	 *
       
   635 	 * @since 5.3.0
       
   636 	 *
       
   637 	 * @param {string} which A CSS selector to target the button to focus.
       
   638 	 */
       
   639 	focusNavButton: function( which ) {
       
   640 		$( which ).trigger( 'focus' );
       
   641 	},
       
   642 
       
   643 	getCurrentIndex: function() {
       
   644 		return this.library.indexOf( this.model );
       
   645 	},
       
   646 
       
   647 	hasNext: function() {
       
   648 		return ( this.getCurrentIndex() + 1 ) < this.library.length;
       
   649 	},
       
   650 
       
   651 	hasPrevious: function() {
       
   652 		return ( this.getCurrentIndex() - 1 ) > -1;
       
   653 	},
       
   654 	/**
       
   655 	 * Respond to the keyboard events: right arrow, left arrow, except when
       
   656 	 * focus is in a textarea or input field.
       
   657 	 */
       
   658 	keyEvent: function( event ) {
       
   659 		if ( ( 'INPUT' === event.target.nodeName || 'TEXTAREA' === event.target.nodeName ) && ! event.target.disabled ) {
       
   660 			return;
       
   661 		}
       
   662 
       
   663 		// The right arrow key.
       
   664 		if ( 39 === event.keyCode ) {
       
   665 			this.nextMediaItem();
       
   666 		}
       
   667 		// The left arrow key.
       
   668 		if ( 37 === event.keyCode ) {
       
   669 			this.previousMediaItem();
       
   670 		}
       
   671 	},
       
   672 
       
   673 	resetRoute: function() {
       
   674 		var searchTerm = this.controller.browserView.toolbar.get( 'search' ).$el.val(),
       
   675 			url = '' !== searchTerm ? '?search=' + searchTerm : '';
       
   676 		this.gridRouter.navigate( this.gridRouter.baseUrl( url ), { replace: true } );
   414 	}
   677 	}
   415 });
   678 });
   416 
   679 
   417 module.exports = Router;
   680 module.exports = EditAttachments;
   418 
   681 
   419 
   682 
   420 /***/ }),
   683 /***/ }),
   421 
   684 
   422 /***/ "ZJBI":
   685 /***/ 4817:
   423 /***/ (function(module, exports) {
   686 /***/ (function(module) {
   424 
       
   425 var l10n = wp.media.view.l10n,
       
   426 	EditAttachmentMetadata;
       
   427 
       
   428 /**
       
   429  * wp.media.controller.EditAttachmentMetadata
       
   430  *
       
   431  * A state for editing an attachment's metadata.
       
   432  *
       
   433  * @memberOf wp.media.controller
       
   434  *
       
   435  * @class
       
   436  * @augments wp.media.controller.State
       
   437  * @augments Backbone.Model
       
   438  */
       
   439 EditAttachmentMetadata = wp.media.controller.State.extend(/** @lends wp.media.controller.EditAttachmentMetadata.prototype */{
       
   440 	defaults: {
       
   441 		id:      'edit-attachment',
       
   442 		// Title string passed to the frame's title region view.
       
   443 		title:   l10n.attachmentDetails,
       
   444 		// Region mode defaults.
       
   445 		content: 'edit-metadata',
       
   446 		menu:    false,
       
   447 		toolbar: false,
       
   448 		router:  false
       
   449 	}
       
   450 });
       
   451 
       
   452 module.exports = EditAttachmentMetadata;
       
   453 
       
   454 
       
   455 /***/ }),
       
   456 
       
   457 /***/ "lH8y":
       
   458 /***/ (function(module, exports) {
       
   459 
   687 
   460 var MediaFrame = wp.media.view.MediaFrame,
   688 var MediaFrame = wp.media.view.MediaFrame,
   461 	Library = wp.media.controller.Library,
   689 	Library = wp.media.controller.Library,
   462 
   690 
   463 	$ = Backbone.$,
   691 	$ = Backbone.$,
   744 });
   972 });
   745 
   973 
   746 module.exports = Manage;
   974 module.exports = Manage;
   747 
   975 
   748 
   976 
   749 /***/ }),
   977 /***/ })
   750 
   978 
   751 /***/ "nD7t":
   979 /******/ 	});
   752 /***/ (function(module, exports) {
   980 /************************************************************************/
   753 
   981 /******/ 	// The module cache
   754 var Button = wp.media.view.Button,
   982 /******/ 	var __webpack_module_cache__ = {};
   755 	l10n = wp.media.view.l10n,
   983 /******/ 	
   756 	DeleteSelected;
   984 /******/ 	// The require function
   757 
   985 /******/ 	function __webpack_require__(moduleId) {
       
   986 /******/ 		// Check if module is in cache
       
   987 /******/ 		var cachedModule = __webpack_module_cache__[moduleId];
       
   988 /******/ 		if (cachedModule !== undefined) {
       
   989 /******/ 			return cachedModule.exports;
       
   990 /******/ 		}
       
   991 /******/ 		// Create a new module (and put it into the cache)
       
   992 /******/ 		var module = __webpack_module_cache__[moduleId] = {
       
   993 /******/ 			// no module.id needed
       
   994 /******/ 			// no module.loaded needed
       
   995 /******/ 			exports: {}
       
   996 /******/ 		};
       
   997 /******/ 	
       
   998 /******/ 		// Execute the module function
       
   999 /******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
       
  1000 /******/ 	
       
  1001 /******/ 		// Return the exports of the module
       
  1002 /******/ 		return module.exports;
       
  1003 /******/ 	}
       
  1004 /******/ 	
       
  1005 /************************************************************************/
       
  1006 var __webpack_exports__ = {};
       
  1007 // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
       
  1008 !function() {
   758 /**
  1009 /**
   759  * wp.media.view.DeleteSelectedButton
  1010  * @output wp-includes/js/media-grid.js
   760  *
       
   761  * A button that handles bulk Delete/Trash logic
       
   762  *
       
   763  * @memberOf wp.media.view
       
   764  *
       
   765  * @class
       
   766  * @augments wp.media.view.Button
       
   767  * @augments wp.media.View
       
   768  * @augments wp.Backbone.View
       
   769  * @augments Backbone.View
       
   770  */
  1011  */
   771 DeleteSelected = Button.extend(/** @lends wp.media.view.DeleteSelectedButton.prototype */{
  1012 
   772 	initialize: function() {
  1013 var media = wp.media;
   773 		Button.prototype.initialize.apply( this, arguments );
  1014 
   774 		if ( this.options.filters ) {
  1015 media.controller.EditAttachmentMetadata = __webpack_require__( 5817 );
   775 			this.options.filters.model.on( 'change', this.filterChange, this );
  1016 media.view.MediaFrame.Manage = __webpack_require__( 4817 );
   776 		}
  1017 media.view.Attachment.Details.TwoColumn = __webpack_require__( 7433 );
   777 		this.controller.on( 'selection:toggle', this.toggleDisabled, this );
  1018 media.view.MediaFrame.Manage.Router = __webpack_require__( 9525 );
   778 		this.controller.on( 'select:activate', this.toggleDisabled, this );
  1019 media.view.EditImage.Details = __webpack_require__( 9157 );
   779 	},
  1020 media.view.MediaFrame.EditAttachments = __webpack_require__( 5169 );
   780 
  1021 media.view.SelectModeToggleButton = __webpack_require__( 6767 );
   781 	filterChange: function( model ) {
  1022 media.view.DeleteSelectedButton = __webpack_require__( 471 );
   782 		if ( 'trash' === model.get( 'status' ) ) {
  1023 media.view.DeleteSelectedPermanentlyButton = __webpack_require__( 5562 );
   783 			this.model.set( 'text', l10n.restoreSelected );
  1024 
   784 		} else if ( wp.media.view.settings.mediaTrash ) {
  1025 }();
   785 			this.model.set( 'text', l10n.trashSelected );
  1026 /******/ })()
   786 		} else {
  1027 ;
   787 			this.model.set( 'text', l10n.deletePermanently );
       
   788 		}
       
   789 	},
       
   790 
       
   791 	toggleDisabled: function() {
       
   792 		this.model.set( 'disabled', ! this.controller.state().get( 'selection' ).length );
       
   793 	},
       
   794 
       
   795 	render: function() {
       
   796 		Button.prototype.render.apply( this, arguments );
       
   797 		if ( this.controller.isModeActive( 'select' ) ) {
       
   798 			this.$el.addClass( 'delete-selected-button' );
       
   799 		} else {
       
   800 			this.$el.addClass( 'delete-selected-button hidden' );
       
   801 		}
       
   802 		this.toggleDisabled();
       
   803 		return this;
       
   804 	}
       
   805 });
       
   806 
       
   807 module.exports = DeleteSelected;
       
   808 
       
   809 
       
   810 /***/ }),
       
   811 
       
   812 /***/ "wQX5":
       
   813 /***/ (function(module, exports) {
       
   814 
       
   815 var Frame = wp.media.view.Frame,
       
   816 	MediaFrame = wp.media.view.MediaFrame,
       
   817 
       
   818 	$ = jQuery,
       
   819 	EditAttachments;
       
   820 
       
   821 /**
       
   822  * wp.media.view.MediaFrame.EditAttachments
       
   823  *
       
   824  * A frame for editing the details of a specific media item.
       
   825  *
       
   826  * Opens in a modal by default.
       
   827  *
       
   828  * Requires an attachment model to be passed in the options hash under `model`.
       
   829  *
       
   830  * @memberOf wp.media.view.MediaFrame
       
   831  *
       
   832  * @class
       
   833  * @augments wp.media.view.Frame
       
   834  * @augments wp.media.View
       
   835  * @augments wp.Backbone.View
       
   836  * @augments Backbone.View
       
   837  * @mixes wp.media.controller.StateMachine
       
   838  */
       
   839 EditAttachments = MediaFrame.extend(/** @lends wp.media.view.MediaFrame.EditAttachments.prototype */{
       
   840 
       
   841 	className: 'edit-attachment-frame',
       
   842 	template:  wp.template( 'edit-attachment-frame' ),
       
   843 	regions:   [ 'title', 'content' ],
       
   844 
       
   845 	events: {
       
   846 		'click .left':  'previousMediaItem',
       
   847 		'click .right': 'nextMediaItem'
       
   848 	},
       
   849 
       
   850 	initialize: function() {
       
   851 		Frame.prototype.initialize.apply( this, arguments );
       
   852 
       
   853 		_.defaults( this.options, {
       
   854 			modal: true,
       
   855 			state: 'edit-attachment'
       
   856 		});
       
   857 
       
   858 		this.controller = this.options.controller;
       
   859 		this.gridRouter = this.controller.gridRouter;
       
   860 		this.library = this.options.library;
       
   861 
       
   862 		if ( this.options.model ) {
       
   863 			this.model = this.options.model;
       
   864 		}
       
   865 
       
   866 		this.bindHandlers();
       
   867 		this.createStates();
       
   868 		this.createModal();
       
   869 
       
   870 		this.title.mode( 'default' );
       
   871 		this.toggleNav();
       
   872 	},
       
   873 
       
   874 	bindHandlers: function() {
       
   875 		// Bind default title creation.
       
   876 		this.on( 'title:create:default', this.createTitle, this );
       
   877 
       
   878 		this.on( 'content:create:edit-metadata', this.editMetadataMode, this );
       
   879 		this.on( 'content:create:edit-image', this.editImageMode, this );
       
   880 		this.on( 'content:render:edit-image', this.editImageModeRender, this );
       
   881 		this.on( 'refresh', this.rerender, this );
       
   882 		this.on( 'close', this.detach );
       
   883 
       
   884 		this.bindModelHandlers();
       
   885 		this.listenTo( this.gridRouter, 'route:search', this.close, this );
       
   886 	},
       
   887 
       
   888 	bindModelHandlers: function() {
       
   889 		// Close the modal if the attachment is deleted.
       
   890 		this.listenTo( this.model, 'change:status destroy', this.close, this );
       
   891 	},
       
   892 
       
   893 	createModal: function() {
       
   894 		// Initialize modal container view.
       
   895 		if ( this.options.modal ) {
       
   896 			this.modal = new wp.media.view.Modal({
       
   897 				controller:     this,
       
   898 				title:          this.options.title,
       
   899 				hasCloseButton: false
       
   900 			});
       
   901 
       
   902 			this.modal.on( 'open', _.bind( function () {
       
   903 				$( 'body' ).on( 'keydown.media-modal', _.bind( this.keyEvent, this ) );
       
   904 			}, this ) );
       
   905 
       
   906 			// Completely destroy the modal DOM element when closing it.
       
   907 			this.modal.on( 'close', _.bind( function() {
       
   908 				// Remove the keydown event.
       
   909 				$( 'body' ).off( 'keydown.media-modal' );
       
   910 				// Move focus back to the original item in the grid if possible.
       
   911 				$( 'li.attachment[data-id="' + this.model.get( 'id' ) +'"]' ).trigger( 'focus' );
       
   912 				this.resetRoute();
       
   913 			}, this ) );
       
   914 
       
   915 			// Set this frame as the modal's content.
       
   916 			this.modal.content( this );
       
   917 			this.modal.open();
       
   918 		}
       
   919 	},
       
   920 
       
   921 	/**
       
   922 	 * Add the default states to the frame.
       
   923 	 */
       
   924 	createStates: function() {
       
   925 		this.states.add([
       
   926 			new wp.media.controller.EditAttachmentMetadata({
       
   927 				model:   this.model,
       
   928 				library: this.library
       
   929 			})
       
   930 		]);
       
   931 	},
       
   932 
       
   933 	/**
       
   934 	 * Content region rendering callback for the `edit-metadata` mode.
       
   935 	 *
       
   936 	 * @param {Object} contentRegion Basic object with a `view` property, which
       
   937 	 *                               should be set with the proper region view.
       
   938 	 */
       
   939 	editMetadataMode: function( contentRegion ) {
       
   940 		contentRegion.view = new wp.media.view.Attachment.Details.TwoColumn({
       
   941 			controller: this,
       
   942 			model:      this.model
       
   943 		});
       
   944 
       
   945 		/**
       
   946 		 * Attach a subview to display fields added via the
       
   947 		 * `attachment_fields_to_edit` filter.
       
   948 		 */
       
   949 		contentRegion.view.views.set( '.attachment-compat', new wp.media.view.AttachmentCompat({
       
   950 			controller: this,
       
   951 			model:      this.model
       
   952 		}) );
       
   953 
       
   954 		// Update browser url when navigating media details, except on load.
       
   955 		if ( this.model && ! this.model.get( 'skipHistory' ) ) {
       
   956 			this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id ) );
       
   957 		}
       
   958 	},
       
   959 
       
   960 	/**
       
   961 	 * Render the EditImage view into the frame's content region.
       
   962 	 *
       
   963 	 * @param {Object} contentRegion Basic object with a `view` property, which
       
   964 	 *                               should be set with the proper region view.
       
   965 	 */
       
   966 	editImageMode: function( contentRegion ) {
       
   967 		var editImageController = new wp.media.controller.EditImage( {
       
   968 			model: this.model,
       
   969 			frame: this
       
   970 		} );
       
   971 		// Noop some methods.
       
   972 		editImageController._toolbar = function() {};
       
   973 		editImageController._router = function() {};
       
   974 		editImageController._menu = function() {};
       
   975 
       
   976 		contentRegion.view = new wp.media.view.EditImage.Details( {
       
   977 			model: this.model,
       
   978 			frame: this,
       
   979 			controller: editImageController
       
   980 		} );
       
   981 
       
   982 		this.gridRouter.navigate( this.gridRouter.baseUrl( '?item=' + this.model.id + '&mode=edit' ) );
       
   983 
       
   984 	},
       
   985 
       
   986 	editImageModeRender: function( view ) {
       
   987 		view.on( 'ready', view.loadEditor );
       
   988 	},
       
   989 
       
   990 	toggleNav: function() {
       
   991 		this.$( '.left' ).prop( 'disabled', ! this.hasPrevious() );
       
   992 		this.$( '.right' ).prop( 'disabled', ! this.hasNext() );
       
   993 	},
       
   994 
       
   995 	/**
       
   996 	 * Rerender the view.
       
   997 	 */
       
   998 	rerender: function( model ) {
       
   999 		this.stopListening( this.model );
       
  1000 
       
  1001 		this.model = model;
       
  1002 
       
  1003 		this.bindModelHandlers();
       
  1004 
       
  1005 		// Only rerender the `content` region.
       
  1006 		if ( this.content.mode() !== 'edit-metadata' ) {
       
  1007 			this.content.mode( 'edit-metadata' );
       
  1008 		} else {
       
  1009 			this.content.render();
       
  1010 		}
       
  1011 
       
  1012 		this.toggleNav();
       
  1013 	},
       
  1014 
       
  1015 	/**
       
  1016 	 * Click handler to switch to the previous media item.
       
  1017 	 */
       
  1018 	previousMediaItem: function() {
       
  1019 		if ( ! this.hasPrevious() ) {
       
  1020 			return;
       
  1021 		}
       
  1022 
       
  1023 		this.trigger( 'refresh', this.library.at( this.getCurrentIndex() - 1 ) );
       
  1024 		// Move focus to the Previous button. When there are no more items, to the Next button.
       
  1025 		this.focusNavButton( this.hasPrevious() ? '.left' : '.right' );
       
  1026 	},
       
  1027 
       
  1028 	/**
       
  1029 	 * Click handler to switch to the next media item.
       
  1030 	 */
       
  1031 	nextMediaItem: function() {
       
  1032 		if ( ! this.hasNext() ) {
       
  1033 			return;
       
  1034 		}
       
  1035 
       
  1036 		this.trigger( 'refresh', this.library.at( this.getCurrentIndex() + 1 ) );
       
  1037 		// Move focus to the Next button. When there are no more items, to the Previous button.
       
  1038 		this.focusNavButton( this.hasNext() ? '.right' : '.left' );
       
  1039 	},
       
  1040 
       
  1041 	/**
       
  1042 	 * Set focus to the navigation buttons depending on the browsing direction.
       
  1043 	 *
       
  1044 	 * @since 5.3.0
       
  1045 	 *
       
  1046 	 * @param {string} which A CSS selector to target the button to focus.
       
  1047 	 */
       
  1048 	focusNavButton: function( which ) {
       
  1049 		$( which ).trigger( 'focus' );
       
  1050 	},
       
  1051 
       
  1052 	getCurrentIndex: function() {
       
  1053 		return this.library.indexOf( this.model );
       
  1054 	},
       
  1055 
       
  1056 	hasNext: function() {
       
  1057 		return ( this.getCurrentIndex() + 1 ) < this.library.length;
       
  1058 	},
       
  1059 
       
  1060 	hasPrevious: function() {
       
  1061 		return ( this.getCurrentIndex() - 1 ) > -1;
       
  1062 	},
       
  1063 	/**
       
  1064 	 * Respond to the keyboard events: right arrow, left arrow, except when
       
  1065 	 * focus is in a textarea or input field.
       
  1066 	 */
       
  1067 	keyEvent: function( event ) {
       
  1068 		if ( ( 'INPUT' === event.target.nodeName || 'TEXTAREA' === event.target.nodeName ) && ! ( event.target.readOnly || event.target.disabled ) ) {
       
  1069 			return;
       
  1070 		}
       
  1071 
       
  1072 		// The right arrow key.
       
  1073 		if ( 39 === event.keyCode ) {
       
  1074 			this.nextMediaItem();
       
  1075 		}
       
  1076 		// The left arrow key.
       
  1077 		if ( 37 === event.keyCode ) {
       
  1078 			this.previousMediaItem();
       
  1079 		}
       
  1080 	},
       
  1081 
       
  1082 	resetRoute: function() {
       
  1083 		var searchTerm = this.controller.browserView.toolbar.get( 'search' ).$el.val(),
       
  1084 			url = '' !== searchTerm ? '?search=' + searchTerm : '';
       
  1085 		this.gridRouter.navigate( this.gridRouter.baseUrl( url ), { replace: true } );
       
  1086 	}
       
  1087 });
       
  1088 
       
  1089 module.exports = EditAttachments;
       
  1090 
       
  1091 
       
  1092 /***/ })
       
  1093 
       
  1094 /******/ });