diff --git src/wp-includes/js/media/controllers/gallery-add.js src/wp-includes/js/media/controllers/gallery-add.js
index 21e611bc33..02e340c934 100644
|
|
|
var Selection = wp.media.model.Selection, |
| 8 | 8 | * |
| 9 | 9 | * A state for selecting more images to add to a gallery. |
| 10 | 10 | * |
| 11 | | * @memberOf wp.media.controller |
| | 11 | * @since 4.2.0 |
| 12 | 12 | * |
| 13 | 13 | * @class |
| 14 | 14 | * @augments wp.media.controller.Library |
| 15 | 15 | * @augments wp.media.controller.State |
| 16 | 16 | * @augments Backbone.Model |
| 17 | 17 | * |
| 18 | | * @param {object} [attributes] The attributes hash passed to the state. |
| | 18 | * @memberof wp.media.controller |
| | 19 | * |
| | 20 | * @param {Object} [attributes] The attributes hash passed to the state. |
| 19 | 21 | * @param {string} [attributes.id=gallery-library] Unique identifier. |
| 20 | 22 | * @param {string} [attributes.title=Add to Gallery] Title for the state. Displays in the frame's title region. |
| 21 | 23 | * @param {boolean} [attributes.multiple=add] Whether multi-select is enabled. @todo 'add' doesn't seem do anything special, and gets used as a boolean. |
| … |
… |
var Selection = wp.media.model.Selection, |
| 32 | 34 | * @param {boolean} [attributes.sortable=true] Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection. |
| 33 | 35 | * @param {boolean} [attributes.autoSelect=true] Whether an uploaded attachment should be automatically added to the selection. |
| 34 | 36 | * @param {boolean} [attributes.contentUserSetting=true] Whether the content region's mode should be set and persisted per user. |
| 35 | | * @param {int} [attributes.priority=100] The priority for the state link in the media menu. |
| | 37 | * @param {number} [attributes.priority=100] The priority for the state link in the media menu. |
| 36 | 38 | * @param {boolean} [attributes.syncSelection=false] Whether the Attachments selection should be persisted from the last state. |
| 37 | 39 | * Defaults to false because for this state, because the library of the Edit Gallery state is the selection. |
| 38 | 40 | */ |
| … |
… |
GalleryAdd = Library.extend(/** @lends wp.media.controller.GalleryAdd.prototype |
| 49 | 51 | }, Library.prototype.defaults ), |
| 50 | 52 | |
| 51 | 53 | /** |
| | 54 | * Initializes the library. Creates a library of images if a library isn't supplied. |
| | 55 | * |
| 52 | 56 | * @since 3.5.0 |
| | 57 | * |
| | 58 | * @returns {void} |
| 53 | 59 | */ |
| 54 | 60 | initialize: function() { |
| 55 | | // If a library wasn't supplied, create a library of images. |
| 56 | 61 | if ( ! this.get('library') ) { |
| 57 | 62 | this.set( 'library', wp.media.query({ type: 'image' }) ); |
| 58 | 63 | } |
| … |
… |
GalleryAdd = Library.extend(/** @lends wp.media.controller.GalleryAdd.prototype |
| 61 | 66 | }, |
| 62 | 67 | |
| 63 | 68 | /** |
| | 69 | * Activates the library. |
| | 70 | * |
| | 71 | * Removes all event listeners if in edit mode. Creates a validator to check an attachment. |
| | 72 | * Resets library and re-enables event listeners. Activates edit mode. Calls the parent's activate method. |
| | 73 | * |
| 64 | 74 | * @since 3.5.0 |
| | 75 | * |
| | 76 | * @returns {void} |
| 65 | 77 | */ |
| 66 | 78 | activate: function() { |
| 67 | 79 | var library = this.get('library'), |
| … |
… |
GalleryAdd = Library.extend(/** @lends wp.media.controller.GalleryAdd.prototype |
| 71 | 83 | library.unobserve( this.editLibrary ); |
| 72 | 84 | } |
| 73 | 85 | |
| 74 | | // Accepts attachments that exist in the original library and |
| 75 | | // that do not exist in gallery's library. |
| | 86 | /* |
| | 87 | * Accept attachments that exist in the original library but |
| | 88 | * that do not exist in gallery's library yet. |
| | 89 | */ |
| 76 | 90 | library.validator = function( attachment ) { |
| 77 | 91 | return !! this.mirroring.get( attachment.cid ) && ! edit.get( attachment.cid ) && Selection.prototype.validator.apply( this, arguments ); |
| 78 | 92 | }; |
| 79 | 93 | |
| 80 | | // Reset the library to ensure that all attachments are re-added |
| 81 | | // to the collection. Do so silently, as calling `observe` will |
| 82 | | // trigger the `reset` event. |
| | 94 | /* |
| | 95 | * Reset the library to ensure that all attachments are re-added |
| | 96 | * to the collection. Do so silently, as calling `observe` will |
| | 97 | * trigger the `reset` event. |
| | 98 | */ |
| 83 | 99 | library.reset( library.mirroring.models, { silent: true }); |
| 84 | 100 | library.observe( edit ); |
| 85 | 101 | this.editLibrary = edit; |