diff --git src/wp-includes/js/media-models.js src/wp-includes/js/media-models.js
index cba928d..854592c 100644
|
|
|
window.wp = window.wp || {}; |
| 65 | 65 | */ |
| 66 | 66 | |
| 67 | 67 | /** |
| 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() |
| 69 | 73 | * |
| 70 | 74 | * @param {mixed} a The primary parameter to compare. |
| 71 | 75 | * @param {mixed} b The primary parameter to compare. |
| … |
… |
window.wp = window.wp || {}; |
| 87 | 91 | /** |
| 88 | 92 | * media.template( id ) |
| 89 | 93 | * |
| 90 | | * Fetches a template by id. |
| | 94 | * Fetch a JavaScript template for an id, and return a templating function. |
| | 95 | * |
| 91 | 96 | * See wp.template() in `wp-includes/js/wp-util.js`. |
| 92 | 97 | * |
| 93 | 98 | * @borrows wp.template as template |
| … |
… |
window.wp = window.wp || {}; |
| 197 | 202 | /** |
| 198 | 203 | * wp.media.model.Attachment |
| 199 | 204 | * |
| 200 | | * @constructor |
| | 205 | * @class |
| 201 | 206 | * @augments Backbone.Model |
| 202 | 207 | */ |
| 203 | 208 | Attachment = media.model.Attachment = Backbone.Model.extend({ |
| … |
… |
window.wp = window.wp || {}; |
| 329 | 334 | } |
| 330 | 335 | }, { |
| 331 | 336 | /** |
| 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. |
| 333 | 338 | * |
| 334 | 339 | * @static |
| 335 | 340 | * @param {Object} attrs |
| … |
… |
window.wp = window.wp || {}; |
| 339 | 344 | return Attachments.all.push( attrs ); |
| 340 | 345 | }, |
| 341 | 346 | /** |
| 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. |
| 343 | 348 | * |
| 344 | 349 | * @static |
| 345 | 350 | * @param {string} id A string used to identify a model. |
| … |
… |
window.wp = window.wp || {}; |
| 354 | 359 | /** |
| 355 | 360 | * wp.media.model.PostImage |
| 356 | 361 | * |
| 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 |
| 358 | 367 | * @augments Backbone.Model |
| | 368 | * |
| | 369 | * @param {int} [attributes] Initial model attributes. |
| | 370 | * @param {int} [attributes.attachment_id] ID of the attachment. |
| 359 | 371 | **/ |
| 360 | 372 | PostImage = media.model.PostImage = Backbone.Model.extend({ |
| 361 | 373 | |
| … |
… |
window.wp = window.wp || {}; |
| 497 | 509 | /** |
| 498 | 510 | * wp.media.model.Attachments |
| 499 | 511 | * |
| 500 | | * @constructor |
| | 512 | * A collection of attachments. |
| | 513 | * |
| | 514 | * @class |
| 501 | 515 | * @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 | * |
| 502 | 526 | */ |
| 503 | 527 | Attachments = media.model.Attachments = Backbone.Collection.extend({ |
| 504 | 528 | /** |
| … |
… |
window.wp = window.wp || {}; |
| 522 | 546 | this.props.on( 'change:orderby', this._changeOrderby, this ); |
| 523 | 547 | this.props.on( 'change:query', this._changeQuery, this ); |
| 524 | 548 | |
| 525 | | // Set the `props` model and fill the default property values. |
| 526 | 549 | this.props.set( _.defaults( options.props || {} ) ); |
| 527 | 550 | |
| 528 | | // Observe another `Attachments` collection if one is provided. |
| 529 | 551 | if ( options.observe ) { |
| 530 | 552 | this.observe( options.observe ); |
| 531 | 553 | } |
| … |
… |
window.wp = window.wp || {}; |
| 761 | 783 | delete this.mirroring; |
| 762 | 784 | }, |
| 763 | 785 | /** |
| | 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 | * |
| 764 | 789 | * @param {Object} options |
| 765 | 790 | * @returns {Promise} |
| 766 | 791 | */ |
| … |
… |
window.wp = window.wp || {}; |
| 784 | 809 | return deferred.promise(); |
| 785 | 810 | }, |
| 786 | 811 | /** |
| 787 | | * @returns {Boolean} |
| | 812 | * @returns {boolean} |
| 788 | 813 | */ |
| 789 | 814 | hasMore: function() { |
| 790 | 815 | return this.mirroring ? this.mirroring.hasMore() : false; |
| 791 | 816 | }, |
| 792 | 817 | /** |
| 793 | | * Overrides Backbone.Collection.parse |
| | 818 | * A custom AJAX-response parser. |
| | 819 | * |
| | 820 | * See trac ticket #24753 |
| 794 | 821 | * |
| 795 | 822 | * @param {Object|Array} resp The raw response Object/Array. |
| 796 | 823 | * @param {Object} xhr |
| … |
… |
window.wp = window.wp || {}; |
| 867 | 894 | } |
| 868 | 895 | }, { |
| 869 | 896 | /** |
| | 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 | * |
| 870 | 902 | * @static |
| 871 | | * Overrides Backbone.Collection.comparator |
| 872 | 903 | * |
| 873 | 904 | * @param {Backbone.Model} a |
| 874 | 905 | * @param {Backbone.Model} b |
| … |
… |
window.wp = window.wp || {}; |
| 991 | 1022 | /** |
| 992 | 1023 | * wp.media.model.Query |
| 993 | 1024 | * |
| 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. |
| 996 | 1026 | * |
| 997 | 1027 | * Note: Do NOT change this.args after the query has been initialized. |
| 998 | 1028 | * Things will break. |
| 999 | 1029 | * |
| 1000 | | * @constructor |
| | 1030 | * @class |
| 1001 | 1031 | * @augments wp.media.model.Attachments |
| 1002 | 1032 | * @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] |
| 1003 | 1038 | */ |
| 1004 | 1039 | Query = media.model.Query = Attachments.extend({ |
| 1005 | 1040 | /** |
| 1006 | 1041 | * @global wp.Uploader |
| 1007 | 1042 | * |
| 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={}] |
| 1010 | 1045 | */ |
| 1011 | 1046 | initialize: function( models, options ) { |
| 1012 | 1047 | var allowed; |
| … |
… |
window.wp = window.wp || {}; |
| 1015 | 1050 | Attachments.prototype.initialize.apply( this, arguments ); |
| 1016 | 1051 | |
| 1017 | 1052 | this.args = options.args; |
| | 1053 | // Whether there are attachments that haven't been sync'd from the server |
| | 1054 | // that match the query. |
| 1018 | 1055 | this._hasMore = true; |
| 1019 | 1056 | this.created = new Date(); |
| 1020 | 1057 | |
| … |
… |
window.wp = window.wp || {}; |
| 1060 | 1097 | } |
| 1061 | 1098 | }, |
| 1062 | 1099 | /** |
| 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} |
| 1064 | 1104 | */ |
| 1065 | 1105 | hasMore: function() { |
| 1066 | 1106 | return this._hasMore; |
| 1067 | 1107 | }, |
| 1068 | 1108 | /** |
| 1069 | | * @param {Object} [options={}] |
| | 1109 | * Fetch more attachments from the server for the collection. |
| | 1110 | * |
| | 1111 | * @param {object} [options={}] |
| 1070 | 1112 | * @returns {Promise} |
| 1071 | 1113 | */ |
| 1072 | 1114 | more: function( options ) { |
| 1073 | 1115 | var query = this; |
| 1074 | 1116 | |
| | 1117 | // If there is already a request pending, return early with the Deferred object. |
| 1075 | 1118 | if ( this._more && 'pending' === this._more.state() ) { |
| 1076 | 1119 | return this._more; |
| 1077 | 1120 | } |
| … |
… |
window.wp = window.wp || {}; |
| 1142 | 1185 | * @readonly |
| 1143 | 1186 | */ |
| 1144 | 1187 | defaultArgs: { |
| 1145 | | posts_per_page: 40 |
| | 1188 | posts_per_page: 10 |
| 1146 | 1189 | }, |
| 1147 | 1190 | /** |
| 1148 | 1191 | * @readonly |
| 1149 | 1192 | */ |
| 1150 | 1193 | orderby: { |
| 1151 | 1194 | 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 | */ |
| 1152 | 1199 | valuemap: { |
| 1153 | 1200 | 'id': 'ID', |
| 1154 | 1201 | 'uploadedTo': 'parent', |
| … |
… |
window.wp = window.wp || {}; |
| 1156 | 1203 | } |
| 1157 | 1204 | }, |
| 1158 | 1205 | /** |
| | 1206 | * A map of JavaScript query properties to their WP_Query equivalents. |
| | 1207 | * |
| 1159 | 1208 | * @readonly |
| 1160 | 1209 | */ |
| 1161 | 1210 | propmap: { |
| … |
… |
window.wp = window.wp || {}; |
| 1262 | 1311 | /** |
| 1263 | 1312 | * wp.media.model.Selection |
| 1264 | 1313 | * |
| 1265 | | * Used to manage a selection of attachments in the views. |
| | 1314 | * A selection of attachments. |
| 1266 | 1315 | * |
| 1267 | | * @constructor |
| | 1316 | * @class |
| 1268 | 1317 | * @augments wp.media.model.Attachments |
| 1269 | 1318 | * @augments Backbone.Collection |
| 1270 | 1319 | */ |
| … |
… |
window.wp = window.wp || {}; |
| 1288 | 1337 | }, |
| 1289 | 1338 | |
| 1290 | 1339 | /** |
| 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. |
| 1297 | 1342 | * |
| 1298 | 1343 | * @param {Array} models |
| 1299 | 1344 | * @param {Object} options |
| … |
… |
window.wp = window.wp || {}; |
| 1310 | 1355 | }, |
| 1311 | 1356 | |
| 1312 | 1357 | /** |
| 1313 | | * Triggered when toggling (clicking on) an attachment in the modal |
| | 1358 | * Fired when toggling (clicking on) an attachment in the modal. |
| 1314 | 1359 | * |
| 1315 | 1360 | * @param {undefined|boolean|wp.media.model.Attachment} model |
| 1316 | 1361 | * |
diff --git src/wp-includes/js/media-views.js src/wp-includes/js/media-views.js
index cc02f43..7111a56 100644
|
|
|
|
| 2664 | 2664 | state: 'insert', |
| 2665 | 2665 | metadata: {} |
| 2666 | 2666 | }); |
| 2667 | | /** |
| 2668 | | * call 'initialize' directly on the parent class |
| 2669 | | */ |
| | 2667 | |
| | 2668 | // Call 'initialize' directly on the parent class. |
| 2670 | 2669 | media.view.MediaFrame.Select.prototype.initialize.apply( this, arguments ); |
| 2671 | 2670 | this.createIframeStates(); |
| 2672 | 2671 | |
diff --git src/wp-includes/js/wp-util.js src/wp-includes/js/wp-util.js
index 867d3a0..591cd40 100644
|
|
|
window.wp = window.wp || {}; |
| 8 | 8 | /** |
| 9 | 9 | * wp.template( id ) |
| 10 | 10 | * |
| 11 | | * Fetches a template by id. |
| | 11 | * Fetch a JavaScript template for an id, and return a templating function. |
| 12 | 12 | * |
| 13 | 13 | * @param {string} id A string that corresponds to a DOM element with an id prefixed with "tmpl-". |
| 14 | 14 | * For example, "attachment" maps to "tmpl-attachment". |
| … |
… |
window.wp = window.wp || {}; |
| 16 | 16 | */ |
| 17 | 17 | wp.template = _.memoize(function ( id ) { |
| 18 | 18 | 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 | */ |
| 19 | 25 | options = { |
| 20 | 26 | evaluate: /<#([\s\S]+?)#>/g, |
| 21 | 27 | interpolate: /\{\{\{([\s\S]+?)\}\}\}/g, |