source: main/trunk/greenstone3/web/interfaces/oran/js/jquery-ui-1.8rc1/demos/position/cycler.html@ 24245

Last change on this file since 24245 was 24245, checked in by sjb48, 13 years ago

Oran code for supporting format changes to document.

  • Property svn:executable set to *
File size: 3.0 KB
Line 
1<!doctype html>
2<html lang="en">
3<head>
4 <title>jQuery UI Position - Default functionality</title>
5 <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
6 <script type="text/javascript" src="../../jquery-1.4.1.js"></script>
7 <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
8 <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
9 <script type="text/javascript" src="../../ui/jquery.ui.position.js"></script>
10 <link type="text/css" href="../demos.css" rel="stylesheet" />
11
12 <style type="text/css">
13 html, body {
14 margin: 0;
15 padding: 0
16 }
17 </style>
18
19 <script type="text/javascript">
20 $(function() {
21
22 $.fn.position2 = function(options) {
23 return this.position($.extend({
24 of: window,
25 using: function(to) {
26 $(this).css({
27 top: to.top,
28 left: to.left
29 })
30 },
31 collision: "none"
32 }, options));
33 }
34
35 $.fn.left = function(using) {
36 return this.position2({
37 my: "right middle",
38 at: "left middle",
39 offset: "25 0",
40 using: using
41 });
42 }
43 $.fn.right = function(using) {
44 return this.position2({
45 my: "left middle",
46 at: "right middle",
47 offset: "-25 0",
48 using: using
49 });
50 }
51 $.fn.center = function(using) {
52 return this.position2({
53 my: "center middle",
54 at: "center middle",
55 using: using
56 });
57 };
58
59 $("img:eq(0)").left();
60 $("img:eq(1)").center();
61 $("img:eq(2)").right();
62
63 $("body").css({
64 overflow: "hidden"
65 })
66 $(".demo").css({
67 position: "relative",
68 });
69 $(".demo img").css({
70 position: "absolute",
71 });
72
73 function animate(to) {
74 $(this).animate(to);
75 }
76 function next() {
77 $("img:eq(2)").center(animate);
78 $("img:eq(1)").left(animate)
79 $("img:eq(0)").right().appendTo(".demo");
80 }
81 function previous() {
82 $("img:eq(0)").center(animate);
83 $("img:eq(1)").right(animate);
84 $("img:eq(2)").left().prependTo(".demo");
85 }
86 $("#previous").click(previous);
87 $("#next").click(next);
88
89 $(".demo img").click(function() {
90 $(".demo img").index(this) == 0 ? previous() : next();
91 });
92
93 $(window).resize(function() {
94 $("img:eq(0)").left(animate);
95 $("img:eq(1)").center(animate);
96 $("img:eq(2)").right(animate);
97 })
98 });
99 </script>
100
101</head>
102<body>
103
104<div class="demo">
105
106 <img src="images/earth.jpg" />
107 <img src="images/flight.jpg" />
108 <img src="images/rocket.jpg" />
109
110 <a id="previous" href="#">Previous</a>
111 <a id="next" href="#">Next</a>
112</div>
113
114<div class="demo-description">
115
116<p>A prototype for the <a href="http://wiki.jqueryui.com/Photoviewer">Photoviewer</a> using Position to place images at the center, left and right and cycle them.
117<br/>Use the links at the top to cycle, or click on the images on the left and right.
118<br/>Note how the images are repositioned when resizing the window.
119<br/>Warning: Doesn't currently work inside the demo viewer; open in a new window instead!</p>
120
121</div><!-- End demo-description -->
122
123</body>
124</html>
Note: See TracBrowser for help on using the repository browser.