Changeset 22681
- Timestamp:
- 11/19/2012 10:40:49 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/media-views.js
r22671 r22681 575 575 576 576 _.extend( media.Views.prototype, { 577 // ### Fetch all of the subviews 578 // 579 // Returns an array of all subviews. 577 580 all: function() { 578 581 return _.flatten( this._views ); 579 582 }, 580 583 584 // ### Get a selector's subviews 585 // 586 // Fetches all subviews that match a given `selector`. 587 // 588 // If no `selector` is provided, it will grab all subviews attached 589 // to the view's root. 581 590 get: function( selector ) { 582 591 selector = selector || ''; … … 584 593 }, 585 594 595 // ### Register subview(s) 596 // 597 // Registers any number of `views` to a `selector`. 598 // 599 // When no `selector` is provided, the root selector (the empty string) 600 // is used. `views` accepts a `Backbone.View` instance or an array of 601 // `Backbone.View` instances. 602 // 603 // Use `Views.add()` as a shortcut for setting `options.add` to `true`. 604 // 605 // Accepts an `options` object, which has a significant effect on the 606 // resulting behavior. By default, the provided `views` will replace 607 // any existing views associated with the selector. If `options.add` 608 // is set to `true`, the provided `views` will be added to the existing 609 // views. When adding, the `views` will added to the end of the array 610 // by default. To insert `views` at a specific index, use `options.at`. 586 611 set: function( selector, views, options ) { 587 612 var $selector, els, existing, add, method; … … 639 664 }, 640 665 666 // ### Add subview(s) to existing subviews 667 // 668 // An alias to `Views.set()`, which defaults `options.add` to true. 669 // 670 // Adds any number of `views` to a `selector`. 671 // 672 // When no `selector` is provided, the root selector (the empty string) 673 // is used. `views` accepts a `Backbone.View` instance or an array of 674 // `Backbone.View` instances. 675 // 676 // Use `Views.set()` when setting `options.add` to `false`. 677 // 678 // Accepts an `options` object. By default, provided `views` will be 679 // inserted at the end of the array of existing views. To insert 680 // `views` at a specific index, use `options.at`. For more information 681 // on the `options` object, see `Views.set()`. 641 682 add: function( selector, views, options ) { 642 683 return this.set( selector, views, _.extend({ add: true }, options ) ); 643 684 }, 644 685 686 // ### Stop tracking subviews 687 // 688 // Stops tracking `views` registered to a `selector`. If no `views` are 689 // set, then all of the `selector`'s subviews will be unregistered. 645 690 unset: function( selector, views ) { 646 691 var existing; … … 659 704 }, 660 705 706 // ### Detach all subviews 707 // 708 // Detaches all subviews from the DOM. 709 // 710 // Helps to preserve all subview events when re-rendering the master 711 // view. Used in conjunction with `Views.render()`. 661 712 detach: function() { 662 713 $( _.pluck( this.all(), 'el' ) ).detach(); … … 664 715 }, 665 716 717 // ### Render all subviews 718 // 719 // Renders all subviews. Used in conjunction with `Views.detach()`. 666 720 render: function() { 667 721 var root = this._views['']; … … 678 732 }, 679 733 734 // ### Dispose all subviews 735 // 736 // Triggers the `dispose()` method on all subviews. Resets the 737 // internals of the views manager. 680 738 dispose: function() { 681 739 delete this.parent; … … 687 745 }, 688 746 747 // ### Replace a selector's subviews 748 // 749 // By default, sets the `$target` selector's html to the subview `els`. 750 // 751 // Can be overridden in subclasses. 689 752 replace: function( $target, els ) { 690 753 $target.html( els ); … … 692 755 }, 693 756 757 // ### Insert subviews into a selector 758 // 759 // By default, appends the subview `els` to the end of the `$target` 760 // selector. If `options.at` is set, inserts the subview `els` at the 761 // provided index. 762 // 763 // Can be overridden in subclasses. 694 764 insert: function( $target, els, options ) { 695 765 var at = options && options.at,
Note: See TracChangeset
for help on using the changeset viewer.