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   @deprecated SC.AutoMixin is deprecated. Please use the property autoMixins of SC.View instead
 10   @namespace
 11 
 12   Use this mixin to automatically mix in a list of mixins into all
 13   child views created _by the view_ (that are created at view initialization).
 14 
 15   @since SproutCore 1.0
 16 */
 17 SC.AutoMixin = {
 18 
 19   /**
 20     An array of mixins to automatically mix in to each child view of this
 21     view when the child view is created.
 22 
 23     @type Array
 24     @default []
 25   */
 26   autoMixins: [],
 27 
 28   /**
 29     @private
 30     Override createChildViews to mix in the mixins defined in autoMixins.
 31   */
 32   createChildView: function (view, attrs) {
 33     if (!view.isClass) {
 34       attrs = view;
 35     } else {
 36       // attrs should always exist...
 37       if (!attrs) { attrs = {}; }
 38       // clone the hash that was given so we do not pollute it if it's being reused
 39       else { attrs = SC.clone(attrs); }
 40     }
 41 
 42     attrs.owner = attrs.parentView = this;
 43     if (!attrs.page) attrs.page = this.page;
 44 
 45     if (view.isClass) {
 46       // Track that we created this view.
 47       attrs.createdByParent = true;
 48 
 49       // Add the mixins to the child's attributes.
 50       var applyMixins = SC.clone(this.get("autoMixins"));
 51       applyMixins.push(attrs);
 52 
 53       view = view.create.apply(view, applyMixins);
 54     }
 55 
 56     return view;
 57   }
 58 
 59 };
 60