base-base.js revision 10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85
157N/A * The base module provides the Base class, which objects requiring attribute and custom event support can extend. 157N/A * The module also provides two ways to reuse code - It augments Base with the Plugin.Host interface which provides 157N/A * plugin support and also provides the Base.build method which provides a way to build custom classes using extensions. 157N/A * The base-base submodule provides the Base class without the Plugin support, provided by Plugin.Host, 157N/A * and without the extension support provided by Base.build. 1413N/A * A base class which objects requiring attributes and custom event support can 157N/A * extend. Base also handles the chaining of initializer and destructor methods across 1413N/A * the hierarchy as part of object construction and destruction. Additionally, attributes configured 260N/A * through the static <a href="#property_Base.ATTRS">ATTRS</a> property for each class 260N/A * in the hierarchy will be initialized by Base. * The static <a href="#property_Base.NAME">NAME</a> property of each class extending * from Base will be used as the identifier for the class, and is used by Base to prefix * all events fired by instances of that class. * @param {Object} config Object with configuration property name/value pairs. The object can be * used to provide default values for the objects published attributes. * The config object can also contain the following non-attribute properties, providing a convenient * way to configure events listeners and plugins for the instance, as part of the constructor call: * <dd>An event name to listener function map, to register event listeners for the "on" moment of the event. A constructor convenience property for the <a href="Base.html#method_on">on</a> method.</dd> * <dd>An event name to listener function map, to register event listeners for the "after" moment of the event. A constructor convenience property for the <a href="Base.html#method_after">after</a> method.</dd> * <dd>An object, or array of objects, to register as bubble targets for bubbled events fired by this instance. A constructor convenience property for the <a href="EventTarget.html#method_addTarget">addTarget</a> method.</dd> * <dd>A plugin, or array of plugins to be plugged into the instance (see PluginHost's plug method for signature details). A constructor convenience property for the <a href="Plugin.Host.html#method_plug">plug</a> method.</dd> // So the object can be used as a hash key (as DD does) // If Plugin.Host has been augmented [ through base-pluginhost ], setup it's // initial state, but don't initialize Plugins yet. That's done after initialization. * The string used to identify the class of this object. * @deprecated Use this.constructor.NAME * The list of properties which can be configured for * each attribute (e.g. setter, getter, writeOnce, readOnly etc.) * The string to be used to identify instances of * this class, for example in prefixing events. * Classes extending Base, should define their own * static NAME property, which should be camelCase by * convention (e.g. MyClass.NAME = "myClass";). * The default set of attributes which will be available for instances of this class, and * their configuration. In addition to the configuration properties listed by * Attribute's <a href="Attribute.html#method_addAttr">addAttr</a> method, the attribute * can also be configured with a "cloneDefaultValue" property, which defines how the statically * defined value field should be protected ("shallow", "deep" and false are supported values). * By default if the value is an object literal or an array it will be "shallow" cloned, to * protect the default value. * Flag indicating whether or not this object * has been through the init lifecycle phase. * Flag indicating whether or not this object * has been through the destroy lifecycle phase. * Init lifecycle method, invoked during construction. * Fires the init event prior to setting up attributes and * invoking initializers for the class hierarchy. * @param {Object} config Object with configuration property name/value pairs * @return {Base} A reference to this object * Lifecycle event for the init phase, fired prior to initialization. * Invoking the preventDefault() method on the event object provided * to subscribers will prevent initialization from occuring. * Subscribers to the "after" momemt of this event, will be notified * after initialization of the object is complete (and therefore * cannot prevent initialization). * @preventable _defInitFn * @param {EventFacade} e Event object, with a cfg property which * refers to the configuration object passed to the constructor. * Handles the special on, after and target properties which allow the user to * easily configure on and after listeners as well as bubble targets during * construction, prior to init. * @method _preInitEventCfg * @param {Object} config The user configuration object * Destroy lifecycle method. Fires the destroy * event, prior to invoking destructors for the * Subscribers to the destroy * event can invoke preventDefault on the event object, to prevent destruction * @return {Base} A reference to this object * Lifecycle event for the destroy phase, * fired prior to destruction. Invoking the preventDefault * method on the event object provided to subscribers will * prevent destruction from proceeding. * Subscribers to the "after" moment of this event, will be notified * after destruction is complete (and as a result cannot prevent * @preventable _defDestroyFn * @param {EventFacade} e Event object * Default init event handler * @param {EventFacade} e Event object, with a cfg property which * refers to the configuration object passed to the constructor. // Need to initPlugins manually, to handle constructor parsing, static Plug parsing * Default destroy event handler * @param {EventFacade} e Event object * Returns the class hierarchy for this object, with Base being the last class in the array. * @return {Function[]} An array of classes (constructor functions), making up the class hierarchy for this object. * This value is cached the first time the method, or _getAttrCfgs, is invoked. Subsequent invocations return the * Returns an aggregated set of attribute configurations, by traversing the class hierarchy. * @return {Object} The hash of attribute configurations, aggregated across classes in the hierarchy * This value is cached the first time the method, or _getClasses, is invoked. Subsequent invocations return * A helper method used when processing ATTRS across the class hierarchy during * initialization. Returns a disposable object with the attributes defined for * the provided class, extracted from the set of all attributes passed in . * @param {Function} clazz The class for which the desired attributes are required. * @param {Object} allCfgs The set of all attribute configurations for this instance. * Attributes will be removed from this set, if they belong to the filtered class, so * that by the time all classes are processed, allCfgs will be empty. * @return {Object} The set of attributes belonging to the class passed in, in the form * A helper method used by _getClasses and _getAttrCfgs, which determines both * the array of classes and aggregate set of attribute configurations * across the class hierarchy for the instance. * @method _initHierarchyData * A helper method, used by _initHierarchyData to aggregate * attribute configuration across the instances class hierarchy. * The method will protect the attribute configuration value to protect the statically defined * default value in ATTRS if required (if the value is an object literal, array or the * attribute configuration has cloneDefaultValue set to shallow or deep). * @method _aggregateAttrs * @param {Array} allAttrs An array of ATTRS definitions across classes in the hierarchy * (subclass first, Base last) * @return {Object} The aggregate set of ATTRS definitions for the instance // Protect config passed in //cfg = Y.mix({}, attrs[attr], true, cfgProps); //cfg = Y.Object(attrs[attr]); // else if (clone === false), don't clone the static default value. // It's intended to be used by reference. * Initializes the class hierarchy for the instance, which includes * initializing attributes for each class defined in the class's * static <a href="#property_Base.ATTRS">ATTRS</a> property and * invoking the initializer method on the prototype of each class in the hierarchy. * @param {Object} userVals Object with configuration property name/value pairs // Using INITIALIZER in hasOwnProperty check, for performance reasons (helps IE6 avoid GC thresholds when // referencing string literals). Not using it in apply, again, for performance "." is faster. * Destroys the class hierarchy for this instance by invoking * the destructor method on the prototype of each class in the hierarchy. * @method _destroyHierarchy * Default toString implementation. Provides the constructor NAME * and the instance guid, if set. * @return {String} String representation for this object return this.
name +
"[" + Y.
stamp(
this,
true) +
"]";
// Straightup augment, no wrapper functions },
'@VERSION@' ,{
requires:[
'attribute-base']});