r87759 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87758‎ | r87759 | r87760 >
Date:19:22, 9 May 2011
Author:yaron
Status:deferred
Tags:
Comment:
Upgraded FancyBox to 1.3.4
Modified paths:
  • /trunk/extensions/SemanticForms/libs/jquery.fancybox.js (modified) (history)
  • /trunk/extensions/SemanticForms/skins/jquery.fancybox.css (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/skins/jquery.fancybox.css
@@ -5,8 +5,9 @@
66 * Examples and documentation at: http://fancybox.net
77 *
88 * 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)
1112 * Requires: jQuery v1.3+
1213 *
1314 * Dual licensed under the MIT and GPL licenses:
@@ -18,8 +19,8 @@
1920 position: fixed;
2021 top: 50%;
2122 left: 50%;
22 - height: 40px;
2323 width: 40px;
 24+ height: 40px;
2425 margin-top: -20px;
2526 margin-left: -20px;
2627 cursor: pointer;
@@ -28,11 +29,6 @@
2930 display: none;
3031 }
3132
32 -* html #fancybox-loading { /* IE6 */
33 - position: absolute;
34 - margin-top: 0;
35 -}
36 -
3733 #fancybox-loading div {
3834 position: absolute;
3935 top: 0;
@@ -43,21 +39,14 @@
4440 }
4541
4642 #fancybox-overlay {
47 - position: fixed;
 43+ position: absolute;
4844 top: 0;
4945 left: 0;
50 - bottom: 0;
51 - right: 0;
52 - background: #000;
 46+ width: 100%;
5347 z-index: 1100;
5448 display: none;
5549 }
5650
57 -* html #fancybox-overlay { /* IE6 */
58 - position: absolute;
59 - width: 100%;
60 -}
61 -
6251 #fancybox-tmp {
6352 padding: 0;
6453 margin: 0;
@@ -70,9 +59,9 @@
7160 position: absolute;
7261 top: 0;
7362 left: 0;
74 - margin: 0;
7563 padding: 20px;
7664 z-index: 1101;
 65+ outline: none;
7766 display: none;
7867 }
7968
@@ -80,19 +69,18 @@
8170 position: relative;
8271 width: 100%;
8372 height: 100%;
84 - background: #FFF;
 73+ background: #fff;
8574 }
8675
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;
9379 padding: 0;
94 - margin: 0;
9580 outline: none;
 81+ position: relative;
9682 overflow: hidden;
 83+ z-index: 1102;
 84+ border: 0px solid #fff;
9785 }
9886
9987 #fancybox-hide-sel-frame {
@@ -102,35 +90,28 @@
10391 width: 100%;
10492 height: 100%;
10593 background: transparent;
 94+ z-index: 1101;
10695 }
10796
10897 #fancybox-close {
10998 position: absolute;
11099 top: -15px;
111100 right: -15px;
112 - width: 27px;
 101+ width: 30px;
113102 height: 30px;
114 - background-image: url('../skins/fancy_close.png');
115 - background-position: -34px 0px;
 103+ background: transparent url('fancybox.png') -40px 0px;
116104 cursor: pointer;
117105 z-index: 1103;
118106 display: none;
119107 }
120108
121 -#fancybox_error {
 109+#fancybox-error {
122110 color: #444;
123111 font: normal 12px/20px Arial;
124 - padding: 7px;
 112+ padding: 14px;
125113 margin: 0;
126114 }
127115
128 -#fancybox-content {
129 - height: auto;
130 - width: auto;
131 - padding: 0;
132 - margin: 0;
133 -}
134 -
135116 #fancybox-img {
136117 width: 100%;
137118 height: 100%;
@@ -140,81 +121,15 @@
141122 outline: none;
142123 line-height: 0;
143124 vertical-align: top;
144 - -ms-interpolation-mode: bicubic;
145125 }
146126
147127 #fancybox-frame {
148 - position: relative;
149128 width: 100%;
150129 height: 100%;
151130 border: none;
152131 display: block;
153132 }
154133
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 -
219134 #fancybox-left, #fancybox-right {
220135 position: absolute;
221136 bottom: 0px;
@@ -222,7 +137,7 @@
223138 width: 35%;
224139 cursor: pointer;
225140 outline: none;
226 - background-image: url('blank.gif');
 141+ background: transparent url('blank.gif');
227142 z-index: 1102;
228143 display: none;
229144 }
@@ -258,7 +173,7 @@
259174 }
260175
261176 #fancybox-left:hover, #fancybox-right:hover {
262 - visibility: visible; /* IE6 */
 177+ visibility: visible; /* IE6 */
263178 }
264179
265180 #fancybox-left:hover span {
@@ -270,7 +185,7 @@
271186 right: 20px;
272187 }
273188
274 -.fancy-bg {
 189+.fancybox-bg {
275190 position: absolute;
276191 padding: 0;
277192 margin: 0;
@@ -280,21 +195,21 @@
281196 z-index: 1001;
282197 }
283198
284 -#fancy-bg-n {
 199+#fancybox-bg-n {
285200 top: -20px;
286201 left: 0;
287202 width: 100%;
288203 background-image: url('fancybox-x.png');
289204 }
290205
291 -#fancy-bg-ne {
 206+#fancybox-bg-ne {
292207 top: -20px;
293208 right: -20px;
294209 background-image: url('fancybox.png');
295210 background-position: -40px -162px;
296211 }
297212
298 -#fancy-bg-e {
 213+#fancybox-bg-e {
299214 top: 0;
300215 right: -20px;
301216 height: 100%;
@@ -302,14 +217,14 @@
303218 background-position: -20px 0px;
304219 }
305220
306 -#fancy-bg-se {
 221+#fancybox-bg-se {
307222 bottom: -20px;
308223 right: -20px;
309224 background-image: url('fancybox.png');
310225 background-position: -40px -182px;
311226 }
312227
313 -#fancy-bg-s {
 228+#fancybox-bg-s {
314229 bottom: -20px;
315230 left: 0;
316231 width: 100%;
@@ -317,47 +232,128 @@
318233 background-position: 0px -20px;
319234 }
320235
321 -#fancy-bg-sw {
 236+#fancybox-bg-sw {
322237 bottom: -20px;
323238 left: -20px;
324239 background-image: url('fancybox.png');
325240 background-position: -40px -142px;
326241 }
327242
328 -#fancy-bg-w {
 243+#fancybox-bg-w {
329244 top: 0;
330245 left: -20px;
331246 height: 100%;
332247 background-image: url('fancybox-y.png');
333248 }
334249
335 -#fancy-bg-nw {
 250+#fancybox-bg-nw {
336251 top: -20px;
337252 left: -20px;
338253 background-image: url('fancybox.png');
339254 background-position: -40px -122px;
340255 }
341256
342 -/* IE */
 257+#fancybox-title {
 258+ font-family: Helvetica;
 259+ font-size: 12px;
 260+ z-index: 1102;
 261+}
343262
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+}
346270
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+}
351275
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+}
354283
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+}
356289
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 @@
44 * Simple and fancy lightbox alternative
55 *
66 * Examples and documentation at: http://fancybox.net
7 - *
 7+ *
88 * 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.
910 *
10 - * Version: 1.3.1 (05/03/2010)
 11+ * Version: 1.3.4 (11/11/2010)
1112 * Requires: jQuery v1.3+
1213 *
1314 * Dual licensed under the MIT and GPL licenses:
@@ -14,25 +15,24 @@
1516 * http://www.gnu.org/licenses/gpl.html
1617 */
1718
18 -(function($) {
 19+;(function($) {
 20+ var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right,
1921
20 - var tmp, loading, overlay, wrap, outer, inner, close, nav_left, nav_right,
21 -
2222 selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],
2323
2424 ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,
2525
2626 loadingTimer, loadingFrame = 1,
2727
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 }),
2929
30 - isIE6 = !$.support.opacity && !window.XMLHttpRequest,
 30+ isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,
3131
3232 /*
3333 * Private methods
3434 */
3535
36 - fancybox_abort = function() {
 36+ _abort = function() {
3737 loading.hide();
3838
3939 imgPreloader.onerror = imgPreloader.onload = null;
@@ -44,402 +44,373 @@
4545 tmp.empty();
4646 },
4747
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+ }
5654
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();
5963 },
6064
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;
6473
65 - margin = currentOpts.margin,
66 - resize = currentOpts.autoScale,
 74+ _abort();
6775
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')));
7377
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);
7779
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);
8085 }
8186
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) || '';
8588
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);
8891 }
8992
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+ }
9496
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;
9698
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+ }
99102
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;
103108 }
104 - }
105109
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';
108112
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';
113116
114 - return to;
115 - },
 117+ } else if (href.match(swfRegExp)) {
 118+ type = 'swf';
116119
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';
126128 }
127129 }
128130
129 - return false;
130 - },
 131+ if (!type) {
 132+ _error();
 133+ return;
 134+ }
131135
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+ }
138140
139 - titleh = 0;
 141+ selectedOpts.type = type;
 142+ selectedOpts.href = href;
 143+ selectedOpts.title = title;
140144
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+ }
143152 }
144153
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;
149160 }
150161
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);
156164
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));
162166
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+ });
166170
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();
169175 break;
170 - }
171176
172 - $('#fancybox-title').appendTo( outer ).hide();
173 - },
 177+ case 'inline' :
 178+ if ( $(obj).parent().is('#fancybox-content') === true) {
 179+ busy = false;
 180+ return;
 181+ }
174182
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+ });
180191
181 - } else if (e.keyCode == 37) {
182 - e.preventDefault();
183 - $.fancybox.prev();
 192+ $(obj).appendTo(tmp);
184193
185 - } else if (e.keyCode == 39) {
186 - e.preventDefault();
187 - $.fancybox.next();
188 - }
189 - });
 194+ _process_inline();
 195+ break;
190196
191 - if ($.fn.mousewheel) {
192 - wrap.unbind('mousewheel.fb');
 197+ case 'image':
 198+ busy = false;
193199
194 - if (currentArray.length > 1) {
195 - wrap.bind('mousewheel.fb', function(e, delta) {
196 - e.preventDefault();
 200+ $.fancybox.showActivity();
197201
198 - if (busy || delta === 0) {
199 - return;
200 - }
 202+ imgPreloader = new Image();
201203
202 - if (delta > 0) {
203 - $.fancybox.prev();
204 - } else {
205 - $.fancybox.next();
206 - }
207 - });
208 - }
209 - }
 204+ imgPreloader.onerror = function() {
 205+ _error();
 206+ };
210207
211 - if (!currentOpts.showNavArrows) { return; }
 208+ imgPreloader.onload = function() {
 209+ busy = true;
212210
213 - if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
214 - nav_left.show();
215 - }
 211+ imgPreloader.onerror = imgPreloader.onload = null;
216212
217 - if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) {
218 - nav_right.show();
219 - }
220 - },
 213+ _process_image();
 214+ };
221215
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;
228218
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';
234221
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 = '';
237224
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+ });
244229
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>';
247231
248 - if (!$.support.opacity) {
249 - inner.get(0).style.removeAttribute('filter');
250 - wrap.get(0).style.removeAttribute('filter');
251 - }
 232+ tmp.html(str);
252233
253 - $('#fancybox-title').show();
 234+ _process_inline();
 235+ break;
254236
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;
261239
262 - if (currentOpts.showCloseButton) {
263 - close.show();
264 - }
 240+ $.fancybox.showActivity();
265241
266 - fancybox_set_navigation();
 242+ selectedOpts.ajax.win = selectedOpts.ajax.success;
267243
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);
269257
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+ }
275265
276 - if ($.isFunction(currentOpts.onComplete)) {
277 - currentOpts.onComplete(currentArray, currentIndex, currentOpts);
278 - }
 266+ tmp.html( data );
 267+ _process_inline();
 268+ }
 269+ }
 270+ }));
279271
280 - busy = false;
 272+ break;
281273
282 - fancybox_preload_images();
 274+ case 'iframe':
 275+ _show();
 276+ break;
 277+ }
283278 },
284279
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;
288284
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';
291287
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+ }
298291
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';
301294
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';
309297 }
310 - },
311298
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>');
314300
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();
317303
318 - pos.top += parseFloat( obj.css('border-top-width') ) || 0;
319 - pos.left += parseFloat( obj.css('border-left-width') ) || 0;
 304+ _show();
 305+ },
320306
321 - pos.width = obj.width();
322 - pos.height = obj.height();
 307+ _process_image = function() {
 308+ selectedOpts.width = imgPreloader.width;
 309+ selectedOpts.height = imgPreloader.height;
323310
324 - return pos;
 311+ $("<img />").attr({
 312+ 'id' : 'fancybox-img',
 313+ 'src' : imgPreloader.src,
 314+ 'alt' : selectedOpts.title
 315+ }).appendTo( tmp );
 316+
 317+ _show();
325318 },
326319
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;
332322
333 - if (orig && orig.length) {
334 - pos = fancybox_get_obj_pos(orig);
 323+ loading.hide();
335324
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');
345327
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;
352330 }
353331
354 - return from;
355 - },
 332+ busy = true;
356333
357 - fancybox_show = function() {
358 - loading.hide();
 334+ $(content.add( overlay )).unbind();
359335
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');
363338
364 - busy = false;
365 - return;
366 - }
 339+ if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') {
 340+ wrap.css('height', wrap.height());
367341 }
368342
369 - currentArray = selectedArray;
370 - currentIndex = selectedIndex;
371 - currentOpts = selectedOpts;
 343+ currentArray = selectedArray;
 344+ currentIndex = selectedIndex;
 345+ currentOpts = selectedOpts;
372346
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+ });
375354
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();
383365 }
384 -
385 - overlay.css({
386 - 'background-color' : currentOpts.overlayColor,
387 - 'opacity' : currentOpts.overlayOpacity
388 - }).unbind().show();
 366+ } else {
 367+ overlay.hide();
389368 }
390369
391 - final_pos = fancybox_get_zoom_to();
 370+ final_pos = _get_zoom_to();
392371
393 - fancybox_process_title();
 372+ _process_title();
394373
395374 if (wrap.is(":visible")) {
396375 $( close.add( nav_left ).add( nav_right ) ).hide();
397376
398 - var pos = wrap.position(),
399 - equal;
 377+ pos = wrap.position(),
400378
401379 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()
406384 };
407385
408386 equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);
409387
410 - inner.fadeOut(currentOpts.changeFade, function() {
 388+ content.fadeTo(currentOpts.changeFade, 0.3, function() {
411389 var finish_resizing = function() {
412 - inner.html( tmp.contents() ).fadeIn(currentOpts.changeFade, _finish);
 390+ content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish);
413391 };
414 -
 392+
415393 $.event.trigger('fancybox-change');
416394
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+ });
418403
419404 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 -
427405 finish_resizing();
428406
429407 } 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 -
437408 fx.prop = 0;
438409
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
444415 });
445416 }
446417 });
@@ -447,20 +418,16 @@
448419 return;
449420 }
450421
451 - wrap.css('opacity', 1);
 422+ wrap.removeAttr("style");
452423
 424+ content.css('border-width', currentOpts.padding);
 425+
453426 if (currentOpts.transitionIn == 'elastic') {
454 - start_pos = fancybox_get_zoom_from();
 427+ start_pos = _get_zoom_from();
455428
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() );
463430
464 - wrap.css(start_pos).show();
 431+ wrap.show();
465432
466433 if (currentOpts.opacity) {
467434 final_pos.opacity = 0;
@@ -468,297 +435,349 @@
469436
470437 fx.prop = 0;
471438
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
477444 });
478445
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+ }
487448
488 - wrap.css( final_pos ).fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish );
 449+ if (currentOpts.titlePosition == 'inside' && titleHeight > 0) {
 450+ title.show();
489451 }
 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 );
490463 },
491464
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+ }
495470
496 - if (selectedOpts.width == 'auto') {
497 - selectedOpts.width = tmp.width();
 471+ return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>';
498472 }
499 - if (selectedOpts.height == 'auto') {
500 - selectedOpts.height = tmp.height();
501 - }
502473
503 - fancybox_show();
 474+ return false;
504475 },
505 -
506 - fancybox_process_image = function() {
507 - busy = true;
508476
509 - selectedOpts.width = imgPreloader.width;
510 - selectedOpts.height = imgPreloader.height;
 477+ _process_title = function() {
 478+ titleStr = currentOpts.title || '';
 479+ titleHeight = 0;
511480
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();
517485
518 - fancybox_show();
519 - },
 486+ if (currentOpts.titleShow === false) {
 487+ title.hide();
 488+ return;
 489+ }
520490
521 - fancybox_start = function() {
522 - fancybox_abort();
 491+ titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr);
523492
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+ }
532497
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;
538545 }
539546
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+ });
542562 }
543563
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;
548568 }
549569
550 - if (selectedOpts.type) {
551 - type = selectedOpts.type;
 570+ if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
 571+ nav_left.show();
 572+ }
552573
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+ },
559578
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+ }
563584
564 - } else if (href.match(swfRegExp)) {
565 - type = 'swf';
 585+ if (selectedOpts.autoDimensions) {
 586+ content.css('height', 'auto');
 587+ }
566588
567 - } else if ($(obj).hasClass("iframe")) {
568 - type = 'iframe';
 589+ wrap.css('height', 'auto');
569590
570 - } else if (href.match(/#/)) {
571 - obj = href.substr(href.indexOf("#"));
 591+ if (titleStr && titleStr.length) {
 592+ title.show();
 593+ }
572594
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();
579597 }
580598
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+ }
584604
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);
588607 }
589608
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);
596613 }
597614
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);
603617 }
604618
605 - tmp.css('padding', (shadow + selectedOpts.padding + selectedOpts.margin));
 619+ wrap.show();
606620
607 - $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
608 - $(this).replaceWith(inner.children());
609 - });
 621+ busy = false;
610622
611 - switch (type) {
612 - case 'html' :
613 - tmp.html( selectedOpts.content );
614 - fancybox_process_inline();
615 - break;
 623+ $.fancybox.center();
616624
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);
623626
624 - $(obj).appendTo(tmp);
 627+ _preload_images();
 628+ },
625629
626 - fancybox_process_inline();
627 - break;
 630+ _preload_images = function() {
 631+ var href,
 632+ objNext;
628633
629 - case 'image':
630 - busy = false;
 634+ if ((currentArray.length -1) > currentIndex) {
 635+ href = currentArray[ currentIndex + 1 ].href;
631636
632 - $.fancybox.showActivity();
 637+ if (typeof href !== 'undefined' && href.match(imgRegExp)) {
 638+ objNext = new Image();
 639+ objNext.src = href;
 640+ }
 641+ }
633642
634 - imgPreloader = new Image();
 643+ if (currentIndex > 0) {
 644+ href = currentArray[ currentIndex - 1 ].href;
635645
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+ },
639652
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),
645657
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+ };
649661
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+ }
658665
659 - str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';
 666+ wrap.css(dim);
660667
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+ },
662673
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+ },
665682
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;
669689
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+ }
672695
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);
678709 }
679710
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+ }
682715
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+ }
694721
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);
696724
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;
702726 },
703727
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();
709730
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;
711733
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;
714736
715 - fancybox_init = function() {
716 - if ($("#fancybox-wrap").length) {
717 - return;
718 - }
 737+ pos.width = obj.width();
 738+ pos.height = obj.height();
719739
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+ },
726742
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;
731748
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);
735751
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+ };
739758
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();
743761
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+ }
746769
747 - nav_left.click(function(e) {
748 - e.preventDefault();
749 - $.fancybox.prev();
750 - });
 770+ return from;
 771+ },
751772
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+ }
756778
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');
760780
761 - outer.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>');
762 - }
 781+ loadingFrame = (loadingFrame + 1) % 12;
763782 };
764783
765784 /*
@@ -766,9 +785,14 @@
767786 */
768787
769788 $.fn.fancybox = function(options) {
 789+ if (!$(this).length) {
 790+ return this;
 791+ }
 792+
770793 $(this)
771794 .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) {
773797 e.preventDefault();
774798
775799 if (busy) {
@@ -779,8 +803,8 @@
780804
781805 $(this).blur();
782806
783 - selectedArray = [];
784 - selectedIndex = 0;
 807+ selectedArray = [];
 808+ selectedIndex = 0;
785809
786810 var rel = $(this).attr('rel') || '';
787811
@@ -788,30 +812,31 @@
789813 selectedArray.push(this);
790814
791815 } 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 );
794818 }
795819
796 - fancybox_start();
 820+ _start();
797821
798 - return false;
 822+ return;
799823 });
800824
801825 return this;
802826 };
803827
804828 $.fancybox = function(obj) {
 829+ var opts;
 830+
805831 if (busy) {
806832 return;
807833 }
808834
809835 busy = true;
 836+ opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};
810837
811 - var opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};
 838+ selectedArray = [];
 839+ selectedIndex = parseInt(opts.index, 10) || 0;
812840
813 - selectedArray = [];
814 - selectedIndex = opts.index || 0;
815 -
816841 if ($.isArray(obj)) {
817842 for (var i = 0, j = obj.length; i < j; i++) {
818843 if (typeof obj[i] == 'object') {
@@ -837,14 +862,14 @@
838863 selectedIndex = 0;
839864 }
840865
841 - fancybox_start();
 866+ _start();
842867 };
843868
844869 $.fancybox.showActivity = function() {
845870 clearInterval(loadingTimer);
846871
847872 loading.show();
848 - loadingTimer = setInterval(fancybox_animate_loading, 66);
 873+ loadingTimer = setInterval(_animate_loading, 66);
849874 };
850875
851876 $.fancybox.hideActivity = function() {
@@ -854,7 +879,7 @@
855880 $.fancybox.next = function() {
856881 return $.fancybox.pos( currentIndex + 1);
857882 };
858 -
 883+
859884 $.fancybox.prev = function() {
860885 return $.fancybox.pos( currentIndex - 1);
861886 };
@@ -864,23 +889,19 @@
865890 return;
866891 }
867892
868 - pos = parseInt(pos, 10);
 893+ pos = parseInt(pos);
869894
870 - if (pos > -1 && currentArray.length > pos) {
 895+ selectedArray = currentArray;
 896+
 897+ if (pos > -1 && pos < currentArray.length) {
871898 selectedIndex = pos;
872 - fancybox_start();
873 - }
 899+ _start();
874900
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();
878904 }
879905
880 - if (currentOpts.cyclic && currentArray.length > 1 && pos >= currentArray.length) {
881 - selectedIndex = 0;
882 - fancybox_start();
883 - }
884 -
885906 return;
886907 };
887908
@@ -893,11 +914,9 @@
894915
895916 $.event.trigger('fancybox-cancel');
896917
897 - fancybox_abort();
 918+ _abort();
898919
899 - if (selectedOpts && $.isFunction(selectedOpts.onCancel)) {
900 - selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);
901 - }
 920+ selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);
902921
903922 busy = false;
904923 };
@@ -910,69 +929,72 @@
911930
912931 busy = true;
913932
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;
919936 }
920937
921 - fancybox_abort();
 938+ _abort();
922939
923940 $(close.add( nav_left ).add( nav_right )).hide();
924941
925 - $('#fancybox-title').remove();
 942+ $(content.add( overlay )).unbind();
926943
927 - wrap.add(inner).add(overlay).unbind();
928 -
929944 $(window).unbind("resize.fb scroll.fb");
930945 $(document).unbind('keydown.fb');
931946
 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+
932955 function _cleanup() {
933956 overlay.fadeOut('fast');
934957
 958+ title.empty().hide();
935959 wrap.hide();
936960
937961 $.event.trigger('fancybox-cleanup');
938962
939 - inner.empty();
 963+ content.empty();
940964
941 - if ($.isFunction(currentOpts.onClosed)) {
942 - currentOpts.onClosed(currentArray, currentIndex, currentOpts);
943 - }
 965+ currentOpts.onClosed(currentArray, currentIndex, currentOpts);
944966
945 - currentArray = selectedOpts = [];
946 - currentIndex = selectedIndex = 0;
947 - currentOpts = selectedOpts = {};
 967+ currentArray = selectedOpts = [];
 968+ currentIndex = selectedIndex = 0;
 969+ currentOpts = selectedOpts = {};
948970
949971 busy = false;
950972 }
951973
952 - inner.css('overflow', 'hidden');
953 -
954974 if (currentOpts.transitionOut == 'elastic') {
955 - start_pos = fancybox_get_zoom_from();
 975+ start_pos = _get_zoom_from();
956976
957977 var pos = wrap.position();
958978
959979 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()
964984 };
965985
966986 if (currentOpts.opacity) {
967987 final_pos.opacity = 1;
968988 }
969989
 990+ title.empty().hide();
 991+
970992 fx.prop = 1;
971993
972994 $(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
977999 });
9781000
9791001 } else {
@@ -981,97 +1003,154 @@
9821004 };
9831005
9841006 $.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());
9891009 }
9901010
991 - busy = true;
 1011+ $.fancybox.center(true);
 1012+ };
9921013
993 - c = inner.wrapInner("<div style='overflow:auto'></div>").children();
994 - h = c.height();
 1014+ $.fancybox.center = function() {
 1015+ var view, align;
9951016
996 - wrap.css({height: h + (currentOpts.padding * 2) + titleh});
997 - inner.css({height: h});
 1017+ if (busy) {
 1018+ return;
 1019+ }
9981020
999 - c.replaceWith(c.children());
 1021+ align = arguments[0] === true ? 1 : 0;
 1022+ view = _get_viewport();
10001023
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);
10021034 };
10031035
1004 - $.fancybox.center = function() {
1005 - busy = true;
 1036+ $.fancybox.init = function() {
 1037+ if ($("#fancybox-wrap").length) {
 1038+ return;
 1039+ }
10061040
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+ );
10101047
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 );
10131051
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>'),
10161056
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+ );
10181060
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+ }
10201096 };
10211097
10221098 $.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'
10291105
1030 - width : 560,
1031 - height : 340,
 1106+ width : 560,
 1107+ height : 340,
10321108
1033 - autoScale : true,
1034 - autoDimensions : true,
1035 - centerOnScroll : false,
 1109+ autoScale : true,
 1110+ autoDimensions : true,
 1111+ centerOnScroll : false,
10361112
1037 - ajax : {},
1038 - swf : { wmode: 'transparent' },
 1113+ ajax : {},
 1114+ swf : { wmode: 'transparent' },
10391115
1040 - hideOnOverlayClick : true,
1041 - hideOnContentClick : false,
 1116+ hideOnOverlayClick : true,
 1117+ hideOnContentClick : false,
10421118
1043 - overlayShow : true,
1044 - overlayOpacity : 0.3,
1045 - overlayColor : '#666',
 1119+ overlayShow : true,
 1120+ overlayOpacity : 0.7,
 1121+ overlayColor : '#777',
10461122
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,
10501127
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'
10531130
1054 - speedIn : 300,
1055 - speedOut : 300,
 1131+ speedIn : 300,
 1132+ speedOut : 300,
10561133
1057 - changeSpeed : 300,
1058 - changeFade : 'fast',
 1134+ changeSpeed : 300,
 1135+ changeFade : 'fast',
10591136
1060 - easingIn : 'swing',
1061 - easingOut : 'swing',
 1137+ easingIn : 'swing',
 1138+ easingOut : 'swing',
10621139
1063 - showCloseButton : true,
1064 - showNavArrows : true,
1065 - enableEscapeButton : true,
 1140+ showCloseButton : true,
 1141+ showNavArrows : true,
 1142+ enableEscapeButton : true,
 1143+ enableKeyboardNav : true,
10661144
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(){}
10721151 };
10731152
10741153 $(document).ready(function() {
1075 - fancybox_init();
 1154+ $.fancybox.init();
10761155 });
10771156
10781157 })(jQuery);
\ No newline at end of file