Make WordPress Core

Ticket #28459: 28459.7.diff

File 28459.7.diff, 10.0 KB (added by ericlewis, 11 years ago)
  • src/wp-includes/js/media-models.js

    diff --git src/wp-includes/js/media-models.js src/wp-includes/js/media-models.js
    index cba928d..854592c 100644
    window.wp = window.wp || {}; 
    6565         */
    6666
    6767        /**
    68          * A basic comparator.
     68         * A basic equality comparator for Backbone models.
     69         *
     70         * Used to order models within a collection.
     71         *
     72         * @see wp.media.model.Attachments.comparator()
    6973         *
    7074         * @param  {mixed}  a  The primary parameter to compare.
    7175         * @param  {mixed}  b  The primary parameter to compare.
    window.wp = window.wp || {}; 
    8791                /**
    8892                 * media.template( id )
    8993                 *
    90                  * Fetches a template by id.
     94                 * Fetch a JavaScript template for an id, and return a templating function.
     95                 *
    9196                 * See wp.template() in `wp-includes/js/wp-util.js`.
    9297                 *
    9398                 * @borrows wp.template as template
    window.wp = window.wp || {}; 
    197202        /**
    198203         * wp.media.model.Attachment
    199204         *
    200          * @constructor
     205         * @class
    201206         * @augments Backbone.Model
    202207         */
    203208        Attachment = media.model.Attachment = Backbone.Model.extend({
    window.wp = window.wp || {}; 
    329334                }
    330335        }, {
    331336                /**
    332                  * Add a model to the end of the static 'all' collection and return it.
     337                 * Create and returnAdd a model to the end of the static 'all' collection and return it.
    333338                 *
    334339                 * @static
    335340                 * @param {Object} attrs
    window.wp = window.wp || {}; 
    339344                        return Attachments.all.push( attrs );
    340345                },
    341346                /**
    342                  * Retrieve a model, or add it to the end of the static 'all' collection before returning it.
     347                 * Create a new model on the static 'all' attachments collection and return it.
    343348                 *
    344349                 * @static
    345350                 * @param {string} id A string used to identify a model.
    window.wp = window.wp || {}; 
    354359        /**
    355360         * wp.media.model.PostImage
    356361         *
    357          * @constructor
     362         * An instance of an image that's been embedded into a post.
     363         *
     364         * Used in the embedded image attachment display settings modal (media.view.MediaFrame.ImageDetails).
     365         *
     366         * @class
    358367         * @augments Backbone.Model
     368         *
     369         * @param {int} [attributes]               Initial model attributes.
     370         * @param {int} [attributes.attachment_id] ID of the attachment.
    359371         **/
    360372        PostImage = media.model.PostImage = Backbone.Model.extend({
    361373
    window.wp = window.wp || {}; 
    497509        /**
    498510         * wp.media.model.Attachments
    499511         *
    500          * @constructor
     512         * A collection of attachments.
     513         *
     514         * @class
    501515         * @augments Backbone.Collection
     516         *
     517         * @param {array}  [models]                Models to initialize with the collection.
     518         * @param {object} [options]               Options object hash.
     519         * @param {string} [options.props]         Object hash for the initial query properties.
     520         * @param {string} [options.props.order]   Initial order (ASC or DESC) for the collection.
     521         * @param {string} [options.props.orderby] Initial attribute key to order the collection by.
     522         * @param {string} [options.props.query]
     523         * @param {string} [options.observe]
     524         * @param {string} [options.filters]
     525         *
    502526         */
    503527        Attachments = media.model.Attachments = Backbone.Collection.extend({
    504528                /**
    window.wp = window.wp || {}; 
    522546                        this.props.on( 'change:orderby', this._changeOrderby, this );
    523547                        this.props.on( 'change:query',   this._changeQuery,   this );
    524548
    525                         // Set the `props` model and fill the default property values.
    526549                        this.props.set( _.defaults( options.props || {} ) );
    527550
    528                         // Observe another `Attachments` collection if one is provided.
    529551                        if ( options.observe ) {
    530552                                this.observe( options.observe );
    531553                        }
    window.wp = window.wp || {}; 
    761783                        delete this.mirroring;
    762784                },
    763785                /**
     786                 * If the collection is mirroring another collection, check if there are more
     787                 * attachments that haven't been sync'd from the server for that collection.
     788                 *
    764789                 * @param {Object} options
    765790                 * @returns {Promise}
    766791                 */
    window.wp = window.wp || {}; 
    784809                        return deferred.promise();
    785810                },
    786811                /**
    787                  * @returns {Boolean}
     812                 * @returns {boolean}
    788813                 */
    789814                hasMore: function() {
    790815                        return this.mirroring ? this.mirroring.hasMore() : false;
    791816                },
    792817                /**
    793                  * Overrides Backbone.Collection.parse
     818                 * A custom AJAX-response parser.
     819                 *
     820                 * See trac ticket #24753
    794821                 *
    795822                 * @param {Object|Array} resp The raw response Object/Array.
    796823                 * @param {Object} xhr
    window.wp = window.wp || {}; 
    867894                }
    868895        }, {
    869896                /**
     897                 * A function to compare two attachment models in an attachments collection.
     898                 *
     899                 * Used as the default comparator for instances of wp.media.model.Attachments
     900                 * and its subclasses. @see media.model.Attachments._changeOrderby().
     901                 *
    870902                 * @static
    871                  * Overrides Backbone.Collection.comparator
    872903                 *
    873904                 * @param {Backbone.Model} a
    874905                 * @param {Backbone.Model} b
    window.wp = window.wp || {}; 
    9911022        /**
    9921023         * wp.media.model.Query
    9931024         *
    994          * A set of attachments that corresponds to a set of consecutively paged
    995          * queries on the server.
     1025         * A collection of attachments that match the supplied query arguments.
    9961026         *
    9971027         * Note: Do NOT change this.args after the query has been initialized.
    9981028         *       Things will break.
    9991029         *
    1000          * @constructor
     1030         * @class
    10011031         * @augments wp.media.model.Attachments
    10021032         * @augments Backbone.Collection
     1033         *
     1034         * @param {array}  [models]                      Models to initialize with the collection.
     1035         * @param {object} [options]                     Options hash.
     1036         * @param {object} [options.args]                Attachments query arguments.
     1037         * @param {object} [options.args.posts_per_page]
    10031038         */
    10041039        Query = media.model.Query = Attachments.extend({
    10051040                /**
    10061041                 * @global wp.Uploader
    10071042                 *
    1008                  * @param {Array} [models=[]] Array of models used to populate the collection.
    1009                  * @param {Object} [options={}]
     1043                 * @param {array}  [models=[]] Array of models used to populate the collection.
     1044                 * @param {object} [options={}]
    10101045                 */
    10111046                initialize: function( models, options ) {
    10121047                        var allowed;
    window.wp = window.wp || {}; 
    10151050                        Attachments.prototype.initialize.apply( this, arguments );
    10161051
    10171052                        this.args     = options.args;
     1053                        // Whether there are attachments that haven't been sync'd from the server
     1054                        // that match the query.
    10181055                        this._hasMore = true;
    10191056                        this.created  = new Date();
    10201057
    window.wp = window.wp || {}; 
    10601097                        }
    10611098                },
    10621099                /**
    1063                  * @returns {Boolean}
     1100                 * Whether there are more attachments that haven't been sync'd from the server
     1101                 * that match the query.
     1102                 *
     1103                 * @returns {boolean}
    10641104                 */
    10651105                hasMore: function() {
    10661106                        return this._hasMore;
    10671107                },
    10681108                /**
    1069                  * @param {Object} [options={}]
     1109                 * Fetch more attachments from the server for the collection.
     1110                 *
     1111                 * @param   {object}  [options={}]
    10701112                 * @returns {Promise}
    10711113                 */
    10721114                more: function( options ) {
    10731115                        var query = this;
    10741116
     1117                        // If there is already a request pending, return early with the Deferred object.
    10751118                        if ( this._more && 'pending' === this._more.state() ) {
    10761119                                return this._more;
    10771120                        }
    window.wp = window.wp || {}; 
    11421185                 * @readonly
    11431186                 */
    11441187                defaultArgs: {
    1145                         posts_per_page: 40
     1188                        posts_per_page: 10
    11461189                },
    11471190                /**
    11481191                 * @readonly
    11491192                 */
    11501193                orderby: {
    11511194                        allowed:  [ 'name', 'author', 'date', 'title', 'modified', 'uploadedTo', 'id', 'post__in', 'menuOrder' ],
     1195                        /**
     1196                         * Map JavaScript orderby values to their WP_Query equivalents.
     1197                         * @type {Object}
     1198                         */
    11521199                        valuemap: {
    11531200                                'id':         'ID',
    11541201                                'uploadedTo': 'parent',
    window.wp = window.wp || {}; 
    11561203                        }
    11571204                },
    11581205                /**
     1206                 * A map of JavaScript query properties to their WP_Query equivalents.
     1207                 *
    11591208                 * @readonly
    11601209                 */
    11611210                propmap: {
    window.wp = window.wp || {}; 
    12621311        /**
    12631312         * wp.media.model.Selection
    12641313         *
    1265          * Used to manage a selection of attachments in the views.
     1314         * A selection of attachments.
    12661315         *
    1267          * @constructor
     1316         * @class
    12681317         * @augments wp.media.model.Attachments
    12691318         * @augments Backbone.Collection
    12701319         */
    window.wp = window.wp || {}; 
    12881337                },
    12891338
    12901339                /**
    1291                  * Override the selection's add method.
    1292                  * If the workflow does not support multiple
    1293                  * selected attachments, reset the selection.
    1294                  *
    1295                  * Overrides Backbone.Collection.add
    1296                  * Overrides wp.media.model.Attachments.add
     1340                 * If the workflow does not support multi-select, clear out the selection
     1341                 * before adding a new attachment to it.
    12971342                 *
    12981343                 * @param {Array} models
    12991344                 * @param {Object} options
    window.wp = window.wp || {}; 
    13101355                },
    13111356
    13121357                /**
    1313                  * Triggered when toggling (clicking on) an attachment in the modal
     1358                 * Fired when toggling (clicking on) an attachment in the modal.
    13141359                 *
    13151360                 * @param {undefined|boolean|wp.media.model.Attachment} model
    13161361                 *
  • src/wp-includes/js/media-views.js

    diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js
    index cc02f43..7111a56 100644
     
    26642664                                state:    'insert',
    26652665                                metadata:  {}
    26662666                        });
    2667                         /**
    2668                          * call 'initialize' directly on the parent class
    2669                          */
     2667
     2668                        // Call 'initialize' directly on the parent class.
    26702669                        media.view.MediaFrame.Select.prototype.initialize.apply( this, arguments );
    26712670                        this.createIframeStates();
    26722671
  • src/wp-includes/js/wp-util.js

    diff --git src/wp-includes/js/wp-util.js src/wp-includes/js/wp-util.js
    index 867d3a0..591cd40 100644
    window.wp = window.wp || {}; 
    88        /**
    99         * wp.template( id )
    1010         *
    11          * Fetches a template by id.
     11         * Fetch a JavaScript template for an id, and return a templating function.
    1212         *
    1313         * @param  {string} id   A string that corresponds to a DOM element with an id prefixed with "tmpl-".
    1414         *                       For example, "attachment" maps to "tmpl-attachment".
    window.wp = window.wp || {}; 
    1616         */
    1717        wp.template = _.memoize(function ( id ) {
    1818                var compiled,
     19                        /*
     20                         * Underscore's default ERB-style templates are incompatible with PHP
     21                         * when asp_tags is enabled, so WordPress uses Mustache-inspired templating syntax.
     22                         *
     23                         * @see trac ticket #22344.
     24                         */
    1925                        options = {
    2026                                evaluate:    /<#([\s\S]+?)#>/g,
    2127                                interpolate: /\{\{\{([\s\S]+?)\}\}\}/g,