<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/*
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 3.4.0
build: nightly
*/
YUI.add('event-outside', function(Y) {

/**
 * Outside events are synthetic DOM events that fire when a corresponding native
 * or synthetic DOM event occurs outside a bound element.
 *
 * The following outside events are pre-defined by this module:
 * &lt;ul&gt;
 *   &lt;li&gt;blur&lt;/li&gt;
 *   &lt;li&gt;change&lt;/li&gt;
 *   &lt;li&gt;click&lt;/li&gt;
 *   &lt;li&gt;dblclick&lt;/li&gt;
 *   &lt;li&gt;focus&lt;/li&gt;
 *   &lt;li&gt;keydown&lt;/li&gt;
 *   &lt;li&gt;keypress&lt;/li&gt;
 *   &lt;li&gt;keyup&lt;/li&gt;
 *   &lt;li&gt;mousedown&lt;/li&gt;
 *   &lt;li&gt;mousemove&lt;/li&gt;
 *   &lt;li&gt;mouseout&lt;/li&gt;
 *   &lt;li&gt;mouseover&lt;/li&gt;
 *   &lt;li&gt;mouseup&lt;/li&gt;
 *   &lt;li&gt;select&lt;/li&gt;
 *   &lt;li&gt;submit&lt;/li&gt;
 * &lt;/ul&gt;
 *
 * Define new outside events with
 * &lt;code&gt;Y.Event.defineOutside(eventType);&lt;/code&gt;.
 * By default, the created synthetic event name will be the name of the event
 * with "outside" appended (e.g. "click" becomes "clickoutside"). If you want
 * a different name for the created Event, pass it as a second argument like so:
 * &lt;code&gt;Y.Event.defineOutside(eventType, "yonderclick")&lt;/code&gt;.
 *
 * @module event
 * @submodule event-outside
 */

// Outside events are pre-defined for each of these native DOM events
var nativeEvents = [
        'blur', 'change', 'click', 'dblclick', 'focus', 'keydown', 'keypress',
        'keyup', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup',
        'select', 'submit'
    ];

/**
 * Defines a new outside event to correspond with the given DOM event.
 *
 * By default, the created synthetic event name will be the name of the event
 * with "outside" appended (e.g. "click" becomes "clickoutside"). If you want
 * a different name for the created Event, pass it as a second argument like so:
 * &lt;code&gt;Y.Event.defineOutside(eventType, "yonderclick")&lt;/code&gt;.
 *
 * @method Y.Event.defineOutside
 * @param {String} event DOM event
 * @param {String} name (optional) custom outside event name
 * @static
 */
Y.Event.defineOutside = function (event, name) {
    name = name || (event + 'outside');

    var config = {
    
        on: function (node, sub, notifier) {
            sub.handle = Y.one('doc').on(event, function(e) {
                if (this.isOutside(node, e.target)) {
                    e.currentTarget = node;
                    notifier.fire(e);
                }
            }, this);
        },
        
        detach: function (node, sub, notifier) {
            sub.handle.detach();
        },
        
        delegate: function (node, sub, notifier, filter) {
            sub.handle = Y.one('doc').delegate(event, function (e) {
                if (this.isOutside(node, e.target)) {
                    notifier.fire(e);
                }
            }, filter, this);
        },
        
        isOutside: function (node, target) {
            return target !== node &amp;&amp; !target.ancestor(function (p) {
                    return p === node;
                });
        }
    };
    config.detachDelegate = config.detach;

    Y.Event.define(name, config);
};

// Define outside events for some common native DOM events
Y.Array.each(nativeEvents, function (event) {
    Y.Event.defineOutside(event);
});


}, '3.4.0' ,{requires:['event-synthetic']});
</pre></body></html>