widget-child.js revision 0891d75cb3cc23db8fc2846447c429a4015a7afb
/**
* Extension enabling a Widget to be a child of another Widget.
*
* @module widget-child
*/
/**
* Widget extension providing functionality enabling a Widget to be a
* child of another Widget.
*
* @class WidgetChild
* @param {Object} config User configuration object.
*/
function Child() {
// Widget method overlap
}
/**
* @attribute selected
* @type Number
* @default 0
*
* @description Number indicating if the Widget is selected. Possible
* values are:
* <dl>
* <dt>0</dt> <dd>(Default) Not selected</dd>
* <dt>1</dt> <dd>Fully selected</dd>
* <dt>2</dt> <dd>Partially selected</dd>
* </dl>
*/
selected: {
value: 0,
},
/**
* @attribute index
* @type Number
* @readOnly
*
* @description Number representing the Widget's ordinal position in its
* parent Widget.
*/
index: {
readOnly: true,
getter: function () {
index = -1;
if (parent) {
}
return index;
}
},
/**
* @attribute parent
* @type Widget
* @readOnly
*
* @description Retrieves the parent of the Widget in the object hierarchy.
*/
parent: {
readOnly: true
},
/**
* @attribute depth
* @type Number
* @default -1
* @readOnly
*
* @description Number representing the depth of this Widget relative to
* the root Widget in the object heirarchy.
*/
depth: {
readOnly: true,
getter: function () {
depth = -1;
while (parent) {
break;
}
}
return depth;
}
},
/**
* @attribute root
* @type Widget
* @readOnly
*
* @description Returns the root Widget in the object hierarchy. If the
* ROOT_TYPE property is set, the search for the root Widget will be
* constrained to parent Widgets of the specified type.
*/
root: {
readOnly: true,
getter: function () {
if (FnRootType) {
}
};
return getParent(this);
}
}
};
/**
* Constructor reference used to determine the root of a Widget-based
* object tree.
* <p>
* Currently used to control the behavior of the <code>root</code>
* attribute so that recursing up the object heirarchy can be constrained
* to a specific type of Widget. Widget authors should set this property
* to the constructor function for a given Widget implementation.
* </p>
*
* @property ROOT_TYPE
* @type Object
*/
ROOT_TYPE: null,
// Override of Widget's implementation of _getUIEventNode() to ensure that
// all event listeners are bound to the Widget's topmost DOM element.
// This ensures that the firing of each type of Widget UI event (click,
// mousedown, etc.) is facilitated by a single, top-level, delegated DOM
// event listener.
_getUIEventNode: function () {
if (root) {
}
return returnVal;
},
/**
* @method next
* @description Returns the Widget's next sibling.
* @param {Boolean} circular Boolean indicating if the parent's first child
* should be returned if the child has no next sibling.
* @return {Widget} Widget instance.
*/
if (parent) {
}
}
return sibling;
},
/**
* @method previous
* @description Returns the Widget's previous sibling.
* @param {Boolean} circular Boolean indicating if the parent's last child
* should be returned if the child has no previous sibling.
* @return {Widget} Widget instance.
*/
}
}
return sibling;
},
// Override of Y.WidgetParent.remove()
// Sugar implementation allowing a child to remove itself from its parent.
var parent,
}
else {
if (parent) {
}
}
return removed;
},
/**
* @method isRoot
* @description Determines if the Widget is the root Widget in the
* object hierarchy.
* @return {Boolean} Boolean indicating if Widget is the root Widget in the
* object hierarchy.
*/
isRoot: function () {
return (this == this.get("root"));
},
/**
* @method ancestor
* @description Returns the Widget instance at the specified depth.
* @param {number} depth Number representing the depth of the ancestor.
* @return {Widget} Widget instance.
*/
}
}
return parent;
},
/**
* Updates the UI to reflect the <code>selected</code> attribute value.
*
* @method _uiSetChildSelected
* @protected
* @param {number} selected The selected value to be reflected in the UI.
*/
_uiSetChildSelected: function (selected) {
if (selected === 0) {
}
else {
}
},
/**
* Default attribute change listener for the <code>selected</code>
* attribute, responsible for updating the UI, in response to
* attribute changes.
*
* @method _afterChildSelectedChange
* @protected
* @param {EventFacade} event The event facade for the attribute change.
*/
_afterChildSelectedChange: function (event) {
},
/**
* Synchronizes the UI to match the WidgetChild state.
* <p>
* This method is invoked after bindUI is invoked for the Widget class
* using YUI's aop infrastructure.
* </p>
*
* @method _syncUIChild
* @protected
*/
_syncUIChild: function () {
},
/**
* Binds event listeners responsible for updating the UI state in response
* to WidgetChild related state changes.
* <p>
* This method is invoked after bindUI is invoked for the Widget class
* using YUI's aop infrastructure.
* </p>
* @method _bindUIChild
* @protected
*/
_bindUIChild: function () {
}
};
Y.WidgetChild = Child;