~bjornt/lazr-js/prefetch-yui-3.5

« back to all changes in this revision

Viewing changes to src-js/lazrjs/yui/yui/yui-later-debug.js

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-01-14 23:32:29 UTC
  • mfrom: (197.1.7 yui-3.3.0)
  • Revision ID: launchpad@pqm.canonical.com-20110114233229-r6i4cazdiiw18o7p
Upgrade to YUI 3.3.0 [r=mars]

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3
3
Code licensed under the BSD License:
4
4
http://developer.yahoo.com/yui/license.html
5
 
version: 3.2.0
6
 
build: 2676
 
5
version: 3.3.0
 
6
build: 3167
7
7
*/
8
8
YUI.add('yui-later', function(Y) {
9
9
 
12
12
 * @module yui
13
13
 * @submodule yui-later
14
14
 */
15
 
(function() {
16
 
    var L = Y.Lang,
17
 
 
18
 
    /**
19
 
     * Executes the supplied function in the context of the supplied 
20
 
     * object 'when' milliseconds later.  Executes the function a 
21
 
     * single time unless periodic is set to true.
22
 
     * @method later
23
 
     * @for YUI
24
 
     * @param when {int} the number of milliseconds to wait until the fn 
25
 
     * is executed.
26
 
     * @param o the context object.
27
 
     * @param fn {Function|String} the function to execute or the name of 
28
 
     * the method in the 'o' object to execute.
29
 
     * @param data [Array] data that is provided to the function.  This accepts
30
 
     * either a single item or an array.  If an array is provided, the
31
 
     * function is executed with one parameter for each array item.  If
32
 
     * you need to pass a single array parameter, it needs to be wrapped in
33
 
     * an array [myarray].
34
 
     * @param periodic {boolean} if true, executes continuously at supplied 
35
 
     * interval until canceled.
36
 
     * @return {object} a timer object. Call the cancel() method on this object to 
37
 
     * stop the timer.
38
 
     */
39
 
    later = function(when, o, fn, data, periodic) {
40
 
        when = when || 0; 
41
 
 
42
 
        var m = fn, f, id;
43
 
 
44
 
        if (o && L.isString(fn)) {
45
 
            m = o[fn];
 
15
 
 
16
/**
 
17
 * Executes the supplied function in the context of the supplied
 
18
 * object 'when' milliseconds later.  Executes the function a
 
19
 * single time unless periodic is set to true.
 
20
 * @method later
 
21
 * @for YUI
 
22
 * @param when {int} the number of milliseconds to wait until the fn
 
23
 * is executed.
 
24
 * @param o the context object.
 
25
 * @param fn {Function|String} the function to execute or the name of
 
26
 * the method in the 'o' object to execute.
 
27
 * @param data [Array] data that is provided to the function.  This
 
28
 * accepts either a single item or an array.  If an array is provided,
 
29
 * the function is executed with one parameter for each array item.
 
30
 * If you need to pass a single array parameter, it needs to be wrapped
 
31
 * in an array [myarray].
 
32
 * @param periodic {boolean} if true, executes continuously at supplied
 
33
 * interval until canceled.
 
34
 * @return {object} a timer object. Call the cancel() method on this
 
35
 * object to stop the timer.
 
36
 */
 
37
Y.later = function(when, o, fn, data, periodic) {
 
38
    when = when || 0;
 
39
 
 
40
    var m = fn, f, id;
 
41
 
 
42
    if (o && Y.Lang.isString(fn)) {
 
43
        m = o[fn];
 
44
    }
 
45
 
 
46
    f = !Y.Lang.isUndefined(data) ? function() {
 
47
        m.apply(o, Y.Array(data));
 
48
    } : function() {
 
49
        m.call(o);
 
50
    };
 
51
 
 
52
    id = (periodic) ? setInterval(f, when) : setTimeout(f, when);
 
53
 
 
54
    return {
 
55
        id: id,
 
56
        interval: periodic,
 
57
        cancel: function() {
 
58
            if (this.interval) {
 
59
                clearInterval(id);
 
60
            } else {
 
61
                clearTimeout(id);
 
62
            }
46
63
        }
47
 
 
48
 
        f = !L.isUndefined(data) ? function() {
49
 
            m.apply(o, Y.Array(data));
50
 
        } : function() {
51
 
            m.call(o);
52
 
        };
53
 
 
54
 
        id = (periodic) ? setInterval(f, when) : setTimeout(f, when);
55
 
 
56
 
        return {
57
 
            id: id,
58
 
            interval: periodic,
59
 
            cancel: function() {
60
 
                if (this.interval) {
61
 
                    clearInterval(id);
62
 
                } else {
63
 
                    clearTimeout(id);
64
 
                }
65
 
            }
66
 
        };
67
64
    };
68
 
 
69
 
    Y.later = later;
70
 
    L.later = later;
71
 
 
72
 
})();
73
 
 
74
 
 
75
 
}, '3.2.0' ,{requires:['yui-base']});
 
65
};
 
66
 
 
67
Y.Lang.later = Y.later;
 
68
 
 
69
 
 
70
 
 
71
}, '3.3.0' ,{requires:['yui-base']});