Changeset 22660
- Timestamp:
- 11/19/2012 04:41:57 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/media-views.js
r22659 r22660 592 592 add = options && options.add; 593 593 existing = this.get( selector ); 594 next = views; 594 595 method = add ? 'attach' : 'replace'; 595 596 596 if ( ! add && existing ) { 597 this.unset( selector ); 598 _.invoke( existing, 'dispose' ); 597 if ( existing ) { 598 if ( add ) { 599 if ( _.isUndefined( options.at ) ) 600 next = existing.concat( views ); 601 else 602 next = existing.splice.apply( existing, [ options.at, 0 ].concat( views ) ); 603 } else { 604 this.unset( selector ); 605 _.invoke( existing, 'dispose' ); 606 } 599 607 } 600 608 601 this._views[ selector ] = add && existing ? existing.concat( views ) : views;609 this._views[ selector ] = next; 602 610 603 611 $selector = selector ? this.view.$( selector ) : this.view.$el; … … 611 619 }, this ); 612 620 613 this[ method ]( $selector, els );614 return this; 615 }, 616 617 add: function( selector, views ) {618 return this.set( selector, views, { add: true });621 this[ method ]( $selector, els, options ); 622 return this; 623 }, 624 625 add: function( selector, views, options ) { 626 return this.set( selector, views, _.extend({ add: true }, options ) ); 619 627 }, 620 628 … … 662 670 }, 663 671 664 attach: function( $target, els ) { 665 $target.append( els ); 672 attach: function( $target, els, options ) { 673 var at = options && options.at, 674 $children; 675 676 if ( _.isNumber( at ) && ($children = $target.children()).length > at ) 677 $children.eq( at ).before( els ); 678 else 679 $target.append( els ); 680 666 681 return this; 667 682 }
Note: See TracChangeset
for help on using the changeset viewer.