Changeset 22951
- Timestamp:
- 11/30/2012 03:11:44 PM (12 years ago)
- Location:
- trunk/wp-includes/js
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/media-editor.js
r22943 r22951 206 206 207 207 if ( ! args.post__in ) 208 args. parent= attrs.id;208 args.uploadedTo = attrs.id; 209 209 210 210 // Collect the attributes that were not included in `args`. … … 229 229 attrs.ids = attachments.pluck('id'); 230 230 231 // Copy the ` parent` post ID.232 if ( props. parent)233 attrs.id = props. parent;231 // Copy the `uploadedTo` post ID. 232 if ( props.uploadedTo ) 233 attrs.id = props.uploadedTo; 234 234 235 235 // If the `ids` attribute is set and `orderby` attribute -
trunk/wp-includes/js/media-models.js
r22882 r22951 317 317 318 318 // Bind default `change` events to the `props` model. 319 this.props.on( 'change', this._changeFilteredProps, this ); 320 319 321 this.props.on( 'change:order', this._changeOrder, this ); 320 322 this.props.on( 'change:orderby', this._changeOrderby, this ); 321 323 this.props.on( 'change:query', this._changeQuery, this ); 322 this.props.on( 'change:search', this._changeSearch, this );323 this.props.on( 'change:type', this._changeType, this );324 324 325 325 // Set the `props` model and fill the default property values. … … 360 360 }, 361 361 362 _changeFilteredProp : function( prop, model, term) {362 _changeFilteredProps: function( model, options ) { 363 363 // If this is a query, updating the collection will be handled by 364 364 // `this._requery()`. … … 366 366 return; 367 367 368 if ( term && ! this.filters[ prop ] ) 369 this.filters[ prop ] = Attachments.filters[ prop ]; 370 else if ( ! term && this.filters[ prop ] === Attachments.filters[ prop ] ) 371 delete this.filters[ prop ]; 368 var changed = _.chain( options.changes ).map( function( t, prop ) { 369 var filter = Attachments.filters[ prop ], 370 term = model.get( prop ); 371 372 if ( ! filter ) 373 return; 374 375 if ( term && ! this.filters[ prop ] ) 376 this.filters[ prop ] = filter; 377 else if ( ! term && this.filters[ prop ] === filter ) 378 delete this.filters[ prop ]; 379 else 380 return; 381 382 // Record the change. 383 return true; 384 }, this ).any().value(); 385 386 if ( ! changed ) 387 return; 372 388 373 389 // If no `Attachments` model is provided to source the searches … … 378 394 379 395 this.reset( this._source.filter( this.validator, this ) ); 380 },381 382 _changeSearch: function( model, term ) {383 return this._changeFilteredProp( 'search', model, term );384 },385 386 _changeType: function( model, term ) {387 return this._changeFilteredProp( 'type', model, term );388 396 }, 389 397 … … 500 508 } 501 509 }, { 502 comparator: function( a, b ) {510 comparator: function( a, b, options ) { 503 511 var key = this.props.get('orderby'), 504 512 order = this.props.get('order') || 'DESC', … … 513 521 b = b || new Date(); 514 522 } 523 524 // If `options.ties` is set, don't enforce the `cid` tiebreaker. 525 if ( options && options.ties ) 526 ac = bc = null; 515 527 516 528 return ( 'DESC' === order ) ? compare( a, b, ac, bc ) : compare( b, a, bc, ac ); … … 532 544 type: function( attachment ) { 533 545 var type = this.props.get('type'); 534 if ( ! type ) 546 return ! type || -1 !== type.indexOf( attachment.get('type') ); 547 }, 548 549 uploadedTo: function( attachment ) { 550 var uploadedTo = this.props.get('uploadedTo'); 551 if ( _.isUndefined( uploadedTo ) ) 535 552 return true; 536 553 537 return -1 !== type.indexOf( attachment.get('type'));554 return uploadedTo === attachment.get('uploadedTo'); 538 555 } 539 556 } … … 572 589 573 590 this.filters.order = function( attachment ) { 591 var orderby = this.props.get('orderby'), 592 order = this.props.get('order'); 593 574 594 if ( ! this.comparator ) 575 595 return true; … … 579 599 // item, then we can't guarantee the set is complete. 580 600 if ( this.length ) { 581 return 1 !== this.comparator( attachment, this.last() 601 return 1 !== this.comparator( attachment, this.last(), { ties: true }); 582 602 583 603 // Handle the case where there are no items yet and 584 604 // we're sorting for recent items. In that case, we want 585 605 // changes that occurred after we created the query. 586 } else if ( 'DESC' === this.args.order && ( 'date' === this.args.orderby || 'modified' === this.args.orderby ) ) { 587 return attachment.get( this.args.orderby ) >= this.created; 606 } else if ( 'DESC' === order && ( 'date' === orderby || 'modified' === orderby ) ) { 607 return attachment.get( orderby ) >= this.created; 608 609 // If we're sorting by menu order and we have no items, 610 // accept any items that have the default menu order (0). 611 } else if ( 'ASC' === order && 'menuOrder' === orderby ) { 612 return attachment.get( orderby ) === 0; 588 613 } 589 614 … … 598 623 // are no filters for other properties, so observing will result in 599 624 // false positives in those queries. 600 allowed = [ 's', 'order', 'orderby', 'posts_per_page', 'post_mime_type' ];625 allowed = [ 's', 'order', 'orderby', 'posts_per_page', 'post_mime_type', 'post_parent' ]; 601 626 if ( wp.Uploader && _( this.args ).chain().keys().difference( allowed ).isEmpty().value() ) 602 627 this.observe( wp.Uploader.queue ); … … 671 696 'search': 's', 672 697 'type': 'post_mime_type', 673 'parent': 'post_parent',674 698 'perPage': 'posts_per_page', 675 'menuOrder': 'menu_order' 699 'menuOrder': 'menu_order', 700 'uploadedTo': 'post_parent' 676 701 }, 677 702 -
trunk/wp-includes/js/media-views.js
r22948 r22951 2921 2921 text: l10n.allMediaItems, 2922 2922 props: { 2923 parent:null,2923 uploadedTo: null, 2924 2924 orderby: 'date', 2925 2925 order: 'DESC' … … 2931 2931 text: l10n.uploadedToThisPost, 2932 2932 props: { 2933 parent:media.view.settings.postId,2933 uploadedTo: media.view.settings.postId, 2934 2934 orderby: 'menuOrder', 2935 2935 order: 'ASC' … … 2949 2949 props: { 2950 2950 type: key, 2951 parent:null,2951 uploadedTo: null, 2952 2952 orderby: 'date', 2953 2953 order: 'DESC' … … 2960 2960 props: { 2961 2961 type: null, 2962 parent:null,2962 uploadedTo: null, 2963 2963 orderby: 'date', 2964 2964 order: 'DESC' … … 2971 2971 props: { 2972 2972 type: null, 2973 parent:media.view.settings.postId,2973 uploadedTo: media.view.settings.postId, 2974 2974 orderby: 'menuOrder', 2975 2975 order: 'ASC' -
trunk/wp-includes/js/plupload/wp-plupload.js
r22822 r22951 156 156 uploading: true, 157 157 date: new Date(), 158 filename: file.name 158 filename: file.name, 159 menuOrder: 0, 160 uploadedTo: media.model.settings.postId 159 161 }, _.pick( file, 'loaded', 'size', 'percent' ) ); 160 162
Note: See TracChangeset
for help on using the changeset viewer.