jquery.wresize.js
2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* @fileOverview 页面resize jquery插件封装
* @author:Hbomb(zhouqq@yoho.cn)
* @date:2012-07-20
*/
define('lib/util/jquery.wresize', [], function(require)
{
/*
* ===============================================================================
* WResize is the jQuery plugin for fixing the IE window resize bug
* ...............................................................................
* Copyright 2007 / Andrea Ercolino
* -------------------------------------------------------------------------------
* LICENSE: http://www.opensource.org/licenses/mit-license.php WEBSITE:
* http://noteslog.com/
* ===============================================================================
*/
return function($)
{
$.fn.wresize = function(f)
{
version = '1.1';
wresize =
{
fired : false,
width : 0
};
function resizeOnce()
{
if ($.browser.msie)
{
if (!wresize.fired)
{
wresize.fired = true;
}
else
{
var version = parseInt($.browser.version, 10);
wresize.fired = false;
if (version < 7)
{
return false;
}
else if (version == 7)
{
// a vertical resize is fired once, an horizontal
// resize twice
var width = $(window).width();
if (width != wresize.width)
{
wresize.width = width;
return false;
}
}
}
}
return true;
}
function handleWResize(e)
{
if (resizeOnce())
{
return f.apply(this, [ e
]);
}
}
this.each(function()
{
if (this == window)
{
$(this).resize(handleWResize);
}
else
{
$(this).resize(f);
}
});
return this;
};
};
});