/**
* Support for Widget UI Events (Custom Events fired by the widget, which wrap the underlying DOM events - e.g. widget:click, widget:mousedown)
*
* @module widget
* @submodule widget-uievents
*/
var BOUNDING_BOX = "boundingBox",
RENDER = "render",
L = Y.Lang,
EVENT_PREFIX_DELIMITER = ":",
// Map of Node instances serving as a delegation containers for a specific
// event type to Widget instances using that delegation container.
/**
* Destructor logic for UI event infrastructure,
* invoked during Widget destruction.
*
* @method _destroyUIEvents
* @for Widget
* @private
*/
_destroyUIEvents: function() {
var widgetGuid = Y.stamp(this, true);
// Unregister this Widget instance as needing this delegated
// event listener.
// There are no more Widget instances using this delegated
// event listener, so detach it.
}
}
}
});
},
/**
* Map of DOM events that should be fired as Custom Events by the
* Widget instance.
*
* @property UI_EVENTS
* @for Widget
* @type Object
*/
/**
* Returns the node on which to bind delegate listeners.
*
* @method _getUIEventNode
* @for Widget
* @protected
*/
_getUIEventNode: function () {
return this.get(BOUNDING_BOX);
},
/**
* Binds a delegated DOM event listener of the specified type to the
* Widget's outtermost DOM element to facilitate the firing of a Custom
* Event of the same type for the Widget instance.
*
* @method _createUIEvent
* @for Widget
* @param type {String} String representing the name of the event
* @private
*/
_createUIEvent: function (type) {
var uiEvtNode = this._getUIEventNode(),
// For each Node instance: Ensure that there is only one delegated
// event listener used to fire Widget UI events.
if (!info) {
// Widget could be null if node instance belongs to
// another Y instance.
if (widget) {
}
}
}
// Register this Widget as using this Node as a delegation container.
},
/**
* This method is used to determine if we should fire
* the UI Event or not. The default implementation makes sure
* that for nested delegates (nested unrelated widgets), we don't
* fire the UI event listener more than once at each level.
*
* <p>For example, without the additional filter, if you have nested
* widgets, each widget will have a delegate listener. If you
* click on the inner widget, the inner delegate listener's
* filter will match once, but the outer will match twice
* (based on delegate's design) - once for the inner widget,
* and once for the outer.</p>
*
* @method _filterUIEvent
* @for Widget
* @param {DOMEventFacade} evt
* @return {boolean} true if it's OK to fire the custom UI event, false if not.
* @private
*
*/
_filterUIEvent: function(evt) {
// Either it's hitting this widget's delegate container (and not some other widget's),
// or the container it's hitting is handling this widget's ui events.
return (evt.currentTarget.compareTo(evt.container) || evt.container.compareTo(this._getUIEventNode()));
},
/**
* Determines if the specified event is a UI event.
*
* @private
* @method _isUIEvent
* @for Widget
* @param type {String} String representing the name of the event
* @return {String} Event Returns the name of the UI Event, otherwise
* undefined.
*/
_getUIEvent: function (type) {
if (sType) {
// TODO: Get delimiter from ET, or have ET support this.
if (iDelim > -1) {
}
}
}
return returnVal;
}
},
/**
* Sets up infrastructure required to fire a UI event.
*
* @private
* @method _initUIEvent
* @for Widget
* @param type {String} String representing the name of the event
* @return {String}
*/
_initUIEvent: function (type) {
queue = this._uiEvtsInitQueue || {};
this._createUIEvent(sType);
delete this._uiEvtsInitQueue[sType];
});
}
},
// Override of "on" from Base to facilitate the firing of Widget events
// Temporary solution until we have the ability to listen to when
// someone adds an event listener (bug 2528230)
this._initUIEvent(type);
},
// Override of "publish" from Base to facilitate the firing of Widget events
// Temporary solution until we have the ability to listen to when
// someone publishes an event (bug 2528230)
this._initUIEvent(sType);
}
}
}, true); // overwrite existing EventTarget methods