~bac/juju-gui/trunkcopy

« back to all changes in this revision

Viewing changes to lib/yui/build/event-resize/event-resize.js

  • Committer: kapil.foss at gmail
  • Date: 2012-07-13 18:45:59 UTC
  • Revision ID: kapil.foss@gmail.com-20120713184559-2xl7be17egsrz0c9
reshape

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('event-resize', function(Y) {
8
 
 
9
 
/**
10
 
 * Adds a window resize event that has its behavior normalized to fire at the
11
 
 * end of the resize rather than constantly during the resize.
12
 
 * @module event
13
 
 * @submodule event-resize
14
 
 */
15
 
 
16
 
 
17
 
/**
18
 
 * Old firefox fires the window resize event once when the resize action
19
 
 * finishes, other browsers fire the event periodically during the
20
 
 * resize.  This code uses timeout logic to simulate the Firefox 
21
 
 * behavior in other browsers.
22
 
 * @event windowresize
23
 
 * @for YUI
24
 
 */
25
 
Y.Event.define('windowresize', {
26
 
 
27
 
    on: (Y.UA.gecko && Y.UA.gecko < 1.91) ?
28
 
        function (node, sub, notifier) {
29
 
            sub._handle = Y.Event.attach('resize', function (e) {
30
 
                notifier.fire(e);
31
 
            });
32
 
        } :
33
 
        function (node, sub, notifier) {
34
 
            // interval bumped from 40 to 100ms as of 3.4.1
35
 
            var delay = Y.config.windowResizeDelay || 100;
36
 
 
37
 
            sub._handle = Y.Event.attach('resize', function (e) {
38
 
                if (sub._timer) {
39
 
                    sub._timer.cancel();
40
 
                }
41
 
 
42
 
                sub._timer = Y.later(delay, Y, function () {
43
 
                    notifier.fire(e);
44
 
                });
45
 
            });
46
 
        },
47
 
 
48
 
    detach: function (node, sub) {
49
 
        if (sub._timer) {
50
 
            sub._timer.cancel();
51
 
        }
52
 
        sub._handle.detach();
53
 
    }
54
 
    // delegate methods not defined because this only works for window
55
 
    // subscriptions, so...yeah.
56
 
});
57
 
 
58
 
 
59
 
}, '3.5.1' ,{requires:['event-synthetic']});