]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/media-models.js
WordPress 4.0
[autoinstalls/wordpress.git] / wp-includes / js / media-models.js
index 1dd719688ecbad869b9983a4878f633abeb4be7b..ac7ee938d6af31f6ab0b5d26c4d6c7f175a74012 100644 (file)
@@ -5,7 +5,7 @@ window.wp = window.wp || {};
        var Attachment, Attachments, Query, PostImage, compare, l10n, media;
 
        /**
-        * wp.media( attributes )
+        * Create and return a media frame.
         *
         * Handles the default media experience. Automatically creates
         * and opens a media frame, and returns the result.
@@ -30,12 +30,16 @@ window.wp = window.wp || {};
                        frame = new MediaFrame.Select( attributes );
                } else if ( 'post' === attributes.frame && MediaFrame.Post ) {
                        frame = new MediaFrame.Post( attributes );
+               } else if ( 'manage' === attributes.frame && MediaFrame.Manage ) {
+                       frame = new MediaFrame.Manage( attributes );
                } else if ( 'image' === attributes.frame && MediaFrame.ImageDetails ) {
                        frame = new MediaFrame.ImageDetails( attributes );
                } else if ( 'audio' === attributes.frame && MediaFrame.AudioDetails ) {
                        frame = new MediaFrame.AudioDetails( attributes );
                } else if ( 'video' === attributes.frame && MediaFrame.VideoDetails ) {
                        frame = new MediaFrame.VideoDetails( attributes );
+               } else if ( 'edit-attachments' === attributes.frame && MediaFrame.EditAttachments ) {
+                       frame = new MediaFrame.EditAttachments( attributes );
                }
 
                delete attributes.frame;
@@ -820,9 +824,12 @@ window.wp = window.wp || {};
                /**
                 * @access private
                 */
-               _requery: function() {
+               _requery: function( refresh ) {
+                       var props;
                        if ( this.props.get('query') ) {
-                               this.mirror( Query.get( this.props.toJSON() ) );
+                               props = this.props.toJSON();
+                               props.cache = ( true !== refresh );
+                               this.mirror( Query.get( props ) );
                        }
                },
                /**
@@ -943,6 +950,22 @@ window.wp = window.wp || {};
                                }
 
                                return uploadedTo === attachment.get('uploadedTo');
+                       },
+                       /**
+                        * @static
+                        * @param {wp.media.model.Attachment} attachment
+                        *
+                        * @this wp.media.model.Attachments
+                        *
+                        * @returns {Boolean}
+                        */
+                       status: function( attachment ) {
+                               var status = this.props.get('status');
+                               if ( _.isUndefined( status ) ) {
+                                       return true;
+                               }
+
+                               return status === attachment.get('status');
                        }
                }
        });
@@ -1140,7 +1163,8 @@ window.wp = window.wp || {};
                        'type':      'post_mime_type',
                        'perPage':   'posts_per_page',
                        'menuOrder': 'menu_order',
-                       'uploadedTo': 'post_parent'
+                       'uploadedTo': 'post_parent',
+                       'status':     'post_status'
                },
                /**
                 * @static
@@ -1165,11 +1189,13 @@ window.wp = window.wp || {};
                                var args     = {},
                                        orderby  = Query.orderby,
                                        defaults = Query.defaultProps,
-                                       query;
+                                       query,
+                                       cache    = !! props.cache || _.isUndefined( props.cache );
 
                                // Remove the `query` property. This isn't linked to a query,
                                // this *is* the query.
                                delete props.query;
+                               delete props.cache;
 
                                // Fill default args.
                                _.defaults( props, defaults );
@@ -1203,9 +1229,13 @@ window.wp = window.wp || {};
                                args.orderby = orderby.valuemap[ props.orderby ] || props.orderby;
 
                                // Search the query cache for matches.
-                               query = _.find( queries, function( query ) {
-                                       return _.isEqual( query.args, args );
-                               });
+                               if ( cache ) {
+                                       query = _.find( queries, function( query ) {
+                                               return _.isEqual( query.args, args );
+                                       });
+                               } else {
+                                       queries = [];
+                               }
 
                                // Otherwise, create a new query and add it to the cache.
                                if ( ! query ) {