NOBUG: Fixed file access permissions
[moodle.git] / lib / yuilib / 3.13.0 / event-resize / event-resize.js
blobfd42dbc01d73c8cc8597400e547f3e68506bb02b
1 /*
2 YUI 3.13.0 (build 508226d)
3 Copyright 2013 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
6 */
8 YUI.add('event-resize', function (Y, NAME) {
10 /**
11  * Adds a window resize event that has its behavior normalized to fire at the
12  * end of the resize rather than constantly during the resize.
13  * @module event
14  * @submodule event-resize
15  */
18 /**
19  * Old firefox fires the window resize event once when the resize action
20  * finishes, other browsers fire the event periodically during the
21  * resize.  This code uses timeout logic to simulate the Firefox
22  * behavior in other browsers.
23  * @event windowresize
24  * @for YUI
25  */
26 Y.Event.define('windowresize', {
28     on: (Y.UA.gecko && Y.UA.gecko < 1.91) ?
29         function (node, sub, notifier) {
30             sub._handle = Y.Event.attach('resize', function (e) {
31                 notifier.fire(e);
32             });
33         } :
34         function (node, sub, notifier) {
35             // interval bumped from 40 to 100ms as of 3.4.1
36             var delay = Y.config.windowResizeDelay || 100;
38             sub._handle = Y.Event.attach('resize', function (e) {
39                 if (sub._timer) {
40                     sub._timer.cancel();
41                 }
43                 sub._timer = Y.later(delay, Y, function () {
44                     notifier.fire(e);
45                 });
46             });
47         },
49     detach: function (node, sub) {
50         if (sub._timer) {
51             sub._timer.cancel();
52         }
53         sub._handle.detach();
54     }
55     // delegate methods not defined because this only works for window
56     // subscriptions, so...yeah.
57 });
60 }, '3.13.0', {"requires": ["node-base", "event-synthetic"]});