]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - jssource/src_files/include/javascript/yui3/build/event/event-resize.js
Release 6.5.0
[Github/sugarcrm.git] / jssource / src_files / include / javascript / yui3 / build / event / event-resize.js
1 /*
2 Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3 Code licensed under the BSD License:
4 http://developer.yahoo.com/yui/license.html
5 version: 3.3.0
6 build: 3167
7 */
8 YUI.add('event-resize', function(Y) {
9
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  */
16 (function() {
17
18 var detachHandle,
19
20     timerHandle,
21
22     CE_NAME = 'window:resize',
23
24     handler = function(e) {
25
26         if (Y.UA.gecko) {
27
28             Y.fire(CE_NAME, e);
29
30         } else {
31
32             if (timerHandle) {
33                 timerHandle.cancel();
34             }
35
36             timerHandle = Y.later(Y.config.windowResizeDelay || 40, Y, function() {
37                 Y.fire(CE_NAME, e);
38             });
39         }
40         
41     };
42
43
44 /**
45  * Firefox fires the window resize event once when the resize action
46  * finishes, other browsers fire the event periodically during the
47  * resize.  This code uses timeout logic to simulate the Firefox 
48  * behavior in other browsers.
49  * @event windowresize
50  * @for YUI
51  */
52 Y.Env.evt.plugins.windowresize = {
53
54     on: function(type, fn) {
55
56         // check for single window listener and add if needed
57         if (!detachHandle) {
58             detachHandle = Y.Event._attach(['resize', handler]);
59         }
60
61         var a = Y.Array(arguments, 0, true);
62         a[0] = CE_NAME;
63
64         return Y.on.apply(Y, a);
65     }
66 };
67
68 })();
69
70
71 }, '3.3.0' ,{requires:['node-base']});