| author | Gautier Thibault <gthibault@universcine.com> |
| Tue, 22 Sep 2009 16:40:38 +0200 | |
| changeset 35 | 94a1dc255022 |
| permissions | -rw-r--r-- |
|
35
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
1 |
/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
2 |
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
3 |
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
4 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
5 |
* $LastChangedDate: 2007-06-22 04:38:37 +0200 (Fr, 22 Jun 2007) $ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
6 |
* $Rev: 2141 $ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
7 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
8 |
* Version: 1.0b2 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
9 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
10 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
11 |
(function($){
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
12 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
13 |
// store a copy of the core height and width methods |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
14 |
var height = $.fn.height, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
15 |
width = $.fn.width; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
16 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
17 |
$.fn.extend({
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
18 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
19 |
* If used on document, returns the document's height (innerHeight) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
20 |
* If used on window, returns the viewport's (window) height |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
21 |
* See core docs on height() to see what happens when used on an element. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
22 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
23 |
* @example $("#testdiv").height()
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
24 |
* @result 200 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
25 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
26 |
* @example $(document).height() |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
27 |
* @result 800 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
28 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
29 |
* @example $(window).height() |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
30 |
* @result 400 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
31 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
32 |
* @name height |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
33 |
* @type Object |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
34 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
35 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
36 |
height: function() {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
37 |
if ( this[0] == window ) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
38 |
return self.innerHeight || |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
39 |
$.boxModel && document.documentElement.clientHeight || |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
40 |
document.body.clientHeight; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
41 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
42 |
if ( this[0] == document ) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
43 |
return Math.max( document.body.scrollHeight, document.body.offsetHeight ); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
44 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
45 |
return height.apply(this, arguments); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
46 |
}, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
47 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
48 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
49 |
* If used on document, returns the document's width (innerWidth) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
50 |
* If used on window, returns the viewport's (window) width |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
51 |
* See core docs on height() to see what happens when used on an element. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
52 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
53 |
* @example $("#testdiv").width()
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
54 |
* @result 200 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
55 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
56 |
* @example $(document).width() |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
57 |
* @result 800 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
58 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
59 |
* @example $(window).width() |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
60 |
* @result 400 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
61 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
62 |
* @name width |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
63 |
* @type Object |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
64 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
65 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
66 |
width: function() {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
67 |
if ( this[0] == window ) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
68 |
return self.innerWidth || |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
69 |
$.boxModel && document.documentElement.clientWidth || |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
70 |
document.body.clientWidth; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
71 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
72 |
if ( this[0] == document ) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
73 |
return Math.max( document.body.scrollWidth, document.body.offsetWidth ); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
74 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
75 |
return width.apply(this, arguments); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
76 |
}, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
77 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
78 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
79 |
* Returns the inner height value (without border) for the first matched element. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
80 |
* If used on document, returns the document's height (innerHeight) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
81 |
* If used on window, returns the viewport's (window) height |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
82 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
83 |
* @example $("#testdiv").innerHeight()
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
84 |
* @result 800 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
85 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
86 |
* @name innerHeight |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
87 |
* @type Number |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
88 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
89 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
90 |
innerHeight: function() {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
91 |
return this[0] == window || this[0] == document ? |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
92 |
this.height() : |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
93 |
this.is(':visible') ?
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
94 |
this[0].offsetHeight - num(this, 'borderTopWidth') - num(this, 'borderBottomWidth') : |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
95 |
this.height() + num(this, 'paddingTop') + num(this, 'paddingBottom'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
96 |
}, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
97 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
98 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
99 |
* Returns the inner width value (without border) for the first matched element. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
100 |
* If used on document, returns the document's Width (innerWidth) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
101 |
* If used on window, returns the viewport's (window) width |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
102 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
103 |
* @example $("#testdiv").innerWidth()
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
104 |
* @result 1000 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
105 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
106 |
* @name innerWidth |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
107 |
* @type Number |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
108 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
109 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
110 |
innerWidth: function() {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
111 |
return this[0] == window || this[0] == document ? |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
112 |
this.width() : |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
113 |
this.is(':visible') ?
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
114 |
this[0].offsetWidth - num(this, 'borderLeftWidth') - num(this, 'borderRightWidth') : |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
115 |
this.width() + num(this, 'paddingLeft') + num(this, 'paddingRight'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
116 |
}, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
117 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
118 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
119 |
* Returns the outer height value (including border) for the first matched element. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
120 |
* Cannot be used on document or window. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
121 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
122 |
* @example $("#testdiv").outerHeight()
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
123 |
* @result 1000 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
124 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
125 |
* @name outerHeight |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
126 |
* @type Number |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
127 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
128 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
129 |
outerHeight: function() {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
130 |
return this[0] == window || this[0] == document ? |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
131 |
this.height() : |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
132 |
this.is(':visible') ?
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
133 |
this[0].offsetHeight : |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
134 |
this.height() + num(this,'borderTopWidth') + num(this, 'borderBottomWidth') + num(this, 'paddingTop') + num(this, 'paddingBottom'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
135 |
}, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
136 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
137 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
138 |
* Returns the outer width value (including border) for the first matched element. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
139 |
* Cannot be used on document or window. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
140 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
141 |
* @example $("#testdiv").outerHeight()
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
142 |
* @result 1000 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
143 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
144 |
* @name outerHeight |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
145 |
* @type Number |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
146 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
147 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
148 |
outerWidth: function() {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
149 |
return this[0] == window || this[0] == document ? |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
150 |
this.width() : |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
151 |
this.is(':visible') ?
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
152 |
this[0].offsetWidth : |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
153 |
this.width() + num(this, 'borderLeftWidth') + num(this, 'borderRightWidth') + num(this, 'paddingLeft') + num(this, 'paddingRight'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
154 |
}, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
155 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
156 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
157 |
* Returns how many pixels the user has scrolled to the right (scrollLeft). |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
158 |
* Works on containers with overflow: auto and window/document. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
159 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
160 |
* @example $("#testdiv").scrollLeft()
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
161 |
* @result 100 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
162 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
163 |
* @name scrollLeft |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
164 |
* @type Number |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
165 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
166 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
167 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
168 |
* Sets the scrollLeft property and continues the chain. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
169 |
* Works on containers with overflow: auto and window/document. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
170 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
171 |
* @example $("#testdiv").scrollLeft(10).scrollLeft()
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
172 |
* @result 10 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
173 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
174 |
* @name scrollLeft |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
175 |
* @param Number value A positive number representing the desired scrollLeft. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
176 |
* @type jQuery |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
177 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
178 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
179 |
scrollLeft: function(val) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
180 |
if ( val != undefined ) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
181 |
// set the scroll left |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
182 |
return this.each(function() {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
183 |
if (this == window || this == document) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
184 |
window.scrollTo( val, $(window).scrollTop() ); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
185 |
else |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
186 |
this.scrollLeft = val; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
187 |
}); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
188 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
189 |
// return the scroll left offest in pixels |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
190 |
if ( this[0] == window || this[0] == document ) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
191 |
return self.pageXOffset || |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
192 |
$.boxModel && document.documentElement.scrollLeft || |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
193 |
document.body.scrollLeft; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
194 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
195 |
return this[0].scrollLeft; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
196 |
}, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
197 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
198 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
199 |
* Returns how many pixels the user has scrolled to the bottom (scrollTop). |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
200 |
* Works on containers with overflow: auto and window/document. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
201 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
202 |
* @example $("#testdiv").scrollTop()
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
203 |
* @result 100 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
204 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
205 |
* @name scrollTop |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
206 |
* @type Number |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
207 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
208 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
209 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
210 |
* Sets the scrollTop property and continues the chain. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
211 |
* Works on containers with overflow: auto and window/document. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
212 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
213 |
* @example $("#testdiv").scrollTop(10).scrollTop()
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
214 |
* @result 10 |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
215 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
216 |
* @name scrollTop |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
217 |
* @param Number value A positive number representing the desired scrollTop. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
218 |
* @type jQuery |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
219 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
220 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
221 |
scrollTop: function(val) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
222 |
if ( val != undefined ) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
223 |
// set the scroll top |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
224 |
return this.each(function() {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
225 |
if (this == window || this == document) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
226 |
window.scrollTo( $(window).scrollLeft(), val ); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
227 |
else |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
228 |
this.scrollTop = val; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
229 |
}); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
230 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
231 |
// return the scroll top offset in pixels |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
232 |
if ( this[0] == window || this[0] == document ) |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
233 |
return self.pageYOffset || |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
234 |
$.boxModel && document.documentElement.scrollTop || |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
235 |
document.body.scrollTop; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
236 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
237 |
return this[0].scrollTop; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
238 |
}, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
239 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
240 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
241 |
* Returns the top and left positioned offset in pixels. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
242 |
* The positioned offset is the offset between a positioned |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
243 |
* parent and the element itself. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
244 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
245 |
* @example $("#testdiv").position()
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
246 |
* @result { top: 100, left: 100 }
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
247 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
248 |
* @name position |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
249 |
* @param Map options Optional settings to configure the way the offset is calculated. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
250 |
* @option Boolean margin Should the margin of the element be included in the calculations? False by default. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
251 |
* @option Boolean border Should the border of the element be included in the calculations? False by default. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
252 |
* @option Boolean padding Should the padding of the element be included in the calculations? False by default. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
253 |
* @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
254 |
* chain will not be broken and the result will be assigned to this object. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
255 |
* @type Object |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
256 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
257 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
258 |
position: function(options, returnObject) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
259 |
var elem = this[0], parent = elem.parentNode, op = elem.offsetParent, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
260 |
options = $.extend({ margin: false, border: false, padding: false, scroll: false }, options || {}),
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
261 |
x = elem.offsetLeft, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
262 |
y = elem.offsetTop, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
263 |
sl = elem.scrollLeft, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
264 |
st = elem.scrollTop; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
265 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
266 |
// Mozilla and IE do not add the border |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
267 |
if ($.browser.mozilla || $.browser.msie) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
268 |
// add borders to offset |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
269 |
x += num(elem, 'borderLeftWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
270 |
y += num(elem, 'borderTopWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
271 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
272 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
273 |
if ($.browser.mozilla) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
274 |
do {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
275 |
// Mozilla does not add the border for a parent that has overflow set to anything but visible |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
276 |
if ($.browser.mozilla && parent != elem && $.css(parent, 'overflow') != 'visible') {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
277 |
x += num(parent, 'borderLeftWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
278 |
y += num(parent, 'borderTopWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
279 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
280 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
281 |
if (parent == op) break; // break if we are already at the offestParent |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
282 |
} while ((parent = parent.parentNode) && (parent.tagName.toLowerCase() != 'body' || parent.tagName.toLowerCase() != 'html')); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
283 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
284 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
285 |
var returnValue = handleOffsetReturn(elem, options, x, y, sl, st); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
286 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
287 |
if (returnObject) { $.extend(returnObject, returnValue); return this; }
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
288 |
else { return returnValue; }
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
289 |
}, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
290 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
291 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
292 |
* Returns the location of the element in pixels from the top left corner of the viewport. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
293 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
294 |
* For accurate readings make sure to use pixel values for margins, borders and padding. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
295 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
296 |
* Known issues: |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
297 |
* - Issue: A div positioned relative or static without any content before it and its parent will report an offsetTop of 0 in Safari |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
298 |
* Workaround: Place content before the relative div ... and set height and width to 0 and overflow to hidden |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
299 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
300 |
* @example $("#testdiv").offset()
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
301 |
* @result { top: 100, left: 100, scrollTop: 10, scrollLeft: 10 }
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
302 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
303 |
* @example $("#testdiv").offset({ scroll: false })
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
304 |
* @result { top: 90, left: 90 }
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
305 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
306 |
* @example var offset = {}
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
307 |
* $("#testdiv").offset({ scroll: false }, offset)
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
308 |
* @result offset = { top: 90, left: 90 }
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
309 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
310 |
* @name offset |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
311 |
* @param Map options Optional settings to configure the way the offset is calculated. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
312 |
* @option Boolean margin Should the margin of the element be included in the calculations? True by default. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
313 |
* @option Boolean border Should the border of the element be included in the calculations? False by default. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
314 |
* @option Boolean padding Should the padding of the element be included in the calculations? False by default. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
315 |
* @option Boolean scroll Should the scroll offsets of the parent elements be included in the calculations? True by default. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
316 |
* When true it adds the totla scroll offets of all parents to the total offset and also adds two properties |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
317 |
* to the returned object, scrollTop and scrollLeft. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
318 |
* @options Boolean lite Will use offsetLite instead of offset when set to true. False by default. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
319 |
* @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
320 |
* chain will not be broken and the result will be assigned to this object. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
321 |
* @type Object |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
322 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
323 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
324 |
offset: function(options, returnObject) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
325 |
var x = 0, y = 0, sl = 0, st = 0, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
326 |
elem = this[0], parent = this[0], op, parPos, elemPos = $.css(elem, 'position'), |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
327 |
mo = $.browser.mozilla, ie = $.browser.msie, sf = $.browser.safari, oa = $.browser.opera, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
328 |
absparent = false, relparent = false, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
329 |
options = $.extend({ margin: true, border: false, padding: false, scroll: true, lite: false }, options || {});
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
330 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
331 |
// Use offsetLite if lite option is true |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
332 |
if (options.lite) return this.offsetLite(options, returnObject); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
333 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
334 |
if (elem.tagName.toLowerCase() == 'body') {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
335 |
// Safari is the only one to get offsetLeft and offsetTop properties of the body "correct" |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
336 |
// Except they all mess up when the body is positioned absolute or relative |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
337 |
x = elem.offsetLeft; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
338 |
y = elem.offsetTop; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
339 |
// Mozilla ignores margin and subtracts border from body element |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
340 |
if (mo) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
341 |
x += num(elem, 'marginLeft') + (num(elem, 'borderLeftWidth')*2); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
342 |
y += num(elem, 'marginTop') + (num(elem, 'borderTopWidth') *2); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
343 |
} else |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
344 |
// Opera ignores margin |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
345 |
if (oa) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
346 |
x += num(elem, 'marginLeft'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
347 |
y += num(elem, 'marginTop'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
348 |
} else |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
349 |
// IE does not add the border in Standards Mode |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
350 |
if (ie && jQuery.boxModel) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
351 |
x += num(elem, 'borderLeftWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
352 |
y += num(elem, 'borderTopWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
353 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
354 |
} else {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
355 |
do {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
356 |
parPos = $.css(parent, 'position'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
357 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
358 |
x += parent.offsetLeft; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
359 |
y += parent.offsetTop; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
360 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
361 |
// Mozilla and IE do not add the border |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
362 |
if (mo || ie) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
363 |
// add borders to offset |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
364 |
x += num(parent, 'borderLeftWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
365 |
y += num(parent, 'borderTopWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
366 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
367 |
// Mozilla does not include the border on body if an element isn't positioned absolute and is without an absolute parent |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
368 |
if (mo && parPos == 'absolute') absparent = true; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
369 |
// IE does not include the border on the body if an element is position static and without an absolute or relative parent |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
370 |
if (ie && parPos == 'relative') relparent = true; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
371 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
372 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
373 |
op = parent.offsetParent; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
374 |
if (options.scroll || mo) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
375 |
do {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
376 |
if (options.scroll) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
377 |
// get scroll offsets |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
378 |
sl += parent.scrollLeft; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
379 |
st += parent.scrollTop; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
380 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
381 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
382 |
// Mozilla does not add the border for a parent that has overflow set to anything but visible |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
383 |
if (mo && parent != elem && $.css(parent, 'overflow') != 'visible') {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
384 |
x += num(parent, 'borderLeftWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
385 |
y += num(parent, 'borderTopWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
386 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
387 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
388 |
parent = parent.parentNode; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
389 |
} while (parent != op); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
390 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
391 |
parent = op; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
392 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
393 |
if (parent.tagName.toLowerCase() == 'body' || parent.tagName.toLowerCase() == 'html') {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
394 |
// Safari and IE Standards Mode doesn't add the body margin for elments positioned with static or relative |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
395 |
if ((sf || (ie && $.boxModel)) && elemPos != 'absolute' && elemPos != 'fixed') {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
396 |
x += num(parent, 'marginLeft'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
397 |
y += num(parent, 'marginTop'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
398 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
399 |
// Mozilla does not include the border on body if an element isn't positioned absolute and is without an absolute parent |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
400 |
// IE does not include the border on the body if an element is positioned static and without an absolute or relative parent |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
401 |
if ( (mo && !absparent && elemPos != 'fixed') || |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
402 |
(ie && elemPos == 'static' && !relparent) ) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
403 |
x += num(parent, 'borderLeftWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
404 |
y += num(parent, 'borderTopWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
405 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
406 |
break; // Exit the loop |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
407 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
408 |
} while (parent); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
409 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
410 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
411 |
var returnValue = handleOffsetReturn(elem, options, x, y, sl, st); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
412 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
413 |
if (returnObject) { $.extend(returnObject, returnValue); return this; }
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
414 |
else { return returnValue; }
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
415 |
}, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
416 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
417 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
418 |
* Returns the location of the element in pixels from the top left corner of the viewport. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
419 |
* This method is much faster than offset but not as accurate. This method can be invoked |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
420 |
* by setting the lite option to true in the offset method. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
421 |
* |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
422 |
* @name offsetLite |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
423 |
* @param Map options Optional settings to configure the way the offset is calculated. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
424 |
* @option Boolean margin Should the margin of the element be included in the calculations? True by default. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
425 |
* @option Boolean border Should the border of the element be included in the calculations? False by default. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
426 |
* @option Boolean padding Should the padding of the element be included in the calculations? False by default. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
427 |
* @option Boolean scroll Should the scroll offsets of the parent elements be included in the calculations? True by default. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
428 |
* When true it adds the totla scroll offets of all parents to the total offset and also adds two properties |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
429 |
* to the returned object, scrollTop and scrollLeft. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
430 |
* @param Object returnObject An object to store the return value in, so as not to break the chain. If passed in the |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
431 |
* chain will not be broken and the result will be assigned to this object. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
432 |
* @type Object |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
433 |
* @cat Plugins/Dimensions |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
434 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
435 |
offsetLite: function(options, returnObject) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
436 |
var x = 0, y = 0, sl = 0, st = 0, parent = this[0], op, |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
437 |
options = $.extend({ margin: true, border: false, padding: false, scroll: true }, options || {});
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
438 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
439 |
do {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
440 |
x += parent.offsetLeft; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
441 |
y += parent.offsetTop; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
442 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
443 |
op = parent.offsetParent; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
444 |
if (options.scroll) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
445 |
// get scroll offsets |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
446 |
do {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
447 |
sl += parent.scrollLeft; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
448 |
st += parent.scrollTop; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
449 |
parent = parent.parentNode; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
450 |
} while(parent != op); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
451 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
452 |
parent = op; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
453 |
} while (parent && parent.tagName.toLowerCase() != 'body' && parent.tagName.toLowerCase() != 'html'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
454 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
455 |
var returnValue = handleOffsetReturn(this[0], options, x, y, sl, st); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
456 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
457 |
if (returnObject) { $.extend(returnObject, returnValue); return this; }
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
458 |
else { return returnValue; }
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
459 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
460 |
}); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
461 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
462 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
463 |
* Handles converting a CSS Style into an Integer. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
464 |
* @private |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
465 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
466 |
var num = function(el, prop) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
467 |
return parseInt($.css(el.jquery?el[0]:el,prop))||0; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
468 |
}; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
469 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
470 |
/** |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
471 |
* Handles the return value of the offset and offsetLite methods. |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
472 |
* @private |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
473 |
*/ |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
474 |
var handleOffsetReturn = function(elem, options, x, y, sl, st) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
475 |
if ( !options.margin ) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
476 |
x -= num(elem, 'marginLeft'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
477 |
y -= num(elem, 'marginTop'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
478 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
479 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
480 |
// Safari and Opera do not add the border for the element |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
481 |
if ( options.border && ($.browser.safari || $.browser.opera) ) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
482 |
x += num(elem, 'borderLeftWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
483 |
y += num(elem, 'borderTopWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
484 |
} else if ( !options.border && !($.browser.safari || $.browser.opera) ) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
485 |
x -= num(elem, 'borderLeftWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
486 |
y -= num(elem, 'borderTopWidth'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
487 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
488 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
489 |
if ( options.padding ) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
490 |
x += num(elem, 'paddingLeft'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
491 |
y += num(elem, 'paddingTop'); |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
492 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
493 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
494 |
// do not include scroll offset on the element |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
495 |
if ( options.scroll ) {
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
496 |
sl -= elem.scrollLeft; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
497 |
st -= elem.scrollTop; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
498 |
} |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
499 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
500 |
return options.scroll ? { top: y - st, left: x - sl, scrollTop: st, scrollLeft: sl }
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
501 |
: { top: y, left: x };
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
502 |
}; |
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
503 |
|
|
94a1dc255022
Commit the all thd project created with the framework symfony
Gautier Thibault <gthibault@universcine.com>
parents:
diff
changeset
|
504 |
})(jQuery); |