annotate jquery-ui/development-bundle/ui/jquery.ui.position.js @ 0:b2e4605f20b2

beta version
author dwinter
date Thu, 30 Jun 2011 09:07:49 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1 /*
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2 * jQuery UI Position 1.8.11
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3 *
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5 * Dual licensed under the MIT or GPL Version 2 licenses.
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6 * http://jquery.org/license
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7 *
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8 * http://docs.jquery.com/UI/Position
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
9 */
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
10 (function( $, undefined ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
11
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
12 $.ui = $.ui || {};
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
13
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
14 var horizontalPositions = /left|center|right/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
15 verticalPositions = /top|center|bottom/,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
16 center = "center",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
17 _position = $.fn.position,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
18 _offset = $.fn.offset;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
19
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
20 $.fn.position = function( options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
21 if ( !options || !options.of ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
22 return _position.apply( this, arguments );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
23 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
24
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
25 // make a copy, we don't want to modify arguments
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
26 options = $.extend( {}, options );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
27
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
28 var target = $( options.of ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
29 targetElem = target[0],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
30 collision = ( options.collision || "flip" ).split( " " ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
31 offset = options.offset ? options.offset.split( " " ) : [ 0, 0 ],
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
32 targetWidth,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
33 targetHeight,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
34 basePosition;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
35
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
36 if ( targetElem.nodeType === 9 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
37 targetWidth = target.width();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
38 targetHeight = target.height();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
39 basePosition = { top: 0, left: 0 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
40 // TODO: use $.isWindow() in 1.9
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
41 } else if ( targetElem.setTimeout ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
42 targetWidth = target.width();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
43 targetHeight = target.height();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
44 basePosition = { top: target.scrollTop(), left: target.scrollLeft() };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
45 } else if ( targetElem.preventDefault ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
46 // force left top to allow flipping
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
47 options.at = "left top";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
48 targetWidth = targetHeight = 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
49 basePosition = { top: options.of.pageY, left: options.of.pageX };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
50 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
51 targetWidth = target.outerWidth();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
52 targetHeight = target.outerHeight();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
53 basePosition = target.offset();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
54 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
55
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
56 // force my and at to have valid horizontal and veritcal positions
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
57 // if a value is missing or invalid, it will be converted to center
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
58 $.each( [ "my", "at" ], function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
59 var pos = ( options[this] || "" ).split( " " );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
60 if ( pos.length === 1) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
61 pos = horizontalPositions.test( pos[0] ) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
62 pos.concat( [center] ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
63 verticalPositions.test( pos[0] ) ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
64 [ center ].concat( pos ) :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
65 [ center, center ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
66 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
67 pos[ 0 ] = horizontalPositions.test( pos[0] ) ? pos[ 0 ] : center;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
68 pos[ 1 ] = verticalPositions.test( pos[1] ) ? pos[ 1 ] : center;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
69 options[ this ] = pos;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
70 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
71
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
72 // normalize collision option
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
73 if ( collision.length === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
74 collision[ 1 ] = collision[ 0 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
75 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
76
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
77 // normalize offset option
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
78 offset[ 0 ] = parseInt( offset[0], 10 ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
79 if ( offset.length === 1 ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
80 offset[ 1 ] = offset[ 0 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
81 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
82 offset[ 1 ] = parseInt( offset[1], 10 ) || 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
83
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
84 if ( options.at[0] === "right" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
85 basePosition.left += targetWidth;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
86 } else if ( options.at[0] === center ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
87 basePosition.left += targetWidth / 2;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
88 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
89
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
90 if ( options.at[1] === "bottom" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
91 basePosition.top += targetHeight;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
92 } else if ( options.at[1] === center ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
93 basePosition.top += targetHeight / 2;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
94 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
95
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
96 basePosition.left += offset[ 0 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
97 basePosition.top += offset[ 1 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
98
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
99 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
100 var elem = $( this ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
101 elemWidth = elem.outerWidth(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
102 elemHeight = elem.outerHeight(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
103 marginLeft = parseInt( $.curCSS( this, "marginLeft", true ) ) || 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
104 marginTop = parseInt( $.curCSS( this, "marginTop", true ) ) || 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
105 collisionWidth = elemWidth + marginLeft +
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
106 ( parseInt( $.curCSS( this, "marginRight", true ) ) || 0 ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
107 collisionHeight = elemHeight + marginTop +
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
108 ( parseInt( $.curCSS( this, "marginBottom", true ) ) || 0 ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
109 position = $.extend( {}, basePosition ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
110 collisionPosition;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
111
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
112 if ( options.my[0] === "right" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
113 position.left -= elemWidth;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
114 } else if ( options.my[0] === center ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
115 position.left -= elemWidth / 2;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
116 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
117
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
118 if ( options.my[1] === "bottom" ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
119 position.top -= elemHeight;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
120 } else if ( options.my[1] === center ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
121 position.top -= elemHeight / 2;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
122 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
123
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
124 // prevent fractions (see #5280)
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
125 position.left = Math.round( position.left );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
126 position.top = Math.round( position.top );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
127
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
128 collisionPosition = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
129 left: position.left - marginLeft,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
130 top: position.top - marginTop
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
131 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
132
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
133 $.each( [ "left", "top" ], function( i, dir ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
134 if ( $.ui.position[ collision[i] ] ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
135 $.ui.position[ collision[i] ][ dir ]( position, {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
136 targetWidth: targetWidth,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
137 targetHeight: targetHeight,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
138 elemWidth: elemWidth,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
139 elemHeight: elemHeight,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
140 collisionPosition: collisionPosition,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
141 collisionWidth: collisionWidth,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
142 collisionHeight: collisionHeight,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
143 offset: offset,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
144 my: options.my,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
145 at: options.at
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
146 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
147 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
148 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
149
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
150 if ( $.fn.bgiframe ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
151 elem.bgiframe();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
152 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
153 elem.offset( $.extend( position, { using: options.using } ) );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
154 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
155 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
156
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
157 $.ui.position = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
158 fit: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
159 left: function( position, data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
160 var win = $( window ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
161 over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
162 position.left = over > 0 ? position.left - over : Math.max( position.left - data.collisionPosition.left, position.left );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
163 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
164 top: function( position, data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
165 var win = $( window ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
166 over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
167 position.top = over > 0 ? position.top - over : Math.max( position.top - data.collisionPosition.top, position.top );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
168 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
169 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
170
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
171 flip: {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
172 left: function( position, data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
173 if ( data.at[0] === center ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
174 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
175 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
176 var win = $( window ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
177 over = data.collisionPosition.left + data.collisionWidth - win.width() - win.scrollLeft(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
178 myOffset = data.my[ 0 ] === "left" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
179 -data.elemWidth :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
180 data.my[ 0 ] === "right" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
181 data.elemWidth :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
182 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
183 atOffset = data.at[ 0 ] === "left" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
184 data.targetWidth :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
185 -data.targetWidth,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
186 offset = -2 * data.offset[ 0 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
187 position.left += data.collisionPosition.left < 0 ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
188 myOffset + atOffset + offset :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
189 over > 0 ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
190 myOffset + atOffset + offset :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
191 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
192 },
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
193 top: function( position, data ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
194 if ( data.at[1] === center ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
195 return;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
196 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
197 var win = $( window ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
198 over = data.collisionPosition.top + data.collisionHeight - win.height() - win.scrollTop(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
199 myOffset = data.my[ 1 ] === "top" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
200 -data.elemHeight :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
201 data.my[ 1 ] === "bottom" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
202 data.elemHeight :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
203 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
204 atOffset = data.at[ 1 ] === "top" ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
205 data.targetHeight :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
206 -data.targetHeight,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
207 offset = -2 * data.offset[ 1 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
208 position.top += data.collisionPosition.top < 0 ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
209 myOffset + atOffset + offset :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
210 over > 0 ?
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
211 myOffset + atOffset + offset :
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
212 0;
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
213 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
214 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
215 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
216
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
217 // offset setter from jQuery 1.4
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
218 if ( !$.offset.setOffset ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
219 $.offset.setOffset = function( elem, options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
220 // set position first, in-case top/left are set even on static elem
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
221 if ( /static/.test( $.curCSS( elem, "position" ) ) ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
222 elem.style.position = "relative";
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
223 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
224 var curElem = $( elem ),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
225 curOffset = curElem.offset(),
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
226 curTop = parseInt( $.curCSS( elem, "top", true ), 10 ) || 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
227 curLeft = parseInt( $.curCSS( elem, "left", true ), 10) || 0,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
228 props = {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
229 top: (options.top - curOffset.top) + curTop,
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
230 left: (options.left - curOffset.left) + curLeft
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
231 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
232
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
233 if ( 'using' in options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
234 options.using.call( elem, props );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
235 } else {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
236 curElem.css( props );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
237 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
238 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
239
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
240 $.fn.offset = function( options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
241 var elem = this[ 0 ];
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
242 if ( !elem || !elem.ownerDocument ) { return null; }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
243 if ( options ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
244 return this.each(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
245 $.offset.setOffset( this, options );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
246 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
247 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
248 return _offset.call( this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
249 };
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
250 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
251
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
252 }( jQuery ));