Commit Graph

58 Commits

Author SHA1 Message Date
Daryl Koopersmith f42b826898 Media: Show an inline uploader when the media library is empty.
Merges most of `wp.media.controller.Upload` into `wp.media.controller.Library`, so we always create an inline uploader instead of an attachments browser if the state's `library` is empty.

props rzen, fixes #22323, see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22363 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-05 02:43:47 +00:00
Daryl Koopersmith 737ed62a1c Streamlining media, part I.
The main goal here is to rearrange the media components in a modularized structure to support more linear workflows. This is that structure using the pre-existing workflows, which will be improved over the course of the next few commits.

This leaves a few pieces a bit rough around the edges: namely gallery editing and selecting a featured image.

The fine print follows.

----

'''Styles'''
* Tightened padding around the modal to optimize for a smaller default screen size.
* Added a light dashed line surrounding the modal to provide a subtle cue for the persistent dropzone (which is evolving into a power user feature since we now have a dedicated `upload` state).
* Add a size for `hero` buttons.
* Remove transitions from frame subviews (e.g. menu, content, sidebar, toolbar).

----

'''Code'''

`wp.media.controller.StateManager`
* Don't fire `activate` and `deactivate` if attempting to switch to the current state.

`wp.media.controller.State`
* Add a base state class to bind default methods (as not all states will inherit from the `Library` state).
* On `activate`, fire `activate()`, `menu()`, `content()`, `sidebar()`, and `toolbar()`.
* The menu view is often a shared object (as its most common use case is switching between states). Assign the view to the state's `menu` attribute.
* `menu()` automatically fetches the state's `menu` attribute, attaches the menu view to the frame, and attempts to select a menu item that matches the state's `id`.

`wp.media.controller.Library`
* Now inherits from `wp.media.controller.State`.

`wp.media.controller.Upload`
* A new state to improve the upload experience.
* Displays a large dropzone when empty (a `UploaderInline` view).
* When attachments are uploaded, displays management interface (a `library` state restricted to attachments uploaded during the current session).

`wp.media.view.Frame`
* In `menu()`, `content()`, `sidebar()`, and `toolbar()`, only change the view if it differs from the current view. Also, ensure `hide-*` classes are properly removed.
*

`wp.media.view.PriorityList`
* A new container view used to sort and render child views by the `priority` property.
* Used by `wp.media.view.Sidebar` and `wp.media.view.Menu`.
* Next step: Use two instances to power `wp.media.view.Toolbar`.

`wp.media.view.Menu` and `wp.media.view.MenuItem`
* A new `PriorityList` view that renders a list of views used to switch between states.
* `MenuItem` instances have `id` attributes that are tied directly to states.
* Separators can be added as plain `Backbone.View` instances with the `separator` class.
* Supports any type of `Backbone.View`.

`media.view.Menu.Landing`
* The landing menu for the 'insert media' workflow.
* Includes an inactive link to an "Embed from URL" state.
* Next steps: only use in select cases to allot for other workflows (such as featured images).

`wp.media.view.AttachmentsBrowser`
* A container to render an `Attachments` view with accompanying UI controls (similar to what the `Attachments` view was when it contained the `$list` property).
* Currently only renders a `Search` view as a control.
* Next steps: Add optional view counts (e.g. "21 images"), upload buttons, and collection filter UI.

`wp.media.view.Attachments`
* If the `Attachments` scroll buffer is not filled with `Attachment` views, continue loading more attachments.
* Use `this.model` instead of `this.controller.state()` to allow `Attachments` views to have differing `edge` and `gutter` properties.
* Add `edge()`, a method used to calculate the optimal dimensions for an attachment based on the current width of the `Attachments` container element.
* `edge()` is currently only enabled on resize, as the relative positioning and CSS transforms used to center thumbnails are suboptimal when coupled with frequent resizing.
* Next steps: For infinite scroll performance improvements, look into absolutely positioning attachment views and paging groups of attachment views.

`wp.media.view.UploaderWindow`
* Now generates a `$browser` element as the browse button (instead of a full `UploaderInline` view). Using a portable browse button prevents us from having to create a new `wp.Uploader` instance every time we want access to a browse button.

`wp.media.view.UploaderInline`
* No longer directly linked to the `UploaderWindow` view or its `wp.Uploader` instance.
* Used as the default `upload` state view.

`wp.media.view.Selection`
* An interactive representation of the selected `Attachments`.
* Based on the improved workflows, this is likely overkill. For simplicity's sake, will probably remove this in favor of `SelectionPreview`.

----

see #21390.



git-svn-id: https://develop.svn.wordpress.org/trunk@22362 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-04 22:59:12 +00:00
Daryl Koopersmith a8b411b563 Media: Update the gallery "add images" state. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22356 602fd350-edb4-49c9-b593-d223f7449a82
2012-11-02 01:20:01 +00:00
Daryl Koopersmith 794c7f6b1c Media: Update gallery editing to work with the new frame view. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22348 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-31 21:43:59 +00:00
Daryl Koopersmith 9703b3a86f Media JS: When editing a gallery, prevent attachments from being selected as they are removed. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22344 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-31 20:51:34 +00:00
Daryl Koopersmith 90888aaebd Remove dead gallery settings code. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22342 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-31 20:00:39 +00:00
Daryl Koopersmith 791d93553a Make gallery columns fallback a string, as the accepted values are strings. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22341 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-31 20:00:02 +00:00
Daryl Koopersmith 3a64c92cf1 Add gallery settings to the media modal.
* Abstracts `wp.media.view.AttachmentDisplaySettings` into `wp.media.view.Settings` for managing lists of settings with button groups and select boxes. Settings can optionally be tied to a user setting (i.e. using `getUserSetting`).
* Adds `wp.media.view.Settings.AttachmentDisplay`.
* Adds `wp.media.view.Settings.Gallery`.

see #21390, #21815.


git-svn-id: https://develop.svn.wordpress.org/trunk@22340 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-31 19:22:25 +00:00
Daryl Koopersmith 61ad4ebfa2 Media JS: Several improvements to the Attachment views.
* Bind Attachment details updates to the Attachments initialize method.
* Improve Attachment view unbinding.
* Re-render Attachment views when titles and captions are updated.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22339 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-30 23:59:57 +00:00
Daryl Koopersmith b5652fb180 Media JS: Properly fire the Attachment view details method on render. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22338 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-30 23:41:13 +00:00
Daryl Koopersmith 6deb5064ee Media JS: Properly build detail views when the selection's single model changes. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22337 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-30 23:36:38 +00:00
Daryl Koopersmith ee6bda8ddd Media JS: Improve handling of single attachments in selections.
* Adds `wp.media.model.Selection.single()` to specify a single item used in a multi-item selection.
* Fixes a bug where the `details` class would not be removed when "Clear Selection" was clicked.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22335 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-30 23:15:16 +00:00
Daryl Koopersmith 66259023dd Media JS: Remove unused Attachment view events. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22333 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-30 21:15:46 +00:00
Daryl Koopersmith 59c70a3061 Improve selection UI/behavior in the media modal.
* Moves handling which models are in the selection into the `Library` state.
* Adds highlight for the last-selected view in a multi-view state.
* A view must be the last-selected view before it can be deselected.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22332 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-30 21:09:45 +00:00
Daryl Koopersmith 3ca8808c3b Add dynamic attachment view sizing. Removes the attachment view zooming in the process. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22324 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-29 18:05:03 +00:00
Daryl Koopersmith bc29728df2 Add attachment details to the media sidebar.
* Also moves most of the `Frame` view's `createSelection` method to a real `Selection` model (which inherits from the `Attachments` model).
* Properly assigns the library within the `Gallery` state, allowing for the `Gallery` state to inherit from the `Library` state.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22323 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-29 15:13:02 +00:00
Daryl Koopersmith 6e387bb2db Add inline uploader UI to media modal sidebar. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22322 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-29 07:38:13 +00:00
Daryl Koopersmith 8fe5b79380 Add a sidebar to the media modal.
* Adds `wp.media.view.Sidebar`, to aid in rendering the sidebar.
* Removes the `directions` from the `Attachments` view and shifts search into a separate view (`wp.mce.view.Search`) that can be relocated at will. This also serves to simplify the `Attachments` view by removing the nested `list` and `$list` parameters.
* Show the toolbar on the featured image workflow, effectively requiring confirmation before closing the dialog.

see #21390, #21776, #21808.


git-svn-id: https://develop.svn.wordpress.org/trunk@22321 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-29 06:56:23 +00:00
Daryl Koopersmith 15c451d2f6 Give media a heart transplant.
Revises the concept of the media controller and workspace views (i.e. two central points of control) to be more granular. The main media object is now the `Frame`, which is a hybrid view and state machine.

The state machine is a collection of states, which are just generic instances of `Backbone.Model`. This circumvents the problem of juggling global parameters when changing states. Each state contains its own event loop. All events are also forwarded to the frame itself (as is the case in all model/collection relationships).

The frame view contains several regions, each of which can be overridden without harming or re-rendering the other regions. These work well when used in conjunction with the state machine events.

This removes the upload sidebar (don't worry, visible upload UI will return). Drag and drop uploading still works. The ability to upload has been abstracted into its own view (instead of being attached to the central workspace view).

Editing galleries is temporarily broken — the gallery creation and editing experiences will be unified in a future patch.

Adds events to detect dragging changes in `wp.Uploader` and adds methods to detect and leverage browser support for CSS3 transitions.

see #21390, #21809.


git-svn-id: https://develop.svn.wordpress.org/trunk@22320 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-28 23:29:17 +00:00
Daryl Koopersmith b246624b4f Correctly assign post_parent to attachments uploaded in the new media modal. fixes #22085, see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22267 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-22 17:40:06 +00:00
Daryl Koopersmith 9e8cd23bdb Add attachment display settings to the media modal.
* Add a media view for button groups.
* Add button dropdown containers.
* Add a dropdown property to the button media model.

fixes #22206, #21814, see #21390, #21813, #21598.


git-svn-id: https://develop.svn.wordpress.org/trunk@22247 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-16 19:25:17 +00:00
Daryl Koopersmith 37fe9438dd Media Modal: Attachments on the gallery page now inherit general events with the exception of click-to-select. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22183 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-11 04:04:12 +00:00
Daryl Koopersmith 56829be438 Media Modal: Only automatically select uploading attachments when in a workflow that supports multiple images.
Fixes a bug in featured images where uploading an image would force you to reopen the modal (as the modal would close on upload).

see #21390, #21776.


git-svn-id: https://develop.svn.wordpress.org/trunk@22175 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-11 00:28:01 +00:00
Daryl Koopersmith 75160e6b3d Add caption and title default values for the attachment view template. see #21390, #21807.
git-svn-id: https://develop.svn.wordpress.org/trunk@22174 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 23:55:45 +00:00
Daryl Koopersmith d27568e703 Caption editing in the media modal library.
* Adds a `describe` option to the workflow controller to support inline caption editing.
* For images, descriptions are mapped to the `caption` attribute.
* For other media items, descriptions are mapped to the `title` attribute.
* Descriptions are saved when the textarea's `change` event fires (i.e. when the textarea is blurred).

fixes #21807, see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22173 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 23:32:48 +00:00
Daryl Koopersmith 72ab49062f Media JS: More default Attachments view template values. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22161 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 10:45:01 +00:00
Daryl Koopersmith 344d0ad7c1 Media JS: Ensure the subtype key has a default set.
Prevents undefined JS errors in the attachments view template.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22160 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 10:08:43 +00:00
Daryl Koopersmith 14de8ad04a Show filenames for non-image attachments in the new media modal.
Also passes all attachment model attributes to the attachment view template by default (instead of selecting specific values).

see #21390, #21836.


git-svn-id: https://develop.svn.wordpress.org/trunk@22159 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 09:55:47 +00:00
Daryl Koopersmith 04143f286a When editing a gallery, images can now be added from the media library.
Enables the "Add images from media library" button when editing. The UX has room for improvement, but it's a start.

see #21390, #21809.


git-svn-id: https://develop.svn.wordpress.org/trunk@22157 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 09:30:22 +00:00
Daryl Koopersmith db21ce7189 Gallery editing in the media modal.
The edit button on gallery MCE views will open a new instance of the media modal. Images can be removed, uploaded, and reordered. However, the "Add images from media library" button is not yet functional.

see #21390, #21809, #21815.


git-svn-id: https://develop.svn.wordpress.org/trunk@22155 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-10 08:31:12 +00:00
Daryl Koopersmith ed281a6f6a Improve JavaScript object formatting. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22143 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-09 02:07:09 +00:00
Daryl Koopersmith f7d1953bcc On second thought, we're going to need the library-specific attachment view. see #21390, [22138].
git-svn-id: https://develop.svn.wordpress.org/trunk@22139 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-09 00:27:14 +00:00
Daryl Koopersmith b26a4d2cde Remove the attachment quick-insert button from the media modal. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@22138 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-09 00:21:52 +00:00
Daryl Koopersmith 91a3c62b3f Better thumbnail previews in the image editor.
* Images are auto-cropped, then fit to the preview on hover (with a slight delay). This is an experiment; we'll see how it turns out.
* Various style changes.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22137 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-08 23:20:04 +00:00
Daryl Koopersmith d43c390e2b Use the new media modal to insert galleries into TinyMCE and the text editor.
'''Galleries'''

* Gallery insertion from the new media modal (into TinyMCE, the text editor, etc).
* Gallery previews in TinyMCE now use the `wp.mce.views` API.
* Disables the TinyMCE `wpgallery` plugin.
* Gallery previews consist of the first image of the gallery and the appearance of a stack. This will later be fleshed out to include more images/functionality (including editing the gallery, gallery properties, and showing the number of images in the gallery).
* Multiple galleries can be added to a single post.
* The gallery MCE view provides a bridge between the `wp.shortcode` and `Attachments` representation of a gallery, which allows the existing collection to persist when a gallery is initially created (preventing a request to the server for the query).


'''Shortcodes'''

* Renames `wp.shortcode.Match` to `wp.shortcode` to better expose the shortcode constructor.
* The `wp.shortcode` constructor now accepts an object of options instead of a `wp.shortcode.regexp()` match.
* A `wp.shortcode` instance can be created from a `wp.shortcode.regexp()` match by calling `wp.shortcode.fromMatch( match )`.
* Adds `wp.shortcode.string()`, which takes a set of shortcode parameters and converts them into a string.* Renames `wp.shortcode.prototype.text()` to `wp.shortcode.prototype.string()`.
* Adds an additional capture group to `wp.shortcode.regexp()` that records whether or not the shortcode has a closing tag. This allows us to improve the accuracy of the syntax used when transforming a shortcode object back into a string.

'''Media Models'''

* Prevents media `Query` models from observing the central `Attachments.all` object when query args without corresponding filters are set (otherwise, queries quickly amass false positives).
* Adds `post__in`, `post__not_in`, and `post_parent` as acceptable JS attachment `Query` args.
* `Attachments.more()` always returns a `$.promise` object.

see #21390, #21809, #21812, #21815, #21817.


git-svn-id: https://develop.svn.wordpress.org/trunk@22120 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-05 04:23:59 +00:00
Daryl Koopersmith 866ffeb1d5 Allow galleries to be reordered by drag and drop.
An `Attachments` view now accepts a `sortable` property. Manual sorting is only enabled when the corresponding collection doesn't have a comparator.

jQuery UI sortable must be enqueued for sorting to work.

see #21390, #21809.


git-svn-id: https://develop.svn.wordpress.org/trunk@22101 602fd350-edb4-49c9-b593-d223f7449a82
2012-10-03 04:21:50 +00:00
Daryl Koopersmith 7354809132 Add quick insert buttons to attachment views in the library and remove buttons to attachment views in the gallery editor. see #21390, #21809.
git-svn-id: https://develop.svn.wordpress.org/trunk@22053 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-27 07:45:26 +00:00
Daryl Koopersmith 22b3981229 Media JS: Use a custom Attachment views for both the media library and gallery screens.
To do so, the Attachment view code had to be shifted above the Workspace view code to ensure the subview is defined (preventing errors).

Also corrects an error in `wp.media.view.Attachments.add` where it was still using the default Attachment view.

see #21390, #21809.


git-svn-id: https://develop.svn.wordpress.org/trunk@22046 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-27 06:53:54 +00:00
Daryl Koopersmith 3324270681 Media JS: Give the master Workspace view control over which Attachment view it uses. see #21390, #21807, #21809.
git-svn-id: https://develop.svn.wordpress.org/trunk@22045 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-27 06:39:12 +00:00
Daryl Koopersmith 6fff91f4d1 Media JS: Move the modal box's title from being stored in the modal view to being stored as an attribute on the workflow. Update modal titles for both the post media and featured image workflows. see #21390, #21776.
git-svn-id: https://develop.svn.wordpress.org/trunk@22044 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-27 06:20:22 +00:00
Daryl Koopersmith c6b63ec34d Automatically add any uploading media files to the group of selected files.
This also automatically adds any files uploaded on the gallery screen to that gallery.

see #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22040 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-27 05:28:37 +00:00
Daryl Koopersmith 692d806fff BUTTON.
Add a "Beta Media" button to the post editor. Currently, it is only capable of inserting images. Other attachment types and galleries need not apply... yet.

* Added `wp.media.string.image( attachment, props )` for generating an image as a string from an attachment and relevant attachment display properties.
* Properly localized the gallery workflow.
* Added `Workflow.update()`, which closes the modal, triggers an `update` event, and resets the selection.
* Added `wp.mce.media` to manage the various media workflows for editors.

see #21813, #21814, #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@22036 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-27 04:09:43 +00:00
Daryl Koopersmith 2fea9cef7e Apply localized strings to media modal. see #21390, #21808.
git-svn-id: https://develop.svn.wordpress.org/trunk@22029 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-27 01:11:04 +00:00
Daryl Koopersmith 419a03862e Media JS: Improve UX for which buttons show when inserting media into a post.
'Insert into post' is the primary action when either one item is selected, or any number of non-image items are selected. If multiple images are selected, 'Insert into post' becomes secondary, and 'Create a new gallery' takes the primary spot.

Adds a method to `get` Button views from the Toolbar. Adds a model for certain button attributes to allow size, style, and text to be easily changed.

see #21390, #21808, #21809.


git-svn-id: https://develop.svn.wordpress.org/trunk@22027 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-27 00:59:04 +00:00
Daryl Koopersmith 749fcf84f9 Limit the featured image workflow to images only.
Adds the ability to set the values used to instantiate both the Workflow's library and selection.
Renames the Workflows internal `_pending` variable to prevent conflicts with a similarly named internal `Backbone.Model` variable.

see #21390, #21776.


git-svn-id: https://develop.svn.wordpress.org/trunk@22022 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-26 21:40:02 +00:00
Daryl Koopersmith 3de3ed85fd Media JS: Prevent infinite scroll events from being unbound when Attachments views are re-rendered. see #21390.
git-svn-id: https://develop.svn.wordpress.org/trunk@21908 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-19 01:00:34 +00:00
Daryl Koopersmith 4442437bd5 The first inklings of a gallery management screen.
* Adds `view.Workspace.Library` and `view.Workspace.Gallery` as extensions of `view.Workspace` to implement the individual screens
* Shifts the toolbar logic that was library-specific from the generic `Workspace` view to `Workspace.Library`.
* Adds a toolbar to the `Gallery` view.
* 'Create a gallery' and 'Return to media library' buttons toggle between the two views.
* 'Insert gallery into post' closes the modal, but does not actually perform its namesake action.
* Note that elements can still be deselected in the gallery view. This will be fixed in a future commit.

Improvements to avoid over-eager event unbinding:
* `Modal` views now properly detach their contents before replacing them with a new element.
* Likewise, `Workspace` views detach their main content blocks when re-rendering the view.

To test the gallery workflow (which is incomplete), run the following in your browser's console:

	`wp.media({ multiple: true });`

see #21809, #21390.


git-svn-id: https://develop.svn.wordpress.org/trunk@21906 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-19 00:34:00 +00:00
Daryl Koopersmith 3d6738c786 Media JS: Improve auto-add functionality in Workspace.render(). see #21390, [21901].
git-svn-id: https://develop.svn.wordpress.org/trunk@21902 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-18 22:59:57 +00:00
Daryl Koopersmith fd40ade3fb Media JS: Improve signature for `Workspace.add()` to accept two arguments instead of an ambiguous object. see #21390, [21820], [21821].
git-svn-id: https://develop.svn.wordpress.org/trunk@21901 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-18 22:41:51 +00:00
Daryl Koopersmith 592b23f94f Allow JS Attachments models to be searchable and sortable.
Moves `wp.media.model.Query` sorting and searching to the parent `wp.media.model.Attachments`.

Query parameters are stored in `attachments.props`, which is a `Backbone.Model`, and supports `order` (`'ASC'` or `'DESC'`), `orderby` (any `Attachment` model property name), `search` (a search term), and `query` (a boolean value that ties the `Attachments` collection to the server).

`wp.media.query( args )` now returns an `Attachments` set that is mapped to a `Query` collection instead of the `Query` collection itself. This allows you to change the query arguments by updating `attachments.props` instead of fetching the mirrored arguments, changing them, and passing them to `wp.media.query()` again.

fixes #21921, see #21390, #21809.


git-svn-id: https://develop.svn.wordpress.org/trunk@21898 602fd350-edb4-49c9-b593-d223f7449a82
2012-09-18 21:42:29 +00:00