1 // ==========================================================================
  2 // Project:   SproutCore - JavaScript Application Framework
  3 // Copyright: ©2006-2011 Strobe Inc. and contributors.
  4 //            Portions ©2008-2011 Apple Inc. All rights reserved.
  5 // License:   Licensed under MIT license (see license.js)
  6 // ==========================================================================
  7 
  8 /**
  9   @static
 10   @constant
 11   @type Number
 12   @default 15
 13 */
 14 SC.WELL_CONTAINER_PADDING = 15;
 15 
 16 /** @class
 17 
 18   A WellView is a ContainerView with a border. It's useful when you want to
 19   group a set of views. It allows you to easily switch its contents too.
 20 
 21   It has a default contentLayout that will replace the layout of the contentView.
 22 
 23   @extends SC.ContainerView
 24   @since SproutCore 1.0
 25   @test in progress
 26 */
 27 SC.WellView = SC.ContainerView.extend(
 28 /** @scope SC.WellView.prototype */ {
 29 
 30   /**
 31     @type Array
 32     @default ['sc-well-view']
 33     @see SC.View#classNames
 34   */
 35   classNames: 'sc-well-view',
 36 
 37   /**
 38     Layout for the content of the container view.
 39     @type Hash
 40   */
 41   contentLayout: {
 42     top: SC.WELL_CONTAINER_PADDING,
 43     bottom: SC.WELL_CONTAINER_PADDING,
 44     left: SC.WELL_CONTAINER_PADDING,
 45     right: SC.WELL_CONTAINER_PADDING
 46   },
 47 
 48   /**
 49     @type String
 50     @default 'wellRenderDelegate'
 51   */
 52   renderDelegateName: 'wellRenderDelegate',
 53 
 54   /** @private
 55      Overrides createChildViews and replaces the layout of the contentView
 56      with the one in contentLayout.
 57    */
 58   createChildView: function (view, attrs) {
 59     view = sc_super();
 60 
 61     view.set('layout', this.contentLayout);
 62     return view;
 63   },
 64 
 65   /** @private
 66      Invoked whenever the content property changes.  This method will simply set the contentLayout
 67      in the new contentView.
 68    */
 69   _sc_contentViewDidChange: function () {
 70     var contentView = this.get('contentView');
 71     contentView.set('layout', this.contentLayout);
 72 
 73     sc_super();
 74   }
 75 
 76 });
 77