Sha256: 798d29a7feea9478d855392265cef19259803c4d70f155eafe8bb7192c2244a2

Contents?: true

Size: 1.83 KB

Versions: 22

Compression:

Stored size: 1.83 KB

Contents

// ========================================================================
// SproutCore
// copyright 2006-2008 Sprout Systems, Inc.
// ========================================================================

require('views/view') ;

/** 
  @class
  
  A container view will place the view of its content property inside
  of itself as its only child.  You can override this with a custom
  replaceContent() method if you want to do something different when the
  content changes.
  
  @extends SC.View

*/
SC.ContainerView = SC.View.extend(
  /** @scope SC.ContainerView.prototype */
  {
  
  /** change this property value to replace the content of the container.
      @type SC.View
  */
  content: null,
  
  /** @private */
  contentBindingDefault: SC.Binding.Single,
  
  /** 
    define an outlet named rootView to use that view as the container.
    
    Normally container view will set its own child views to the content you
    set. Instead, you can set the rootView property to point to a child view 
    of the container and the child views in that view will be changed instead.
    
    @type SC.View
  */
  rootView: null,

  /**
    Replaces any child views with the passed new content.  
    
    This method is automatically called whenever your content property 
    changes.  You can override it if you want to provide some behavior other
    than the default.
    
    @param {SC.View} newContent the new content view or null.
  */
  replaceContent: function(newContent) {
    var containerView = this.get('rootView') || this ;
    containerView.clear() ;
    var newView = newContent ;
    
    if (newView) {
      newView.viewFrameWillChange() ;
      containerView.appendChild(newView) ;
      newView.viewFrameDidChange() ;
    }
  },
  
  _contentObserver: function() {
    this.replaceContent(this.get('content'));
  }.observes('content')
  
}) ;

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
sproutcore-0.9.10 frameworks/sproutcore/views/container.js
sproutcore-0.9.11 frameworks/sproutcore/views/container.js
sproutcore-0.9.12 frameworks/sproutcore/views/container.js
sproutcore-0.9.15 frameworks/sproutcore/views/container.js
sproutcore-0.9.14 frameworks/sproutcore/views/container.js
sproutcore-0.9.13 frameworks/sproutcore/views/container.js
sproutcore-0.9.18 frameworks/sproutcore/views/container.js
sproutcore-0.9.19 frameworks/sproutcore/views/container.js
sproutcore-0.9.17 frameworks/sproutcore/views/container.js
sproutcore-0.9.16 frameworks/sproutcore/views/container.js
sproutcore-0.9.2 frameworks/sproutcore/views/container.js
sproutcore-0.9.22 frameworks/sproutcore/views/container.js
sproutcore-0.9.23 frameworks/sproutcore/views/container.js
sproutcore-0.9.21 frameworks/sproutcore/views/container.js
sproutcore-0.9.20 frameworks/sproutcore/views/container.js
sproutcore-0.9.3 frameworks/sproutcore/views/container.js
sproutcore-0.9.4 frameworks/sproutcore/views/container.js
sproutcore-0.9.5 frameworks/sproutcore/views/container.js
sproutcore-0.9.9 frameworks/sproutcore/views/container.js
sproutcore-0.9.8 frameworks/sproutcore/views/container.js