wp/wp-includes/js/media-models.js
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
--- a/wp/wp-includes/js/media-models.js	Tue Jun 09 11:14:17 2015 +0000
+++ b/wp/wp-includes/js/media-models.js	Mon Oct 14 17:39:30 2019 +0200
@@ -1,9 +1,77 @@
-(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
-/*globals wp, _, jQuery */
+/******/ (function(modules) { // webpackBootstrap
+/******/ 	// The module cache
+/******/ 	var installedModules = {};
+/******/
+/******/ 	// The require function
+/******/ 	function __webpack_require__(moduleId) {
+/******/
+/******/ 		// Check if module is in cache
+/******/ 		if(installedModules[moduleId]) {
+/******/ 			return installedModules[moduleId].exports;
+/******/ 		}
+/******/ 		// Create a new module (and put it into the cache)
+/******/ 		var module = installedModules[moduleId] = {
+/******/ 			i: moduleId,
+/******/ 			l: false,
+/******/ 			exports: {}
+/******/ 		};
+/******/
+/******/ 		// Execute the module function
+/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ 		// Flag the module as loaded
+/******/ 		module.l = true;
+/******/
+/******/ 		// Return the exports of the module
+/******/ 		return module.exports;
+/******/ 	}
+/******/
+/******/
+/******/ 	// expose the modules object (__webpack_modules__)
+/******/ 	__webpack_require__.m = modules;
+/******/
+/******/ 	// expose the module cache
+/******/ 	__webpack_require__.c = installedModules;
+/******/
+/******/ 	// define getter function for harmony exports
+/******/ 	__webpack_require__.d = function(exports, name, getter) {
+/******/ 		if(!__webpack_require__.o(exports, name)) {
+/******/ 			Object.defineProperty(exports, name, {
+/******/ 				configurable: false,
+/******/ 				enumerable: true,
+/******/ 				get: getter
+/******/ 			});
+/******/ 		}
+/******/ 	};
+/******/
+/******/ 	// getDefaultExport function for compatibility with non-harmony modules
+/******/ 	__webpack_require__.n = function(module) {
+/******/ 		var getter = module && module.__esModule ?
+/******/ 			function getDefault() { return module['default']; } :
+/******/ 			function getModuleExports() { return module; };
+/******/ 		__webpack_require__.d(getter, 'a', getter);
+/******/ 		return getter;
+/******/ 	};
+/******/
+/******/ 	// Object.prototype.hasOwnProperty.call
+/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
+/******/
+/******/ 	// __webpack_public_path__
+/******/ 	__webpack_require__.p = "";
+/******/
+/******/ 	// Load entry module and return exports
+/******/ 	return __webpack_require__(__webpack_require__.s = 20);
+/******/ })
+/************************************************************************/
+/******/ ({
+
+/***/ 20:
+/***/ (function(module, exports, __webpack_require__) {
 
 var $ = jQuery,
 	Attachment, Attachments, l10n, media;
 
+/** @namespace wp */
 window.wp = window.wp || {};
 
 /**
@@ -11,6 +79,10 @@
  *
  * Handles the default media experience.
  *
+ * @alias wp.media
+ * @memberOf wp
+ * @namespace
+ *
  * @param  {object} attributes The properties passed to the main media controller.
  * @return {wp.media.view.MediaFrame} A media workflow.
  */
@@ -49,6 +121,10 @@
 	return frame;
 };
 
+/** @namespace wp.media.model */
+/** @namespace wp.media.view */
+/** @namespace wp.media.controller */
+/** @namespace wp.media.frames */
 _.extend( media, { model: {}, view: {}, controller: {}, frames: {} });
 
 // Link any localized strings.
@@ -58,12 +134,12 @@
 media.model.settings = l10n.settings || {};
 delete l10n.settings;
 
-Attachment = media.model.Attachment = require( './models/attachment.js' );
-Attachments = media.model.Attachments = require( './models/attachments.js' );
+Attachment = media.model.Attachment = __webpack_require__( 21 );
+Attachments = media.model.Attachments = __webpack_require__( 22 );
 
-media.model.Query = require( './models/query.js' );
-media.model.PostImage = require( './models/post-image.js' );
-media.model.Selection = require( './models/selection.js' );
+media.model.Query = __webpack_require__( 23 );
+media.model.PostImage = __webpack_require__( 24 );
+media.model.Selection = __webpack_require__( 25 );
 
 /**
  * ========================================================================
@@ -92,7 +168,7 @@
 	}
 };
 
-_.extend( media, {
+_.extend( media, /** @lends wp.media */{
 	/**
 	 * media.template( id )
 	 *
@@ -231,19 +307,24 @@
 	window.wp = null;
 });
 
-},{"./models/attachment.js":2,"./models/attachments.js":3,"./models/post-image.js":4,"./models/query.js":5,"./models/selection.js":6}],2:[function(require,module,exports){
-/*globals wp, _, Backbone */
+
+/***/ }),
+
+/***/ 21:
+/***/ (function(module, exports) {
+
+var $ = Backbone.$,
+	Attachment;
 
 /**
  * wp.media.model.Attachment
  *
+ * @memberOf wp.media.model
+ *
  * @class
  * @augments Backbone.Model
  */
-var $ = Backbone.$,
-	Attachment;
-
-Attachment = Backbone.Model.extend({
+Attachment = Backbone.Model.extend(/** @lends wp.media.model.Attachment.prototype */{
 	/**
 	 * Triggered when attachment details change
 	 * Overrides Backbone.Model.sync
@@ -370,11 +451,12 @@
 			model.set( model.parse( resp, xhr ), options );
 		});
 	}
-}, {
+},/** @lends wp.media.model.Attachment */{
 	/**
 	 * Create a new model on the static 'all' attachments collection and return it.
 	 *
 	 * @static
+	 *
 	 * @param {Object} attrs
 	 * @returns {wp.media.model.Attachment}
 	 */
@@ -401,8 +483,11 @@
 
 module.exports = Attachment;
 
-},{}],3:[function(require,module,exports){
-/*globals wp, _, Backbone */
+
+/***/ }),
+
+/***/ 22:
+/***/ (function(module, exports) {
 
 /**
  * wp.media.model.Attachments
@@ -413,6 +498,8 @@
  * 'options.props.query = true', which will mirror the collection
  * to an Attachments Query collection - @see wp.media.model.Attachments.mirror().
  *
+ * @memberOf wp.media.model
+ *
  * @class
  * @augments Backbone.Collection
  *
@@ -426,7 +513,7 @@
  * @param {string} [options.filters]
  *
  */
-var Attachments = Backbone.Collection.extend({
+var Attachments = Backbone.Collection.extend(/** @lends wp.media.model.Attachments.prototype */{
 	/**
 	 * @type {wp.media.model.Attachment}
 	 */
@@ -555,6 +642,15 @@
 	 * @returns {Boolean}
 	 */
 	validator: function( attachment ) {
+
+		// Filter out contextually created attachments (e.g. headers, logos, etc.).
+		if (
+			! _.isUndefined( attachment.attributes.context ) &&
+			'' !== attachment.attributes.context
+		) {
+			return false;
+		}
+
 		if ( ! this.validateDestroyed && attachment.destroyed ) {
 			return false;
 		}
@@ -702,7 +798,7 @@
 		delete this.mirroring;
 	},
 	/**
-	 * Retrive more attachments from the server for the collection.
+	 * Retrieve more attachments from the server for the collection.
 	 *
 	 * Only works if the collection is mirroring a Query Attachments collection,
 	 * and forwards to its `more` method. This collection class doesn't have
@@ -824,15 +920,13 @@
 			attachments: attachments
 		});
 	}
-}, {
+},/** @lends wp.media.model.Attachments */{
 	/**
 	 * A function to compare two attachment models in an attachments collection.
 	 *
 	 * Used as the default comparator for instances of wp.media.model.Attachments
 	 * and its subclasses. @see wp.media.model.Attachments._changeOrderby().
 	 *
-	 * @static
-	 *
 	 * @param {Backbone.Model} a
 	 * @param {Backbone.Model} b
 	 * @param {Object} options
@@ -861,9 +955,7 @@
 
 		return ( 'DESC' === order ) ? wp.media.compare( a, b, ac, bc ) : wp.media.compare( b, a, bc, ac );
 	},
-	/**
-	 * @namespace
-	 */
+	/** @namespace wp.media.model.Attachments.filters */
 	filters: {
 		/**
 		 * @static
@@ -895,8 +987,23 @@
 		 * @returns {Boolean}
 		 */
 		type: function( attachment ) {
-			var type = this.props.get('type');
-			return ! type || -1 !== type.indexOf( attachment.get('type') );
+			var type = this.props.get('type'), atts = attachment.toJSON(), mime, found;
+
+			if ( ! type || ( _.isArray( type ) && ! type.length ) ) {
+				return true;
+			}
+
+			mime = atts.mime || ( atts.file && atts.file.type ) || '';
+
+			if ( _.isArray( type ) ) {
+				found = _.find( type, function (t) {
+					return -1 !== mime.indexOf( t );
+				} );
+			} else {
+				found = -1 !== mime.indexOf( type );
+			}
+
+			return found;
 		},
 		/**
 		 * @static
@@ -935,8 +1042,326 @@
 
 module.exports = Attachments;
 
-},{}],4:[function(require,module,exports){
-/*globals Backbone */
+
+/***/ }),
+
+/***/ 23:
+/***/ (function(module, exports) {
+
+var Attachments = wp.media.model.Attachments,
+	Query;
+
+/**
+ * wp.media.model.Query
+ *
+ * A collection of attachments that match the supplied query arguments.
+ *
+ * Note: Do NOT change this.args after the query has been initialized.
+ *       Things will break.
+ *
+ * @memberOf wp.media.model
+ *
+ * @class
+ * @augments wp.media.model.Attachments
+ * @augments Backbone.Collection
+ *
+ * @param {array}  [models]                      Models to initialize with the collection.
+ * @param {object} [options]                     Options hash.
+ * @param {object} [options.args]                Attachments query arguments.
+ * @param {object} [options.args.posts_per_page]
+ */
+Query = Attachments.extend(/** @lends wp.media.model.Query.prototype */{
+	/**
+	 * @param {array}  [models=[]]  Array of initial models to populate the collection.
+	 * @param {object} [options={}]
+	 */
+	initialize: function( models, options ) {
+		var allowed;
+
+		options = options || {};
+		Attachments.prototype.initialize.apply( this, arguments );
+
+		this.args     = options.args;
+		this._hasMore = true;
+		this.created  = new Date();
+
+		this.filters.order = function( attachment ) {
+			var orderby = this.props.get('orderby'),
+				order = this.props.get('order');
+
+			if ( ! this.comparator ) {
+				return true;
+			}
+
+			// We want any items that can be placed before the last
+			// item in the set. If we add any items after the last
+			// item, then we can't guarantee the set is complete.
+			if ( this.length ) {
+				return 1 !== this.comparator( attachment, this.last(), { ties: true });
+
+			// Handle the case where there are no items yet and
+			// we're sorting for recent items. In that case, we want
+			// changes that occurred after we created the query.
+			} else if ( 'DESC' === order && ( 'date' === orderby || 'modified' === orderby ) ) {
+				return attachment.get( orderby ) >= this.created;
+
+			// If we're sorting by menu order and we have no items,
+			// accept any items that have the default menu order (0).
+			} else if ( 'ASC' === order && 'menuOrder' === orderby ) {
+				return attachment.get( orderby ) === 0;
+			}
+
+			// Otherwise, we don't want any items yet.
+			return false;
+		};
+
+		// Observe the central `wp.Uploader.queue` collection to watch for
+		// new matches for the query.
+		//
+		// Only observe when a limited number of query args are set. There
+		// are no filters for other properties, so observing will result in
+		// false positives in those queries.
+		allowed = [ 's', 'order', 'orderby', 'posts_per_page', 'post_mime_type', 'post_parent', 'author' ];
+		if ( wp.Uploader && _( this.args ).chain().keys().difference( allowed ).isEmpty().value() ) {
+			this.observe( wp.Uploader.queue );
+		}
+	},
+	/**
+	 * Whether there are more attachments that haven't been sync'd from the server
+	 * that match the collection's query.
+	 *
+	 * @returns {boolean}
+	 */
+	hasMore: function() {
+		return this._hasMore;
+	},
+	/**
+	 * Fetch more attachments from the server for the collection.
+	 *
+	 * @param   {object}  [options={}]
+	 * @returns {Promise}
+	 */
+	more: function( options ) {
+		var query = this;
+
+		// If there is already a request pending, return early with the Deferred object.
+		if ( this._more && 'pending' === this._more.state() ) {
+			return this._more;
+		}
+
+		if ( ! this.hasMore() ) {
+			return jQuery.Deferred().resolveWith( this ).promise();
+		}
+
+		options = options || {};
+		options.remove = false;
+
+		return this._more = this.fetch( options ).done( function( resp ) {
+			if ( _.isEmpty( resp ) || -1 === this.args.posts_per_page || resp.length < this.args.posts_per_page ) {
+				query._hasMore = false;
+			}
+		});
+	},
+	/**
+	 * Overrides Backbone.Collection.sync
+	 * Overrides wp.media.model.Attachments.sync
+	 *
+	 * @param {String} method
+	 * @param {Backbone.Model} model
+	 * @param {Object} [options={}]
+	 * @returns {Promise}
+	 */
+	sync: function( method, model, options ) {
+		var args, fallback;
+
+		// Overload the read method so Attachment.fetch() functions correctly.
+		if ( 'read' === method ) {
+			options = options || {};
+			options.context = this;
+			options.data = _.extend( options.data || {}, {
+				action:  'query-attachments',
+				post_id: wp.media.model.settings.post.id
+			});
+
+			// Clone the args so manipulation is non-destructive.
+			args = _.clone( this.args );
+
+			// Determine which page to query.
+			if ( -1 !== args.posts_per_page ) {
+				args.paged = Math.round( this.length / args.posts_per_page ) + 1;
+			}
+
+			options.data.query = args;
+			return wp.media.ajax( options );
+
+		// Otherwise, fall back to Backbone.sync()
+		} else {
+			/**
+			 * Call wp.media.model.Attachments.sync or Backbone.sync
+			 */
+			fallback = Attachments.prototype.sync ? Attachments.prototype : Backbone;
+			return fallback.sync.apply( this, arguments );
+		}
+	}
+}, /** @lends wp.media.model.Query */{
+	/**
+	 * @readonly
+	 */
+	defaultProps: {
+		orderby: 'date',
+		order:   'DESC'
+	},
+	/**
+	 * @readonly
+	 */
+	defaultArgs: {
+		posts_per_page: 40
+	},
+	/**
+	 * @readonly
+	 */
+	orderby: {
+		allowed:  [ 'name', 'author', 'date', 'title', 'modified', 'uploadedTo', 'id', 'post__in', 'menuOrder' ],
+		/**
+		 * A map of JavaScript orderby values to their WP_Query equivalents.
+		 * @type {Object}
+		 */
+		valuemap: {
+			'id':         'ID',
+			'uploadedTo': 'parent',
+			'menuOrder':  'menu_order ID'
+		}
+	},
+	/**
+	 * A map of JavaScript query properties to their WP_Query equivalents.
+	 *
+	 * @readonly
+	 */
+	propmap: {
+		'search':		's',
+		'type':			'post_mime_type',
+		'perPage':		'posts_per_page',
+		'menuOrder':	'menu_order',
+		'uploadedTo':	'post_parent',
+		'status':		'post_status',
+		'include':		'post__in',
+		'exclude':		'post__not_in',
+		'author':		'author'
+	},
+	/**
+	 * Creates and returns an Attachments Query collection given the properties.
+	 *
+	 * Caches query objects and reuses where possible.
+	 *
+	 * @static
+	 * @method
+	 *
+	 * @param {object} [props]
+	 * @param {Object} [props.cache=true]   Whether to use the query cache or not.
+	 * @param {Object} [props.order]
+	 * @param {Object} [props.orderby]
+	 * @param {Object} [props.include]
+	 * @param {Object} [props.exclude]
+	 * @param {Object} [props.s]
+	 * @param {Object} [props.post_mime_type]
+	 * @param {Object} [props.posts_per_page]
+	 * @param {Object} [props.menu_order]
+	 * @param {Object} [props.post_parent]
+	 * @param {Object} [props.post_status]
+	 * @param {Object} [props.author]
+	 * @param {Object} [options]
+	 *
+	 * @returns {wp.media.model.Query} A new Attachments Query collection.
+	 */
+	get: (function(){
+		/**
+		 * @static
+		 * @type Array
+		 */
+		var queries = [];
+
+		/**
+		 * @returns {Query}
+		 */
+		return function( props, options ) {
+			var args     = {},
+				orderby  = Query.orderby,
+				defaults = Query.defaultProps,
+				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 );
+
+			// Normalize the order.
+			props.order = props.order.toUpperCase();
+			if ( 'DESC' !== props.order && 'ASC' !== props.order ) {
+				props.order = defaults.order.toUpperCase();
+			}
+
+			// Ensure we have a valid orderby value.
+			if ( ! _.contains( orderby.allowed, props.orderby ) ) {
+				props.orderby = defaults.orderby;
+			}
+
+			_.each( [ 'include', 'exclude' ], function( prop ) {
+				if ( props[ prop ] && ! _.isArray( props[ prop ] ) ) {
+					props[ prop ] = [ props[ prop ] ];
+				}
+			} );
+
+			// Generate the query `args` object.
+			// Correct any differing property names.
+			_.each( props, function( value, prop ) {
+				if ( _.isNull( value ) ) {
+					return;
+				}
+
+				args[ Query.propmap[ prop ] || prop ] = value;
+			});
+
+			// Fill any other default query args.
+			_.defaults( args, Query.defaultArgs );
+
+			// `props.orderby` does not always map directly to `args.orderby`.
+			// Substitute exceptions specified in orderby.keymap.
+			args.orderby = orderby.valuemap[ props.orderby ] || props.orderby;
+
+			// Search the query cache for a matching query.
+			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 ) {
+				query = new Query( [], _.extend( options || {}, {
+					props: props,
+					args:  args
+				} ) );
+				queries.push( query );
+			}
+
+			return query;
+		};
+	}())
+});
+
+module.exports = Query;
+
+
+/***/ }),
+
+/***/ 24:
+/***/ (function(module, exports) {
 
 /**
  * wp.media.model.PostImage
@@ -945,13 +1370,15 @@
  *
  * Used in the embedded image attachment display settings modal - @see wp.media.view.MediaFrame.ImageDetails.
  *
+ * @memberOf wp.media.model
+ *
  * @class
  * @augments Backbone.Model
  *
  * @param {int} [attributes]               Initial model attributes.
  * @param {int} [attributes.attachment_id] ID of the attachment.
  **/
-var PostImage = Backbone.Model.extend({
+var PostImage = Backbone.Model.extend(/** @lends wp.media.model.PostImage.prototype */{
 
 	initialize: function( attributes ) {
 		var Attachment = wp.media.model.Attachment;
@@ -1091,332 +1518,27 @@
 
 module.exports = PostImage;
 
-},{}],5:[function(require,module,exports){
-/*globals wp, _ */
 
-/**
- * wp.media.model.Query
- *
- * A collection of attachments that match the supplied query arguments.
- *
- * Note: Do NOT change this.args after the query has been initialized.
- *       Things will break.
- *
- * @class
- * @augments wp.media.model.Attachments
- * @augments Backbone.Collection
- *
- * @param {array}  [models]                      Models to initialize with the collection.
- * @param {object} [options]                     Options hash.
- * @param {object} [options.args]                Attachments query arguments.
- * @param {object} [options.args.posts_per_page]
- */
-var Attachments = wp.media.model.Attachments,
-	Query;
-
-Query = Attachments.extend({
-	/**
-	 * @global wp.Uploader
-	 *
-	 * @param {array}  [models=[]]  Array of initial models to populate the collection.
-	 * @param {object} [options={}]
-	 */
-	initialize: function( models, options ) {
-		var allowed;
-
-		options = options || {};
-		Attachments.prototype.initialize.apply( this, arguments );
-
-		this.args     = options.args;
-		this._hasMore = true;
-		this.created  = new Date();
-
-		this.filters.order = function( attachment ) {
-			var orderby = this.props.get('orderby'),
-				order = this.props.get('order');
-
-			if ( ! this.comparator ) {
-				return true;
-			}
-
-			// We want any items that can be placed before the last
-			// item in the set. If we add any items after the last
-			// item, then we can't guarantee the set is complete.
-			if ( this.length ) {
-				return 1 !== this.comparator( attachment, this.last(), { ties: true });
-
-			// Handle the case where there are no items yet and
-			// we're sorting for recent items. In that case, we want
-			// changes that occurred after we created the query.
-			} else if ( 'DESC' === order && ( 'date' === orderby || 'modified' === orderby ) ) {
-				return attachment.get( orderby ) >= this.created;
-
-			// If we're sorting by menu order and we have no items,
-			// accept any items that have the default menu order (0).
-			} else if ( 'ASC' === order && 'menuOrder' === orderby ) {
-				return attachment.get( orderby ) === 0;
-			}
-
-			// Otherwise, we don't want any items yet.
-			return false;
-		};
-
-		// Observe the central `wp.Uploader.queue` collection to watch for
-		// new matches for the query.
-		//
-		// Only observe when a limited number of query args are set. There
-		// are no filters for other properties, so observing will result in
-		// false positives in those queries.
-		allowed = [ 's', 'order', 'orderby', 'posts_per_page', 'post_mime_type', 'post_parent' ];
-		if ( wp.Uploader && _( this.args ).chain().keys().difference( allowed ).isEmpty().value() ) {
-			this.observe( wp.Uploader.queue );
-		}
-	},
-	/**
-	 * Whether there are more attachments that haven't been sync'd from the server
-	 * that match the collection's query.
-	 *
-	 * @returns {boolean}
-	 */
-	hasMore: function() {
-		return this._hasMore;
-	},
-	/**
-	 * Fetch more attachments from the server for the collection.
-	 *
-	 * @param   {object}  [options={}]
-	 * @returns {Promise}
-	 */
-	more: function( options ) {
-		var query = this;
-
-		// If there is already a request pending, return early with the Deferred object.
-		if ( this._more && 'pending' === this._more.state() ) {
-			return this._more;
-		}
-
-		if ( ! this.hasMore() ) {
-			return jQuery.Deferred().resolveWith( this ).promise();
-		}
-
-		options = options || {};
-		options.remove = false;
-
-		return this._more = this.fetch( options ).done( function( resp ) {
-			if ( _.isEmpty( resp ) || -1 === this.args.posts_per_page || resp.length < this.args.posts_per_page ) {
-				query._hasMore = false;
-			}
-		});
-	},
-	/**
-	 * Overrides Backbone.Collection.sync
-	 * Overrides wp.media.model.Attachments.sync
-	 *
-	 * @param {String} method
-	 * @param {Backbone.Model} model
-	 * @param {Object} [options={}]
-	 * @returns {Promise}
-	 */
-	sync: function( method, model, options ) {
-		var args, fallback;
-
-		// Overload the read method so Attachment.fetch() functions correctly.
-		if ( 'read' === method ) {
-			options = options || {};
-			options.context = this;
-			options.data = _.extend( options.data || {}, {
-				action:  'query-attachments',
-				post_id: wp.media.model.settings.post.id
-			});
-
-			// Clone the args so manipulation is non-destructive.
-			args = _.clone( this.args );
-
-			// Determine which page to query.
-			if ( -1 !== args.posts_per_page ) {
-				args.paged = Math.round( this.length / args.posts_per_page ) + 1;
-			}
-
-			options.data.query = args;
-			return wp.media.ajax( options );
+/***/ }),
 
-		// Otherwise, fall back to Backbone.sync()
-		} else {
-			/**
-			 * Call wp.media.model.Attachments.sync or Backbone.sync
-			 */
-			fallback = Attachments.prototype.sync ? Attachments.prototype : Backbone;
-			return fallback.sync.apply( this, arguments );
-		}
-	}
-}, {
-	/**
-	 * @readonly
-	 */
-	defaultProps: {
-		orderby: 'date',
-		order:   'DESC'
-	},
-	/**
-	 * @readonly
-	 */
-	defaultArgs: {
-		posts_per_page: 40
-	},
-	/**
-	 * @readonly
-	 */
-	orderby: {
-		allowed:  [ 'name', 'author', 'date', 'title', 'modified', 'uploadedTo', 'id', 'post__in', 'menuOrder' ],
-		/**
-		 * A map of JavaScript orderby values to their WP_Query equivalents.
-		 * @type {Object}
-		 */
-		valuemap: {
-			'id':         'ID',
-			'uploadedTo': 'parent',
-			'menuOrder':  'menu_order ID'
-		}
-	},
-	/**
-	 * A map of JavaScript query properties to their WP_Query equivalents.
-	 *
-	 * @readonly
-	 */
-	propmap: {
-		'search':    's',
-		'type':      'post_mime_type',
-		'perPage':   'posts_per_page',
-		'menuOrder': 'menu_order',
-		'uploadedTo': 'post_parent',
-		'status':     'post_status',
-		'include':    'post__in',
-		'exclude':    'post__not_in'
-	},
-	/**
-	 * Creates and returns an Attachments Query collection given the properties.
-	 *
-	 * Caches query objects and reuses where possible.
-	 *
-	 * @static
-	 * @method
-	 *
-	 * @param {object} [props]
-	 * @param {Object} [props.cache=true]   Whether to use the query cache or not.
-	 * @param {Object} [props.order]
-	 * @param {Object} [props.orderby]
-	 * @param {Object} [props.include]
-	 * @param {Object} [props.exclude]
-	 * @param {Object} [props.s]
-	 * @param {Object} [props.post_mime_type]
-	 * @param {Object} [props.posts_per_page]
-	 * @param {Object} [props.menu_order]
-	 * @param {Object} [props.post_parent]
-	 * @param {Object} [props.post_status]
-	 * @param {Object} [options]
-	 *
-	 * @returns {wp.media.model.Query} A new Attachments Query collection.
-	 */
-	get: (function(){
-		/**
-		 * @static
-		 * @type Array
-		 */
-		var queries = [];
+/***/ 25:
+/***/ (function(module, exports) {
 
-		/**
-		 * @returns {Query}
-		 */
-		return function( props, options ) {
-			var args     = {},
-				orderby  = Query.orderby,
-				defaults = Query.defaultProps,
-				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 );
-
-			// Normalize the order.
-			props.order = props.order.toUpperCase();
-			if ( 'DESC' !== props.order && 'ASC' !== props.order ) {
-				props.order = defaults.order.toUpperCase();
-			}
-
-			// Ensure we have a valid orderby value.
-			if ( ! _.contains( orderby.allowed, props.orderby ) ) {
-				props.orderby = defaults.orderby;
-			}
-
-			_.each( [ 'include', 'exclude' ], function( prop ) {
-				if ( props[ prop ] && ! _.isArray( props[ prop ] ) ) {
-					props[ prop ] = [ props[ prop ] ];
-				}
-			} );
-
-			// Generate the query `args` object.
-			// Correct any differing property names.
-			_.each( props, function( value, prop ) {
-				if ( _.isNull( value ) ) {
-					return;
-				}
-
-				args[ Query.propmap[ prop ] || prop ] = value;
-			});
-
-			// Fill any other default query args.
-			_.defaults( args, Query.defaultArgs );
-
-			// `props.orderby` does not always map directly to `args.orderby`.
-			// Substitute exceptions specified in orderby.keymap.
-			args.orderby = orderby.valuemap[ props.orderby ] || props.orderby;
-
-			// Search the query cache for a matching query.
-			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 ) {
-				query = new Query( [], _.extend( options || {}, {
-					props: props,
-					args:  args
-				} ) );
-				queries.push( query );
-			}
-
-			return query;
-		};
-	}())
-});
-
-module.exports = Query;
-
-},{}],6:[function(require,module,exports){
-/*globals wp, _ */
+var Attachments = wp.media.model.Attachments,
+	Selection;
 
 /**
  * wp.media.model.Selection
  *
  * A selection of attachments.
  *
+ * @memberOf wp.media.model
+ *
  * @class
  * @augments wp.media.model.Attachments
  * @augments Backbone.Collection
  */
-var Attachments = wp.media.model.Attachments,
-	Selection;
-
-Selection = Attachments.extend({
+Selection = Attachments.extend(/** @lends wp.media.model.Selection.prototype */{
 	/**
 	 * Refresh the `single` model whenever the selection changes.
 	 * Binds `single` instead of using the context argument to ensure
@@ -1500,4 +1622,7 @@
 
 module.exports = Selection;
 
-},{}]},{},[1]);
+
+/***/ })
+
+/******/ });
\ No newline at end of file