Make WordPress Core

Ticket #43500: gallery-add-documentation.diff

File gallery-add-documentation.diff, 4.3 KB (added by boblinthorst, 8 years ago)
  • src/wp-includes/js/media/controllers/gallery-add.js

    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, 
    88 *
    99 * A state for selecting more images to add to a gallery.
    1010 *
    11  * @memberOf wp.media.controller
     11 * @since 4.2.0
    1212 *
    1313 * @class
    1414 * @augments wp.media.controller.Library
    1515 * @augments wp.media.controller.State
    1616 * @augments Backbone.Model
    1717 *
    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.
    1921 * @param {string}                     [attributes.id=gallery-library]      Unique identifier.
    2022 * @param {string}                     [attributes.title=Add to Gallery]    Title for the state. Displays in the frame's title region.
    2123 * @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, 
    3234 * @param {boolean}                    [attributes.sortable=true]           Whether the Attachments should be sortable. Depends on the orderby property being set to menuOrder on the attachments collection.
    3335 * @param {boolean}                    [attributes.autoSelect=true]         Whether an uploaded attachment should be automatically added to the selection.
    3436 * @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.
    3638 * @param {boolean}                    [attributes.syncSelection=false]     Whether the Attachments selection should be persisted from the last state.
    3739 *                                                                          Defaults to false because for this state, because the library of the Edit Gallery state is the selection.
    3840 */
    GalleryAdd = Library.extend(/** @lends wp.media.controller.GalleryAdd.prototype 
    4951        }, Library.prototype.defaults ),
    5052
    5153        /**
     54         * Initializes the library. Creates a library of images if a library isn't supplied.
     55         *
    5256         * @since 3.5.0
     57         *
     58         * @returns {void}
    5359         */
    5460        initialize: function() {
    55                 // If a library wasn't supplied, create a library of images.
    5661                if ( ! this.get('library') ) {
    5762                        this.set( 'library', wp.media.query({ type: 'image' }) );
    5863                }
    GalleryAdd = Library.extend(/** @lends wp.media.controller.GalleryAdd.prototype 
    6166        },
    6267
    6368        /**
     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         *
    6474         * @since 3.5.0
     75         *
     76         * @returns {void}
    6577         */
    6678        activate: function() {
    6779                var library = this.get('library'),
    GalleryAdd = Library.extend(/** @lends wp.media.controller.GalleryAdd.prototype 
    7183                        library.unobserve( this.editLibrary );
    7284                }
    7385
    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                 */
    7690                library.validator = function( attachment ) {
    7791                        return !! this.mirroring.get( attachment.cid ) && ! edit.get( attachment.cid ) && Selection.prototype.validator.apply( this, arguments );
    7892                };
    7993
    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                 */
    8399                library.reset( library.mirroring.models, { silent: true });
    84100                library.observe( edit );
    85101                this.editLibrary = edit;