Commit Graph

107 Commits

Author SHA1 Message Date
Adam Silverstein
8a23b80b56 Docs: JSDoc improvements for namespaces.
Improve JS parsing of our inline JSDocs by introducing `@namespace`, `@lends` and `@memberOf`. Helps set the way for showing our JavaScript documentation on developer.wordpress.org, see https://meta.trac.wordpress.org/ticket/3063.

* Define all used namespaces using @namespace.
* Correctly specify in which namespace each class is using @memberOf.
* Define each usage of the extend function as a prototype assignment using @lends.
* Some comment blocks were moved to correct the parsing of certain definitions. 

Props herregroen, atimmer, netweb, SergeyBiryukov.  
Fixes #41682.

Built from https://develop.svn.wordpress.org/trunk@41351


git-svn-id: http://core.svn.wordpress.org/trunk@41184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2017-09-08 18:42:49 +00:00
Drew Jaynes
5f4497f0af Docs: Fix multiple trivial typos throughout a variety of core files.
Props ottok.
Fixes #38489.

Built from https://develop.svn.wordpress.org/trunk@39051


git-svn-id: http://core.svn.wordpress.org/trunk@38993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-10-31 06:28:32 +00:00
Ella Iseulde Van Dorpe
1d92ed1c79 JSHint: don't redeclare globals listed in .jshintrc
See #33021.

Built from https://develop.svn.wordpress.org/trunk@33337


git-svn-id: http://core.svn.wordpress.org/trunk@33309 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-20 23:39:24 +00:00
Scott Taylor
c65b89be19 In wp.media.model.Attachments.filters.type(), return true earlier if type isn't set.
Props vivekbhusal.
Fixes #32746.

Built from https://develop.svn.wordpress.org/trunk@33091


git-svn-id: http://core.svn.wordpress.org/trunk@33062 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-06 15:34:26 +00:00
Scott Taylor
8854256155 Because programming is fun. After [32915], _.find() will return undefined if an empty array is passed - in that case, the function should return true.
See #32746.

Built from https://develop.svn.wordpress.org/trunk@32916


git-svn-id: http://core.svn.wordpress.org/trunk@32887 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-23 19:43:25 +00:00
Scott Taylor
15bfe75f88 When filtering media by type in wp.media.model.Attachments.filters.type(), account for the library's type being an array of full mime-types.
Fixes #32746.

Built from https://develop.svn.wordpress.org/trunk@32915


git-svn-id: http://core.svn.wordpress.org/trunk@32886 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-23 19:40:26 +00:00
Scott Taylor
5e4616039c Move the built media JS files up a directory to their previous location and naming convention. This fidgets with part of [31373] and will maintain BC for those who were loading those files directly (not using the enqueue system).
Props iseulde, ocean90.
Fixes #31912.

Built from https://develop.svn.wordpress.org/trunk@32125


git-svn-id: http://core.svn.wordpress.org/trunk@32104 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-14 15:31:28 +00:00
Scott Taylor
6cb16f7a21 Remove unused media JS files.
See #28510.

Built from https://develop.svn.wordpress.org/trunk@31405


git-svn-id: http://core.svn.wordpress.org/trunk@31386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-10 22:45:28 +00:00
Dominik Schilling
5742174ba8 Remove incorrect documentation for wp.media().
props ericlewis.
fixes #30090.
Built from https://develop.svn.wordpress.org/trunk@30556


git-svn-id: http://core.svn.wordpress.org/trunk@30545 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-24 23:12:22 +00:00
Scott Taylor
d5a9d63114 Improve wp.media documentation.
Props ericlewis.
See #28459.

Built from https://develop.svn.wordpress.org/trunk@30245


git-svn-id: http://core.svn.wordpress.org/trunk@30245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-05 19:39:22 +00:00
Scott Taylor
e3eaed1c78 Add two properties to media.model.Attachments.propmap: include and exclude, which are aliases for post__in and post__not_in.
This allows you to instantiate a library that includes and/or excludes specific attachments by passing a single ID or an array of IDs.

Example usage:
{{{
wp.media({frame: 'post', library: {include: [414, 415]}}).open()
wp.media({frame: 'post', library: {include: 414}}).open()
wp.media({frame: 'post', library: {exclude: [414, 415]}}).open()
wp.media({frame: 'post', library: {exclude: 414}}).open()
}}}

Fixes #26587.

Built from https://develop.svn.wordpress.org/trunk@29759


git-svn-id: http://core.svn.wordpress.org/trunk@29531 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-09-23 03:38:16 +00:00
Scott Taylor
a0f2fe6599 After [29507], move unreachable code from _requery() to Query.get().
Built from https://develop.svn.wordpress.org/trunk@29531


git-svn-id: http://core.svn.wordpress.org/trunk@29307 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-18 04:08:15 +00:00
Scott Taylor
4d20246173 Media Grid: $.when expects a splat. Disambiguation: change cache to refresh as the arg name for _requery().
See [29490], #29145.

Built from https://develop.svn.wordpress.org/trunk@29507


git-svn-id: http://core.svn.wordpress.org/trunk@29284 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-15 19:00:16 +00:00
Scott Taylor
571111022e Media Grid, support MEDIA_TRASH:
* Add a setting to `_wpMediaViewsL10n.settings`: `mediaTrash`
* In the attachment edit modal, properly toggle between Trash/Untrash
* In `media.view.Attachment`, add a method for `untrashAttachment`
* When creating the grid toolbar, switch the setting order of subviews so that `media.view.DeleteSelectedButton` can listen to the instance of `media.view.AttachmentFilters.All` to update the text in its UI.
* Add a new filter to `media.view.AttachmentFilters.All`, `trash`, when `settings.mediaTrash` is true
* Allow the cached queries in `Query.get()` to be flushed when race conditions exist and collections need to be refreshed. This is currently only being used when `MEDIA_TRASH` is set, to refresh the filtered/mirrored collections related to `all`, `trash`, and any already queried filter.
* Cleanup the bootstrapping of `media.view.MediaFrame.Manage`
* Allow `wp_ajax_query_attachments()` to return items from the trash when `MEDIA_TRASH` is `true`
* Allow `wp_ajax_save_attachment()` to set `post_status` when `MEDIA_TRASH` is `true`. It allows `wp_delete_post()` to be called, which will trash the attachment instead of deleting when the flag is set.

Props koop for the knowledge sharing and thought partnership.
See #29145.

Built from https://develop.svn.wordpress.org/trunk@29490


git-svn-id: http://core.svn.wordpress.org/trunk@29268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-14 18:31:19 +00:00
Scott Taylor
b7c8dee8f5 Media Grid: decouple the Grid and Edit modal frames. Next steps: we shouldn't have to reload the frame while paginating.
See #24716.

Built from https://develop.svn.wordpress.org/trunk@29076


git-svn-id: http://core.svn.wordpress.org/trunk@28862 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-10 19:39:14 +00:00
Scott Taylor
1bb24133d9 Improve inline doc descriptions in media-views.js.
Props ericlewis.
See #28459.

Built from https://develop.svn.wordpress.org/trunk@28688


git-svn-id: http://core.svn.wordpress.org/trunk@28506 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-06 14:13:17 +00:00
Helen Hou-Sandí
b5ef672c6b Grid view for the media library, first pass. This is alpha; expect imperfection. We will be iterating further.
props ericlewis, shaunandrews, wonderboymusic.
see #24716.

Built from https://develop.svn.wordpress.org/trunk@28682


git-svn-id: http://core.svn.wordpress.org/trunk@28500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-05 22:01:18 +00:00
Andrew Ozz
0df02eb8ea Add hooks to the wpeditimage tinymce plugin and to the image details portion of the media modal.
- Add wp.media.events which is intended to be a global media event bus.
- Add a post-render event to the ImageDetails view that third-party code can leverage to add subviews.
- Performance improvement for the initialization of the PostImage model.
- A bit more markup to the image details template to make it easier to add a view to the advanced options.
Props gcorne, fixes #27698
Built from https://develop.svn.wordpress.org/trunk@28095


git-svn-id: http://core.svn.wordpress.org/trunk@27926 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-04-13 04:02:15 +00:00
Andrew Ozz
b41e23efac Edit image modal: check if full size exists before trying to use it for setting aspect ratio, props gcorne, see #27366
Built from https://develop.svn.wordpress.org/trunk@27948


git-svn-id: http://core.svn.wordpress.org/trunk@27778 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-04-04 18:01:17 +00:00
Andrew Ozz
a3650b68cd Edit image modal:
- Make the calculation of the aspect ratio more robust.
- Better getting of the image height and width.
Props gcorne, see #27366
Built from https://develop.svn.wordpress.org/trunk@27942


git-svn-id: http://core.svn.wordpress.org/trunk@27772 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-04-04 01:49:15 +00:00
Andrew Ozz
a2e1d9f4c8 Edit Image modal:
- Fix issue with adding a link to an image that didn't have one previously.
- Adjust the look-and-feel of the advance options toggle so that it becomes a section heading that can be open/closed.
- Add a Custom Size option to the size drop-down that reveals fields for soft-resizing the image inserted into the post.
Props gcorne, and props sdasse for the design help, see #27366
Built from https://develop.svn.wordpress.org/trunk@27918


git-svn-id: http://core.svn.wordpress.org/trunk@27748 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-04-03 03:21:15 +00:00
Andrew Nacin
c4aab42b4b Media manager: Avoid a blank modal when an invalid image size class is set on the image.
props gcorne.
fixes #24409.

Built from https://develop.svn.wordpress.org/trunk@27687


git-svn-id: http://core.svn.wordpress.org/trunk@27526 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-24 19:01:15 +00:00
Scott Taylor
a17dd704c4 Create a new file, media-audiovideo.js, to house all of the audio and video JS code in core.
UX Changes:
* Don't add a menu item for "Add Audio|Video Source"
* In the Audio|Video Details modal, add buttons and some suggestive text for adding alternate playback sources
* Don't show "Create Audio|Video Playlist" menu items until the user has uploaded audio or video files

See #27437.


Built from https://develop.svn.wordpress.org/trunk@27608


git-svn-id: http://core.svn.wordpress.org/trunk@27451 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-19 05:31:15 +00:00
Scott Taylor
608177d39b In media.model.PostMedia, for these 2 scenarios:
* `src` is set, and 'Add a Source' results in the same file (or a file with the same extension) being added
* `src` is set, and 'Replace Audio|Video' is used, which will add a model property named by the attachment's extension

... call `model.unset( 'src' )`.

See #27389.


Built from https://develop.svn.wordpress.org/trunk@27536


git-svn-id: http://core.svn.wordpress.org/trunk@27379 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-14 13:00:14 +00:00
Scott Taylor
b4569b69dc Revert [27528] until Flash in Firefox behaves :(
See #27389.


Built from https://develop.svn.wordpress.org/trunk@27530


git-svn-id: http://core.svn.wordpress.org/trunk@27373 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-13 23:39:16 +00:00
Scott Taylor
ba84f57083 Add MCE Views for audio and video. Please clear your browser cache so that you get the latest TinyMCE stylesheet.
* Move TinyMCE shortcode handling from `wpgallery` plugin to `mce-view.js`
* Force `preload="none"` when rendering media in the editor to ensure fast loading (I realize this sounds illogical)
* Move audio and video tag builder logic in `media-template.php` into PHP funcs that can be reused by any code passing `data.model` to an Underscore template
* Pause all players when moving between editor tabs and when moving from the editor to editing in the media modal.
* Rename `wp.media.audio|video.shortcode()` to the more appropriate `wp.media.audio|video.update()` that now returns a `wp.shortcode` object instead of a string.
* Add necessary MediaElement css files to `$mce_css`
* In `wp.mce.View.render()`, support multiple instances of the same shortcode
* When rendering `wp.mce.View`s, fire a ready event that passes the current MCE View root element as context 

See #27389.


Built from https://develop.svn.wordpress.org/trunk@27528


git-svn-id: http://core.svn.wordpress.org/trunk@27371 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-13 23:10:14 +00:00
Scott Taylor
f7af18e1d6 Audio/Video shortcodes in the media modal:
* Make a generic model, `wp.media.model.PostMedia`, which replaces `wp.media.model.PostAudio` and `wp.media.model.PostVideo`
* Make a generic library, `wp.media.controller.MediaLibrary`, which replaces `wp.media.controller.ReplaceVideo` and `wp.media.controller.ReplaceAudio`
* `wp.media.controller.MediaLibrary` is used to create new states that want to load a library filtered by type, making it incredibly simple to add states to frames. See `wp.media.view.MediaFrame.VideoDetails` and `wp.media.view.MediaFrame.AudioDetails`.

UX changes:

* Add the ability to manage HTML5 fallbacks - add additional `<source>`s or remove specific `<source>`s
* In the Video Details state, add the ability to select a poster image

See #27016.


Built from https://develop.svn.wordpress.org/trunk@27478


git-svn-id: http://core.svn.wordpress.org/trunk@27322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-09 05:25:15 +00:00
Scott Taylor
f0863476f5 In wp.media.model.PostAudio and wp.media.model.PostVideo, use Underscore's unset method when clearing out properties when the attachment changes.
See #27016.


Built from https://develop.svn.wordpress.org/trunk@27477


git-svn-id: http://core.svn.wordpress.org/trunk@27321 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-09 01:06:14 +00:00
Helen Hou-Sandí
4bb7e03548 At long last, a first pass at bringing the image editor into the media modal. props gcorne, DH-Shredder, tomauger. see #21811.
Built from https://develop.svn.wordpress.org/trunk@27445


git-svn-id: http://core.svn.wordpress.org/trunk@27292 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-06 22:55:14 +00:00
Scott Taylor
bc9838f86f We shall pledge to run jshint before committing.
Props nacin for the nudge.


Built from https://develop.svn.wordpress.org/trunk@27435


git-svn-id: http://core.svn.wordpress.org/trunk@27282 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-06 16:06:14 +00:00
Scott Taylor
ff8844deae Add TinyMCE placeholders for audio and video shortcodes.
* Add `wp.media.mixin`.
* Add `wp.media.audio` and `wp.media.video`.
* Add `wp.media.model.PostAudio` and `wp.media.model.PostVideo`
* Add `wp.media.controller.AudioDetails` and `wp.media.controller.VideoDetails`.
* Add `wp.media.controller.ReplaceAudio` and `wp.media.controller.ReplaceVideo`.
* Add `wp.media.view.MediaFrame.AudioDetails` and `wp.media.view.MediaFrame.VideoDetails`.
* Add `wp.media.view.AudioDetails` and `wp.media.view.VideoDetails`.
* Update the `wpgallery` TinyMCE plugin.
* Display audio and video players in the media modal when shortcode is clicked.
* Provide a UI to edit shortcode attributes in the media modal.
* Provide a UI to replace the `src` media file in an `audio` or `video` shortcode.

See #27016.


Built from https://develop.svn.wordpress.org/trunk@27411


git-svn-id: http://core.svn.wordpress.org/trunk@27258 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-05 15:06:14 +00:00
Scott Taylor
e1759d668a For starters, [27050] is rad. This just cleans up some extra new lines that were littered about, updates *some* of the inline docs (needs more), moves wp.media.controller.ImageDetails closer to its parent class, and de-dupes some code in media-template.php.
See #24409.


Built from https://develop.svn.wordpress.org/trunk@27051


git-svn-id: http://core.svn.wordpress.org/trunk@26925 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-28 23:21:13 +00:00
Andrew Ozz
33eedc570b Introduce Edit Image (single mode) in the media modal and use it to edit images inserted in the editor. Adds new feature: replace an image in the editor. Props gcorne, see #24409.
Built from https://develop.svn.wordpress.org/trunk@27050


git-svn-id: http://core.svn.wordpress.org/trunk@26924 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-28 21:17:12 +00:00
Scott Taylor
7ef7a7cb47 Add some inline docs to methods in media-models.js - particularly around @param and @returns.
See #26870.


Built from https://develop.svn.wordpress.org/trunk@27032


git-svn-id: http://core.svn.wordpress.org/trunk@26908 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-25 08:56:12 +00:00
Scott Taylor
bf09d042eb Add some JSDoc annotations to media-models.js to disambiguate instance properties and static class properties/methods in the base media Models.
See #26870.


Built from https://develop.svn.wordpress.org/trunk@27031


git-svn-id: http://core.svn.wordpress.org/trunk@26907 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-25 07:39:11 +00:00
Scott Taylor
18b8c717f2 Make some @param types more specific in media-models.js.
See #26870.


Built from https://develop.svn.wordpress.org/trunk@26991


git-svn-id: http://core.svn.wordpress.org/trunk@26868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-21 17:37:12 +00:00
Scott Taylor
e2cec2e4d8 Add initial JSDoc blocks to media-models.js. The initial blocks are a baseline to work from and invite future iterations. Initial commit is to avoid commits this large in the future.
See #26870.


Built from https://develop.svn.wordpress.org/trunk@26985


git-svn-id: http://core.svn.wordpress.org/trunk@26862 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-20 23:40:11 +00:00
Sergey Biryukov
ef621a3c8b Fix JSHint errors in media-models.js.
props kadamwhite.
fixes #26132.
Built from https://develop.svn.wordpress.org/trunk@26295


git-svn-id: http://core.svn.wordpress.org/trunk@26200 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-20 23:07:10 +00:00
Sergey Biryukov
6509e4e686 Declare args as a local variable. props greuben. fixes #25078.
Built from https://develop.svn.wordpress.org/trunk@25080


git-svn-id: http://core.svn.wordpress.org/trunk@25065 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-22 02:11:08 +00:00
Mark Jaquith
ea1092eb7c Parse attrs before comparing to attachment.attributes. Small efficiency gain.
Props garyc40. Fixes #24753.

git-svn-id: http://core.svn.wordpress.org/trunk@24800 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-27 07:09:05 +00:00
Mark Jaquith
bbf338666e Fix a media regression in [24110] that could cause duplicate models.
Props garyc40. Fixes #24753. See #24094, #23830.

git-svn-id: http://core.svn.wordpress.org/trunk@24771 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-22 22:24:33 +00:00
Andrew Nacin
721f7ba271 Rename wp.xhr to wp.ajax to match admin-ajax.php (which it uses), jQuery.ajax (which it wraps), etc. see #24424.
git-svn-id: http://core.svn.wordpress.org/trunk@24652 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-11 00:20:36 +00:00
Daryl Koopersmith
6a4d212138 Move XHR helpers from media to utils. See #24424.
git-svn-id: http://core.svn.wordpress.org/trunk@24369 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-05-26 06:58:01 +00:00
Daryl Koopersmith
c4fe4ebd42 Alias media.template to wp.template. See #23263, #24424.
git-svn-id: http://core.svn.wordpress.org/trunk@24366 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-05-26 05:55:49 +00:00
Mark Jaquith
82df929f30 Fix the appearance of a blank media item due to [23893].
props kovshenin. fixes #24094.

git-svn-id: http://core.svn.wordpress.org/trunk@24110 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-04-26 15:10:06 +00:00
Andrew Nacin
ec0e3724e1 Backbone 1.0.0.
Update media JS to reflect changes. Please open new tickets for remaining issues.

props koopersmith.
fixes #23830.



git-svn-id: http://core.svn.wordpress.org/trunk@23893 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-04-03 17:40:52 +00:00
Daryl Koopersmith
00d88af87a Update Backbone to 0.9.10. Update media to handle breaking changes.
* When overriding `Backbone.sync()`, ensure the `sync` and `error` events fire consistently.

* `Model#make()` has been removed. Use `$` instead, and be sure to grab the DOM node where necessary (using `[0]`).

* `Collection#get()` now accepts `cid`s. `Collection#getByCid()` has been removed.

* When overriding the `State` constructor, bind `change` callbacks after the default `Model` constructor is called, because the `Model` constructor no longer passes the `silent` flag when calling `set()` for the default attributes.

* In 'change' events, `options.changes` was removed. It can now be accessed through `model.changed`. Check if any attributes have changed by calling `model.hasChanged()`. Also, don't mess with `model.changed`; it persists beyond the scope of a single event.

* `options.index` is no longer be set in the `add` event callback. Use `collection.indexOf(model)` can be used to retrieve the index of a model instead.

props gcorne. fixes #23262.


git-svn-id: http://core.svn.wordpress.org/trunk@23589 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-03 07:04:06 +00:00
Daryl Koopersmith
30440dbb66 Add a canonical location for media frames, an alias to fetch attachments, and frame caching to custom header. fixes #22775.
git-svn-id: http://core.svn.wordpress.org/trunk@23092 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-12-06 05:06:49 +00:00
Andrew Nacin
a914ab2e43 Media models: Trac and ignore deleted attachments.
Treat an admin-ajax response of 1 as successful for backwards compatibility with existing handlers.

props koopersmith. fixes #22750.



git-svn-id: http://core.svn.wordpress.org/trunk@23057 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-12-05 02:31:41 +00:00
Ryan Boren
edf9769d26 In the media modal, clear attachment details when clearing the selection.
Props koopersmith
fixes #22718


git-svn-id: http://core.svn.wordpress.org/trunk@23045 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-12-04 22:19:08 +00:00