2 * FancyBox - jQuery Plugin
\r
3 * Simple and fancy lightbox alternative
\r
5 * Examples and documentation at: http://fancybox.net
\r
7 * Copyright (c) 2008 - 2010 Janis Skarnelis
\r
9 * Version: 1.3.1 (05/03/2010)
\r
10 * Requires: jQuery v1.3+
\r
12 * Dual licensed under the MIT and GPL licenses:
\r
13 * http://www.opensource.org/licenses/mit-license.php
\r
14 * http://www.gnu.org/licenses/gpl.html
\r
19 var tmp, loading, overlay, wrap, outer, inner, close, nav_left, nav_right,
\r
21 selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],
\r
23 ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,
\r
25 loadingTimer, loadingFrame = 1,
\r
27 start_pos, final_pos, busy = false, shadow = 20, fx = $.extend($('<div/>')[0], { prop: 0 }), titleh = 0,
\r
29 isIE6 = !$.support.opacity && !window.XMLHttpRequest,
\r
35 fancybox_abort = function() {
\r
38 imgPreloader.onerror = imgPreloader.onload = null;
\r
47 fancybox_error = function() {
\r
48 $.fancybox('<p id="fancybox_error">The requested content cannot be loaded.<br />Please try again later.</p>', {
\r
51 'transitionIn' : 'none',
\r
52 'transitionOut' : 'none'
\r
56 fancybox_get_viewport = function() {
\r
57 return [ $(window).width(), $(window).height(), $(document).scrollLeft(), $(document).scrollTop() ];
\r
60 fancybox_get_zoom_to = function () {
\r
61 var view = fancybox_get_viewport(),
\r
64 margin = currentOpts.margin,
\r
65 resize = currentOpts.autoScale,
\r
67 horizontal_space = (shadow + margin) * 2,
\r
68 vertical_space = (shadow + margin) * 2,
\r
69 double_padding = (currentOpts.padding * 2),
\r
73 if (currentOpts.width.toString().indexOf('%') > -1) {
\r
74 to.width = ((view[0] * parseFloat(currentOpts.width)) / 100) - (shadow * 2) ;
\r
78 to.width = currentOpts.width + double_padding;
\r
81 if (currentOpts.height.toString().indexOf('%') > -1) {
\r
82 to.height = ((view[1] * parseFloat(currentOpts.height)) / 100) - (shadow * 2);
\r
86 to.height = currentOpts.height + double_padding;
\r
89 if (resize && (to.width > (view[0] - horizontal_space) || to.height > (view[1] - vertical_space))) {
\r
90 if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
\r
91 horizontal_space += double_padding;
\r
92 vertical_space += double_padding;
\r
94 ratio = Math.min(Math.min( view[0] - horizontal_space, currentOpts.width) / currentOpts.width, Math.min( view[1] - vertical_space, currentOpts.height) / currentOpts.height);
\r
96 to.width = Math.round(ratio * (to.width - double_padding)) + double_padding;
\r
97 to.height = Math.round(ratio * (to.height - double_padding)) + double_padding;
\r
100 to.width = Math.min(to.width, (view[0] - horizontal_space));
\r
101 to.height = Math.min(to.height, (view[1] - vertical_space));
\r
105 to.top = view[3] + ((view[1] - (to.height + (shadow * 2 ))) * 0.5);
\r
106 to.left = view[2] + ((view[0] - (to.width + (shadow * 2 ))) * 0.5);
\r
108 if (currentOpts.autoScale === false) {
\r
109 to.top = Math.max(view[3] + margin, to.top);
\r
110 to.left = Math.max(view[2] + margin, to.left);
\r
116 fancybox_format_title = function(title) {
\r
117 if (title && title.length) {
\r
118 switch (currentOpts.titlePosition) {
\r
122 return '<span id="fancybox-title-over">' + title + '</span>';
\r
124 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>';
\r
131 fancybox_process_title = function() {
\r
132 var title = currentOpts.title,
\r
133 width = final_pos.width - (currentOpts.padding * 2),
\r
134 titlec = 'fancybox-title-' + currentOpts.titlePosition;
\r
136 $('#fancybox-title').remove();
\r
140 if (currentOpts.titleShow === false) {
\r
144 title = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(title, currentArray, currentIndex, currentOpts) : fancybox_format_title(title);
\r
146 if (!title || title === '') {
\r
150 $('<div id="fancybox-title" class="' + titlec + '" />').css({
\r
152 'paddingLeft' : currentOpts.padding,
\r
153 'paddingRight' : currentOpts.padding
\r
154 }).html(title).appendTo('body');
\r
156 switch (currentOpts.titlePosition) {
\r
158 titleh = $("#fancybox-title").outerHeight(true) - currentOpts.padding;
\r
159 final_pos.height += titleh;
\r
163 $('#fancybox-title').css('bottom', currentOpts.padding);
\r
167 $('#fancybox-title').css('bottom', $("#fancybox-title").outerHeight(true) * -1);
\r
171 $('#fancybox-title').appendTo( outer ).hide();
\r
174 fancybox_set_navigation = function() {
\r
175 $(document).unbind('keydown.fb').bind('keydown.fb', function(e) {
\r
176 if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
\r
177 e.preventDefault();
\r
178 $.fancybox.close();
\r
180 } else if (e.keyCode == 37) {
\r
181 e.preventDefault();
\r
184 } else if (e.keyCode == 39) {
\r
185 e.preventDefault();
\r
190 if ($.fn.mousewheel) {
\r
191 wrap.unbind('mousewheel.fb');
\r
193 if (currentArray.length > 1) {
\r
194 wrap.bind('mousewheel.fb', function(e, delta) {
\r
195 e.preventDefault();
\r
197 if (busy || delta === 0) {
\r
210 if (!currentOpts.showNavArrows) { return; }
\r
212 if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
\r
216 if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) {
\r
221 fancybox_preload_images = function() {
\r
225 if ((currentArray.length -1) > currentIndex) {
\r
226 href = currentArray[ currentIndex + 1 ].href;
\r
228 if (typeof href !== 'undefined' && href.match(imgRegExp)) {
\r
229 objNext = new Image();
\r
230 objNext.src = href;
\r
234 if (currentIndex > 0) {
\r
235 href = currentArray[ currentIndex - 1 ].href;
\r
237 if (typeof href !== 'undefined' && href.match(imgRegExp)) {
\r
238 objNext = new Image();
\r
239 objNext.src = href;
\r
244 _finish = function () {
\r
245 inner.css('overflow', (currentOpts.scrolling == 'auto' ? (currentOpts.type == 'image' || currentOpts.type == 'iframe' || currentOpts.type == 'swf' ? 'hidden' : 'auto') : (currentOpts.scrolling == 'yes' ? 'auto' : 'visible')));
\r
247 if (!$.support.opacity) {
\r
248 inner.get(0).style.removeAttribute('filter');
\r
249 wrap.get(0).style.removeAttribute('filter');
\r
252 $('#fancybox-title').show();
\r
254 if (currentOpts.hideOnContentClick) {
\r
255 inner.one('click', $.fancybox.close);
\r
257 if (currentOpts.hideOnOverlayClick) {
\r
258 overlay.one('click', $.fancybox.close);
\r
261 if (currentOpts.showCloseButton) {
\r
265 fancybox_set_navigation();
\r
267 $(window).bind("resize.fb", $.fancybox.center);
\r
269 if (currentOpts.centerOnScroll) {
\r
270 $(window).bind("scroll.fb", $.fancybox.center);
\r
272 $(window).unbind("scroll.fb");
\r
275 if ($.isFunction(currentOpts.onComplete)) {
\r
276 currentOpts.onComplete(currentArray, currentIndex, currentOpts);
\r
281 fancybox_preload_images();
\r
284 fancybox_draw = function(pos) {
\r
285 var width = Math.round(start_pos.width + (final_pos.width - start_pos.width) * pos),
\r
286 height = Math.round(start_pos.height + (final_pos.height - start_pos.height) * pos),
\r
288 top = Math.round(start_pos.top + (final_pos.top - start_pos.top) * pos),
\r
289 left = Math.round(start_pos.left + (final_pos.left - start_pos.left) * pos);
\r
292 'width' : width + 'px',
\r
293 'height' : height + 'px',
\r
294 'top' : top + 'px',
\r
295 'left' : left + 'px'
\r
298 width = Math.max(width - currentOpts.padding * 2, 0);
\r
299 height = Math.max(height - (currentOpts.padding * 2 + (titleh * pos)), 0);
\r
302 'width' : width + 'px',
\r
303 'height' : height + 'px'
\r
306 if (typeof final_pos.opacity !== 'undefined') {
\r
307 wrap.css('opacity', (pos < 0.5 ? 0.5 : pos));
\r
311 fancybox_get_obj_pos = function(obj) {
\r
312 var pos = obj.offset();
\r
314 pos.top += parseFloat( obj.css('paddingTop') ) || 0;
\r
315 pos.left += parseFloat( obj.css('paddingLeft') ) || 0;
\r
317 pos.top += parseFloat( obj.css('border-top-width') ) || 0;
\r
318 pos.left += parseFloat( obj.css('border-left-width') ) || 0;
\r
320 pos.width = obj.width();
\r
321 pos.height = obj.height();
\r
326 fancybox_get_zoom_from = function() {
\r
327 var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
\r
332 if (orig && orig.length) {
\r
333 pos = fancybox_get_obj_pos(orig);
\r
336 width : (pos.width + (currentOpts.padding * 2)),
\r
337 height : (pos.height + (currentOpts.padding * 2)),
\r
338 top : (pos.top - currentOpts.padding - shadow),
\r
339 left : (pos.left - currentOpts.padding - shadow)
\r
343 view = fancybox_get_viewport();
\r
348 top : view[3] + view[1] * 0.5,
\r
349 left : view[2] + view[0] * 0.5
\r
356 fancybox_show = function() {
\r
359 if (wrap.is(":visible") && $.isFunction(currentOpts.onCleanup)) {
\r
360 if (currentOpts.onCleanup(currentArray, currentIndex, currentOpts) === false) {
\r
361 $.event.trigger('fancybox-cancel');
\r
368 currentArray = selectedArray;
\r
369 currentIndex = selectedIndex;
\r
370 currentOpts = selectedOpts;
\r
372 inner.get(0).scrollTop = 0;
\r
373 inner.get(0).scrollLeft = 0;
\r
375 if (currentOpts.overlayShow) {
\r
377 $('select:not(#fancybox-tmp select)').filter(function() {
\r
378 return this.style.visibility !== 'hidden';
\r
379 }).css({'visibility':'hidden'}).one('fancybox-cleanup', function() {
\r
380 this.style.visibility = 'inherit';
\r
385 'background-color' : currentOpts.overlayColor,
\r
386 'opacity' : currentOpts.overlayOpacity
\r
387 }).unbind().show();
\r
390 final_pos = fancybox_get_zoom_to();
\r
392 fancybox_process_title();
\r
394 if (wrap.is(":visible")) {
\r
395 $( close.add( nav_left ).add( nav_right ) ).hide();
\r
397 var pos = wrap.position(),
\r
403 width : wrap.width(),
\r
404 height : wrap.height()
\r
407 equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);
\r
409 inner.fadeOut(currentOpts.changeFade, function() {
\r
410 var finish_resizing = function() {
\r
411 inner.html( tmp.contents() ).fadeIn(currentOpts.changeFade, _finish);
\r
414 $.event.trigger('fancybox-change');
\r
416 inner.empty().css('overflow', 'hidden');
\r
420 top : currentOpts.padding,
\r
421 left : currentOpts.padding,
\r
422 width : Math.max(final_pos.width - (currentOpts.padding * 2), 1),
\r
423 height : Math.max(final_pos.height - (currentOpts.padding * 2) - titleh, 1)
\r
430 top : currentOpts.padding,
\r
431 left : currentOpts.padding,
\r
432 width : Math.max(start_pos.width - (currentOpts.padding * 2), 1),
\r
433 height : Math.max(start_pos.height - (currentOpts.padding * 2), 1)
\r
438 $(fx).animate({ prop: 1 }, {
\r
439 duration : currentOpts.changeSpeed,
\r
440 easing : currentOpts.easingChange,
\r
441 step : fancybox_draw,
\r
442 complete : finish_resizing
\r
450 wrap.css('opacity', 1);
\r
452 if (currentOpts.transitionIn == 'elastic') {
\r
453 start_pos = fancybox_get_zoom_from();
\r
456 top : currentOpts.padding,
\r
457 left : currentOpts.padding,
\r
458 width : Math.max(start_pos.width - (currentOpts.padding * 2), 1),
\r
459 height : Math.max(start_pos.height - (currentOpts.padding * 2), 1)
\r
461 .html( tmp.contents() );
\r
463 wrap.css(start_pos).show();
\r
465 if (currentOpts.opacity) {
\r
466 final_pos.opacity = 0;
\r
471 $(fx).animate({ prop: 1 }, {
\r
472 duration : currentOpts.speedIn,
\r
473 easing : currentOpts.easingIn,
\r
474 step : fancybox_draw,
\r
480 top : currentOpts.padding,
\r
481 left : currentOpts.padding,
\r
482 width : Math.max(final_pos.width - (currentOpts.padding * 2), 1),
\r
483 height : Math.max(final_pos.height - (currentOpts.padding * 2) - titleh, 1)
\r
485 .html( tmp.contents() );
\r
487 wrap.css( final_pos ).fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish );
\r
491 fancybox_process_inline = function() {
\r
492 tmp.width( selectedOpts.width );
\r
493 tmp.height( selectedOpts.height );
\r
495 if (selectedOpts.width == 'auto') {
\r
496 selectedOpts.width = tmp.width();
\r
498 if (selectedOpts.height == 'auto') {
\r
499 selectedOpts.height = tmp.height();
\r
505 fancybox_process_image = function() {
\r
508 selectedOpts.width = imgPreloader.width;
\r
509 selectedOpts.height = imgPreloader.height;
\r
511 $("<img />").attr({
\r
512 'id' : 'fancybox-img',
\r
513 'src' : imgPreloader.src,
\r
514 'alt' : selectedOpts.title
\r
515 }).appendTo( tmp );
\r
520 fancybox_start = function() {
\r
523 var obj = selectedArray[ selectedIndex ],
\r
532 selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));
\r
533 title = obj.title || $(obj).title || selectedOpts.title || '';
\r
535 if (obj.nodeName && !selectedOpts.orig) {
\r
536 selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
\r
539 if (title === '' && selectedOpts.orig) {
\r
540 title = selectedOpts.orig.attr('alt');
\r
543 if (obj.nodeName && (/^(?:javascript|#)/i).test(obj.href)) {
\r
544 href = selectedOpts.href || null;
\r
546 href = selectedOpts.href || obj.href || null;
\r
549 if (selectedOpts.type) {
\r
550 type = selectedOpts.type;
\r
553 href = selectedOpts.content;
\r
556 } else if (selectedOpts.content) {
\r
560 if (href.match(imgRegExp)) {
\r
563 } else if (href.match(swfRegExp)) {
\r
566 } else if ($(obj).hasClass("iframe")) {
\r
569 } else if (href.match(/#/)) {
\r
570 obj = href.substr(href.indexOf("#"));
\r
572 type = $(obj).length > 0 ? 'inline' : 'ajax';
\r
580 selectedOpts.type = type;
\r
581 selectedOpts.href = href;
\r
582 selectedOpts.title = title;
\r
584 if (selectedOpts.autoDimensions && selectedOpts.type !== 'iframe' && selectedOpts.type !== 'swf') {
\r
585 selectedOpts.width = 'auto';
\r
586 selectedOpts.height = 'auto';
\r
589 if (selectedOpts.modal) {
\r
590 selectedOpts.overlayShow = true;
\r
591 selectedOpts.hideOnOverlayClick = false;
\r
592 selectedOpts.hideOnContentClick = false;
\r
593 selectedOpts.enableEscapeButton = false;
\r
594 selectedOpts.showCloseButton = false;
\r
597 if ($.isFunction(selectedOpts.onStart)) {
\r
598 if (selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts) === false) {
\r
604 tmp.css('padding', (shadow + selectedOpts.padding + selectedOpts.margin));
\r
606 $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
\r
607 $(this).replaceWith(inner.children());
\r
612 tmp.html( selectedOpts.content );
\r
613 fancybox_process_inline();
\r
617 $('<div class="fancybox-inline-tmp" />').hide().insertBefore( $(obj) ).bind('fancybox-cleanup', function() {
\r
618 $(this).replaceWith(inner.children());
\r
619 }).bind('fancybox-cancel', function() {
\r
620 $(this).replaceWith(tmp.children());
\r
623 $(obj).appendTo(tmp);
\r
625 fancybox_process_inline();
\r
631 $.fancybox.showActivity();
\r
633 imgPreloader = new Image();
\r
635 imgPreloader.onerror = function() {
\r
639 imgPreloader.onload = function() {
\r
640 imgPreloader.onerror = null;
\r
641 imgPreloader.onload = null;
\r
642 fancybox_process_image();
\r
645 imgPreloader.src = href;
\r
650 str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
\r
653 $.each(selectedOpts.swf, function(name, val) {
\r
654 str += '<param name="' + name + '" value="' + val + '"></param>';
\r
655 emb += ' ' + name + '="' + val + '"';
\r
658 str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';
\r
662 fancybox_process_inline();
\r
666 selector = href.split('#', 2);
\r
667 data = selectedOpts.ajax.data || {};
\r
669 if (selector.length > 1) {
\r
670 href = selector[0];
\r
672 if (typeof data == "string") {
\r
673 data += '&selector=' + selector[1];
\r
675 data.selector = selector[1];
\r
680 $.fancybox.showActivity();
\r
682 ajaxLoader = $.ajax($.extend(selectedOpts.ajax, {
\r
685 error : fancybox_error,
\r
686 success : function(data, textStatus, XMLHttpRequest) {
\r
687 if (ajaxLoader.status == 200) {
\r
689 fancybox_process_inline();
\r
697 $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" scrolling="' + selectedOpts.scrolling + '" src="' + selectedOpts.href + '"></iframe>').appendTo(tmp);
\r
703 fancybox_animate_loading = function() {
\r
704 if (!loading.is(':visible')){
\r
705 clearInterval(loadingTimer);
\r
709 $('div', loading).css('top', (loadingFrame * -40) + 'px');
\r
711 loadingFrame = (loadingFrame + 1) % 12;
\r
714 fancybox_init = function() {
\r
715 if ($("#fancybox-wrap").length) {
\r
720 tmp = $('<div id="fancybox-tmp"></div>'),
\r
721 loading = $('<div id="fancybox-loading"><div></div></div>'),
\r
722 overlay = $('<div id="fancybox-overlay"></div>'),
\r
723 wrap = $('<div id="fancybox-wrap"></div>')
\r
726 if (!$.support.opacity) {
\r
727 wrap.addClass('fancybox-ie');
\r
728 loading.addClass('fancybox-ie');
\r
731 outer = $('<div id="fancybox-outer"></div>')
\r
732 .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>')
\r
736 inner = $('<div id="fancybox-inner"></div>'),
\r
737 close = $('<a id="fancybox-close"></a>'),
\r
739 nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
\r
740 nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
\r
743 close.click($.fancybox.close);
\r
744 loading.click($.fancybox.cancel);
\r
746 nav_left.click(function(e) {
\r
747 e.preventDefault();
\r
751 nav_right.click(function(e) {
\r
752 e.preventDefault();
\r
757 overlay.get(0).style.setExpression('height', "document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px'");
\r
758 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'");
\r
760 outer.prepend('<iframe id="fancybox-hide-sel-frame" src="javascript:\'\';" scrolling="no" frameborder="0" ></iframe>');
\r
768 $.fn.fancybox = function(options) {
\r
770 .data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
\r
771 .unbind('click.fb').bind('click.fb', function(e) {
\r
772 e.preventDefault();
\r
782 selectedArray = [];
\r
785 var rel = $(this).attr('rel') || '';
\r
787 if (!rel || rel == '' || rel === 'nofollow') {
\r
788 selectedArray.push(this);
\r
791 selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
\r
792 selectedIndex = selectedArray.index( this );
\r
803 $.fancybox = function(obj) {
\r
810 var opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};
\r
812 selectedArray = [];
\r
813 selectedIndex = opts.index || 0;
\r
815 if ($.isArray(obj)) {
\r
816 for (var i = 0, j = obj.length; i < j; i++) {
\r
817 if (typeof obj[i] == 'object') {
\r
818 $(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
\r
820 obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts));
\r
824 selectedArray = jQuery.merge(selectedArray, obj);
\r
827 if (typeof obj == 'object') {
\r
828 $(obj).data('fancybox', $.extend({}, opts, obj));
\r
830 obj = $({}).data('fancybox', $.extend({content : obj}, opts));
\r
833 selectedArray.push(obj);
\r
836 if (selectedIndex > selectedArray.length || selectedIndex < 0) {
\r
843 $.fancybox.showActivity = function() {
\r
844 clearInterval(loadingTimer);
\r
847 loadingTimer = setInterval(fancybox_animate_loading, 66);
\r
850 $.fancybox.hideActivity = function() {
\r
854 $.fancybox.next = function() {
\r
855 return $.fancybox.pos( currentIndex + 1);
\r
858 $.fancybox.prev = function() {
\r
859 return $.fancybox.pos( currentIndex - 1);
\r
862 $.fancybox.pos = function(pos) {
\r
867 pos = parseInt(pos, 10);
\r
869 if (pos > -1 && currentArray.length > pos) {
\r
870 selectedIndex = pos;
\r
874 if (currentOpts.cyclic && currentArray.length > 1 && pos < 0) {
\r
875 selectedIndex = currentArray.length - 1;
\r
879 if (currentOpts.cyclic && currentArray.length > 1 && pos >= currentArray.length) {
\r
887 $.fancybox.cancel = function() {
\r
894 $.event.trigger('fancybox-cancel');
\r
898 if (selectedOpts && $.isFunction(selectedOpts.onCancel)) {
\r
899 selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);
\r
905 // Note: within an iframe use - parent.$.fancybox.close();
\r
906 $.fancybox.close = function() {
\r
907 if (busy || wrap.is(':hidden')) {
\r
913 if (currentOpts && $.isFunction(currentOpts.onCleanup)) {
\r
914 if (currentOpts.onCleanup(currentArray, currentIndex, currentOpts) === false) {
\r
922 $(close.add( nav_left ).add( nav_right )).hide();
\r
924 $('#fancybox-title').remove();
\r
926 wrap.add(inner).add(overlay).unbind();
\r
928 $(window).unbind("resize.fb scroll.fb");
\r
929 $(document).unbind('keydown.fb');
\r
931 function _cleanup() {
\r
932 overlay.fadeOut('fast');
\r
936 $.event.trigger('fancybox-cleanup');
\r
940 if ($.isFunction(currentOpts.onClosed)) {
\r
941 currentOpts.onClosed(currentArray, currentIndex, currentOpts);
\r
944 currentArray = selectedOpts = [];
\r
945 currentIndex = selectedIndex = 0;
\r
946 currentOpts = selectedOpts = {};
\r
951 inner.css('overflow', 'hidden');
\r
953 if (currentOpts.transitionOut == 'elastic') {
\r
954 start_pos = fancybox_get_zoom_from();
\r
956 var pos = wrap.position();
\r
961 width : wrap.width(),
\r
962 height : wrap.height()
\r
965 if (currentOpts.opacity) {
\r
966 final_pos.opacity = 1;
\r
971 $(fx).animate({ prop: 0 }, {
\r
972 duration : currentOpts.speedOut,
\r
973 easing : currentOpts.easingOut,
\r
974 step : fancybox_draw,
\r
975 complete : _cleanup
\r
979 wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
\r
983 $.fancybox.resize = function() {
\r
986 if (busy || wrap.is(':hidden')) {
\r
992 c = inner.wrapInner("<div style='overflow:auto'></div>").children();
\r
995 wrap.css({height: h + (currentOpts.padding * 2) + titleh});
\r
996 inner.css({height: h});
\r
998 c.replaceWith(c.children());
\r
1000 $.fancybox.center();
\r
1003 $.fancybox.center = function() {
\r
1006 var view = fancybox_get_viewport(),
\r
1007 margin = currentOpts.margin,
\r
1010 to.top = view[3] + ((view[1] - ((wrap.height() - titleh) + (shadow * 2 ))) * 0.5);
\r
1011 to.left = view[2] + ((view[0] - (wrap.width() + (shadow * 2 ))) * 0.5);
\r
1013 to.top = Math.max(view[3] + margin, to.top);
\r
1014 to.left = Math.max(view[2] + margin, to.left);
\r
1021 $.fn.fancybox.defaults = {
\r
1027 scrolling : 'auto', // 'auto', 'yes' or 'no'
\r
1033 autoDimensions : true,
\r
1034 centerOnScroll : false,
\r
1037 swf : { wmode: 'transparent' },
\r
1039 hideOnOverlayClick : true,
\r
1040 hideOnContentClick : false,
\r
1042 overlayShow : true,
\r
1043 overlayOpacity : 0.3,
\r
1044 overlayColor : '#666',
\r
1047 titlePosition : 'outside', // 'outside', 'inside' or 'over'
\r
1048 titleFormat : null,
\r
1050 transitionIn : 'fade', // 'elastic', 'fade' or 'none'
\r
1051 transitionOut : 'fade', // 'elastic', 'fade' or 'none'
\r
1056 changeSpeed : 300,
\r
1057 changeFade : 'fast',
\r
1059 easingIn : 'swing',
\r
1060 easingOut : 'swing',
\r
1062 showCloseButton : true,
\r
1063 showNavArrows : true,
\r
1064 enableEscapeButton : true,
\r
1068 onComplete : null,
\r
1073 $(document).ready(function() {
\r