a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * Outside events are synthetic DOM events that fire when a corresponding native
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * or synthetic DOM event occurs outside a bound element.
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * The following outside events are pre-defined by this module:
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>blur</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>change</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>click</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>dblclick</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>focus</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>keydown</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>keypress</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>keyup</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>mousedown</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>mousemove</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>mouseout</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>mouseover</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>mouseup</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>select</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <li>submit</li>
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * Define new outside events with
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <code>Y.Event.defineOutside(eventType);</code>.
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * By default, the created synthetic event name will be the name of the event
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * with "outside" appended (e.g. "click" becomes "clickoutside"). If you want
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * a different name for the created Event, pass it as a second argument like so:
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <code>Y.Event.defineOutside(eventType, "yonderclick")</code>.
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * @module event
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * @submodule event-outside
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith// Outside events are pre-defined for each of these native DOM events
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith 'blur', 'change', 'click', 'dblclick', 'focus', 'keydown', 'keypress',
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith 'keyup', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup',
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * Defines a new outside event to correspond with the given DOM event.
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * By default, the created synthetic event name will be the name of the event
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * with "outside" appended (e.g. "click" becomes "clickoutside"). If you want
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * a different name for the created Event, pass it as a second argument like so:
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * <code>Y.Event.defineOutside(eventType, "yonderclick")</code>.
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * @method Y.Event.defineOutside
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * @param {String} event DOM event
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith * @param {String} name (optional) custom outside event name
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith sub.handle = Y.one('doc').on(event, function(e) {
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith delegate: function (node, sub, notifier, filter) {
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith sub.handle = Y.one('doc').delegate(event, function (e) {
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith return target !== node && !target.ancestor(function (p) {
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith return p === node;
a958fdd529761b111fb3d448b732519434c5d4afLuke Smith// Define outside events for some common native DOM events