Index: trunk/extensions/SemanticForms/skins/jquery.fancybox.css |
— | — | @@ -5,8 +5,9 @@ |
6 | 6 | * Examples and documentation at: http://fancybox.net |
7 | 7 | * |
8 | 8 | * Copyright (c) 2008 - 2010 Janis Skarnelis |
9 | | - * |
10 | | - * Version: 1.3.1 (05/03/2010) |
| 9 | + * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated. |
| 10 | + * |
| 11 | + * Version: 1.3.4 (11/11/2010) |
11 | 12 | * Requires: jQuery v1.3+ |
12 | 13 | * |
13 | 14 | * Dual licensed under the MIT and GPL licenses: |
— | — | @@ -18,8 +19,8 @@ |
19 | 20 | position: fixed; |
20 | 21 | top: 50%; |
21 | 22 | left: 50%; |
22 | | - height: 40px; |
23 | 23 | width: 40px; |
| 24 | + height: 40px; |
24 | 25 | margin-top: -20px; |
25 | 26 | margin-left: -20px; |
26 | 27 | cursor: pointer; |
— | — | @@ -28,11 +29,6 @@ |
29 | 30 | display: none; |
30 | 31 | } |
31 | 32 | |
32 | | -* html #fancybox-loading { /* IE6 */ |
33 | | - position: absolute; |
34 | | - margin-top: 0; |
35 | | -} |
36 | | - |
37 | 33 | #fancybox-loading div { |
38 | 34 | position: absolute; |
39 | 35 | top: 0; |
— | — | @@ -43,21 +39,14 @@ |
44 | 40 | } |
45 | 41 | |
46 | 42 | #fancybox-overlay { |
47 | | - position: fixed; |
| 43 | + position: absolute; |
48 | 44 | top: 0; |
49 | 45 | left: 0; |
50 | | - bottom: 0; |
51 | | - right: 0; |
52 | | - background: #000; |
| 46 | + width: 100%; |
53 | 47 | z-index: 1100; |
54 | 48 | display: none; |
55 | 49 | } |
56 | 50 | |
57 | | -* html #fancybox-overlay { /* IE6 */ |
58 | | - position: absolute; |
59 | | - width: 100%; |
60 | | -} |
61 | | - |
62 | 51 | #fancybox-tmp { |
63 | 52 | padding: 0; |
64 | 53 | margin: 0; |
— | — | @@ -70,9 +59,9 @@ |
71 | 60 | position: absolute; |
72 | 61 | top: 0; |
73 | 62 | left: 0; |
74 | | - margin: 0; |
75 | 63 | padding: 20px; |
76 | 64 | z-index: 1101; |
| 65 | + outline: none; |
77 | 66 | display: none; |
78 | 67 | } |
79 | 68 | |
— | — | @@ -80,19 +69,18 @@ |
81 | 70 | position: relative; |
82 | 71 | width: 100%; |
83 | 72 | height: 100%; |
84 | | - background: #FFF; |
| 73 | + background: #fff; |
85 | 74 | } |
86 | 75 | |
87 | | -#fancybox-inner { |
88 | | - position: absolute; |
89 | | - top: 0; |
90 | | - left: 0; |
91 | | - width: 1px; |
92 | | - height: 1px; |
| 76 | +#fancybox-content { |
| 77 | + width: 0; |
| 78 | + height: 0; |
93 | 79 | padding: 0; |
94 | | - margin: 0; |
95 | 80 | outline: none; |
| 81 | + position: relative; |
96 | 82 | overflow: hidden; |
| 83 | + z-index: 1102; |
| 84 | + border: 0px solid #fff; |
97 | 85 | } |
98 | 86 | |
99 | 87 | #fancybox-hide-sel-frame { |
— | — | @@ -102,35 +90,28 @@ |
103 | 91 | width: 100%; |
104 | 92 | height: 100%; |
105 | 93 | background: transparent; |
| 94 | + z-index: 1101; |
106 | 95 | } |
107 | 96 | |
108 | 97 | #fancybox-close { |
109 | 98 | position: absolute; |
110 | 99 | top: -15px; |
111 | 100 | right: -15px; |
112 | | - width: 27px; |
| 101 | + width: 30px; |
113 | 102 | height: 30px; |
114 | | - background-image: url('../skins/fancy_close.png'); |
115 | | - background-position: -34px 0px; |
| 103 | + background: transparent url('fancybox.png') -40px 0px; |
116 | 104 | cursor: pointer; |
117 | 105 | z-index: 1103; |
118 | 106 | display: none; |
119 | 107 | } |
120 | 108 | |
121 | | -#fancybox_error { |
| 109 | +#fancybox-error { |
122 | 110 | color: #444; |
123 | 111 | font: normal 12px/20px Arial; |
124 | | - padding: 7px; |
| 112 | + padding: 14px; |
125 | 113 | margin: 0; |
126 | 114 | } |
127 | 115 | |
128 | | -#fancybox-content { |
129 | | - height: auto; |
130 | | - width: auto; |
131 | | - padding: 0; |
132 | | - margin: 0; |
133 | | -} |
134 | | - |
135 | 116 | #fancybox-img { |
136 | 117 | width: 100%; |
137 | 118 | height: 100%; |
— | — | @@ -140,81 +121,15 @@ |
141 | 122 | outline: none; |
142 | 123 | line-height: 0; |
143 | 124 | vertical-align: top; |
144 | | - -ms-interpolation-mode: bicubic; |
145 | 125 | } |
146 | 126 | |
147 | 127 | #fancybox-frame { |
148 | | - position: relative; |
149 | 128 | width: 100%; |
150 | 129 | height: 100%; |
151 | 130 | border: none; |
152 | 131 | display: block; |
153 | 132 | } |
154 | 133 | |
155 | | -#fancybox-title { |
156 | | - position: absolute; |
157 | | - bottom: 0; |
158 | | - left: 0; |
159 | | - font-family: Arial; |
160 | | - font-size: 12px; |
161 | | - z-index: 1102; |
162 | | -} |
163 | | - |
164 | | -.fancybox-title-inside { |
165 | | - padding: 10px 0; |
166 | | - text-align: center; |
167 | | - color: #333; |
168 | | -} |
169 | | - |
170 | | -.fancybox-title-outside { |
171 | | - padding-top: 5px; |
172 | | - color: #FFF; |
173 | | - text-align: center; |
174 | | - font-weight: bold; |
175 | | -} |
176 | | - |
177 | | -.fancybox-title-over { |
178 | | - color: #FFF; |
179 | | - text-align: left; |
180 | | -} |
181 | | - |
182 | | -#fancybox-title-over { |
183 | | - padding: 10px; |
184 | | - background-image: url('fancy_title_over.png'); |
185 | | - display: block; |
186 | | -} |
187 | | - |
188 | | -#fancybox-title-wrap { |
189 | | - display: inline-block; |
190 | | -} |
191 | | - |
192 | | -#fancybox-title-wrap span { |
193 | | - height: 32px; |
194 | | - float: left; |
195 | | -} |
196 | | - |
197 | | -#fancybox-title-left { |
198 | | - padding-left: 15px; |
199 | | - background-image: url('fancybox.png'); |
200 | | - background-position: -40px -90px; |
201 | | - background-repeat: no-repeat; |
202 | | -} |
203 | | - |
204 | | -#fancybox-title-main { |
205 | | - font-weight: bold; |
206 | | - line-height: 29px; |
207 | | - background-image: url('fancybox-x.png'); |
208 | | - background-position: 0px -40px; |
209 | | - color: #FFF; |
210 | | -} |
211 | | - |
212 | | -#fancybox-title-right { |
213 | | - padding-left: 15px; |
214 | | - background-image: url('fancybox.png'); |
215 | | - background-position: -55px -90px; |
216 | | - background-repeat: no-repeat; |
217 | | -} |
218 | | - |
219 | 134 | #fancybox-left, #fancybox-right { |
220 | 135 | position: absolute; |
221 | 136 | bottom: 0px; |
— | — | @@ -222,7 +137,7 @@ |
223 | 138 | width: 35%; |
224 | 139 | cursor: pointer; |
225 | 140 | outline: none; |
226 | | - background-image: url('blank.gif'); |
| 141 | + background: transparent url('blank.gif'); |
227 | 142 | z-index: 1102; |
228 | 143 | display: none; |
229 | 144 | } |
— | — | @@ -258,7 +173,7 @@ |
259 | 174 | } |
260 | 175 | |
261 | 176 | #fancybox-left:hover, #fancybox-right:hover { |
262 | | - visibility: visible; /* IE6 */ |
| 177 | + visibility: visible; /* IE6 */ |
263 | 178 | } |
264 | 179 | |
265 | 180 | #fancybox-left:hover span { |
— | — | @@ -270,7 +185,7 @@ |
271 | 186 | right: 20px; |
272 | 187 | } |
273 | 188 | |
274 | | -.fancy-bg { |
| 189 | +.fancybox-bg { |
275 | 190 | position: absolute; |
276 | 191 | padding: 0; |
277 | 192 | margin: 0; |
— | — | @@ -280,21 +195,21 @@ |
281 | 196 | z-index: 1001; |
282 | 197 | } |
283 | 198 | |
284 | | -#fancy-bg-n { |
| 199 | +#fancybox-bg-n { |
285 | 200 | top: -20px; |
286 | 201 | left: 0; |
287 | 202 | width: 100%; |
288 | 203 | background-image: url('fancybox-x.png'); |
289 | 204 | } |
290 | 205 | |
291 | | -#fancy-bg-ne { |
| 206 | +#fancybox-bg-ne { |
292 | 207 | top: -20px; |
293 | 208 | right: -20px; |
294 | 209 | background-image: url('fancybox.png'); |
295 | 210 | background-position: -40px -162px; |
296 | 211 | } |
297 | 212 | |
298 | | -#fancy-bg-e { |
| 213 | +#fancybox-bg-e { |
299 | 214 | top: 0; |
300 | 215 | right: -20px; |
301 | 216 | height: 100%; |
— | — | @@ -302,14 +217,14 @@ |
303 | 218 | background-position: -20px 0px; |
304 | 219 | } |
305 | 220 | |
306 | | -#fancy-bg-se { |
| 221 | +#fancybox-bg-se { |
307 | 222 | bottom: -20px; |
308 | 223 | right: -20px; |
309 | 224 | background-image: url('fancybox.png'); |
310 | 225 | background-position: -40px -182px; |
311 | 226 | } |
312 | 227 | |
313 | | -#fancy-bg-s { |
| 228 | +#fancybox-bg-s { |
314 | 229 | bottom: -20px; |
315 | 230 | left: 0; |
316 | 231 | width: 100%; |
— | — | @@ -317,47 +232,128 @@ |
318 | 233 | background-position: 0px -20px; |
319 | 234 | } |
320 | 235 | |
321 | | -#fancy-bg-sw { |
| 236 | +#fancybox-bg-sw { |
322 | 237 | bottom: -20px; |
323 | 238 | left: -20px; |
324 | 239 | background-image: url('fancybox.png'); |
325 | 240 | background-position: -40px -142px; |
326 | 241 | } |
327 | 242 | |
328 | | -#fancy-bg-w { |
| 243 | +#fancybox-bg-w { |
329 | 244 | top: 0; |
330 | 245 | left: -20px; |
331 | 246 | height: 100%; |
332 | 247 | background-image: url('fancybox-y.png'); |
333 | 248 | } |
334 | 249 | |
335 | | -#fancy-bg-nw { |
| 250 | +#fancybox-bg-nw { |
336 | 251 | top: -20px; |
337 | 252 | left: -20px; |
338 | 253 | background-image: url('fancybox.png'); |
339 | 254 | background-position: -40px -122px; |
340 | 255 | } |
341 | 256 | |
342 | | -/* IE */ |
| 257 | +#fancybox-title { |
| 258 | + font-family: Helvetica; |
| 259 | + font-size: 12px; |
| 260 | + z-index: 1102; |
| 261 | +} |
343 | 262 | |
344 | | -#fancybox-loading.fancybox-ie div { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/loading.gif', sizingMethod='scale'); } |
345 | | -.fancybox-ie #fancybox-close { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancy_close.png', sizingMethod='scale'); } |
| 263 | +.fancybox-title-inside { |
| 264 | + padding-bottom: 10px; |
| 265 | + text-align: center; |
| 266 | + color: #333; |
| 267 | + background: #fff; |
| 268 | + position: relative; |
| 269 | +} |
346 | 270 | |
347 | | -.fancybox-ie #fancybox-title-over { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_title_over.png', sizingMethod='scale'); zoom: 1; } |
348 | | -.fancybox-ie #fancybox-title-left { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_title_left.png', sizingMethod='scale'); } |
349 | | -.fancybox-ie #fancybox-title-main { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_title_main.png', sizingMethod='scale'); } |
350 | | -.fancybox-ie #fancybox-title-right { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_title_right.png', sizingMethod='scale'); } |
| 271 | +.fancybox-title-outside { |
| 272 | + padding-top: 10px; |
| 273 | + color: #fff; |
| 274 | +} |
351 | 275 | |
352 | | -.fancybox-ie #fancybox-left-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_nav_left.png', sizingMethod='scale'); } |
353 | | -.fancybox-ie #fancybox-right-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_nav_right.png', sizingMethod='scale'); } |
| 276 | +.fancybox-title-over { |
| 277 | + position: absolute; |
| 278 | + bottom: 0; |
| 279 | + left: 0; |
| 280 | + color: #FFF; |
| 281 | + text-align: left; |
| 282 | +} |
354 | 283 | |
355 | | -.fancybox-ie .fancy-bg { background: transparent !important; } |
| 284 | +#fancybox-title-over { |
| 285 | + padding: 10px; |
| 286 | + background-image: url('fancy_title_over.png'); |
| 287 | + display: block; |
| 288 | +} |
356 | 289 | |
357 | | -.fancybox-ie #fancy-bg-n { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_shadow_n.png', sizingMethod='scale'); } |
358 | | -.fancybox-ie #fancy-bg-ne { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_shadow_ne.png', sizingMethod='scale'); } |
359 | | -.fancybox-ie #fancy-bg-e { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_shadow_e.png', sizingMethod='scale'); } |
360 | | -.fancybox-ie #fancy-bg-se { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_shadow_se.png', sizingMethod='scale'); } |
361 | | -.fancybox-ie #fancy-bg-s { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_shadow_s.png', sizingMethod='scale'); } |
362 | | -.fancybox-ie #fancy-bg-sw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_shadow_sw.png', sizingMethod='scale'); } |
363 | | -.fancybox-ie #fancy-bg-w { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_shadow_w.png', sizingMethod='scale'); } |
364 | | -.fancybox-ie #fancy-bg-nw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='../skins/fancybox/fancy_shadow_nw.png', sizingMethod='scale'); } |
| 290 | +.fancybox-title-float { |
| 291 | + position: absolute; |
| 292 | + left: 0; |
| 293 | + bottom: -20px; |
| 294 | + height: 32px; |
| 295 | +} |
| 296 | + |
| 297 | +#fancybox-title-float-wrap { |
| 298 | + border: none; |
| 299 | + border-collapse: collapse; |
| 300 | + width: auto; |
| 301 | +} |
| 302 | + |
| 303 | +#fancybox-title-float-wrap td { |
| 304 | + border: none; |
| 305 | + white-space: nowrap; |
| 306 | +} |
| 307 | + |
| 308 | +#fancybox-title-float-left { |
| 309 | + padding: 0 0 0 15px; |
| 310 | + background: url('fancybox.png') -40px -90px no-repeat; |
| 311 | +} |
| 312 | + |
| 313 | +#fancybox-title-float-main { |
| 314 | + color: #FFF; |
| 315 | + line-height: 29px; |
| 316 | + font-weight: bold; |
| 317 | + padding: 0 0 3px 0; |
| 318 | + background: url('fancybox-x.png') 0px -40px; |
| 319 | +} |
| 320 | + |
| 321 | +#fancybox-title-float-right { |
| 322 | + padding: 0 0 0 15px; |
| 323 | + background: url('fancybox.png') -55px -90px no-repeat; |
| 324 | +} |
| 325 | + |
| 326 | +/* IE6 */ |
| 327 | + |
| 328 | +.fancybox-ie6 #fancybox-close { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_close.png', sizingMethod='scale'); } |
| 329 | + |
| 330 | +.fancybox-ie6 #fancybox-left-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_nav_left.png', sizingMethod='scale'); } |
| 331 | +.fancybox-ie6 #fancybox-right-ico { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_nav_right.png', sizingMethod='scale'); } |
| 332 | + |
| 333 | +.fancybox-ie6 #fancybox-title-over { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_over.png', sizingMethod='scale'); zoom: 1; } |
| 334 | +.fancybox-ie6 #fancybox-title-float-left { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_left.png', sizingMethod='scale'); } |
| 335 | +.fancybox-ie6 #fancybox-title-float-main { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_main.png', sizingMethod='scale'); } |
| 336 | +.fancybox-ie6 #fancybox-title-float-right { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_title_right.png', sizingMethod='scale'); } |
| 337 | + |
| 338 | +.fancybox-ie6 #fancybox-bg-w, .fancybox-ie6 #fancybox-bg-e, .fancybox-ie6 #fancybox-left, .fancybox-ie6 #fancybox-right, #fancybox-hide-sel-frame { |
| 339 | + height: expression(this.parentNode.clientHeight + "px"); |
| 340 | +} |
| 341 | + |
| 342 | +#fancybox-loading.fancybox-ie6 { |
| 343 | + position: absolute; margin-top: 0; |
| 344 | + top: expression( (-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'); |
| 345 | +} |
| 346 | + |
| 347 | +#fancybox-loading.fancybox-ie6 div { background: transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_loading.png', sizingMethod='scale'); } |
| 348 | + |
| 349 | +/* IE6, IE7, IE8 */ |
| 350 | + |
| 351 | +.fancybox-ie .fancybox-bg { background: transparent !important; } |
| 352 | + |
| 353 | +.fancybox-ie #fancybox-bg-n { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_n.png', sizingMethod='scale'); } |
| 354 | +.fancybox-ie #fancybox-bg-ne { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_ne.png', sizingMethod='scale'); } |
| 355 | +.fancybox-ie #fancybox-bg-e { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_e.png', sizingMethod='scale'); } |
| 356 | +.fancybox-ie #fancybox-bg-se { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_se.png', sizingMethod='scale'); } |
| 357 | +.fancybox-ie #fancybox-bg-s { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_s.png', sizingMethod='scale'); } |
| 358 | +.fancybox-ie #fancybox-bg-sw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_sw.png', sizingMethod='scale'); } |
| 359 | +.fancybox-ie #fancybox-bg-w { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_w.png', sizingMethod='scale'); } |
| 360 | +.fancybox-ie #fancybox-bg-nw { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='fancybox/fancy_shadow_nw.png', sizingMethod='scale'); } |
\ No newline at end of file |
Index: trunk/extensions/SemanticForms/libs/jquery.fancybox.js |
— | — | @@ -3,10 +3,11 @@ |
4 | 4 | * Simple and fancy lightbox alternative |
5 | 5 | * |
6 | 6 | * Examples and documentation at: http://fancybox.net |
7 | | - * |
| 7 | + * |
8 | 8 | * Copyright (c) 2008 - 2010 Janis Skarnelis |
| 9 | + * That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated. |
9 | 10 | * |
10 | | - * Version: 1.3.1 (05/03/2010) |
| 11 | + * Version: 1.3.4 (11/11/2010) |
11 | 12 | * Requires: jQuery v1.3+ |
12 | 13 | * |
13 | 14 | * Dual licensed under the MIT and GPL licenses: |
— | — | @@ -14,25 +15,24 @@ |
15 | 16 | * http://www.gnu.org/licenses/gpl.html |
16 | 17 | */ |
17 | 18 | |
18 | | -(function($) { |
| 19 | +;(function($) { |
| 20 | + var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right, |
19 | 21 | |
20 | | - var tmp, loading, overlay, wrap, outer, inner, close, nav_left, nav_right, |
21 | | - |
22 | 22 | selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [], |
23 | 23 | |
24 | 24 | ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i, |
25 | 25 | |
26 | 26 | loadingTimer, loadingFrame = 1, |
27 | 27 | |
28 | | - start_pos, final_pos, busy = false, shadow = 20, fx = $.extend($('<div/>')[0], { prop: 0 }), titleh = 0, |
| 28 | + titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }), |
29 | 29 | |
30 | | - isIE6 = !$.support.opacity && !window.XMLHttpRequest, |
| 30 | + isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest, |
31 | 31 | |
32 | 32 | /* |
33 | 33 | * Private methods |
34 | 34 | */ |
35 | 35 | |
36 | | - fancybox_abort = function() { |
| 36 | + _abort = function() { |
37 | 37 | loading.hide(); |
38 | 38 | |
39 | 39 | imgPreloader.onerror = imgPreloader.onload = null; |
— | — | @@ -44,402 +44,373 @@ |
45 | 45 | tmp.empty(); |
46 | 46 | }, |
47 | 47 | |
48 | | - fancybox_error = function() { |
49 | | - $.fancybox('<p id="fancybox_error">The requested content cannot be loaded.<br />Please try again later.</p>', { |
50 | | - 'scrolling' : 'no', |
51 | | - 'padding' : 20, |
52 | | - 'transitionIn' : 'none', |
53 | | - 'transitionOut' : 'none' |
54 | | - }); |
55 | | - }, |
| 48 | + _error = function() { |
| 49 | + if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) { |
| 50 | + loading.hide(); |
| 51 | + busy = false; |
| 52 | + return; |
| 53 | + } |
56 | 54 | |
57 | | - fancybox_get_viewport = function() { |
58 | | - return [ $(window).width(), $(window).height(), $(document).scrollLeft(), $(document).scrollTop() ]; |
| 55 | + selectedOpts.titleShow = false; |
| 56 | + |
| 57 | + selectedOpts.width = 'auto'; |
| 58 | + selectedOpts.height = 'auto'; |
| 59 | + |
| 60 | + tmp.html( '<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>' ); |
| 61 | + |
| 62 | + _process_inline(); |
59 | 63 | }, |
60 | 64 | |
61 | | - fancybox_get_zoom_to = function () { |
62 | | - var view = fancybox_get_viewport(), |
63 | | - to = {}, |
| 65 | + _start = function() { |
| 66 | + var obj = selectedArray[ selectedIndex ], |
| 67 | + href, |
| 68 | + type, |
| 69 | + title, |
| 70 | + str, |
| 71 | + emb, |
| 72 | + ret; |
64 | 73 | |
65 | | - margin = currentOpts.margin, |
66 | | - resize = currentOpts.autoScale, |
| 74 | + _abort(); |
67 | 75 | |
68 | | - horizontal_space = (shadow + margin) * 2, |
69 | | - vertical_space = (shadow + margin) * 2, |
70 | | - double_padding = (currentOpts.padding * 2), |
71 | | - |
72 | | - ratio; |
| 76 | + selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox'))); |
73 | 77 | |
74 | | - if (currentOpts.width.toString().indexOf('%') > -1) { |
75 | | - to.width = ((view[0] * parseFloat(currentOpts.width)) / 100) - (shadow * 2) ; |
76 | | - resize = false; |
| 78 | + ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts); |
77 | 79 | |
78 | | - } else { |
79 | | - to.width = currentOpts.width + double_padding; |
| 80 | + if (ret === false) { |
| 81 | + busy = false; |
| 82 | + return; |
| 83 | + } else if (typeof ret == 'object') { |
| 84 | + selectedOpts = $.extend(selectedOpts, ret); |
80 | 85 | } |
81 | 86 | |
82 | | - if (currentOpts.height.toString().indexOf('%') > -1) { |
83 | | - to.height = ((view[1] * parseFloat(currentOpts.height)) / 100) - (shadow * 2); |
84 | | - resize = false; |
| 87 | + title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || ''; |
85 | 88 | |
86 | | - } else { |
87 | | - to.height = currentOpts.height + double_padding; |
| 89 | + if (obj.nodeName && !selectedOpts.orig) { |
| 90 | + selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj); |
88 | 91 | } |
89 | 92 | |
90 | | - if (resize && (to.width > (view[0] - horizontal_space) || to.height > (view[1] - vertical_space))) { |
91 | | - if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') { |
92 | | - horizontal_space += double_padding; |
93 | | - vertical_space += double_padding; |
| 93 | + if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) { |
| 94 | + title = selectedOpts.orig.attr('alt'); |
| 95 | + } |
94 | 96 | |
95 | | - ratio = Math.min(Math.min( view[0] - horizontal_space, currentOpts.width) / currentOpts.width, Math.min( view[1] - vertical_space, currentOpts.height) / currentOpts.height); |
| 97 | + href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null; |
96 | 98 | |
97 | | - to.width = Math.round(ratio * (to.width - double_padding)) + double_padding; |
98 | | - to.height = Math.round(ratio * (to.height - double_padding)) + double_padding; |
| 99 | + if ((/^(?:javascript)/i).test(href) || href == '#') { |
| 100 | + href = null; |
| 101 | + } |
99 | 102 | |
100 | | - } else { |
101 | | - to.width = Math.min(to.width, (view[0] - horizontal_space)); |
102 | | - to.height = Math.min(to.height, (view[1] - vertical_space)); |
| 103 | + if (selectedOpts.type) { |
| 104 | + type = selectedOpts.type; |
| 105 | + |
| 106 | + if (!href) { |
| 107 | + href = selectedOpts.content; |
103 | 108 | } |
104 | | - } |
105 | 109 | |
106 | | - to.top = view[3] + ((view[1] - (to.height + (shadow * 2 ))) * 0.5); |
107 | | - to.left = view[2] + ((view[0] - (to.width + (shadow * 2 ))) * 0.5); |
| 110 | + } else if (selectedOpts.content) { |
| 111 | + type = 'html'; |
108 | 112 | |
109 | | - if (currentOpts.autoScale === false) { |
110 | | - to.top = Math.max(view[3] + margin, to.top); |
111 | | - to.left = Math.max(view[2] + margin, to.left); |
112 | | - } |
| 113 | + } else if (href) { |
| 114 | + if (href.match(imgRegExp)) { |
| 115 | + type = 'image'; |
113 | 116 | |
114 | | - return to; |
115 | | - }, |
| 117 | + } else if (href.match(swfRegExp)) { |
| 118 | + type = 'swf'; |
116 | 119 | |
117 | | - fancybox_format_title = function(title) { |
118 | | - if (title && title.length) { |
119 | | - switch (currentOpts.titlePosition) { |
120 | | - case 'inside': |
121 | | - return title; |
122 | | - case 'over': |
123 | | - return '<span id="fancybox-title-over">' + title + '</span>'; |
124 | | - default: |
125 | | - return '<span id="fancybox-title-wrap"><span id="fancybox-title-left"></span><span id="fancybox-title-main">' + title + '</span><span id="fancybox-title-right"></span></span>'; |
| 120 | + } else if ($(obj).hasClass("iframe")) { |
| 121 | + type = 'iframe'; |
| 122 | + |
| 123 | + } else if (href.indexOf("#") === 0) { |
| 124 | + type = 'inline'; |
| 125 | + |
| 126 | + } else { |
| 127 | + type = 'ajax'; |
126 | 128 | } |
127 | 129 | } |
128 | 130 | |
129 | | - return false; |
130 | | - }, |
| 131 | + if (!type) { |
| 132 | + _error(); |
| 133 | + return; |
| 134 | + } |
131 | 135 | |
132 | | - fancybox_process_title = function() { |
133 | | - var title = currentOpts.title, |
134 | | - width = final_pos.width - (currentOpts.padding * 2), |
135 | | - titlec = 'fancybox-title-' + currentOpts.titlePosition; |
136 | | - |
137 | | - $('#fancybox-title').remove(); |
| 136 | + if (type == 'inline') { |
| 137 | + obj = href.substr(href.indexOf("#")); |
| 138 | + type = $(obj).length > 0 ? 'inline' : 'ajax'; |
| 139 | + } |
138 | 140 | |
139 | | - titleh = 0; |
| 141 | + selectedOpts.type = type; |
| 142 | + selectedOpts.href = href; |
| 143 | + selectedOpts.title = title; |
140 | 144 | |
141 | | - if (currentOpts.titleShow === false) { |
142 | | - return; |
| 145 | + if (selectedOpts.autoDimensions) { |
| 146 | + if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') { |
| 147 | + selectedOpts.width = 'auto'; |
| 148 | + selectedOpts.height = 'auto'; |
| 149 | + } else { |
| 150 | + selectedOpts.autoDimensions = false; |
| 151 | + } |
143 | 152 | } |
144 | 153 | |
145 | | - title = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(title, currentArray, currentIndex, currentOpts) : fancybox_format_title(title); |
146 | | - |
147 | | - if (!title || title === '') { |
148 | | - return; |
| 154 | + if (selectedOpts.modal) { |
| 155 | + selectedOpts.overlayShow = true; |
| 156 | + selectedOpts.hideOnOverlayClick = false; |
| 157 | + selectedOpts.hideOnContentClick = false; |
| 158 | + selectedOpts.enableEscapeButton = false; |
| 159 | + selectedOpts.showCloseButton = false; |
149 | 160 | } |
150 | 161 | |
151 | | - $('<div id="fancybox-title" class="' + titlec + '" />').css({ |
152 | | - 'width' : width, |
153 | | - 'paddingLeft' : currentOpts.padding, |
154 | | - 'paddingRight' : currentOpts.padding |
155 | | - }).html(title).appendTo('body'); |
| 162 | + selectedOpts.padding = parseInt(selectedOpts.padding, 10); |
| 163 | + selectedOpts.margin = parseInt(selectedOpts.margin, 10); |
156 | 164 | |
157 | | - switch (currentOpts.titlePosition) { |
158 | | - case 'inside': |
159 | | - titleh = $("#fancybox-title").outerHeight(true) - currentOpts.padding; |
160 | | - final_pos.height += titleh; |
161 | | - break; |
| 165 | + tmp.css('padding', (selectedOpts.padding + selectedOpts.margin)); |
162 | 166 | |
163 | | - case 'over': |
164 | | - $('#fancybox-title').css('bottom', currentOpts.padding); |
165 | | - break; |
| 167 | + $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() { |
| 168 | + $(this).replaceWith(content.children()); |
| 169 | + }); |
166 | 170 | |
167 | | - default: |
168 | | - $('#fancybox-title').css('bottom', $("#fancybox-title").outerHeight(true) * -1); |
| 171 | + switch (type) { |
| 172 | + case 'html' : |
| 173 | + tmp.html( selectedOpts.content ); |
| 174 | + _process_inline(); |
169 | 175 | break; |
170 | | - } |
171 | 176 | |
172 | | - $('#fancybox-title').appendTo( outer ).hide(); |
173 | | - }, |
| 177 | + case 'inline' : |
| 178 | + if ( $(obj).parent().is('#fancybox-content') === true) { |
| 179 | + busy = false; |
| 180 | + return; |
| 181 | + } |
174 | 182 | |
175 | | - fancybox_set_navigation = function() { |
176 | | - $(document).unbind('keydown.fb').bind('keydown.fb', function(e) { |
177 | | - if (e.keyCode == 27 && currentOpts.enableEscapeButton) { |
178 | | - e.preventDefault(); |
179 | | - $.fancybox.close(); |
| 183 | + $('<div class="fancybox-inline-tmp" />') |
| 184 | + .hide() |
| 185 | + .insertBefore( $(obj) ) |
| 186 | + .bind('fancybox-cleanup', function() { |
| 187 | + $(this).replaceWith(content.children()); |
| 188 | + }).bind('fancybox-cancel', function() { |
| 189 | + $(this).replaceWith(tmp.children()); |
| 190 | + }); |
180 | 191 | |
181 | | - } else if (e.keyCode == 37) { |
182 | | - e.preventDefault(); |
183 | | - $.fancybox.prev(); |
| 192 | + $(obj).appendTo(tmp); |
184 | 193 | |
185 | | - } else if (e.keyCode == 39) { |
186 | | - e.preventDefault(); |
187 | | - $.fancybox.next(); |
188 | | - } |
189 | | - }); |
| 194 | + _process_inline(); |
| 195 | + break; |
190 | 196 | |
191 | | - if ($.fn.mousewheel) { |
192 | | - wrap.unbind('mousewheel.fb'); |
| 197 | + case 'image': |
| 198 | + busy = false; |
193 | 199 | |
194 | | - if (currentArray.length > 1) { |
195 | | - wrap.bind('mousewheel.fb', function(e, delta) { |
196 | | - e.preventDefault(); |
| 200 | + $.fancybox.showActivity(); |
197 | 201 | |
198 | | - if (busy || delta === 0) { |
199 | | - return; |
200 | | - } |
| 202 | + imgPreloader = new Image(); |
201 | 203 | |
202 | | - if (delta > 0) { |
203 | | - $.fancybox.prev(); |
204 | | - } else { |
205 | | - $.fancybox.next(); |
206 | | - } |
207 | | - }); |
208 | | - } |
209 | | - } |
| 204 | + imgPreloader.onerror = function() { |
| 205 | + _error(); |
| 206 | + }; |
210 | 207 | |
211 | | - if (!currentOpts.showNavArrows) { return; } |
| 208 | + imgPreloader.onload = function() { |
| 209 | + busy = true; |
212 | 210 | |
213 | | - if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) { |
214 | | - nav_left.show(); |
215 | | - } |
| 211 | + imgPreloader.onerror = imgPreloader.onload = null; |
216 | 212 | |
217 | | - if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) { |
218 | | - nav_right.show(); |
219 | | - } |
220 | | - }, |
| 213 | + _process_image(); |
| 214 | + }; |
221 | 215 | |
222 | | - fancybox_preload_images = function() { |
223 | | - var href, |
224 | | - objNext; |
225 | | - |
226 | | - if ((currentArray.length -1) > currentIndex) { |
227 | | - href = currentArray[ currentIndex + 1 ].href; |
| 216 | + imgPreloader.src = href; |
| 217 | + break; |
228 | 218 | |
229 | | - if (typeof href !== 'undefined' && href.match(imgRegExp)) { |
230 | | - objNext = new Image(); |
231 | | - objNext.src = href; |
232 | | - } |
233 | | - } |
| 219 | + case 'swf': |
| 220 | + selectedOpts.scrolling = 'no'; |
234 | 221 | |
235 | | - if (currentIndex > 0) { |
236 | | - href = currentArray[ currentIndex - 1 ].href; |
| 222 | + str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>'; |
| 223 | + emb = ''; |
237 | 224 | |
238 | | - if (typeof href !== 'undefined' && href.match(imgRegExp)) { |
239 | | - objNext = new Image(); |
240 | | - objNext.src = href; |
241 | | - } |
242 | | - } |
243 | | - }, |
| 225 | + $.each(selectedOpts.swf, function(name, val) { |
| 226 | + str += '<param name="' + name + '" value="' + val + '"></param>'; |
| 227 | + emb += ' ' + name + '="' + val + '"'; |
| 228 | + }); |
244 | 229 | |
245 | | - _finish = function () { |
246 | | - inner.css('overflow', (currentOpts.scrolling == 'auto' ? (currentOpts.type == 'image' || currentOpts.type == 'iframe' || currentOpts.type == 'swf' ? 'hidden' : 'auto') : (currentOpts.scrolling == 'yes' ? 'auto' : 'visible'))); |
| 230 | + str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>'; |
247 | 231 | |
248 | | - if (!$.support.opacity) { |
249 | | - inner.get(0).style.removeAttribute('filter'); |
250 | | - wrap.get(0).style.removeAttribute('filter'); |
251 | | - } |
| 232 | + tmp.html(str); |
252 | 233 | |
253 | | - $('#fancybox-title').show(); |
| 234 | + _process_inline(); |
| 235 | + break; |
254 | 236 | |
255 | | - if (currentOpts.hideOnContentClick) { |
256 | | - inner.one('click', $.fancybox.close); |
257 | | - } |
258 | | - if (currentOpts.hideOnOverlayClick) { |
259 | | - overlay.one('click', $.fancybox.close); |
260 | | - } |
| 237 | + case 'ajax': |
| 238 | + busy = false; |
261 | 239 | |
262 | | - if (currentOpts.showCloseButton) { |
263 | | - close.show(); |
264 | | - } |
| 240 | + $.fancybox.showActivity(); |
265 | 241 | |
266 | | - fancybox_set_navigation(); |
| 242 | + selectedOpts.ajax.win = selectedOpts.ajax.success; |
267 | 243 | |
268 | | - $(window).bind("resize.fb", $.fancybox.center); |
| 244 | + ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, { |
| 245 | + url : href, |
| 246 | + data : selectedOpts.ajax.data || {}, |
| 247 | + error : function(XMLHttpRequest, textStatus, errorThrown) { |
| 248 | + if ( XMLHttpRequest.status > 0 ) { |
| 249 | + _error(); |
| 250 | + } |
| 251 | + }, |
| 252 | + success : function(data, textStatus, XMLHttpRequest) { |
| 253 | + var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader; |
| 254 | + if (o.status == 200) { |
| 255 | + if ( typeof selectedOpts.ajax.win == 'function' ) { |
| 256 | + ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest); |
269 | 257 | |
270 | | - if (currentOpts.centerOnScroll) { |
271 | | - $(window).bind("scroll.fb", $.fancybox.center); |
272 | | - } else { |
273 | | - $(window).unbind("scroll.fb"); |
274 | | - } |
| 258 | + if (ret === false) { |
| 259 | + loading.hide(); |
| 260 | + return; |
| 261 | + } else if (typeof ret == 'string' || typeof ret == 'object') { |
| 262 | + data = ret; |
| 263 | + } |
| 264 | + } |
275 | 265 | |
276 | | - if ($.isFunction(currentOpts.onComplete)) { |
277 | | - currentOpts.onComplete(currentArray, currentIndex, currentOpts); |
278 | | - } |
| 266 | + tmp.html( data ); |
| 267 | + _process_inline(); |
| 268 | + } |
| 269 | + } |
| 270 | + })); |
279 | 271 | |
280 | | - busy = false; |
| 272 | + break; |
281 | 273 | |
282 | | - fancybox_preload_images(); |
| 274 | + case 'iframe': |
| 275 | + _show(); |
| 276 | + break; |
| 277 | + } |
283 | 278 | }, |
284 | 279 | |
285 | | - fancybox_draw = function(pos) { |
286 | | - var width = Math.round(start_pos.width + (final_pos.width - start_pos.width) * pos), |
287 | | - height = Math.round(start_pos.height + (final_pos.height - start_pos.height) * pos), |
| 280 | + _process_inline = function() { |
| 281 | + var |
| 282 | + w = selectedOpts.width, |
| 283 | + h = selectedOpts.height; |
288 | 284 | |
289 | | - top = Math.round(start_pos.top + (final_pos.top - start_pos.top) * pos), |
290 | | - left = Math.round(start_pos.left + (final_pos.left - start_pos.left) * pos); |
| 285 | + if (w.toString().indexOf('%') > -1) { |
| 286 | + w = parseInt( ($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px'; |
291 | 287 | |
292 | | - wrap.css({ |
293 | | - 'width' : width + 'px', |
294 | | - 'height' : height + 'px', |
295 | | - 'top' : top + 'px', |
296 | | - 'left' : left + 'px' |
297 | | - }); |
| 288 | + } else { |
| 289 | + w = w == 'auto' ? 'auto' : w + 'px'; |
| 290 | + } |
298 | 291 | |
299 | | - width = Math.max(width - currentOpts.padding * 2, 0); |
300 | | - height = Math.max(height - (currentOpts.padding * 2 + (titleh * pos)), 0); |
| 292 | + if (h.toString().indexOf('%') > -1) { |
| 293 | + h = parseInt( ($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px'; |
301 | 294 | |
302 | | - inner.css({ |
303 | | - 'width' : width + 'px', |
304 | | - 'height' : height + 'px' |
305 | | - }); |
306 | | - |
307 | | - if (typeof final_pos.opacity !== 'undefined') { |
308 | | - wrap.css('opacity', (pos < 0.5 ? 0.5 : pos)); |
| 295 | + } else { |
| 296 | + h = h == 'auto' ? 'auto' : h + 'px'; |
309 | 297 | } |
310 | | - }, |
311 | 298 | |
312 | | - fancybox_get_obj_pos = function(obj) { |
313 | | - var pos = obj.offset(); |
| 299 | + tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>'); |
314 | 300 | |
315 | | - pos.top += parseFloat( obj.css('paddingTop') ) || 0; |
316 | | - pos.left += parseFloat( obj.css('paddingLeft') ) || 0; |
| 301 | + selectedOpts.width = tmp.width(); |
| 302 | + selectedOpts.height = tmp.height(); |
317 | 303 | |
318 | | - pos.top += parseFloat( obj.css('border-top-width') ) || 0; |
319 | | - pos.left += parseFloat( obj.css('border-left-width') ) || 0; |
| 304 | + _show(); |
| 305 | + }, |
320 | 306 | |
321 | | - pos.width = obj.width(); |
322 | | - pos.height = obj.height(); |
| 307 | + _process_image = function() { |
| 308 | + selectedOpts.width = imgPreloader.width; |
| 309 | + selectedOpts.height = imgPreloader.height; |
323 | 310 | |
324 | | - return pos; |
| 311 | + $("<img />").attr({ |
| 312 | + 'id' : 'fancybox-img', |
| 313 | + 'src' : imgPreloader.src, |
| 314 | + 'alt' : selectedOpts.title |
| 315 | + }).appendTo( tmp ); |
| 316 | + |
| 317 | + _show(); |
325 | 318 | }, |
326 | 319 | |
327 | | - fancybox_get_zoom_from = function() { |
328 | | - var orig = selectedOpts.orig ? $(selectedOpts.orig) : false, |
329 | | - from = {}, |
330 | | - pos, |
331 | | - view; |
| 320 | + _show = function() { |
| 321 | + var pos, equal; |
332 | 322 | |
333 | | - if (orig && orig.length) { |
334 | | - pos = fancybox_get_obj_pos(orig); |
| 323 | + loading.hide(); |
335 | 324 | |
336 | | - from = { |
337 | | - width : (pos.width + (currentOpts.padding * 2)), |
338 | | - height : (pos.height + (currentOpts.padding * 2)), |
339 | | - top : (pos.top - currentOpts.padding - shadow), |
340 | | - left : (pos.left - currentOpts.padding - shadow) |
341 | | - }; |
342 | | - |
343 | | - } else { |
344 | | - view = fancybox_get_viewport(); |
| 325 | + if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) { |
| 326 | + $.event.trigger('fancybox-cancel'); |
345 | 327 | |
346 | | - from = { |
347 | | - width : 1, |
348 | | - height : 1, |
349 | | - top : view[3] + view[1] * 0.5, |
350 | | - left : view[2] + view[0] * 0.5 |
351 | | - }; |
| 328 | + busy = false; |
| 329 | + return; |
352 | 330 | } |
353 | 331 | |
354 | | - return from; |
355 | | - }, |
| 332 | + busy = true; |
356 | 333 | |
357 | | - fancybox_show = function() { |
358 | | - loading.hide(); |
| 334 | + $(content.add( overlay )).unbind(); |
359 | 335 | |
360 | | - if (wrap.is(":visible") && $.isFunction(currentOpts.onCleanup)) { |
361 | | - if (currentOpts.onCleanup(currentArray, currentIndex, currentOpts) === false) { |
362 | | - $.event.trigger('fancybox-cancel'); |
| 336 | + $(window).unbind("resize.fb scroll.fb"); |
| 337 | + $(document).unbind('keydown.fb'); |
363 | 338 | |
364 | | - busy = false; |
365 | | - return; |
366 | | - } |
| 339 | + if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') { |
| 340 | + wrap.css('height', wrap.height()); |
367 | 341 | } |
368 | 342 | |
369 | | - currentArray = selectedArray; |
370 | | - currentIndex = selectedIndex; |
371 | | - currentOpts = selectedOpts; |
| 343 | + currentArray = selectedArray; |
| 344 | + currentIndex = selectedIndex; |
| 345 | + currentOpts = selectedOpts; |
372 | 346 | |
373 | | - inner.get(0).scrollTop = 0; |
374 | | - inner.get(0).scrollLeft = 0; |
| 347 | + if (currentOpts.overlayShow) { |
| 348 | + overlay.css({ |
| 349 | + 'background-color' : currentOpts.overlayColor, |
| 350 | + 'opacity' : currentOpts.overlayOpacity, |
| 351 | + 'cursor' : currentOpts.hideOnOverlayClick ? 'pointer' : 'auto', |
| 352 | + 'height' : $(document).height() |
| 353 | + }); |
375 | 354 | |
376 | | - if (currentOpts.overlayShow) { |
377 | | - if (isIE6) { |
378 | | - $('select:not(#fancybox-tmp select)').filter(function() { |
379 | | - return this.style.visibility !== 'hidden'; |
380 | | - }).css({'visibility':'hidden'}).one('fancybox-cleanup', function() { |
381 | | - this.style.visibility = 'inherit'; |
382 | | - }); |
| 355 | + if (!overlay.is(':visible')) { |
| 356 | + if (isIE6) { |
| 357 | + $('select:not(#fancybox-tmp select)').filter(function() { |
| 358 | + return this.style.visibility !== 'hidden'; |
| 359 | + }).css({'visibility' : 'hidden'}).one('fancybox-cleanup', function() { |
| 360 | + this.style.visibility = 'inherit'; |
| 361 | + }); |
| 362 | + } |
| 363 | + |
| 364 | + overlay.show(); |
383 | 365 | } |
384 | | - |
385 | | - overlay.css({ |
386 | | - 'background-color' : currentOpts.overlayColor, |
387 | | - 'opacity' : currentOpts.overlayOpacity |
388 | | - }).unbind().show(); |
| 366 | + } else { |
| 367 | + overlay.hide(); |
389 | 368 | } |
390 | 369 | |
391 | | - final_pos = fancybox_get_zoom_to(); |
| 370 | + final_pos = _get_zoom_to(); |
392 | 371 | |
393 | | - fancybox_process_title(); |
| 372 | + _process_title(); |
394 | 373 | |
395 | 374 | if (wrap.is(":visible")) { |
396 | 375 | $( close.add( nav_left ).add( nav_right ) ).hide(); |
397 | 376 | |
398 | | - var pos = wrap.position(), |
399 | | - equal; |
| 377 | + pos = wrap.position(), |
400 | 378 | |
401 | 379 | start_pos = { |
402 | | - top : pos.top , |
403 | | - left : pos.left, |
404 | | - width : wrap.width(), |
405 | | - height : wrap.height() |
| 380 | + top : pos.top, |
| 381 | + left : pos.left, |
| 382 | + width : wrap.width(), |
| 383 | + height : wrap.height() |
406 | 384 | }; |
407 | 385 | |
408 | 386 | equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height); |
409 | 387 | |
410 | | - inner.fadeOut(currentOpts.changeFade, function() { |
| 388 | + content.fadeTo(currentOpts.changeFade, 0.3, function() { |
411 | 389 | var finish_resizing = function() { |
412 | | - inner.html( tmp.contents() ).fadeIn(currentOpts.changeFade, _finish); |
| 390 | + content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish); |
413 | 391 | }; |
414 | | - |
| 392 | + |
415 | 393 | $.event.trigger('fancybox-change'); |
416 | 394 | |
417 | | - inner.empty().css('overflow', 'hidden'); |
| 395 | + content |
| 396 | + .empty() |
| 397 | + .removeAttr('filter') |
| 398 | + .css({ |
| 399 | + 'border-width' : currentOpts.padding, |
| 400 | + 'width' : final_pos.width - currentOpts.padding * 2, |
| 401 | + 'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2 |
| 402 | + }); |
418 | 403 | |
419 | 404 | if (equal) { |
420 | | - inner.css({ |
421 | | - top : currentOpts.padding, |
422 | | - left : currentOpts.padding, |
423 | | - width : Math.max(final_pos.width - (currentOpts.padding * 2), 1), |
424 | | - height : Math.max(final_pos.height - (currentOpts.padding * 2) - titleh, 1) |
425 | | - }); |
426 | | - |
427 | 405 | finish_resizing(); |
428 | 406 | |
429 | 407 | } else { |
430 | | - inner.css({ |
431 | | - top : currentOpts.padding, |
432 | | - left : currentOpts.padding, |
433 | | - width : Math.max(start_pos.width - (currentOpts.padding * 2), 1), |
434 | | - height : Math.max(start_pos.height - (currentOpts.padding * 2), 1) |
435 | | - }); |
436 | | - |
437 | 408 | fx.prop = 0; |
438 | 409 | |
439 | | - $(fx).animate({ prop: 1 }, { |
440 | | - duration : currentOpts.changeSpeed, |
441 | | - easing : currentOpts.easingChange, |
442 | | - step : fancybox_draw, |
443 | | - complete : finish_resizing |
| 410 | + $(fx).animate({prop: 1}, { |
| 411 | + duration : currentOpts.changeSpeed, |
| 412 | + easing : currentOpts.easingChange, |
| 413 | + step : _draw, |
| 414 | + complete : finish_resizing |
444 | 415 | }); |
445 | 416 | } |
446 | 417 | }); |
— | — | @@ -447,20 +418,16 @@ |
448 | 419 | return; |
449 | 420 | } |
450 | 421 | |
451 | | - wrap.css('opacity', 1); |
| 422 | + wrap.removeAttr("style"); |
452 | 423 | |
| 424 | + content.css('border-width', currentOpts.padding); |
| 425 | + |
453 | 426 | if (currentOpts.transitionIn == 'elastic') { |
454 | | - start_pos = fancybox_get_zoom_from(); |
| 427 | + start_pos = _get_zoom_from(); |
455 | 428 | |
456 | | - inner.css({ |
457 | | - top : currentOpts.padding, |
458 | | - left : currentOpts.padding, |
459 | | - width : Math.max(start_pos.width - (currentOpts.padding * 2), 1), |
460 | | - height : Math.max(start_pos.height - (currentOpts.padding * 2), 1) |
461 | | - }) |
462 | | - .html( tmp.contents() ); |
| 429 | + content.html( tmp.contents() ); |
463 | 430 | |
464 | | - wrap.css(start_pos).show(); |
| 431 | + wrap.show(); |
465 | 432 | |
466 | 433 | if (currentOpts.opacity) { |
467 | 434 | final_pos.opacity = 0; |
— | — | @@ -468,297 +435,349 @@ |
469 | 436 | |
470 | 437 | fx.prop = 0; |
471 | 438 | |
472 | | - $(fx).animate({ prop: 1 }, { |
473 | | - duration : currentOpts.speedIn, |
474 | | - easing : currentOpts.easingIn, |
475 | | - step : fancybox_draw, |
476 | | - complete : _finish |
| 439 | + $(fx).animate({prop: 1}, { |
| 440 | + duration : currentOpts.speedIn, |
| 441 | + easing : currentOpts.easingIn, |
| 442 | + step : _draw, |
| 443 | + complete : _finish |
477 | 444 | }); |
478 | 445 | |
479 | | - } else { |
480 | | - inner.css({ |
481 | | - top : currentOpts.padding, |
482 | | - left : currentOpts.padding, |
483 | | - width : Math.max(final_pos.width - (currentOpts.padding * 2), 1), |
484 | | - height : Math.max(final_pos.height - (currentOpts.padding * 2) - titleh, 1) |
485 | | - }) |
486 | | - .html( tmp.contents() ); |
| 446 | + return; |
| 447 | + } |
487 | 448 | |
488 | | - wrap.css( final_pos ).fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish ); |
| 449 | + if (currentOpts.titlePosition == 'inside' && titleHeight > 0) { |
| 450 | + title.show(); |
489 | 451 | } |
| 452 | + |
| 453 | + content |
| 454 | + .css({ |
| 455 | + 'width' : final_pos.width - currentOpts.padding * 2, |
| 456 | + 'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2 |
| 457 | + }) |
| 458 | + .html( tmp.contents() ); |
| 459 | + |
| 460 | + wrap |
| 461 | + .css(final_pos) |
| 462 | + .fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish ); |
490 | 463 | }, |
491 | 464 | |
492 | | - fancybox_process_inline = function() { |
493 | | - tmp.width( selectedOpts.width ); |
494 | | - tmp.height( selectedOpts.height ); |
| 465 | + _format_title = function(title) { |
| 466 | + if (title && title.length) { |
| 467 | + if (currentOpts.titlePosition == 'float') { |
| 468 | + return '<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">' + title + '</td><td id="fancybox-title-float-right"></td></tr></table>'; |
| 469 | + } |
495 | 470 | |
496 | | - if (selectedOpts.width == 'auto') { |
497 | | - selectedOpts.width = tmp.width(); |
| 471 | + return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>'; |
498 | 472 | } |
499 | | - if (selectedOpts.height == 'auto') { |
500 | | - selectedOpts.height = tmp.height(); |
501 | | - } |
502 | 473 | |
503 | | - fancybox_show(); |
| 474 | + return false; |
504 | 475 | }, |
505 | | - |
506 | | - fancybox_process_image = function() { |
507 | | - busy = true; |
508 | 476 | |
509 | | - selectedOpts.width = imgPreloader.width; |
510 | | - selectedOpts.height = imgPreloader.height; |
| 477 | + _process_title = function() { |
| 478 | + titleStr = currentOpts.title || ''; |
| 479 | + titleHeight = 0; |
511 | 480 | |
512 | | - $("<img />").attr({ |
513 | | - 'id' : 'fancybox-img', |
514 | | - 'src' : imgPreloader.src, |
515 | | - 'alt' : selectedOpts.title |
516 | | - }).appendTo( tmp ); |
| 481 | + title |
| 482 | + .empty() |
| 483 | + .removeAttr('style') |
| 484 | + .removeClass(); |
517 | 485 | |
518 | | - fancybox_show(); |
519 | | - }, |
| 486 | + if (currentOpts.titleShow === false) { |
| 487 | + title.hide(); |
| 488 | + return; |
| 489 | + } |
520 | 490 | |
521 | | - fancybox_start = function() { |
522 | | - fancybox_abort(); |
| 491 | + titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr); |
523 | 492 | |
524 | | - var obj = selectedArray[ selectedIndex ], |
525 | | - href, |
526 | | - type, |
527 | | - title, |
528 | | - str, |
529 | | - emb, |
530 | | - selector, |
531 | | - data; |
| 493 | + if (!titleStr || titleStr === '') { |
| 494 | + title.hide(); |
| 495 | + return; |
| 496 | + } |
532 | 497 | |
533 | | - selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox'))); |
534 | | - title = obj.title || $(obj).title || selectedOpts.title || ''; |
535 | | - |
536 | | - if (obj.nodeName && !selectedOpts.orig) { |
537 | | - selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj); |
| 498 | + title |
| 499 | + .addClass('fancybox-title-' + currentOpts.titlePosition) |
| 500 | + .html( titleStr ) |
| 501 | + .appendTo( 'body' ) |
| 502 | + .show(); |
| 503 | + |
| 504 | + switch (currentOpts.titlePosition) { |
| 505 | + case 'inside': |
| 506 | + title |
| 507 | + .css({ |
| 508 | + 'width' : final_pos.width - (currentOpts.padding * 2), |
| 509 | + 'marginLeft' : currentOpts.padding, |
| 510 | + 'marginRight' : currentOpts.padding |
| 511 | + }); |
| 512 | + |
| 513 | + titleHeight = title.outerHeight(true); |
| 514 | + |
| 515 | + title.appendTo( outer ); |
| 516 | + |
| 517 | + final_pos.height += titleHeight; |
| 518 | + break; |
| 519 | + |
| 520 | + case 'over': |
| 521 | + title |
| 522 | + .css({ |
| 523 | + 'marginLeft' : currentOpts.padding, |
| 524 | + 'width' : final_pos.width - (currentOpts.padding * 2), |
| 525 | + 'bottom' : currentOpts.padding |
| 526 | + }) |
| 527 | + .appendTo( outer ); |
| 528 | + break; |
| 529 | + |
| 530 | + case 'float': |
| 531 | + title |
| 532 | + .css('left', parseInt((title.width() - final_pos.width - 40)/ 2, 10) * -1) |
| 533 | + .appendTo( wrap ); |
| 534 | + break; |
| 535 | + |
| 536 | + default: |
| 537 | + title |
| 538 | + .css({ |
| 539 | + 'width' : final_pos.width - (currentOpts.padding * 2), |
| 540 | + 'paddingLeft' : currentOpts.padding, |
| 541 | + 'paddingRight' : currentOpts.padding |
| 542 | + }) |
| 543 | + .appendTo( wrap ); |
| 544 | + break; |
538 | 545 | } |
539 | 546 | |
540 | | - if (title === '' && selectedOpts.orig) { |
541 | | - title = selectedOpts.orig.attr('alt'); |
| 547 | + title.hide(); |
| 548 | + }, |
| 549 | + |
| 550 | + _set_navigation = function() { |
| 551 | + if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) { |
| 552 | + $(document).bind('keydown.fb', function(e) { |
| 553 | + if (e.keyCode == 27 && currentOpts.enableEscapeButton) { |
| 554 | + e.preventDefault(); |
| 555 | + $.fancybox.close(); |
| 556 | + |
| 557 | + } else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') { |
| 558 | + e.preventDefault(); |
| 559 | + $.fancybox[ e.keyCode == 37 ? 'prev' : 'next'](); |
| 560 | + } |
| 561 | + }); |
542 | 562 | } |
543 | 563 | |
544 | | - if (obj.nodeName && (/^(?:javascript|#)/i).test(obj.href)) { |
545 | | - href = selectedOpts.href || null; |
546 | | - } else { |
547 | | - href = selectedOpts.href || obj.href || null; |
| 564 | + if (!currentOpts.showNavArrows) { |
| 565 | + nav_left.hide(); |
| 566 | + nav_right.hide(); |
| 567 | + return; |
548 | 568 | } |
549 | 569 | |
550 | | - if (selectedOpts.type) { |
551 | | - type = selectedOpts.type; |
| 570 | + if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) { |
| 571 | + nav_left.show(); |
| 572 | + } |
552 | 573 | |
553 | | - if (!href) { |
554 | | - href = selectedOpts.content; |
555 | | - } |
556 | | - |
557 | | - } else if (selectedOpts.content) { |
558 | | - type = 'html'; |
| 574 | + if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) { |
| 575 | + nav_right.show(); |
| 576 | + } |
| 577 | + }, |
559 | 578 | |
560 | | - } else if (href) { |
561 | | - if (href.match(imgRegExp)) { |
562 | | - type = 'image'; |
| 579 | + _finish = function () { |
| 580 | + if (!$.support.opacity) { |
| 581 | + content.get(0).style.removeAttribute('filter'); |
| 582 | + wrap.get(0).style.removeAttribute('filter'); |
| 583 | + } |
563 | 584 | |
564 | | - } else if (href.match(swfRegExp)) { |
565 | | - type = 'swf'; |
| 585 | + if (selectedOpts.autoDimensions) { |
| 586 | + content.css('height', 'auto'); |
| 587 | + } |
566 | 588 | |
567 | | - } else if ($(obj).hasClass("iframe")) { |
568 | | - type = 'iframe'; |
| 589 | + wrap.css('height', 'auto'); |
569 | 590 | |
570 | | - } else if (href.match(/#/)) { |
571 | | - obj = href.substr(href.indexOf("#")); |
| 591 | + if (titleStr && titleStr.length) { |
| 592 | + title.show(); |
| 593 | + } |
572 | 594 | |
573 | | - type = $(obj).length > 0 ? 'inline' : 'ajax'; |
574 | | - } else { |
575 | | - type = 'ajax'; |
576 | | - } |
577 | | - } else { |
578 | | - type = 'inline'; |
| 595 | + if (currentOpts.showCloseButton) { |
| 596 | + close.show(); |
579 | 597 | } |
580 | 598 | |
581 | | - selectedOpts.type = type; |
582 | | - selectedOpts.href = href; |
583 | | - selectedOpts.title = title; |
| 599 | + _set_navigation(); |
| 600 | + |
| 601 | + if (currentOpts.hideOnContentClick) { |
| 602 | + content.bind('click', $.fancybox.close); |
| 603 | + } |
584 | 604 | |
585 | | - if (selectedOpts.autoDimensions && selectedOpts.type !== 'iframe' && selectedOpts.type !== 'swf') { |
586 | | - selectedOpts.width = 'auto'; |
587 | | - selectedOpts.height = 'auto'; |
| 605 | + if (currentOpts.hideOnOverlayClick) { |
| 606 | + overlay.bind('click', $.fancybox.close); |
588 | 607 | } |
589 | 608 | |
590 | | - if (selectedOpts.modal) { |
591 | | - selectedOpts.overlayShow = true; |
592 | | - selectedOpts.hideOnOverlayClick = false; |
593 | | - selectedOpts.hideOnContentClick = false; |
594 | | - selectedOpts.enableEscapeButton = false; |
595 | | - selectedOpts.showCloseButton = false; |
| 609 | + $(window).bind("resize.fb", $.fancybox.resize); |
| 610 | + |
| 611 | + if (currentOpts.centerOnScroll) { |
| 612 | + $(window).bind("scroll.fb", $.fancybox.center); |
596 | 613 | } |
597 | 614 | |
598 | | - if ($.isFunction(selectedOpts.onStart)) { |
599 | | - if (selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts) === false) { |
600 | | - busy = false; |
601 | | - return; |
602 | | - } |
| 615 | + if (currentOpts.type == 'iframe') { |
| 616 | + $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content); |
603 | 617 | } |
604 | 618 | |
605 | | - tmp.css('padding', (shadow + selectedOpts.padding + selectedOpts.margin)); |
| 619 | + wrap.show(); |
606 | 620 | |
607 | | - $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() { |
608 | | - $(this).replaceWith(inner.children()); |
609 | | - }); |
| 621 | + busy = false; |
610 | 622 | |
611 | | - switch (type) { |
612 | | - case 'html' : |
613 | | - tmp.html( selectedOpts.content ); |
614 | | - fancybox_process_inline(); |
615 | | - break; |
| 623 | + $.fancybox.center(); |
616 | 624 | |
617 | | - case 'inline' : |
618 | | - $('<div class="fancybox-inline-tmp" />').hide().insertBefore( $(obj) ).bind('fancybox-cleanup', function() { |
619 | | - $(this).replaceWith(inner.children()); |
620 | | - }).bind('fancybox-cancel', function() { |
621 | | - $(this).replaceWith(tmp.children()); |
622 | | - }); |
| 625 | + currentOpts.onComplete(currentArray, currentIndex, currentOpts); |
623 | 626 | |
624 | | - $(obj).appendTo(tmp); |
| 627 | + _preload_images(); |
| 628 | + }, |
625 | 629 | |
626 | | - fancybox_process_inline(); |
627 | | - break; |
| 630 | + _preload_images = function() { |
| 631 | + var href, |
| 632 | + objNext; |
628 | 633 | |
629 | | - case 'image': |
630 | | - busy = false; |
| 634 | + if ((currentArray.length -1) > currentIndex) { |
| 635 | + href = currentArray[ currentIndex + 1 ].href; |
631 | 636 | |
632 | | - $.fancybox.showActivity(); |
| 637 | + if (typeof href !== 'undefined' && href.match(imgRegExp)) { |
| 638 | + objNext = new Image(); |
| 639 | + objNext.src = href; |
| 640 | + } |
| 641 | + } |
633 | 642 | |
634 | | - imgPreloader = new Image(); |
| 643 | + if (currentIndex > 0) { |
| 644 | + href = currentArray[ currentIndex - 1 ].href; |
635 | 645 | |
636 | | - imgPreloader.onerror = function() { |
637 | | - fancybox_error(); |
638 | | - }; |
| 646 | + if (typeof href !== 'undefined' && href.match(imgRegExp)) { |
| 647 | + objNext = new Image(); |
| 648 | + objNext.src = href; |
| 649 | + } |
| 650 | + } |
| 651 | + }, |
639 | 652 | |
640 | | - imgPreloader.onload = function() { |
641 | | - imgPreloader.onerror = null; |
642 | | - imgPreloader.onload = null; |
643 | | - fancybox_process_image(); |
644 | | - }; |
| 653 | + _draw = function(pos) { |
| 654 | + var dim = { |
| 655 | + width : parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10), |
| 656 | + height : parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10), |
645 | 657 | |
646 | | - imgPreloader.src = href; |
647 | | - |
648 | | - break; |
| 658 | + top : parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10), |
| 659 | + left : parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10) |
| 660 | + }; |
649 | 661 | |
650 | | - case 'swf': |
651 | | - str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>'; |
652 | | - emb = ''; |
653 | | - |
654 | | - $.each(selectedOpts.swf, function(name, val) { |
655 | | - str += '<param name="' + name + '" value="' + val + '"></param>'; |
656 | | - emb += ' ' + name + '="' + val + '"'; |
657 | | - }); |
| 662 | + if (typeof final_pos.opacity !== 'undefined') { |
| 663 | + dim.opacity = pos < 0.5 ? 0.5 : pos; |
| 664 | + } |
658 | 665 | |
659 | | - str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>'; |
| 666 | + wrap.css(dim); |
660 | 667 | |
661 | | - tmp.html(str); |
| 668 | + content.css({ |
| 669 | + 'width' : dim.width - currentOpts.padding * 2, |
| 670 | + 'height' : dim.height - (titleHeight * pos) - currentOpts.padding * 2 |
| 671 | + }); |
| 672 | + }, |
662 | 673 | |
663 | | - fancybox_process_inline(); |
664 | | - break; |
| 674 | + _get_viewport = function() { |
| 675 | + return [ |
| 676 | + $(window).width() - (currentOpts.margin * 2), |
| 677 | + $(window).height() - (currentOpts.margin * 2), |
| 678 | + $(document).scrollLeft() + currentOpts.margin, |
| 679 | + $(document).scrollTop() + currentOpts.margin |
| 680 | + ]; |
| 681 | + }, |
665 | 682 | |
666 | | - case 'ajax': |
667 | | - selector = href.split('#', 2); |
668 | | - data = selectedOpts.ajax.data || {}; |
| 683 | + _get_zoom_to = function () { |
| 684 | + var view = _get_viewport(), |
| 685 | + to = {}, |
| 686 | + resize = currentOpts.autoScale, |
| 687 | + double_padding = currentOpts.padding * 2, |
| 688 | + ratio; |
669 | 689 | |
670 | | - if (selector.length > 1) { |
671 | | - href = selector[0]; |
| 690 | + if (currentOpts.width.toString().indexOf('%') > -1) { |
| 691 | + to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10); |
| 692 | + } else { |
| 693 | + to.width = currentOpts.width + double_padding; |
| 694 | + } |
672 | 695 | |
673 | | - if (typeof data == "string") { |
674 | | - data += '&selector=' + selector[1]; |
675 | | - } else { |
676 | | - data.selector = selector[1]; |
677 | | - } |
| 696 | + if (currentOpts.height.toString().indexOf('%') > -1) { |
| 697 | + to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10); |
| 698 | + } else { |
| 699 | + to.height = currentOpts.height + double_padding; |
| 700 | + } |
| 701 | + |
| 702 | + if (resize && (to.width > view[0] || to.height > view[1])) { |
| 703 | + if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') { |
| 704 | + ratio = (currentOpts.width ) / (currentOpts.height ); |
| 705 | + |
| 706 | + if ((to.width ) > view[0]) { |
| 707 | + to.width = view[0]; |
| 708 | + to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10); |
678 | 709 | } |
679 | 710 | |
680 | | - busy = false; |
681 | | - $.fancybox.showActivity(); |
| 711 | + if ((to.height) > view[1]) { |
| 712 | + to.height = view[1]; |
| 713 | + to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10); |
| 714 | + } |
682 | 715 | |
683 | | - ajaxLoader = $.ajax($.extend(selectedOpts.ajax, { |
684 | | - url : href, |
685 | | - data : data, |
686 | | - error : fancybox_error, |
687 | | - success : function(data, textStatus, XMLHttpRequest) { |
688 | | - if (ajaxLoader.status == 200) { |
689 | | - tmp.html( data ); |
690 | | - fancybox_process_inline(); |
691 | | - } |
692 | | - } |
693 | | - })); |
| 716 | + } else { |
| 717 | + to.width = Math.min(to.width, view[0]); |
| 718 | + to.height = Math.min(to.height, view[1]); |
| 719 | + } |
| 720 | + } |
694 | 721 | |
695 | | - break; |
| 722 | + to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10); |
| 723 | + to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10); |
696 | 724 | |
697 | | - case 'iframe' : |
698 | | - $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" scrolling="' + selectedOpts.scrolling + '" src="' + selectedOpts.href + '"></iframe>').appendTo(tmp); |
699 | | - fancybox_show(); |
700 | | - break; |
701 | | - } |
| 725 | + return to; |
702 | 726 | }, |
703 | 727 | |
704 | | - fancybox_animate_loading = function() { |
705 | | - if (!loading.is(':visible')){ |
706 | | - clearInterval(loadingTimer); |
707 | | - return; |
708 | | - } |
| 728 | + _get_obj_pos = function(obj) { |
| 729 | + var pos = obj.offset(); |
709 | 730 | |
710 | | - $('div', loading).css('top', (loadingFrame * -40) + 'px'); |
| 731 | + pos.top += parseInt( obj.css('paddingTop'), 10 ) || 0; |
| 732 | + pos.left += parseInt( obj.css('paddingLeft'), 10 ) || 0; |
711 | 733 | |
712 | | - loadingFrame = (loadingFrame + 1) % 12; |
713 | | - }, |
| 734 | + pos.top += parseInt( obj.css('border-top-width'), 10 ) || 0; |
| 735 | + pos.left += parseInt( obj.css('border-left-width'), 10 ) || 0; |
714 | 736 | |
715 | | - fancybox_init = function() { |
716 | | - if ($("#fancybox-wrap").length) { |
717 | | - return; |
718 | | - } |
| 737 | + pos.width = obj.width(); |
| 738 | + pos.height = obj.height(); |
719 | 739 | |
720 | | - $('body').append( |
721 | | - tmp = $('<div id="fancybox-tmp"></div>'), |
722 | | - loading = $('<div id="fancybox-loading"><div></div></div>'), |
723 | | - overlay = $('<div id="fancybox-overlay"></div>'), |
724 | | - wrap = $('<div id="fancybox-wrap"></div>') |
725 | | - ); |
| 740 | + return pos; |
| 741 | + }, |
726 | 742 | |
727 | | - if (!$.support.opacity) { |
728 | | - wrap.addClass('fancybox-ie'); |
729 | | - loading.addClass('fancybox-ie'); |
730 | | - } |
| 743 | + _get_zoom_from = function() { |
| 744 | + var orig = selectedOpts.orig ? $(selectedOpts.orig) : false, |
| 745 | + from = {}, |
| 746 | + pos, |
| 747 | + view; |
731 | 748 | |
732 | | - outer = $('<div id="fancybox-outer"></div>') |
733 | | - .append('<div class="fancy-bg" id="fancy-bg-n"></div><div class="fancy-bg" id="fancy-bg-ne"></div><div class="fancy-bg" id="fancy-bg-e"></div><div class="fancy-bg" id="fancy-bg-se"></div><div class="fancy-bg" id="fancy-bg-s"></div><div class="fancy-bg" id="fancy-bg-sw"></div><div class="fancy-bg" id="fancy-bg-w"></div><div class="fancy-bg" id="fancy-bg-nw"></div>') |
734 | | - .appendTo( wrap ); |
| 749 | + if (orig && orig.length) { |
| 750 | + pos = _get_obj_pos(orig); |
735 | 751 | |
736 | | - outer.append( |
737 | | - inner = $('<div id="fancybox-inner"></div>'), |
738 | | - close = $('<a id="fancybox-close"></a>'), |
| 752 | + from = { |
| 753 | + width : pos.width + (currentOpts.padding * 2), |
| 754 | + height : pos.height + (currentOpts.padding * 2), |
| 755 | + top : pos.top - currentOpts.padding - 20, |
| 756 | + left : pos.left - currentOpts.padding - 20 |
| 757 | + }; |
739 | 758 | |
740 | | - nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'), |
741 | | - nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>') |
742 | | - ); |
| 759 | + } else { |
| 760 | + view = _get_viewport(); |
743 | 761 | |
744 | | - close.click($.fancybox.close); |
745 | | - loading.click($.fancybox.cancel); |
| 762 | + from = { |
| 763 | + width : currentOpts.padding * 2, |
| 764 | + height : currentOpts.padding * 2, |
| 765 | + top : parseInt(view[3] + view[1] * 0.5, 10), |
| 766 | + left : parseInt(view[2] + view[0] * 0.5, 10) |
| 767 | + }; |
| 768 | + } |
746 | 769 | |
747 | | - nav_left.click(function(e) { |
748 | | - e.preventDefault(); |
749 | | - $.fancybox.prev(); |
750 | | - }); |
| 770 | + return from; |
| 771 | + }, |
751 | 772 | |
752 | | - nav_right.click(function(e) { |
753 | | - e.preventDefault(); |
754 | | - $.fancybox.next(); |
755 | | - }); |
| 773 | + _animate_loading = function() { |
| 774 | + if (!loading.is(':visible')){ |
| 775 | + clearInterval(loadingTimer); |
| 776 | + return; |
| 777 | + } |
756 | 778 | |
757 | | - if (isIE6) { |
758 | | - overlay.get(0).style.setExpression('height', "document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'"); |
759 | | - loading.get(0).style.setExpression('top', "(-20 + (document.documentElement.clientHeight ? document.documentElement.clientHeight/2 : document.body.clientHeight/2 ) + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop )) + 'px'"); |
| 779 | + $('div', loading).css('top', (loadingFrame * -40) + 'px'); |
760 | 780 | |
761 | | - outer.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>'); |
762 | | - } |
| 781 | + loadingFrame = (loadingFrame + 1) % 12; |
763 | 782 | }; |
764 | 783 | |
765 | 784 | /* |
— | — | @@ -766,9 +785,14 @@ |
767 | 786 | */ |
768 | 787 | |
769 | 788 | $.fn.fancybox = function(options) { |
| 789 | + if (!$(this).length) { |
| 790 | + return this; |
| 791 | + } |
| 792 | + |
770 | 793 | $(this) |
771 | 794 | .data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {}))) |
772 | | - .unbind('click.fb').bind('click.fb', function(e) { |
| 795 | + .unbind('click.fb') |
| 796 | + .bind('click.fb', function(e) { |
773 | 797 | e.preventDefault(); |
774 | 798 | |
775 | 799 | if (busy) { |
— | — | @@ -779,8 +803,8 @@ |
780 | 804 | |
781 | 805 | $(this).blur(); |
782 | 806 | |
783 | | - selectedArray = []; |
784 | | - selectedIndex = 0; |
| 807 | + selectedArray = []; |
| 808 | + selectedIndex = 0; |
785 | 809 | |
786 | 810 | var rel = $(this).attr('rel') || ''; |
787 | 811 | |
— | — | @@ -788,30 +812,31 @@ |
789 | 813 | selectedArray.push(this); |
790 | 814 | |
791 | 815 | } else { |
792 | | - selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]"); |
793 | | - selectedIndex = selectedArray.index( this ); |
| 816 | + selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]"); |
| 817 | + selectedIndex = selectedArray.index( this ); |
794 | 818 | } |
795 | 819 | |
796 | | - fancybox_start(); |
| 820 | + _start(); |
797 | 821 | |
798 | | - return false; |
| 822 | + return; |
799 | 823 | }); |
800 | 824 | |
801 | 825 | return this; |
802 | 826 | }; |
803 | 827 | |
804 | 828 | $.fancybox = function(obj) { |
| 829 | + var opts; |
| 830 | + |
805 | 831 | if (busy) { |
806 | 832 | return; |
807 | 833 | } |
808 | 834 | |
809 | 835 | busy = true; |
| 836 | + opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {}; |
810 | 837 | |
811 | | - var opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {}; |
| 838 | + selectedArray = []; |
| 839 | + selectedIndex = parseInt(opts.index, 10) || 0; |
812 | 840 | |
813 | | - selectedArray = []; |
814 | | - selectedIndex = opts.index || 0; |
815 | | - |
816 | 841 | if ($.isArray(obj)) { |
817 | 842 | for (var i = 0, j = obj.length; i < j; i++) { |
818 | 843 | if (typeof obj[i] == 'object') { |
— | — | @@ -837,14 +862,14 @@ |
838 | 863 | selectedIndex = 0; |
839 | 864 | } |
840 | 865 | |
841 | | - fancybox_start(); |
| 866 | + _start(); |
842 | 867 | }; |
843 | 868 | |
844 | 869 | $.fancybox.showActivity = function() { |
845 | 870 | clearInterval(loadingTimer); |
846 | 871 | |
847 | 872 | loading.show(); |
848 | | - loadingTimer = setInterval(fancybox_animate_loading, 66); |
| 873 | + loadingTimer = setInterval(_animate_loading, 66); |
849 | 874 | }; |
850 | 875 | |
851 | 876 | $.fancybox.hideActivity = function() { |
— | — | @@ -854,7 +879,7 @@ |
855 | 880 | $.fancybox.next = function() { |
856 | 881 | return $.fancybox.pos( currentIndex + 1); |
857 | 882 | }; |
858 | | - |
| 883 | + |
859 | 884 | $.fancybox.prev = function() { |
860 | 885 | return $.fancybox.pos( currentIndex - 1); |
861 | 886 | }; |
— | — | @@ -864,23 +889,19 @@ |
865 | 890 | return; |
866 | 891 | } |
867 | 892 | |
868 | | - pos = parseInt(pos, 10); |
| 893 | + pos = parseInt(pos); |
869 | 894 | |
870 | | - if (pos > -1 && currentArray.length > pos) { |
| 895 | + selectedArray = currentArray; |
| 896 | + |
| 897 | + if (pos > -1 && pos < currentArray.length) { |
871 | 898 | selectedIndex = pos; |
872 | | - fancybox_start(); |
873 | | - } |
| 899 | + _start(); |
874 | 900 | |
875 | | - if (currentOpts.cyclic && currentArray.length > 1 && pos < 0) { |
876 | | - selectedIndex = currentArray.length - 1; |
877 | | - fancybox_start(); |
| 901 | + } else if (currentOpts.cyclic && currentArray.length > 1) { |
| 902 | + selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1; |
| 903 | + _start(); |
878 | 904 | } |
879 | 905 | |
880 | | - if (currentOpts.cyclic && currentArray.length > 1 && pos >= currentArray.length) { |
881 | | - selectedIndex = 0; |
882 | | - fancybox_start(); |
883 | | - } |
884 | | - |
885 | 906 | return; |
886 | 907 | }; |
887 | 908 | |
— | — | @@ -893,11 +914,9 @@ |
894 | 915 | |
895 | 916 | $.event.trigger('fancybox-cancel'); |
896 | 917 | |
897 | | - fancybox_abort(); |
| 918 | + _abort(); |
898 | 919 | |
899 | | - if (selectedOpts && $.isFunction(selectedOpts.onCancel)) { |
900 | | - selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts); |
901 | | - } |
| 920 | + selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts); |
902 | 921 | |
903 | 922 | busy = false; |
904 | 923 | }; |
— | — | @@ -910,69 +929,72 @@ |
911 | 930 | |
912 | 931 | busy = true; |
913 | 932 | |
914 | | - if (currentOpts && $.isFunction(currentOpts.onCleanup)) { |
915 | | - if (currentOpts.onCleanup(currentArray, currentIndex, currentOpts) === false) { |
916 | | - busy = false; |
917 | | - return; |
918 | | - } |
| 933 | + if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) { |
| 934 | + busy = false; |
| 935 | + return; |
919 | 936 | } |
920 | 937 | |
921 | | - fancybox_abort(); |
| 938 | + _abort(); |
922 | 939 | |
923 | 940 | $(close.add( nav_left ).add( nav_right )).hide(); |
924 | 941 | |
925 | | - $('#fancybox-title').remove(); |
| 942 | + $(content.add( overlay )).unbind(); |
926 | 943 | |
927 | | - wrap.add(inner).add(overlay).unbind(); |
928 | | - |
929 | 944 | $(window).unbind("resize.fb scroll.fb"); |
930 | 945 | $(document).unbind('keydown.fb'); |
931 | 946 | |
| 947 | + content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank'); |
| 948 | + |
| 949 | + if (currentOpts.titlePosition !== 'inside') { |
| 950 | + title.empty(); |
| 951 | + } |
| 952 | + |
| 953 | + wrap.stop(); |
| 954 | + |
932 | 955 | function _cleanup() { |
933 | 956 | overlay.fadeOut('fast'); |
934 | 957 | |
| 958 | + title.empty().hide(); |
935 | 959 | wrap.hide(); |
936 | 960 | |
937 | 961 | $.event.trigger('fancybox-cleanup'); |
938 | 962 | |
939 | | - inner.empty(); |
| 963 | + content.empty(); |
940 | 964 | |
941 | | - if ($.isFunction(currentOpts.onClosed)) { |
942 | | - currentOpts.onClosed(currentArray, currentIndex, currentOpts); |
943 | | - } |
| 965 | + currentOpts.onClosed(currentArray, currentIndex, currentOpts); |
944 | 966 | |
945 | | - currentArray = selectedOpts = []; |
946 | | - currentIndex = selectedIndex = 0; |
947 | | - currentOpts = selectedOpts = {}; |
| 967 | + currentArray = selectedOpts = []; |
| 968 | + currentIndex = selectedIndex = 0; |
| 969 | + currentOpts = selectedOpts = {}; |
948 | 970 | |
949 | 971 | busy = false; |
950 | 972 | } |
951 | 973 | |
952 | | - inner.css('overflow', 'hidden'); |
953 | | - |
954 | 974 | if (currentOpts.transitionOut == 'elastic') { |
955 | | - start_pos = fancybox_get_zoom_from(); |
| 975 | + start_pos = _get_zoom_from(); |
956 | 976 | |
957 | 977 | var pos = wrap.position(); |
958 | 978 | |
959 | 979 | final_pos = { |
960 | | - top : pos.top , |
961 | | - left : pos.left, |
962 | | - width : wrap.width(), |
963 | | - height : wrap.height() |
| 980 | + top : pos.top , |
| 981 | + left : pos.left, |
| 982 | + width : wrap.width(), |
| 983 | + height : wrap.height() |
964 | 984 | }; |
965 | 985 | |
966 | 986 | if (currentOpts.opacity) { |
967 | 987 | final_pos.opacity = 1; |
968 | 988 | } |
969 | 989 | |
| 990 | + title.empty().hide(); |
| 991 | + |
970 | 992 | fx.prop = 1; |
971 | 993 | |
972 | 994 | $(fx).animate({ prop: 0 }, { |
973 | | - duration : currentOpts.speedOut, |
974 | | - easing : currentOpts.easingOut, |
975 | | - step : fancybox_draw, |
976 | | - complete : _cleanup |
| 995 | + duration : currentOpts.speedOut, |
| 996 | + easing : currentOpts.easingOut, |
| 997 | + step : _draw, |
| 998 | + complete : _cleanup |
977 | 999 | }); |
978 | 1000 | |
979 | 1001 | } else { |
— | — | @@ -981,97 +1003,154 @@ |
982 | 1004 | }; |
983 | 1005 | |
984 | 1006 | $.fancybox.resize = function() { |
985 | | - var c, h; |
986 | | - |
987 | | - if (busy || wrap.is(':hidden')) { |
988 | | - return; |
| 1007 | + if (overlay.is(':visible')) { |
| 1008 | + overlay.css('height', $(document).height()); |
989 | 1009 | } |
990 | 1010 | |
991 | | - busy = true; |
| 1011 | + $.fancybox.center(true); |
| 1012 | + }; |
992 | 1013 | |
993 | | - c = inner.wrapInner("<div style='overflow:auto'></div>").children(); |
994 | | - h = c.height(); |
| 1014 | + $.fancybox.center = function() { |
| 1015 | + var view, align; |
995 | 1016 | |
996 | | - wrap.css({height: h + (currentOpts.padding * 2) + titleh}); |
997 | | - inner.css({height: h}); |
| 1017 | + if (busy) { |
| 1018 | + return; |
| 1019 | + } |
998 | 1020 | |
999 | | - c.replaceWith(c.children()); |
| 1021 | + align = arguments[0] === true ? 1 : 0; |
| 1022 | + view = _get_viewport(); |
1000 | 1023 | |
1001 | | - $.fancybox.center(); |
| 1024 | + if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) { |
| 1025 | + return; |
| 1026 | + } |
| 1027 | + |
| 1028 | + wrap |
| 1029 | + .stop() |
| 1030 | + .animate({ |
| 1031 | + 'top' : parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)), |
| 1032 | + 'left' : parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding)) |
| 1033 | + }, typeof arguments[0] == 'number' ? arguments[0] : 200); |
1002 | 1034 | }; |
1003 | 1035 | |
1004 | | - $.fancybox.center = function() { |
1005 | | - busy = true; |
| 1036 | + $.fancybox.init = function() { |
| 1037 | + if ($("#fancybox-wrap").length) { |
| 1038 | + return; |
| 1039 | + } |
1006 | 1040 | |
1007 | | - var view = fancybox_get_viewport(), |
1008 | | - margin = currentOpts.margin, |
1009 | | - to = {}; |
| 1041 | + $('body').append( |
| 1042 | + tmp = $('<div id="fancybox-tmp"></div>'), |
| 1043 | + loading = $('<div id="fancybox-loading"><div></div></div>'), |
| 1044 | + overlay = $('<div id="fancybox-overlay"></div>'), |
| 1045 | + wrap = $('<div id="fancybox-wrap"></div>') |
| 1046 | + ); |
1010 | 1047 | |
1011 | | - to.top = view[3] + ((view[1] - ((wrap.height() - titleh) + (shadow * 2 ))) * 0.5); |
1012 | | - to.left = view[2] + ((view[0] - (wrap.width() + (shadow * 2 ))) * 0.5); |
| 1048 | + outer = $('<div id="fancybox-outer"></div>') |
| 1049 | + .append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>') |
| 1050 | + .appendTo( wrap ); |
1013 | 1051 | |
1014 | | - to.top = Math.max(view[3] + margin, to.top); |
1015 | | - to.left = Math.max(view[2] + margin, to.left); |
| 1052 | + outer.append( |
| 1053 | + content = $('<div id="fancybox-content"></div>'), |
| 1054 | + close = $('<a id="fancybox-close"></a>'), |
| 1055 | + title = $('<div id="fancybox-title"></div>'), |
1016 | 1056 | |
1017 | | - wrap.css(to); |
| 1057 | + nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'), |
| 1058 | + nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>') |
| 1059 | + ); |
1018 | 1060 | |
1019 | | - busy = false; |
| 1061 | + close.click($.fancybox.close); |
| 1062 | + loading.click($.fancybox.cancel); |
| 1063 | + |
| 1064 | + nav_left.click(function(e) { |
| 1065 | + e.preventDefault(); |
| 1066 | + $.fancybox.prev(); |
| 1067 | + }); |
| 1068 | + |
| 1069 | + nav_right.click(function(e) { |
| 1070 | + e.preventDefault(); |
| 1071 | + $.fancybox.next(); |
| 1072 | + }); |
| 1073 | + |
| 1074 | + if ($.fn.mousewheel) { |
| 1075 | + wrap.bind('mousewheel.fb', function(e, delta) { |
| 1076 | + if (busy) { |
| 1077 | + e.preventDefault(); |
| 1078 | + |
| 1079 | + } else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) { |
| 1080 | + e.preventDefault(); |
| 1081 | + $.fancybox[ delta > 0 ? 'prev' : 'next'](); |
| 1082 | + } |
| 1083 | + }); |
| 1084 | + } |
| 1085 | + |
| 1086 | + if (!$.support.opacity) { |
| 1087 | + wrap.addClass('fancybox-ie'); |
| 1088 | + } |
| 1089 | + |
| 1090 | + if (isIE6) { |
| 1091 | + loading.addClass('fancybox-ie6'); |
| 1092 | + wrap.addClass('fancybox-ie6'); |
| 1093 | + |
| 1094 | + $('<iframe id="fancybox-hide-sel-frame" src="' + (/^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank' ) + '" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer); |
| 1095 | + } |
1020 | 1096 | }; |
1021 | 1097 | |
1022 | 1098 | $.fn.fancybox.defaults = { |
1023 | | - padding : 10, |
1024 | | - margin : 20, |
1025 | | - opacity : false, |
1026 | | - modal : false, |
1027 | | - cyclic : false, |
1028 | | - scrolling : 'auto', // 'auto', 'yes' or 'no' |
| 1099 | + padding : 10, |
| 1100 | + margin : 40, |
| 1101 | + opacity : false, |
| 1102 | + modal : false, |
| 1103 | + cyclic : false, |
| 1104 | + scrolling : 'auto', // 'auto', 'yes' or 'no' |
1029 | 1105 | |
1030 | | - width : 560, |
1031 | | - height : 340, |
| 1106 | + width : 560, |
| 1107 | + height : 340, |
1032 | 1108 | |
1033 | | - autoScale : true, |
1034 | | - autoDimensions : true, |
1035 | | - centerOnScroll : false, |
| 1109 | + autoScale : true, |
| 1110 | + autoDimensions : true, |
| 1111 | + centerOnScroll : false, |
1036 | 1112 | |
1037 | | - ajax : {}, |
1038 | | - swf : { wmode: 'transparent' }, |
| 1113 | + ajax : {}, |
| 1114 | + swf : { wmode: 'transparent' }, |
1039 | 1115 | |
1040 | | - hideOnOverlayClick : true, |
1041 | | - hideOnContentClick : false, |
| 1116 | + hideOnOverlayClick : true, |
| 1117 | + hideOnContentClick : false, |
1042 | 1118 | |
1043 | | - overlayShow : true, |
1044 | | - overlayOpacity : 0.3, |
1045 | | - overlayColor : '#666', |
| 1119 | + overlayShow : true, |
| 1120 | + overlayOpacity : 0.7, |
| 1121 | + overlayColor : '#777', |
1046 | 1122 | |
1047 | | - titleShow : true, |
1048 | | - titlePosition : 'outside', // 'outside', 'inside' or 'over' |
1049 | | - titleFormat : null, |
| 1123 | + titleShow : true, |
| 1124 | + titlePosition : 'float', // 'float', 'outside', 'inside' or 'over' |
| 1125 | + titleFormat : null, |
| 1126 | + titleFromAlt : false, |
1050 | 1127 | |
1051 | | - transitionIn : 'fade', // 'elastic', 'fade' or 'none' |
1052 | | - transitionOut : 'fade', // 'elastic', 'fade' or 'none' |
| 1128 | + transitionIn : 'fade', // 'elastic', 'fade' or 'none' |
| 1129 | + transitionOut : 'fade', // 'elastic', 'fade' or 'none' |
1053 | 1130 | |
1054 | | - speedIn : 300, |
1055 | | - speedOut : 300, |
| 1131 | + speedIn : 300, |
| 1132 | + speedOut : 300, |
1056 | 1133 | |
1057 | | - changeSpeed : 300, |
1058 | | - changeFade : 'fast', |
| 1134 | + changeSpeed : 300, |
| 1135 | + changeFade : 'fast', |
1059 | 1136 | |
1060 | | - easingIn : 'swing', |
1061 | | - easingOut : 'swing', |
| 1137 | + easingIn : 'swing', |
| 1138 | + easingOut : 'swing', |
1062 | 1139 | |
1063 | | - showCloseButton : true, |
1064 | | - showNavArrows : true, |
1065 | | - enableEscapeButton : true, |
| 1140 | + showCloseButton : true, |
| 1141 | + showNavArrows : true, |
| 1142 | + enableEscapeButton : true, |
| 1143 | + enableKeyboardNav : true, |
1066 | 1144 | |
1067 | | - onStart : null, |
1068 | | - onCancel : null, |
1069 | | - onComplete : null, |
1070 | | - onCleanup : null, |
1071 | | - onClosed : null |
| 1145 | + onStart : function(){}, |
| 1146 | + onCancel : function(){}, |
| 1147 | + onComplete : function(){}, |
| 1148 | + onCleanup : function(){}, |
| 1149 | + onClosed : function(){}, |
| 1150 | + onError : function(){} |
1072 | 1151 | }; |
1073 | 1152 | |
1074 | 1153 | $(document).ready(function() { |
1075 | | - fancybox_init(); |
| 1154 | + $.fancybox.init(); |
1076 | 1155 | }); |
1077 | 1156 | |
1078 | 1157 | })(jQuery); |
\ No newline at end of file |