source: Dev/branches/jQueryUI/js/jquery/docs/position.html @ 244

Last change on this file since 244 was 244, checked in by hendrikvanantwerpen, 13 years ago

Inlogscherm werkt met jQuery UI! Woot!

File size: 7.7 KB
Line 
1
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">
26Clicking on the green element transfers to the other.<br />
27</p>
28<pre>
29$(&quot;#position1&quot;).position({
30  my: &quot;center&quot;,
31  at: &quot;center&quot;,
32  of: &quot;#targetElement&quot;
33});
34$(&quot;#position2&quot;).position({
35  my: &quot;left top&quot;,
36  at: &quot;left top&quot;,
37  of: &quot;#targetElement&quot;
38});
39$(&quot;#position3&quot;).position({
40  my: &quot;right center&quot;,
41  at: &quot;right bottom&quot;,
42  of: &quot;#targetElement&quot;
43});
44$(document).mousemove(function(ev){
45  $(&quot;#position4&quot;).position({
46    my: &quot;left bottom&quot;,
47    of: ev,
48    offset: &quot;3 -3&quot;,
49    collision: &quot;fit&quot;
50  });
51});
52
53</pre>
54<p></div><div id="source" class="tabs-container">
55</p>
56<pre>&lt;!DOCTYPE html&gt;
57&lt;html&gt;
58&lt;head&gt;
59  &lt;link href=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;/&gt;
60  &lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js&quot;&gt;&lt;/script&gt;
61  &lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js&quot;&gt;&lt;/script&gt;
62  &lt;style type=&quot;text/css&quot;&gt;
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&lt;/style&gt;
70
71  &lt;script&gt;
72  $(document).ready(function() {
73   
74$(&quot;#position1&quot;).position({
75  my: &quot;center&quot;,
76  at: &quot;center&quot;,
77  of: &quot;#targetElement&quot;
78});
79$(&quot;#position2&quot;).position({
80  my: &quot;left top&quot;,
81  at: &quot;left top&quot;,
82  of: &quot;#targetElement&quot;
83});
84$(&quot;#position3&quot;).position({
85  my: &quot;right center&quot;,
86  at: &quot;right bottom&quot;,
87  of: &quot;#targetElement&quot;
88});
89$(document).mousemove(function(ev){
90  $(&quot;#position4&quot;).position({
91    my: &quot;left bottom&quot;,
92    of: ev,
93    offset: &quot;3 -3&quot;,
94    collision: &quot;fit&quot;
95  });
96});
97
98  });
99  &lt;/script&gt;
100&lt;/head&gt;
101&lt;body style="font-size:62.5%;"&gt;
102 
103&lt;div id=&quot;targetElement&quot;&gt;
104  &lt;div class=&quot;positionDiv&quot; id=&quot;position1&quot;&gt;&lt;/div&gt;
105  &lt;div class=&quot;positionDiv&quot; id=&quot;position2&quot;&gt;&lt;/div&gt;
106  &lt;div class=&quot;positionDiv&quot; id=&quot;position3&quot;&gt;&lt;/div&gt;
107  &lt;div class=&quot;positionDiv&quot; id=&quot;position4&quot;&gt;&lt;/div&gt;
108&lt;/div&gt;
109
110&lt;/body&gt;
111&lt;/html&gt;
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><!--
221Pre-expand include size: 7124 bytes
222Post-expand include size: 11012 bytes
223Template argument size: 7642 bytes
224Maximum: 2097152 bytes
225-->
226
227<!-- Saved in parser cache with key jqdocs_docs:pcache:idhash:3784-1!1!0!!en!2 and timestamp 20111201164650 -->
Note: See TracBrowser for help on using the repository browser.