/usr/share/javascript/yui3/event-outside/event-outside.js is in libjs-yui3-full 3.5.1-1ubuntu3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | /*
YUI 3.5.1 (build 22)
Copyright 2012 Yahoo! Inc. All rights reserved.
Licensed under the BSD License.
http://yuilibrary.com/license/
*/
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:
* <ul>
* <li>blur</li>
* <li>change</li>
* <li>click</li>
* <li>dblclick</li>
* <li>focus</li>
* <li>keydown</li>
* <li>keypress</li>
* <li>keyup</li>
* <li>mousedown</li>
* <li>mousemove</li>
* <li>mouseout</li>
* <li>mouseover</li>
* <li>mouseup</li>
* <li>select</li>
* <li>submit</li>
* </ul>
*
* Define new outside events with
* <code>Y.Event.defineOutside(eventType);</code>.
* 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:
* <code>Y.Event.defineOutside(eventType, "yonderclick")</code>.
*
* @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:
* <code>Y.Event.defineOutside(eventType, "yonderclick")</code>.
*
* @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 && !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.5.1' ,{requires:['event-synthetic']});
|