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