1 |
5703
|
leinfelder
|
|
2 |
|
|
<ul class="UIAPIPlugin-toc">
|
3 |
|
|
<li><a href="#overview">Overview</a></li>
|
4 |
|
|
<li><a href="#options">Arguments</a></li>
|
5 |
|
|
</ul>
|
6 |
|
|
<div class="UIAPIPlugin">
|
7 |
|
|
<h1>jQuery UI Position Utility</h1>
|
8 |
|
|
<div id="overview">
|
9 |
|
|
<h2 class="top-header">Overview</h2>
|
10 |
|
|
<div id="overview-main">
|
11 |
|
|
<p>Utility script for positioning any widget relative to the window, document, a particular element, or the cursor/mouse.</p>
|
12 |
|
|
<p><em>Note: jQuery UI does not support positioning hidden elements.</em></p>
|
13 |
|
|
<p>Does not need ui.core.js or effects.core.js.</p>
|
14 |
|
|
</div>
|
15 |
|
|
<div id="overview-dependencies">
|
16 |
|
|
<h3>Dependencies</h3>
|
17 |
|
|
<ul>
|
18 |
|
|
<li><i>none (only jQuery core)</i></li>
|
19 |
|
|
</ul>
|
20 |
|
|
</div>
|
21 |
|
|
<div id="overview-example">
|
22 |
|
|
<h3>Example</h3>
|
23 |
|
|
<div id="overview-example" class="example">
|
24 |
|
|
<ul><li><a href="#demo"><span>Demo</span></a></li><li><a href="#source"><span>View Source</span></a></li></ul>
|
25 |
|
|
<p><div id="demo" class="tabs-container" rel="300">
|
26 |
|
|
Clicking on the green element transfers to the other.<br />
|
27 |
|
|
</p>
|
28 |
|
|
<pre>
|
29 |
|
|
$("#position1").position({
|
30 |
|
|
my: "center",
|
31 |
|
|
at: "center",
|
32 |
|
|
of: "#targetElement"
|
33 |
|
|
});
|
34 |
|
|
$("#position2").position({
|
35 |
|
|
my: "left top",
|
36 |
|
|
at: "left top",
|
37 |
|
|
of: "#targetElement"
|
38 |
|
|
});
|
39 |
|
|
$("#position3").position({
|
40 |
|
|
my: "right center",
|
41 |
|
|
at: "right bottom",
|
42 |
|
|
of: "#targetElement"
|
43 |
|
|
});
|
44 |
|
|
$(document).mousemove(function(ev){
|
45 |
|
|
$("#position4").position({
|
46 |
|
|
my: "left bottom",
|
47 |
|
|
of: ev,
|
48 |
|
|
offset: "3 -3",
|
49 |
|
|
collision: "fit"
|
50 |
|
|
});
|
51 |
|
|
});
|
52 |
|
|
|
53 |
|
|
</pre>
|
54 |
|
|
<p></div><div id="source" class="tabs-container">
|
55 |
|
|
</p>
|
56 |
|
|
<pre><!DOCTYPE html>
|
57 |
|
|
<html>
|
58 |
|
|
<head>
|
59 |
|
|
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
|
60 |
|
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
|
61 |
|
|
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
|
62 |
|
|
<style type="text/css">
|
63 |
|
|
#targetElement { width:240px;height:200px;background-color:#999;margin:30px auto; }
|
64 |
|
|
.positionDiv { width:50px;height:50px;opacity:0.6; }
|
65 |
|
|
#position1 {background-color:#F00;}
|
66 |
|
|
#position2 {background-color:#0F0;}
|
67 |
|
|
#position3 {background-color:#00F;}
|
68 |
|
|
#position4 {background-color:#FF0;}
|
69 |
|
|
</style>
|
70 |
|
|
|
71 |
|
|
<script>
|
72 |
|
|
$(document).ready(function() {
|
73 |
|
|
|
74 |
|
|
$("#position1").position({
|
75 |
|
|
my: "center",
|
76 |
|
|
at: "center",
|
77 |
|
|
of: "#targetElement"
|
78 |
|
|
});
|
79 |
|
|
$("#position2").position({
|
80 |
|
|
my: "left top",
|
81 |
|
|
at: "left top",
|
82 |
|
|
of: "#targetElement"
|
83 |
|
|
});
|
84 |
|
|
$("#position3").position({
|
85 |
|
|
my: "right center",
|
86 |
|
|
at: "right bottom",
|
87 |
|
|
of: "#targetElement"
|
88 |
|
|
});
|
89 |
|
|
$(document).mousemove(function(ev){
|
90 |
|
|
$("#position4").position({
|
91 |
|
|
my: "left bottom",
|
92 |
|
|
of: ev,
|
93 |
|
|
offset: "3 -3",
|
94 |
|
|
collision: "fit"
|
95 |
|
|
});
|
96 |
|
|
});
|
97 |
|
|
|
98 |
|
|
});
|
99 |
|
|
</script>
|
100 |
|
|
</head>
|
101 |
|
|
<body style="font-size:62.5%;">
|
102 |
|
|
|
103 |
|
|
<div id="targetElement">
|
104 |
|
|
<div class="positionDiv" id="position1"></div>
|
105 |
|
|
<div class="positionDiv" id="position2"></div>
|
106 |
|
|
<div class="positionDiv" id="position3"></div>
|
107 |
|
|
<div class="positionDiv" id="position4"></div>
|
108 |
|
|
</div>
|
109 |
|
|
|
110 |
|
|
</body>
|
111 |
|
|
</html>
|
112 |
|
|
</pre>
|
113 |
|
|
<p></div>
|
114 |
|
|
</p><p></div>
|
115 |
|
|
</div>
|
116 |
|
|
</div>
|
117 |
|
|
<div id="options">
|
118 |
|
|
<h2 class="top-header">Arguments</h2>
|
119 |
|
|
<ul class="options-list">
|
120 |
|
|
|
121 |
|
|
<li class="option" id="option-my">
|
122 |
|
|
<div class="option-header">
|
123 |
|
|
<h3 class="option-name"><a href="#option-my">my</a></h3>
|
124 |
|
|
<dl>
|
125 |
|
|
<dt class="option-type-label">Type:</dt>
|
126 |
|
|
<dd class="option-type">String</dd>
|
127 |
|
|
|
128 |
|
|
</dl>
|
129 |
|
|
</div>
|
130 |
|
|
<div class="option-description">
|
131 |
|
|
<p>Defines which position on <b>the element being positioned</b> to align with the target element: "horizontal vertical" alignment. A single value such as "right" will default to "right center", "top" will default to "center top" (following CSS convention). Acceptable values: "top", "center", "bottom", "left", "right". Example: "left top" or "center center"</p>
|
132 |
|
|
</div>
|
133 |
|
|
</li>
|
134 |
|
|
|
135 |
|
|
|
136 |
|
|
<li class="option" id="option-at">
|
137 |
|
|
<div class="option-header">
|
138 |
|
|
<h3 class="option-name"><a href="#option-at">at</a></h3>
|
139 |
|
|
<dl>
|
140 |
|
|
<dt class="option-type-label">Type:</dt>
|
141 |
|
|
<dd class="option-type">String</dd>
|
142 |
|
|
|
143 |
|
|
</dl>
|
144 |
|
|
</div>
|
145 |
|
|
<div class="option-description">
|
146 |
|
|
<p>Defines which position on <b>the target element</b> to align the positioned element against: "horizontal vertical" alignment. A single value such as "right" will default to "right center", "top" will default to "center top" (following CSS convention). Acceptable values: "top", "center", "bottom", "left", "right". Example: "left top" or "center center"</p>
|
147 |
|
|
</div>
|
148 |
|
|
</li>
|
149 |
|
|
|
150 |
|
|
|
151 |
|
|
<li class="option" id="option-of">
|
152 |
|
|
<div class="option-header">
|
153 |
|
|
<h3 class="option-name"><a href="#option-of">of</a></h3>
|
154 |
|
|
<dl>
|
155 |
|
|
<dt class="option-type-label">Type:</dt>
|
156 |
|
|
<dd class="option-type">Selector, Element, jQuery, Event</dd>
|
157 |
|
|
|
158 |
|
|
</dl>
|
159 |
|
|
</div>
|
160 |
|
|
<div class="option-description">
|
161 |
|
|
<p>Element to position against. If you provide a selector, the first matching element will be used. If you provide a jQuery object, the first element will be used. If you provide an event object, the pageX and pageY properties will be used. Example: "#top-menu"</p>
|
162 |
|
|
</div>
|
163 |
|
|
</li>
|
164 |
|
|
|
165 |
|
|
|
166 |
|
|
<li class="option" id="option-offset">
|
167 |
|
|
<div class="option-header">
|
168 |
|
|
<h3 class="option-name"><a href="#option-offset">offset</a></h3>
|
169 |
|
|
<dl>
|
170 |
|
|
<dt class="option-type-label">Type:</dt>
|
171 |
|
|
<dd class="option-type">String</dd>
|
172 |
|
|
|
173 |
|
|
</dl>
|
174 |
|
|
</div>
|
175 |
|
|
<div class="option-description">
|
176 |
|
|
<p>Add these left-top values to the calculated position, eg. "50 50" (left top) A single value such as "50" will apply to both.</p>
|
177 |
|
|
</div>
|
178 |
|
|
</li>
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
<li class="option" id="option-collision">
|
182 |
|
|
<div class="option-header">
|
183 |
|
|
<h3 class="option-name"><a href="#option-collision">collision</a></h3>
|
184 |
|
|
<dl>
|
185 |
|
|
<dt class="option-type-label">Type:</dt>
|
186 |
|
|
<dd class="option-type">String</dd>
|
187 |
|
|
|
188 |
|
|
</dl>
|
189 |
|
|
</div>
|
190 |
|
|
<div class="option-description">
|
191 |
|
|
<p>When the positioned element overflows the window in some direction, move it to an alternative position. Similar to my and at, this accepts a single value or a pair for horizontal/vertical, eg. "flip", "fit", "fit flip", "fit none".
|
192 |
|
|
</p>
|
193 |
|
|
<ul><li> <b>flip</b>: to the opposite side and the collision detection is run again to see if it will fit. If it won't fit in either position, the center option should be used as a fall back.
|
194 |
|
|
</li><li> <b>fit</b>: so the element keeps in the desired direction, but is re-positioned so it fits.
|
195 |
|
|
</li><li> <b>none</b>: not do collision detection.
|
196 |
|
|
</li></ul>
|
197 |
|
|
<p></p>
|
198 |
|
|
</div>
|
199 |
|
|
</li>
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
<li class="option" id="option-using">
|
203 |
|
|
<div class="option-header">
|
204 |
|
|
<h3 class="option-name"><a href="#option-using">using</a></h3>
|
205 |
|
|
<dl>
|
206 |
|
|
<dt class="option-type-label">Type:</dt>
|
207 |
|
|
<dd class="option-type">Function</dd>
|
208 |
|
|
|
209 |
|
|
</dl>
|
210 |
|
|
</div>
|
211 |
|
|
<div class="option-description">
|
212 |
|
|
<p>When specified the actual property setting is delegated to this callback. Receives a single parameter which is a hash of top and left values for the position that should be set.</p>
|
213 |
|
|
</div>
|
214 |
|
|
</li>
|
215 |
|
|
|
216 |
|
|
</ul>
|
217 |
|
|
</div>
|
218 |
|
|
</div>
|
219 |
|
|
|
220 |
|
|
</p><!--
|
221 |
|
|
Pre-expand include size: 7124 bytes
|
222 |
|
|
Post-expand include size: 11012 bytes
|
223 |
|
|
Template argument size: 7642 bytes
|
224 |
|
|
Maximum: 2097152 bytes
|
225 |
|
|
-->
|
226 |
|
|
|
227 |
|
|
<!-- Saved in parser cache with key jqdocs_docs:pcache:idhash:3784-1!1!0!!en!2 and timestamp 20101025190222 -->
|