base-base-debug.js revision e0008d92cea7515616980ad13e1075346a3bca2e
3738N/A * An augmentable class, which when augmented onto a Base based class, allows 3738N/A * the class to support plugins, providing plug and unplug methods and the ability 3738N/A * to add plugins through the configuration literal passed to the constructor. 3738N/A * The PlugHost's _initPlugins() and _destroyPlugins() methods should be invoked by the 3738N/A * host class at the appropriate point in the instance's lifecyle. This is done 3738N/A * by default for the Base class, so developers extending base don't need to do 3738N/A * anything to get plugin support. 3738N/A * Adds a plugin to the host object. This will instantiate the 3738N/A * plugin and attach it to the configured namespace on the host object. 3738N/A * @param p {Function | Object |Array} Accepts the plugin class, or an 3738N/A * object literal with a "fn" property specifying the plugin class and 3738N/A * a "cfg" property specifying the configuration for the Plugin. 3738N/A * Additionally an Array can also be passed in, with the above function or 3738N/A * object literal values, allowing the user to add multiple plugins in a single call. 3738N/A * @param config (Optional) If the first argument is the plugin class, the second argument 3738N/A * can be the configuration for the plugin. 3738N/A * @return {Base} A reference to the host object 3738N/A * Removes a plugin from the host object. This will destroy the 3738N/A * plugin instance and delete the namepsace from the host object. 3738N/A * @param {String | Function} plugin The namespace of the plugin, or the plugin class with the static NS namespace property defined. If not provided, 3738N/A * all registered plugins are unplugged. 3738N/A * @return {Base} A reference to the host object 3738N/A * Determines if a plugin has plugged into this host. 3738N/A * @param The plugin's namespace 3738N/A * @return {boolean} returns true, if the plugin has been plugged into this host, false otherwise. 3738N/A * Initializes static plugins registered on the host (using the 3738N/A * Base.plug static method) and any plugins passed to the 3738N/A * instance through the "plugins" configuration property. 3738N/A * @param {Config} config The configuration object literal for the host. 3738N/A * Unplugs and destroys all plugins on the host 3738N/A * Private method used to instantiate and attach plugins to the host 3738N/A * @param {Function} PluginClass The plugin class to instantiate 3738N/A * @param {Object} config The configuration object for the plugin 3738N/A * Unplugs and destroys a plugin already instantiated with the host. 3738N/A * @param {String | Function} plugin The namespace for the plugin, or a plugin class with the static NS property defined. 3738N/A * Registers plugins to be instantiated at the class level (plugins 3738N/A * which should be plugged into every instance of the class by default). 3738N/A * @param {Function} hostClass The host class on which to register the plugins 3738N/A * @param {Function | Array} plugin Either the plugin class, an array of plugin classes or an array of object literals (with fn and cfg properties defined) 3738N/A * @param {Object} config (Optional) If plugin is the plugin class, the configuration for the plugin 3738N/A // Cannot plug into Base, since Plugins derive from Base [ will cause infinite recurrsion ] 3738N/A * Unregisters any class level plugins which have been registered by the host class, or any 3738N/A * other class in the hierarchy. 3738N/A * @method PluginHost.unplug 3738N/A * @param {Function} hostClass The host class from which to unregister the plugins 3738N/A * @param {Function | Array} plugin The plugin class, or an array of plugin classes 3738N/A * The base module provides the Base class, which objects requiring managed attributes 3738N/A * and custom event support can extend. The base module also provides two ways to reuse 3738N/A * code - An augmentable PluginHost interface which provides plugin support 3738N/A * (which is augmented to the Base class) and Base.build which provides a way to 3738N/A * build custom classes using extensions. 3738N/A * The base-base submodule provides the Base class and augmentable PluginHost implementation, 3738N/A * without the extension support provided by Base.build. 3738N/A * Provides a base class for which objects requiring managed attributes and 3738N/A * custom event support can extend. The Base class also handles the chaining of 3738N/A * initializer and destructor methods across the hierarchy as part of object construction 3738N/A * and destruction. Additionally, attributes configured through the static 3738N/A * <a href="#property_ATTRS">ATTRS</a> property for each class in the hierarchy will be 3738N/A * <p>The static <a href="#property_NAME">NAME</a> property of each class extending 3738N/A * from Base will be used as the identifier for the class, and is used by Base to prefix 3738N/A * all events fired by instances of that class.</p> 3738N/A * @uses Attribute, Plugin.Host 3738N/A * @param {Object} config Object literal of configuration property name/value pairs 3738N/A Y.
log(
'constructor called',
'life',
'base');
3738N/A * The list of properties which can be configured for 3738N/A * each attribute (e.g. setter, getter, writeOnce, readOnly etc.) 3738N/A * The string to be used to identify instances of 3738N/A * this class, for example in prefixing events. 3738N/A * Classes extending Base, should define their own 3738N/A * static NAME property, which should be camelCase by 3738N/A * convention (e.g. MyClass.NAME = "myClass";). 3738N/A * Object literal defining the set of attributes which 3738N/A * will be available for instances of this class, and 3738N/A * method for a description of configuration options available 3738N/A * Flag indicating whether or not this object 3738N/A * has been through the init lifecycle phase. 3738N/A * Flag indicating whether or not this object 3738N/A * has been through the destroy lifecycle phase. 3738N/A * Init lifecycle method, invoked during construction. 3738N/A * Fires the init event prior to setting up attributes and 3738N/A * invoking initializers for the class hierarchy. 3738N/A * @param {Object} config Object literal of configuration property name/value pairs 3738N/A * @return {Base} A reference to this object 3738N/A * The string used to identify the class of this object. 3738N/A * @deprecated Use this.constructor.NAME 3738N/A * Lifecycle event for the init phase, fired prior to initialization. 3738N/A * Invoking the preventDefault() method on the event object provided 3738N/A * to subscribers will prevent initialization from occuring. 3738N/A * Subscribers to the "after" momemt of this event, will be notified 3738N/A * after initialization of the object is complete (and therefore 3738N/A * cannot prevent initialization). 3738N/A * @param {Event.Facade} e Event object, with a cfg property which 3738N/A * refers to the configuration object literal passed to the constructor. * 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 Y.
log(
'destroy called',
'life',
'base');
* 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 {Event.Facade} e Event object * Default init event handler * @param {Event.Facade} e Event object, with a cfg property which * refers to the configuration object literal passed to the constructor. * Default destroy event handler * @param {Event.Facade} 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 * of an object literal with name/cfg pairs. * 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 potect the attribute configuration value to protect the statically defined * default value in ATTRS if required (value is an object literal or array or the * attribute configuration has clone 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 Y.
log(
'Cloning default value for attribute:' +
attr,
'info',
'base');
Y.
log(
'Merging default value for attribute:' +
attr,
'info',
'base');
// 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_ATTRS">ATTRS</a> property and * invoking the initializer method on the prototype of each class in the hierarchy. * @param {Object} userVals Object literal containing configuration name/value pairs * Destroys the class hierarchy for this instance by invoking * the descructor method on the prototype of each class in the hierarchy. * @method _destroyHierarchy * Default toString implementation. Provides the constructor NAME * @return {String} String representation for this object // Straightup augment, no wrapper functions * Alias for <a href="PluginHost.html#method_PluginHost.plug">PluginHost.plug</a>. * Alias for <a href="PluginHost.html#method_PluginHost.unplug">PluginHost.unplug</a>. },
'@VERSION@' ,{
requires:[
'attribute']});