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
8 * 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.
\r
10 * Version: 1.3.4 (11/11/2010)
\r
11 * Requires: jQuery v1.3+
\r
13 * Dual licensed under the MIT and GPL licenses:
\r
14 * http://www.opensource.org/licenses/mit-license.php
\r
15 * http://www.gnu.org/licenses/gpl.html
\r
19 var tmp, loading, overlay, wrap, outer, content, close, title, 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 titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),
\r
29 isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,
\r
35 _abort = function() {
\r
38 imgPreloader.onerror = imgPreloader.onload = null;
\r
47 _error = function() {
\r
48 if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) {
\r
54 selectedOpts.titleShow = false;
\r
56 selectedOpts.width = 'auto';
\r
57 selectedOpts.height = 'auto';
\r
59 tmp.html( '<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>' );
\r
64 _start = function() {
\r
65 var obj = selectedArray[ selectedIndex ],
\r
75 selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));
\r
77 ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts);
\r
79 if (ret === false) {
\r
82 } else if (typeof ret == 'object') {
\r
83 selectedOpts = $.extend(selectedOpts, ret);
\r
86 title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || '';
\r
88 if (obj.nodeName && !selectedOpts.orig) {
\r
89 selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
\r
92 if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) {
\r
93 title = selectedOpts.orig.attr('alt');
\r
96 href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null;
\r
98 if ((/^(?:javascript)/i).test(href) || href == '#') {
\r
102 if (selectedOpts.type) {
\r
103 type = selectedOpts.type;
\r
106 href = selectedOpts.content;
\r
109 } else if (selectedOpts.content) {
\r
113 if (href.match(imgRegExp)) {
\r
116 } else if (href.match(swfRegExp)) {
\r
119 } else if ($(obj).hasClass("iframe")) {
\r
122 } else if (href.indexOf("#") === 0) {
\r
135 if (type == 'inline') {
\r
136 obj = href.substr(href.indexOf("#"));
\r
137 type = $(obj).length > 0 ? 'inline' : 'ajax';
\r
140 selectedOpts.type = type;
\r
141 selectedOpts.href = href;
\r
142 selectedOpts.title = title;
\r
144 if (selectedOpts.autoDimensions) {
\r
145 if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') {
\r
146 selectedOpts.width = 'auto';
\r
147 selectedOpts.height = 'auto';
\r
149 selectedOpts.autoDimensions = false;
\r
153 if (selectedOpts.modal) {
\r
154 selectedOpts.overlayShow = true;
\r
155 selectedOpts.hideOnOverlayClick = false;
\r
156 selectedOpts.hideOnContentClick = false;
\r
157 selectedOpts.enableEscapeButton = false;
\r
158 selectedOpts.showCloseButton = false;
\r
161 selectedOpts.padding = parseInt(selectedOpts.padding, 10);
\r
162 selectedOpts.margin = parseInt(selectedOpts.margin, 10);
\r
164 tmp.css('padding', (selectedOpts.padding + selectedOpts.margin));
\r
166 $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
\r
167 $(this).replaceWith(content.children());
\r
172 tmp.html( selectedOpts.content );
\r
177 if ( $(obj).parent().is('#fancybox-content') === true) {
\r
182 $('<div class="fancybox-inline-tmp" />')
\r
184 .insertBefore( $(obj) )
\r
185 .bind('fancybox-cleanup', function() {
\r
186 $(this).replaceWith(content.children());
\r
187 }).bind('fancybox-cancel', function() {
\r
188 $(this).replaceWith(tmp.children());
\r
191 $(obj).appendTo(tmp);
\r
199 $.fancybox.showActivity();
\r
201 imgPreloader = new Image();
\r
203 imgPreloader.onerror = function() {
\r
207 imgPreloader.onload = function() {
\r
210 imgPreloader.onerror = imgPreloader.onload = null;
\r
215 imgPreloader.src = href;
\r
219 selectedOpts.scrolling = 'no';
\r
221 str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
\r
224 $.each(selectedOpts.swf, function(name, val) {
\r
225 str += '<param name="' + name + '" value="' + val + '"></param>';
\r
226 emb += ' ' + name + '="' + val + '"';
\r
229 str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';
\r
239 $.fancybox.showActivity();
\r
241 selectedOpts.ajax.win = selectedOpts.ajax.success;
\r
243 ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, {
\r
245 data : selectedOpts.ajax.data || {},
\r
246 error : function(XMLHttpRequest, textStatus, errorThrown) {
\r
247 if ( XMLHttpRequest.status > 0 ) {
\r
251 success : function(data, textStatus, XMLHttpRequest) {
\r
252 var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader;
\r
253 if (o.status == 200) {
\r
254 if ( typeof selectedOpts.ajax.win == 'function' ) {
\r
255 ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest);
\r
257 if (ret === false) {
\r
260 } else if (typeof ret == 'string' || typeof ret == 'object') {
\r
279 _process_inline = function() {
\r
281 w = selectedOpts.width,
\r
282 h = selectedOpts.height;
\r
284 if (w.toString().indexOf('%') > -1) {
\r
285 w = parseInt( ($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px';
\r
288 w = w == 'auto' ? 'auto' : w + 'px';
\r
291 if (h.toString().indexOf('%') > -1) {
\r
292 h = parseInt( ($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px';
\r
295 h = h == 'auto' ? 'auto' : h + 'px';
\r
298 tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>');
\r
300 selectedOpts.width = tmp.width();
\r
301 selectedOpts.height = tmp.height();
\r
306 _process_image = function() {
\r
307 selectedOpts.width = imgPreloader.width;
\r
308 selectedOpts.height = imgPreloader.height;
\r
310 $("<img />").attr({
\r
311 'id' : 'fancybox-img',
\r
312 'src' : imgPreloader.src,
\r
313 'alt' : selectedOpts.title
\r
314 }).appendTo( tmp );
\r
319 _show = function() {
\r
324 if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
\r
325 $.event.trigger('fancybox-cancel');
\r
333 $(content.add( overlay )).unbind();
\r
335 $(window).unbind("resize.fb scroll.fb");
\r
336 $(document).unbind('keydown.fb');
\r
338 if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') {
\r
339 wrap.css('height', wrap.height());
\r
342 currentArray = selectedArray;
\r
343 currentIndex = selectedIndex;
\r
344 currentOpts = selectedOpts;
\r
346 if (currentOpts.overlayShow) {
\r
348 'background-color' : currentOpts.overlayColor,
\r
349 'opacity' : currentOpts.overlayOpacity,
\r
350 'cursor' : currentOpts.hideOnOverlayClick ? 'pointer' : 'auto',
\r
351 'height' : $(document).height()
\r
354 if (!overlay.is(':visible')) {
\r
356 $('select:not(#fancybox-tmp select)').filter(function() {
\r
357 return this.style.visibility !== 'hidden';
\r
358 }).css({'visibility' : 'hidden'}).one('fancybox-cleanup', function() {
\r
359 this.style.visibility = 'inherit';
\r
369 final_pos = _get_zoom_to();
\r
373 if (wrap.is(":visible")) {
\r
374 $( close.add( nav_left ).add( nav_right ) ).hide();
\r
376 pos = wrap.position(),
\r
381 width : wrap.width(),
\r
382 height : wrap.height()
\r
385 equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);
\r
387 content.fadeTo(currentOpts.changeFade, 0.3, function() {
\r
388 var finish_resizing = function() {
\r
389 content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish);
\r
392 $.event.trigger('fancybox-change');
\r
396 .removeAttr('filter')
\r
398 'border-width' : currentOpts.padding,
\r
399 'width' : final_pos.width - currentOpts.padding * 2,
\r
400 'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
\r
409 $(fx).animate({prop: 1}, {
\r
410 duration : currentOpts.changeSpeed,
\r
411 easing : currentOpts.easingChange,
\r
413 complete : finish_resizing
\r
421 wrap.removeAttr("style");
\r
423 content.css('border-width', currentOpts.padding);
\r
425 if (currentOpts.transitionIn == 'elastic') {
\r
426 start_pos = _get_zoom_from();
\r
428 content.html( tmp.contents() );
\r
432 if (currentOpts.opacity) {
\r
433 final_pos.opacity = 0;
\r
438 $(fx).animate({prop: 1}, {
\r
439 duration : currentOpts.speedIn,
\r
440 easing : currentOpts.easingIn,
\r
448 if (currentOpts.titlePosition == 'inside' && titleHeight > 0) {
\r
454 'width' : final_pos.width - currentOpts.padding * 2,
\r
455 'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
\r
457 .html( tmp.contents() );
\r
461 .fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish );
\r
464 _format_title = function(title) {
\r
465 if (title && title.length) {
\r
466 if (currentOpts.titlePosition == 'float') {
\r
467 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>';
\r
470 return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>';
\r
476 _process_title = function() {
\r
477 titleStr = currentOpts.title || '';
\r
482 .removeAttr('style')
\r
485 if (currentOpts.titleShow === false) {
\r
490 titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr);
\r
492 if (!titleStr || titleStr === '') {
\r
498 .addClass('fancybox-title-' + currentOpts.titlePosition)
\r
500 .appendTo( 'body' )
\r
503 switch (currentOpts.titlePosition) {
\r
507 'width' : final_pos.width - (currentOpts.padding * 2),
\r
508 'marginLeft' : currentOpts.padding,
\r
509 'marginRight' : currentOpts.padding
\r
512 titleHeight = title.outerHeight(true);
\r
514 title.appendTo( outer );
\r
516 final_pos.height += titleHeight;
\r
522 'marginLeft' : currentOpts.padding,
\r
523 'width' : final_pos.width - (currentOpts.padding * 2),
\r
524 'bottom' : currentOpts.padding
\r
526 .appendTo( outer );
\r
531 .css('left', parseInt((title.width() - final_pos.width - 40)/ 2, 10) * -1)
\r
538 'width' : final_pos.width - (currentOpts.padding * 2),
\r
539 'paddingLeft' : currentOpts.padding,
\r
540 'paddingRight' : currentOpts.padding
\r
549 _set_navigation = function() {
\r
550 if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) {
\r
551 $(document).bind('keydown.fb', function(e) {
\r
552 if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
\r
553 e.preventDefault();
\r
554 $.fancybox.close();
\r
556 } else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
\r
557 e.preventDefault();
\r
558 $.fancybox[ e.keyCode == 37 ? 'prev' : 'next']();
\r
563 if (!currentOpts.showNavArrows) {
\r
569 if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
\r
573 if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) {
\r
578 _finish = function () {
\r
579 if (!$.support.opacity) {
\r
580 content.get(0).style.removeAttribute('filter');
\r
581 wrap.get(0).style.removeAttribute('filter');
\r
584 if (selectedOpts.autoDimensions) {
\r
585 content.css('height', 'auto');
\r
588 wrap.css('height', 'auto');
\r
590 if (titleStr && titleStr.length) {
\r
594 if (currentOpts.showCloseButton) {
\r
600 if (currentOpts.hideOnContentClick) {
\r
601 content.bind('click', $.fancybox.close);
\r
604 if (currentOpts.hideOnOverlayClick) {
\r
605 overlay.bind('click', $.fancybox.close);
\r
608 $(window).bind("resize.fb", $.fancybox.resize);
\r
610 if (currentOpts.centerOnScroll) {
\r
611 $(window).bind("scroll.fb", $.fancybox.center);
\r
614 if (currentOpts.type == 'iframe') {
\r
615 $('<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);
\r
622 $.fancybox.center();
\r
624 currentOpts.onComplete(currentArray, currentIndex, currentOpts);
\r
629 _preload_images = function() {
\r
633 if ((currentArray.length -1) > currentIndex) {
\r
634 href = currentArray[ currentIndex + 1 ].href;
\r
636 if (typeof href !== 'undefined' && href.match(imgRegExp)) {
\r
637 objNext = new Image();
\r
638 objNext.src = href;
\r
642 if (currentIndex > 0) {
\r
643 href = currentArray[ currentIndex - 1 ].href;
\r
645 if (typeof href !== 'undefined' && href.match(imgRegExp)) {
\r
646 objNext = new Image();
\r
647 objNext.src = href;
\r
652 _draw = function(pos) {
\r
654 width : parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10),
\r
655 height : parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10),
\r
657 top : parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10),
\r
658 left : parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10)
\r
661 if (typeof final_pos.opacity !== 'undefined') {
\r
662 dim.opacity = pos < 0.5 ? 0.5 : pos;
\r
668 'width' : dim.width - currentOpts.padding * 2,
\r
669 'height' : dim.height - (titleHeight * pos) - currentOpts.padding * 2
\r
673 _get_viewport = function() {
\r
675 $(window).width() - (currentOpts.margin * 2),
\r
676 $(window).height() - (currentOpts.margin * 2),
\r
677 $(document).scrollLeft() + currentOpts.margin,
\r
678 $(document).scrollTop() + currentOpts.margin
\r
682 _get_zoom_to = function () {
\r
683 var view = _get_viewport(),
\r
685 resize = currentOpts.autoScale,
\r
686 double_padding = currentOpts.padding * 2,
\r
689 if (currentOpts.width.toString().indexOf('%') > -1) {
\r
690 to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10);
\r
692 to.width = currentOpts.width + double_padding;
\r
695 if (currentOpts.height.toString().indexOf('%') > -1) {
\r
696 to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10);
\r
698 to.height = currentOpts.height + double_padding;
\r
701 if (resize && (to.width > view[0] || to.height > view[1])) {
\r
702 if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
\r
703 ratio = (currentOpts.width ) / (currentOpts.height );
\r
705 if ((to.width ) > view[0]) {
\r
706 to.width = view[0];
\r
707 to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10);
\r
710 if ((to.height) > view[1]) {
\r
711 to.height = view[1];
\r
712 to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10);
\r
716 to.width = Math.min(to.width, view[0]);
\r
717 to.height = Math.min(to.height, view[1]);
\r
721 to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10);
\r
722 to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10);
\r
727 _get_obj_pos = function(obj) {
\r
728 var pos = obj.offset();
\r
730 pos.top += parseInt( obj.css('paddingTop'), 10 ) || 0;
\r
731 pos.left += parseInt( obj.css('paddingLeft'), 10 ) || 0;
\r
733 pos.top += parseInt( obj.css('border-top-width'), 10 ) || 0;
\r
734 pos.left += parseInt( obj.css('border-left-width'), 10 ) || 0;
\r
736 pos.width = obj.width();
\r
737 pos.height = obj.height();
\r
742 _get_zoom_from = function() {
\r
743 var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
\r
748 if (orig && orig.length) {
\r
749 pos = _get_obj_pos(orig);
\r
752 width : pos.width + (currentOpts.padding * 2),
\r
753 height : pos.height + (currentOpts.padding * 2),
\r
754 top : pos.top - currentOpts.padding - 20,
\r
755 left : pos.left - currentOpts.padding - 20
\r
759 view = _get_viewport();
\r
762 width : currentOpts.padding * 2,
\r
763 height : currentOpts.padding * 2,
\r
764 top : parseInt(view[3] + view[1] * 0.5, 10),
\r
765 left : parseInt(view[2] + view[0] * 0.5, 10)
\r
772 _animate_loading = function() {
\r
773 if (!loading.is(':visible')){
\r
774 clearInterval(loadingTimer);
\r
778 $('div', loading).css('top', (loadingFrame * -40) + 'px');
\r
780 loadingFrame = (loadingFrame + 1) % 12;
\r
787 $.fn.fancybox = function(options) {
\r
788 if (!$(this).length) {
\r
793 .data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
\r
794 .unbind('click.fb')
\r
795 .bind('click.fb', function(e) {
\r
796 e.preventDefault();
\r
806 selectedArray = [];
\r
809 var rel = $(this).attr('rel') || '';
\r
811 if (!rel || rel == '' || rel === 'nofollow') {
\r
812 selectedArray.push(this);
\r
815 selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
\r
816 selectedIndex = selectedArray.index( this );
\r
827 $.fancybox = function(obj) {
\r
835 opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};
\r
837 selectedArray = [];
\r
838 selectedIndex = parseInt(opts.index, 10) || 0;
\r
840 if ($.isArray(obj)) {
\r
841 for (var i = 0, j = obj.length; i < j; i++) {
\r
842 if (typeof obj[i] == 'object') {
\r
843 $(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
\r
845 obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts));
\r
849 selectedArray = jQuery.merge(selectedArray, obj);
\r
852 if (typeof obj == 'object') {
\r
853 $(obj).data('fancybox', $.extend({}, opts, obj));
\r
855 obj = $({}).data('fancybox', $.extend({content : obj}, opts));
\r
858 selectedArray.push(obj);
\r
861 if (selectedIndex > selectedArray.length || selectedIndex < 0) {
\r
868 $.fancybox.showActivity = function() {
\r
869 clearInterval(loadingTimer);
\r
872 loadingTimer = setInterval(_animate_loading, 66);
\r
875 $.fancybox.hideActivity = function() {
\r
879 $.fancybox.next = function() {
\r
880 return $.fancybox.pos( currentIndex + 1);
\r
883 $.fancybox.prev = function() {
\r
884 return $.fancybox.pos( currentIndex - 1);
\r
887 $.fancybox.pos = function(pos) {
\r
892 pos = parseInt(pos);
\r
894 selectedArray = currentArray;
\r
896 if (pos > -1 && pos < currentArray.length) {
\r
897 selectedIndex = pos;
\r
900 } else if (currentOpts.cyclic && currentArray.length > 1) {
\r
901 selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1;
\r
908 $.fancybox.cancel = function() {
\r
915 $.event.trigger('fancybox-cancel');
\r
919 selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);
\r
924 // Note: within an iframe use - parent.$.fancybox.close();
\r
925 $.fancybox.close = function() {
\r
926 if (busy || wrap.is(':hidden')) {
\r
932 if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
\r
939 $(close.add( nav_left ).add( nav_right )).hide();
\r
941 $(content.add( overlay )).unbind();
\r
943 $(window).unbind("resize.fb scroll.fb");
\r
944 $(document).unbind('keydown.fb');
\r
946 content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank');
\r
948 if (currentOpts.titlePosition !== 'inside') {
\r
954 function _cleanup() {
\r
955 overlay.fadeOut('fast');
\r
957 title.empty().hide();
\r
960 $.event.trigger('fancybox-cleanup');
\r
964 currentOpts.onClosed(currentArray, currentIndex, currentOpts);
\r
966 currentArray = selectedOpts = [];
\r
967 currentIndex = selectedIndex = 0;
\r
968 currentOpts = selectedOpts = {};
\r
973 if (currentOpts.transitionOut == 'elastic') {
\r
974 start_pos = _get_zoom_from();
\r
976 var pos = wrap.position();
\r
981 width : wrap.width(),
\r
982 height : wrap.height()
\r
985 if (currentOpts.opacity) {
\r
986 final_pos.opacity = 1;
\r
989 title.empty().hide();
\r
993 $(fx).animate({ prop: 0 }, {
\r
994 duration : currentOpts.speedOut,
\r
995 easing : currentOpts.easingOut,
\r
997 complete : _cleanup
\r
1001 wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
\r
1005 $.fancybox.resize = function() {
\r
1006 if (overlay.is(':visible')) {
\r
1007 overlay.css('height', $(document).height());
\r
1010 $.fancybox.center(true);
\r
1013 $.fancybox.center = function() {
\r
1020 align = arguments[0] === true ? 1 : 0;
\r
1021 view = _get_viewport();
\r
1023 if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) {
\r
1030 'top' : parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)),
\r
1031 'left' : parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding))
\r
1032 }, typeof arguments[0] == 'number' ? arguments[0] : 200);
\r
1035 $.fancybox.init = function() {
\r
1036 if ($("#fancybox-wrap").length) {
\r
1041 tmp = $('<div id="fancybox-tmp"></div>'),
\r
1042 loading = $('<div id="fancybox-loading"><div></div></div>'),
\r
1043 overlay = $('<div id="fancybox-overlay"></div>'),
\r
1044 wrap = $('<div id="fancybox-wrap"></div>')
\r
1047 outer = $('<div id="fancybox-outer"></div>')
\r
1048 .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>')
\r
1049 .appendTo( wrap );
\r
1052 content = $('<div id="fancybox-content"></div>'),
\r
1053 close = $('<a id="fancybox-close"></a>'),
\r
1054 title = $('<div id="fancybox-title"></div>'),
\r
1056 nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
\r
1057 nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
\r
1060 close.click($.fancybox.close);
\r
1061 loading.click($.fancybox.cancel);
\r
1063 nav_left.click(function(e) {
\r
1064 e.preventDefault();
\r
1065 $.fancybox.prev();
\r
1068 nav_right.click(function(e) {
\r
1069 e.preventDefault();
\r
1070 $.fancybox.next();
\r
1073 if ($.fn.mousewheel) {
\r
1074 wrap.bind('mousewheel.fb', function(e, delta) {
\r
1076 e.preventDefault();
\r
1078 } else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) {
\r
1079 e.preventDefault();
\r
1080 $.fancybox[ delta > 0 ? 'prev' : 'next']();
\r
1085 if (!$.support.opacity) {
\r
1086 wrap.addClass('fancybox-ie');
\r
1090 loading.addClass('fancybox-ie6');
\r
1091 wrap.addClass('fancybox-ie6');
\r
1093 $('<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);
\r
1097 $.fn.fancybox.defaults = {
\r
1103 scrolling : 'auto', // 'auto', 'yes' or 'no'
\r
1109 autoDimensions : true,
\r
1110 centerOnScroll : false,
\r
1113 swf : { wmode: 'transparent' },
\r
1115 hideOnOverlayClick : true,
\r
1116 hideOnContentClick : false,
\r
1118 overlayShow : true,
\r
1119 overlayOpacity : 0.7,
\r
1120 overlayColor : '#777',
\r
1123 titlePosition : 'float', // 'float', 'outside', 'inside' or 'over'
\r
1124 titleFormat : null,
\r
1125 titleFromAlt : false,
\r
1127 transitionIn : 'fade', // 'elastic', 'fade' or 'none'
\r
1128 transitionOut : 'fade', // 'elastic', 'fade' or 'none'
\r
1133 changeSpeed : 300,
\r
1134 changeFade : 'fast',
\r
1136 easingIn : 'swing',
\r
1137 easingOut : 'swing',
\r
1139 showCloseButton : true,
\r
1140 showNavArrows : true,
\r
1141 enableEscapeButton : true,
\r
1142 enableKeyboardNav : true,
\r
1144 onStart : function(){},
\r
1145 onCancel : function(){},
\r
1146 onComplete : function(){},
\r
1147 onCleanup : function(){},
\r
1148 onClosed : function(){},
\r
1149 onError : function(){}
\r
1152 $(document).ready(function() {
\r
1153 $.fancybox.init();
\r