1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
<!doctype html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Slider Gallery</title>
<style type="text/css" media="screen">
<!--
body {
padding: 0;
font: 1em "Trebuchet MS", verdana, arial, sans-serif;
font-size: 100%;
background-color: #212121;
margin: 0;
}
h1 {
margin-bottom: 2px;
}
#container {
background-color: #fff;
width: 580px;
margin: 15px auto;
padding: 50px;
}
/* slider specific CSS */
.sliderGallery {
background: url(images/productbrowser_background_20070622.jpg) no-repeat;
overflow: hidden;
position: relative;
padding: 10px;
height: 160px;
width: 560px;
}
.sliderGallery UL {
position: absolute;
list-style: none;
overflow: none;
white-space: nowrap;
padding: 0;
margin: 0;
}
.sliderGallery UL LI {
display: inline;
}
.slider {
width: 542px;
height: 17px;
margin-top: 140px;
margin-left: 5px;
padding: 1px;
position: absolute;
background: url(images/productbrowser_scrollbar_20070622.png) no-repeat;
}
.handle {
position: absolute;
cursor: move;
height: 17px;
width: 181px;
top: 0;
background: url(images/productbrowser_scroller_20080115.png) no-repeat;
z-index: 100;
}
.slider span {
color: #bbb;
font-size: 80%;
cursor: pointer;
position: absolute;
z-index: 110;
top: 3px;
}
.slider .slider-lbl1 {
left: 50px;
}
.slider .slider-lbl2 {
left: 107px;
}
.slider .slider-lbl3 {
left: 156px;
}
.slider .slider-lbl4 {
left: 280px;
}
.slider .slider-lbl5 {
left: 455px;
}
-->
</style>
<script type="text/javascript" src="../../../jquery-1.2.6.js"></script>
<script type="text/javascript" src="../../../ui/ui.core.js"></script>
<script type="text/javascript" src="../../../ui/ui.slider.js"></script>
<script type="text/javascript" charset="utf-8">
/**
* Note that we have to use window.onload because $(document).ready() fires before images are loaded
* and ul.innerWidth() - container.outerWidth(); doesn't give the correct width because the width
* of the UL hasn't expanded out until the images have finished rendering.
*/
window.onload = function () {
var container = $('div.sliderGallery');
var ul = $('ul', container);
var itemsWidth = ul.innerWidth() - container.outerWidth();
$('.slider', container).slider({
min: 0,
max: itemsWidth,
handle: '.handle',
stop: function (event, ui) {
ul.animate({'left' : ui.value * -1}, 500);
},
slide: function (event, ui) {
ul.css('left', ui.value * -1);
}
});
};
</script>
</head>
<body>
<div id="container">
<h1>Slider Gallery</h1>
<p>This shows a demonstration of a slider widget from the jQuery UI library used to create the same effect used on <a href="http://www.apple.com/mac/">Apple's web site</a>.</p>
<p><a href="http://jqueryfordesigners.com/slider-gallery">Read the article, and see the screencast this demonstration relates to</a></p>
<div class="sliderGallery">
<ul>
<li><img class="pb-airportexpress" src="images/pb_airport_express.jpg" /></li>
<li><img src="images/pb_airport_extreme.jpg" /></li>
<li><img src="images/pb_timecapsule_20080115.jpg" /></li>
<li><img src="images/pb_keyboards20070807.jpg" /></li>
<li><img src="images/pb_mighty_mouse.jpg" /></li>
<li><img src="images/pb_cinema_display20071026.jpg" /></li>
<li><img src="images/pb_mac_pro_20070622.jpg" /></li>
<li><img class="pb-macmini" src="images/pb_mac_mini.jpg" /></li>
<li><img src="images/pb_macbook20071026.jpg" /></li>
<li><img class="pb-macbookair" src="images/pb_macbookair_20080115.jpg" /></li>
<li><img class="pb-macbookpro" src="images/pb_macbook_pro20071026.jpg" /></li>
<li><img class="pb-imac" src="images/pb_imac20071026.jpg" /></li>
<li><img src="images/pb_macosx_20080115.jpg" /></li>
<li><img src="images/pb_ilife_20080115.jpg" /></li>
<li><img src="images/pb_dot_mac_20080115.jpg" /></li>
<li><img src="images/pb_iwork_20080115.jpg" /></li>
<li><img src="images/pb_quicktime.jpg" /></li>
<li><img src="images/pb_aperture20080212.jpg" /></li>
<li><img src="images/pb_final_cut_studio2_20080115.jpg" /></li>
<li><img src="images/pb_final_cut_express_20080115.jpg" /></li>
<li><img src="images/pb_logic_studio_20080115.jpg" /></li>
<li><img src="images/pb_logic_express_20080115.jpg" /></li>
<li><img src="images/pb_shake_20080115.jpg" /></li>
<li><img src="images/pb_apple_remote_desktop_20080115.jpg" /></li>
<li><img src="images/pb_xserve.jpg" /></li>
<li><img src="images/pb_xserve_raid.jpg" /></li>
<li><img class="pb-xsan" src="images/pb_xsan_20080115.jpg" /></li>
<li><img class="pb-macosxserver" src="images/pb_macosx_server20071016.jpg" /></li>
</ul>
<div class="slider">
<div class="handle"></div>
<span class="slider-lbl1">Wi-Fi</span>
<span class="slider-lbl3">Macs</span>
<span class="slider-lbl4">Applications</span>
<span class="slider-lbl5">Servers</span>
</div>
</div>
</div>
</body>
</html>
|