Docs: Improve JSDoc for media/views/attachment/details.js.

Props maartenleenders, boblinthorst, dfangstrom.
Fixes #47588.


git-svn-id: https://develop.svn.wordpress.org/trunk@45561 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Anton Timmermans 2019-06-22 13:01:22 +00:00
parent 183b4b6212
commit 3099359887

View File

@ -3,17 +3,6 @@ var Attachment = wp.media.view.Attachment,
$ = jQuery, $ = jQuery,
Details; Details;
/**
* wp.media.view.Attachment.Details
*
* @memberOf wp.media.view.Attachment
*
* @class
* @augments wp.media.view.Attachment
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototype */{ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototype */{
tagName: 'div', tagName: 'div',
className: 'attachment-details', className: 'attachment-details',
@ -37,6 +26,16 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp
'keydown': 'toggleSelectionHandler' 'keydown': 'toggleSelectionHandler'
}, },
/**
* Shows the details of an attachment.
*
* @since 3.5.0
*
* @constructs wp.media.view.Attachment.Details
* @augments wp.media.view.Attachment
*
* @returns {void}
*/
initialize: function() { initialize: function() {
this.options = _.defaults( this.options, { this.options = _.defaults( this.options, {
rerenderOnModelChange: false rerenderOnModelChange: false
@ -98,7 +97,16 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp
}, },
/** /**
* @param {Object} event * Deletes an attachment.
*
* Deletes an attachment after asking for confirmation. After deletion,
* keeps focus in the modal.
*
* @since 3.5.0
*
* @param {MouseEvent} event A click event.
*
* @returns {void}
*/ */
deleteAttachment: function( event ) { deleteAttachment: function( event ) {
event.preventDefault(); event.preventDefault();
@ -110,8 +118,18 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp
this.moveFocus(); this.moveFocus();
} }
}, },
/** /**
* @param {Object} event * Sets the trash state on an attachment, or destroys the model itself.
*
* If the mediaTrash setting is set to true, trashes the attachment.
* Otherwise, the model itself is destroyed.
*
* @since 3.9.0
*
* @param {MouseEvent} event A click event.
*
* @returns {void}
*/ */
trashAttachment: function( event ) { trashAttachment: function( event ) {
var library = this.controller.library, var library = this.controller.library,
@ -141,7 +159,13 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp
} }
}, },
/** /**
* @param {Object} event * Untrashes an attachment.
*
* @since 4.0.0
*
* @param {MouseEvent} event A click event.
*
* @returns {void}
*/ */
untrashAttachment: function( event ) { untrashAttachment: function( event ) {
var library = this.controller.library; var library = this.controller.library;
@ -152,8 +176,15 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp
library._requery( true ); library._requery( true );
} ); } );
}, },
/** /**
* @param {Object} event * Opens the edit page for a specific attachment.
*
* @since 3.5.0
*
* @param {MouseEvent} event A click event.
*
* @returns {void}
*/ */
editAttachment: function( event ) { editAttachment: function( event ) {
var editState = this.controller.states.get( 'edit-image' ); var editState = this.controller.states.get( 'edit-image' );
@ -166,11 +197,20 @@ Details = Attachment.extend(/** @lends wp.media.view.Attachment.Details.prototyp
this.$el.addClass('needs-refresh'); this.$el.addClass('needs-refresh');
} }
}, },
/** /**
* When reverse tabbing (shift+tab) out of the right details panel, * Triggers an event on the controller when reverse tabbing (shift+tab).
* move focus to the item that was being edited in the attachments list.
* *
* @param {Object} event * This event can be used to make sure to move the focus correctly.
*
* @since 4.0.0
*
* @fires wp.media.controller.MediaLibrary#attachment:details:shift-tab
* @fires wp.media.controller.MediaLibrary#attachment:keydown:arrow
*
* @param {KeyboardEvent} event A keyboard event.
*
* @returns {boolean|void} Returns false or undefined.
*/ */
toggleSelectionHandler: function( event ) { toggleSelectionHandler: function( event ) {
if ( 'keydown' === event.type && 9 === event.keyCode && event.shiftKey && event.target === this.$( ':tabbable' ).get( 0 ) ) { if ( 'keydown' === event.type && 9 === event.keyCode && event.shiftKey && event.target === this.$( ':tabbable' ).get( 0 ) ) {