~smagoun/whoopsie/whoopsie-lp1017637

« back to all changes in this revision

Viewing changes to backend/stats/static/js/yui/build/node-event-delegate/node-event-delegate.js

  • Committer: Evan Dandrea
  • Date: 2012-05-09 05:53:45 UTC
  • Revision ID: evan.dandrea@canonical.com-20120509055345-z2j41tmcbf4as5uf
The backend now lives in lp:daisy and the website (errors.ubuntu.com) now lives in lp:errors.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.5.0 (build 5089)
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.0' ,{requires:['node-base', 'event-delegate']});