wp/wp-includes/js/media-grid.js
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    30 		router:  false
    30 		router:  false
    31 	}
    31 	}
    32 });
    32 });
    33 
    33 
    34 module.exports = EditAttachmentMetadata;
    34 module.exports = EditAttachmentMetadata;
    35 
       
    36 
       
    37 /***/ }),
       
    38 
       
    39 /***/ 2429:
       
    40 /***/ ((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 /***/ 1312:
       
   114 /***/ ((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 /***/ 5806:
       
   163 /***/ ((module) => {
       
   164 
       
   165 var Button = wp.media.view.Button,
       
   166 	DeleteSelected = wp.media.view.DeleteSelectedButton,
       
   167 	DeleteSelectedPermanently;
       
   168 
       
   169 /**
       
   170  * wp.media.view.DeleteSelectedPermanentlyButton
       
   171  *
       
   172  * When MEDIA_TRASH is true, a button that handles bulk Delete Permanently logic
       
   173  *
       
   174  * @memberOf wp.media.view
       
   175  *
       
   176  * @class
       
   177  * @augments wp.media.view.DeleteSelectedButton
       
   178  * @augments wp.media.view.Button
       
   179  * @augments wp.media.View
       
   180  * @augments wp.Backbone.View
       
   181  * @augments Backbone.View
       
   182  */
       
   183 DeleteSelectedPermanently = DeleteSelected.extend(/** @lends wp.media.view.DeleteSelectedPermanentlyButton.prototype */{
       
   184 	initialize: function() {
       
   185 		DeleteSelected.prototype.initialize.apply( this, arguments );
       
   186 		this.controller.on( 'select:activate', this.selectActivate, this );
       
   187 		this.controller.on( 'select:deactivate', this.selectDeactivate, this );
       
   188 	},
       
   189 
       
   190 	filterChange: function( model ) {
       
   191 		this.canShow = ( 'trash' === model.get( 'status' ) );
       
   192 	},
       
   193 
       
   194 	selectActivate: function() {
       
   195 		this.toggleDisabled();
       
   196 		this.$el.toggleClass( 'hidden', ! this.canShow );
       
   197 	},
       
   198 
       
   199 	selectDeactivate: function() {
       
   200 		this.toggleDisabled();
       
   201 		this.$el.addClass( 'hidden' );
       
   202 	},
       
   203 
       
   204 	render: function() {
       
   205 		Button.prototype.render.apply( this, arguments );
       
   206 		this.selectActivate();
       
   207 		return this;
       
   208 	}
       
   209 });
       
   210 
       
   211 module.exports = DeleteSelectedPermanently;
       
   212 
       
   213 
       
   214 /***/ }),
       
   215 
       
   216 /***/ 6606:
       
   217 /***/ ((module) => {
       
   218 
       
   219 var Button = wp.media.view.Button,
       
   220 	l10n = wp.media.view.l10n,
       
   221 	DeleteSelected;
       
   222 
       
   223 /**
       
   224  * wp.media.view.DeleteSelectedButton
       
   225  *
       
   226  * A button that handles bulk Delete/Trash logic
       
   227  *
       
   228  * @memberOf wp.media.view
       
   229  *
       
   230  * @class
       
   231  * @augments wp.media.view.Button
       
   232  * @augments wp.media.View
       
   233  * @augments wp.Backbone.View
       
   234  * @augments Backbone.View
       
   235  */
       
   236 DeleteSelected = Button.extend(/** @lends wp.media.view.DeleteSelectedButton.prototype */{
       
   237 	initialize: function() {
       
   238 		Button.prototype.initialize.apply( this, arguments );
       
   239 		if ( this.options.filters ) {
       
   240 			this.options.filters.model.on( 'change', this.filterChange, this );
       
   241 		}
       
   242 		this.controller.on( 'selection:toggle', this.toggleDisabled, this );
       
   243 		this.controller.on( 'select:activate', this.toggleDisabled, this );
       
   244 	},
       
   245 
       
   246 	filterChange: function( model ) {
       
   247 		if ( 'trash' === model.get( 'status' ) ) {
       
   248 			this.model.set( 'text', l10n.restoreSelected );
       
   249 		} else if ( wp.media.view.settings.mediaTrash ) {
       
   250 			this.model.set( 'text', l10n.trashSelected );
       
   251 		} else {
       
   252 			this.model.set( 'text', l10n.deletePermanently );
       
   253 		}
       
   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 	}
       
   270 });
       
   271 
       
   272 module.exports = DeleteSelected;
       
   273 
    35 
   274 
    36 
   275 /***/ }),
    37 /***/ }),
   276 
    38 
   277 /***/ 682:
    39 /***/ 682:
   356 module.exports = SelectModeToggle;
   118 module.exports = SelectModeToggle;
   357 
   119 
   358 
   120 
   359 /***/ }),
   121 /***/ }),
   360 
   122 
   361 /***/ 8521:
       
   362 /***/ ((module) => {
       
   363 
       
   364 var View = wp.media.View,
       
   365 	EditImage = wp.media.view.EditImage,
       
   366 	Details;
       
   367 
       
   368 /**
       
   369  * wp.media.view.EditImage.Details
       
   370  *
       
   371  * @memberOf wp.media.view.EditImage
       
   372  *
       
   373  * @class
       
   374  * @augments wp.media.view.EditImage
       
   375  * @augments wp.media.View
       
   376  * @augments wp.Backbone.View
       
   377  * @augments Backbone.View
       
   378  */
       
   379 Details = EditImage.extend(/** @lends wp.media.view.EditImage.Details.prototype */{
       
   380 	initialize: function( options ) {
       
   381 		this.editor = window.imageEdit;
       
   382 		this.frame = options.frame;
       
   383 		this.controller = options.controller;
       
   384 		View.prototype.initialize.apply( this, arguments );
       
   385 	},
       
   386 
       
   387 	back: function() {
       
   388 		this.frame.content.mode( 'edit-metadata' );
       
   389 	},
       
   390 
       
   391 	save: function() {
       
   392 		this.model.fetch().done( _.bind( function() {
       
   393 			this.frame.content.mode( 'edit-metadata' );
       
   394 		}, this ) );
       
   395 	}
       
   396 });
       
   397 
       
   398 module.exports = Details;
       
   399 
       
   400 
       
   401 /***/ }),
       
   402 
       
   403 /***/ 1003:
   123 /***/ 1003:
   404 /***/ ((module) => {
   124 /***/ ((module) => {
   405 
   125 
   406 var Frame = wp.media.view.Frame,
   126 var Frame = wp.media.view.Frame,
   407 	MediaFrame = wp.media.view.MediaFrame,
   127 	MediaFrame = wp.media.view.MediaFrame,
   676 		this.gridRouter.navigate( this.gridRouter.baseUrl( url ), { replace: true } );
   396 		this.gridRouter.navigate( this.gridRouter.baseUrl( url ), { replace: true } );
   677 	}
   397 	}
   678 });
   398 });
   679 
   399 
   680 module.exports = EditAttachments;
   400 module.exports = EditAttachments;
       
   401 
       
   402 
       
   403 /***/ }),
       
   404 
       
   405 /***/ 1312:
       
   406 /***/ ((module) => {
       
   407 
       
   408 var Details = wp.media.view.Attachment.Details,
       
   409 	TwoColumn;
       
   410 
       
   411 /**
       
   412  * wp.media.view.Attachment.Details.TwoColumn
       
   413  *
       
   414  * A similar view to media.view.Attachment.Details
       
   415  * for use in the Edit Attachment modal.
       
   416  *
       
   417  * @memberOf wp.media.view.Attachment.Details
       
   418  *
       
   419  * @class
       
   420  * @augments wp.media.view.Attachment.Details
       
   421  * @augments wp.media.view.Attachment
       
   422  * @augments wp.media.View
       
   423  * @augments wp.Backbone.View
       
   424  * @augments Backbone.View
       
   425  */
       
   426 TwoColumn = Details.extend(/** @lends wp.media.view.Attachment.Details.TwoColumn.prototype */{
       
   427 	template: wp.template( 'attachment-details-two-column' ),
       
   428 
       
   429 	initialize: function() {
       
   430 		this.controller.on( 'content:activate:edit-details', _.bind( this.editAttachment, this ) );
       
   431 
       
   432 		Details.prototype.initialize.apply( this, arguments );
       
   433 	},
       
   434 
       
   435 	editAttachment: function( event ) {
       
   436 		if ( event ) {
       
   437 			event.preventDefault();
       
   438 		}
       
   439 		this.controller.content.mode( 'edit-image' );
       
   440 	},
       
   441 
       
   442 	/**
       
   443 	 * Noop this from parent class, doesn't apply here.
       
   444 	 */
       
   445 	toggleSelectionHandler: function() {}
       
   446 
       
   447 });
       
   448 
       
   449 module.exports = TwoColumn;
       
   450 
       
   451 
       
   452 /***/ }),
       
   453 
       
   454 /***/ 2429:
       
   455 /***/ ((module) => {
       
   456 
       
   457 /**
       
   458  * wp.media.view.MediaFrame.Manage.Router
       
   459  *
       
   460  * A router for handling the browser history and application state.
       
   461  *
       
   462  * @memberOf wp.media.view.MediaFrame.Manage
       
   463  *
       
   464  * @class
       
   465  * @augments Backbone.Router
       
   466  */
       
   467 var Router = Backbone.Router.extend(/** @lends wp.media.view.MediaFrame.Manage.Router.prototype */{
       
   468 	routes: {
       
   469 		'upload.php?item=:slug&mode=edit': 'editItem',
       
   470 		'upload.php?item=:slug':           'showItem',
       
   471 		'upload.php?search=:query':        'search',
       
   472 		'upload.php':                      'reset'
       
   473 	},
       
   474 
       
   475 	// Map routes against the page URL.
       
   476 	baseUrl: function( url ) {
       
   477 		return 'upload.php' + url;
       
   478 	},
       
   479 
       
   480 	reset: function() {
       
   481 		var frame = wp.media.frames.edit;
       
   482 
       
   483 		if ( frame ) {
       
   484 			frame.close();
       
   485 		}
       
   486 	},
       
   487 
       
   488 	// Respond to the search route by filling the search field and triggering the input event.
       
   489 	search: function( query ) {
       
   490 		jQuery( '#media-search-input' ).val( query ).trigger( 'input' );
       
   491 	},
       
   492 
       
   493 	// Show the modal with a specific item.
       
   494 	showItem: function( query ) {
       
   495 		var media = wp.media,
       
   496 			frame = media.frames.browse,
       
   497 			library = frame.state().get('library'),
       
   498 			item;
       
   499 
       
   500 		// Trigger the media frame to open the correct item.
       
   501 		item = library.findWhere( { id: parseInt( query, 10 ) } );
       
   502 
       
   503 		if ( item ) {
       
   504 			item.set( 'skipHistory', true );
       
   505 			frame.trigger( 'edit:attachment', item );
       
   506 		} else {
       
   507 			item = media.attachment( query );
       
   508 			frame.listenTo( item, 'change', function( model ) {
       
   509 				frame.stopListening( item );
       
   510 				frame.trigger( 'edit:attachment', model );
       
   511 			} );
       
   512 			item.fetch();
       
   513 		}
       
   514 	},
       
   515 
       
   516 	// Show the modal in edit mode with a specific item.
       
   517 	editItem: function( query ) {
       
   518 		this.showItem( query );
       
   519 		wp.media.frames.edit.content.mode( 'edit-details' );
       
   520 	}
       
   521 });
       
   522 
       
   523 module.exports = Router;
       
   524 
       
   525 
       
   526 /***/ }),
       
   527 
       
   528 /***/ 5806:
       
   529 /***/ ((module) => {
       
   530 
       
   531 var Button = wp.media.view.Button,
       
   532 	DeleteSelected = wp.media.view.DeleteSelectedButton,
       
   533 	DeleteSelectedPermanently;
       
   534 
       
   535 /**
       
   536  * wp.media.view.DeleteSelectedPermanentlyButton
       
   537  *
       
   538  * When MEDIA_TRASH is true, a button that handles bulk Delete Permanently logic
       
   539  *
       
   540  * @memberOf wp.media.view
       
   541  *
       
   542  * @class
       
   543  * @augments wp.media.view.DeleteSelectedButton
       
   544  * @augments wp.media.view.Button
       
   545  * @augments wp.media.View
       
   546  * @augments wp.Backbone.View
       
   547  * @augments Backbone.View
       
   548  */
       
   549 DeleteSelectedPermanently = DeleteSelected.extend(/** @lends wp.media.view.DeleteSelectedPermanentlyButton.prototype */{
       
   550 	initialize: function() {
       
   551 		DeleteSelected.prototype.initialize.apply( this, arguments );
       
   552 		this.controller.on( 'select:activate', this.selectActivate, this );
       
   553 		this.controller.on( 'select:deactivate', this.selectDeactivate, this );
       
   554 	},
       
   555 
       
   556 	filterChange: function( model ) {
       
   557 		this.canShow = ( 'trash' === model.get( 'status' ) );
       
   558 	},
       
   559 
       
   560 	selectActivate: function() {
       
   561 		this.toggleDisabled();
       
   562 		this.$el.toggleClass( 'hidden', ! this.canShow );
       
   563 	},
       
   564 
       
   565 	selectDeactivate: function() {
       
   566 		this.toggleDisabled();
       
   567 		this.$el.addClass( 'hidden' );
       
   568 	},
       
   569 
       
   570 	render: function() {
       
   571 		Button.prototype.render.apply( this, arguments );
       
   572 		this.selectActivate();
       
   573 		return this;
       
   574 	}
       
   575 });
       
   576 
       
   577 module.exports = DeleteSelectedPermanently;
       
   578 
       
   579 
       
   580 /***/ }),
       
   581 
       
   582 /***/ 6606:
       
   583 /***/ ((module) => {
       
   584 
       
   585 var Button = wp.media.view.Button,
       
   586 	l10n = wp.media.view.l10n,
       
   587 	DeleteSelected;
       
   588 
       
   589 /**
       
   590  * wp.media.view.DeleteSelectedButton
       
   591  *
       
   592  * A button that handles bulk Delete/Trash logic
       
   593  *
       
   594  * @memberOf wp.media.view
       
   595  *
       
   596  * @class
       
   597  * @augments wp.media.view.Button
       
   598  * @augments wp.media.View
       
   599  * @augments wp.Backbone.View
       
   600  * @augments Backbone.View
       
   601  */
       
   602 DeleteSelected = Button.extend(/** @lends wp.media.view.DeleteSelectedButton.prototype */{
       
   603 	initialize: function() {
       
   604 		Button.prototype.initialize.apply( this, arguments );
       
   605 		if ( this.options.filters ) {
       
   606 			this.options.filters.model.on( 'change', this.filterChange, this );
       
   607 		}
       
   608 		this.controller.on( 'selection:toggle', this.toggleDisabled, this );
       
   609 		this.controller.on( 'select:activate', this.toggleDisabled, this );
       
   610 	},
       
   611 
       
   612 	filterChange: function( model ) {
       
   613 		if ( 'trash' === model.get( 'status' ) ) {
       
   614 			this.model.set( 'text', l10n.restoreSelected );
       
   615 		} else if ( wp.media.view.settings.mediaTrash ) {
       
   616 			this.model.set( 'text', l10n.trashSelected );
       
   617 		} else {
       
   618 			this.model.set( 'text', l10n.deletePermanently );
       
   619 		}
       
   620 	},
       
   621 
       
   622 	toggleDisabled: function() {
       
   623 		this.model.set( 'disabled', ! this.controller.state().get( 'selection' ).length );
       
   624 	},
       
   625 
       
   626 	render: function() {
       
   627 		Button.prototype.render.apply( this, arguments );
       
   628 		if ( this.controller.isModeActive( 'select' ) ) {
       
   629 			this.$el.addClass( 'delete-selected-button' );
       
   630 		} else {
       
   631 			this.$el.addClass( 'delete-selected-button hidden' );
       
   632 		}
       
   633 		this.toggleDisabled();
       
   634 		return this;
       
   635 	}
       
   636 });
       
   637 
       
   638 module.exports = DeleteSelected;
   681 
   639 
   682 
   640 
   683 /***/ }),
   641 /***/ }),
   684 
   642 
   685 /***/ 8359:
   643 /***/ 8359:
   970 		}
   928 		}
   971 	}
   929 	}
   972 });
   930 });
   973 
   931 
   974 module.exports = Manage;
   932 module.exports = Manage;
       
   933 
       
   934 
       
   935 /***/ }),
       
   936 
       
   937 /***/ 8521:
       
   938 /***/ ((module) => {
       
   939 
       
   940 var View = wp.media.View,
       
   941 	EditImage = wp.media.view.EditImage,
       
   942 	Details;
       
   943 
       
   944 /**
       
   945  * wp.media.view.EditImage.Details
       
   946  *
       
   947  * @memberOf wp.media.view.EditImage
       
   948  *
       
   949  * @class
       
   950  * @augments wp.media.view.EditImage
       
   951  * @augments wp.media.View
       
   952  * @augments wp.Backbone.View
       
   953  * @augments Backbone.View
       
   954  */
       
   955 Details = EditImage.extend(/** @lends wp.media.view.EditImage.Details.prototype */{
       
   956 	initialize: function( options ) {
       
   957 		this.editor = window.imageEdit;
       
   958 		this.frame = options.frame;
       
   959 		this.controller = options.controller;
       
   960 		View.prototype.initialize.apply( this, arguments );
       
   961 	},
       
   962 
       
   963 	back: function() {
       
   964 		this.frame.content.mode( 'edit-metadata' );
       
   965 	},
       
   966 
       
   967 	save: function() {
       
   968 		this.model.fetch().done( _.bind( function() {
       
   969 			this.frame.content.mode( 'edit-metadata' );
       
   970 		}, this ) );
       
   971 	}
       
   972 });
       
   973 
       
   974 module.exports = Details;
   975 
   975 
   976 
   976 
   977 /***/ })
   977 /***/ })
   978 
   978 
   979 /******/ 	});
   979 /******/ 	});
  1001 /******/ 		// Return the exports of the module
  1001 /******/ 		// Return the exports of the module
  1002 /******/ 		return module.exports;
  1002 /******/ 		return module.exports;
  1003 /******/ 	}
  1003 /******/ 	}
  1004 /******/ 	
  1004 /******/ 	
  1005 /************************************************************************/
  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 (() => {
       
  1009 /**
  1006 /**
  1010  * @output wp-includes/js/media-grid.js
  1007  * @output wp-includes/js/media-grid.js
  1011  */
  1008  */
  1012 
  1009 
  1013 var media = wp.media;
  1010 var media = wp.media;
  1020 media.view.MediaFrame.EditAttachments = __webpack_require__( 1003 );
  1017 media.view.MediaFrame.EditAttachments = __webpack_require__( 1003 );
  1021 media.view.SelectModeToggleButton = __webpack_require__( 682 );
  1018 media.view.SelectModeToggleButton = __webpack_require__( 682 );
  1022 media.view.DeleteSelectedButton = __webpack_require__( 6606 );
  1019 media.view.DeleteSelectedButton = __webpack_require__( 6606 );
  1023 media.view.DeleteSelectedPermanentlyButton = __webpack_require__( 5806 );
  1020 media.view.DeleteSelectedPermanentlyButton = __webpack_require__( 5806 );
  1024 
  1021 
  1025 })();
       
  1026 
       
  1027 /******/ })()
  1022 /******/ })()
  1028 ;
  1023 ;