~andreserl/maas/packaging_precise_rebase

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/node-event-delegate/node-event-delegate.js

  • Committer: Andres Rodriguez
  • Date: 2013-03-20 18:12:30 UTC
  • mfrom: (145.2.22 precise.sru)
  • Revision ID: andreserl@ubuntu.com-20130320181230-6l5guc0nhlv2z4p7
Re-base againts latest quantal released branch towards SRU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.5.1 (build 22)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('node-event-delegate', function(Y) {
 
8
 
 
9
/**
 
10
 * Functionality to make the node a delegated event container
 
11
 * @module node
 
12
 * @submodule node-event-delegate
 
13
 */
 
14
 
 
15
/**
 
16
 * <p>Sets up a delegation listener for an event occurring inside the Node.
 
17
 * The delegated event will be verified against a supplied selector or
 
18
 * filtering function to test if the event references at least one node that
 
19
 * should trigger the subscription callback.</p>
 
20
 *
 
21
 * <p>Selector string filters will trigger the callback if the event originated
 
22
 * from a node that matches it or is contained in a node that matches it.
 
23
 * Function filters are called for each Node up the parent axis to the
 
24
 * subscribing container node, and receive at each level the Node and the event
 
25
 * object.  The function should return true (or a truthy value) if that Node
 
26
 * should trigger the subscription callback.  Note, it is possible for filters
 
27
 * to match multiple Nodes for a single event.  In this case, the delegate
 
28
 * callback will be executed for each matching Node.</p>
 
29
 *
 
30
 * <p>For each matching Node, the callback will be executed with its 'this'
 
31
 * object set to the Node matched by the filter (unless a specific context was
 
32
 * provided during subscription), and the provided event's
 
33
 * <code>currentTarget</code> will also be set to the matching Node.  The
 
34
 * containing Node from which the subscription was originally made can be
 
35
 * referenced as <code>e.container</code>.
 
36
 *
 
37
 * @method delegate
 
38
 * @param type {String} the event type to delegate
 
39
 * @param fn {Function} the callback function to execute.  This function
 
40
 *              will be provided the event object for the delegated event.
 
41
 * @param spec {String|Function} a selector that must match the target of the
 
42
 *              event or a function to test target and its parents for a match
 
43
 * @param context {Object} optional argument that specifies what 'this' refers to.
 
44
 * @param args* {any} 0..n additional arguments to pass on to the callback function.
 
45
 *              These arguments will be added after the event object.
 
46
 * @return {EventHandle} the detach handle
 
47
 * @for Node
 
48
 */
 
49
Y.Node.prototype.delegate = function(type) {
 
50
 
 
51
    var args = Y.Array(arguments, 0, true),
 
52
        index = (Y.Lang.isObject(type) && !Y.Lang.isArray(type)) ? 1 : 2;
 
53
 
 
54
    args.splice(index, 0, this._node);
 
55
 
 
56
    return Y.delegate.apply(Y, args);
 
57
};
 
58
 
 
59
 
 
60
}, '3.5.1' ,{requires:['node-base', 'event-delegate']});