Class: Selection

wp.media.view.Attachments. Selection


new Selection()

wp.media.view.Attachments.Selection
Source:

Extends

Methods


arrowEvent(event)

Handles events for arrow key presses. Focuses the attachment in the direction of the used arrow key if it exists.
Parameters:
Name Type Description
event KeyboardEvent The keyboard event that triggered this function.
Since:
  • 4.0.0
Inherited From:
Source:
Returns:
Type
void

attachmentFocus()

Focuses the first item in the collection.
Since:
  • 4.0.0
Inherited From:
Source:
Returns:
Type
void

bindEvents()

Listens to the resizeEvent on the window. Adjusts the amount of columns accordingly. First removes any existing event handlers to prevent duplicate listeners.
Since:
  • 4.0.0
Inherited From:
Source:
Listens to Events:
  • window:resize
Returns:
Type
void

createAttachmentView(attachment)

Creates a new view for an attachment and adds it to _viewsByCid.
Parameters:
Name Type Description
attachment wp.media.model.Attachment
Since:
  • 3.5.0
Inherited From:
Source:
Returns:
The created view.
Type
wp.media.View

dispose()

Clears any set event handlers.
Since:
  • 3.5.0
Inherited From:
Overrides:
Source:
Returns:
Type
void

initSortable()

Initializes jQuery sortable on the attachment list. Fails gracefully if jQuery sortable doesn't exist or isn't passed in the options.
Since:
  • 3.5.0
Inherited From:
Source:
Fires:
  • collection:reset
Returns:
Type
void

prepare()

Prepares view for display. Creates views for every attachment in collection if the collection is not empty, otherwise clears all views and loads more attachments.
Since:
  • 3.5.0
Inherited From:
Source:
Returns:
Type
void

ready()

Triggers the scroll function to check if we should query for additional attachments right away.
Since:
  • 3.5.0
Inherited From:
Source:
Returns:
Type
void

refreshSortable()

Disables jQuery sortable if collection has a comparator or collection.orderby equals menuOrder.
Since:
  • 3.5.0
Inherited From:
Source:
Returns:
Type
void

remove()

Inherited From:
Overrides:
Source:
Returns:
Returns itself to allow chaining.
Type
wp.media.View

restoreFocus()

Restores focus to the selected item in the collection. Moves focus back to the first selected attachment in the grid. Used when tabbing backwards from the attachment details sidebar. See media.view.AttachmentsBrowser.
Since:
  • 4.0.0
Inherited From:
Source:
Returns:
Type
void

scroll()

Handles scroll events. Shows the spinner if we're close to the bottom. Loads more attachments from server if we're {refreshThreshold} times away from the bottom.
Since:
  • 3.5.0
Inherited From:
Source:
Returns:
Type
void

setColumns()

Calculates the amount of columns. Calculates the amount of columns and sets it on the data-columns attribute of .media-frame-content.
Since:
  • 4.0.0
Inherited From:
Source:
Returns:
Type
void