diff --git a/bookdetail.php b/bookdetail.php
index 5e86287..2529834 100644
--- a/bookdetail.php
+++ b/bookdetail.php
@@ -78,6 +78,6 @@ $book->getLinkArray ();
The requested content cannot be loaded.
Please try again later.
',
- closeBtn: 'The requested content cannot be loaded.
Please try again later.
',
+ closeBtn : '').html(content).find(current.selector);
- } else if (content instanceof $) {
- if (content.parent().hasClass('fancybox-inner')) {
- content.parents('.fancybox-wrap').unbind('onReset');
+ } else if (isQuery(content)) {
+ if (!content.data(placeholder)) {
+ content.data(placeholder, $('
').insertAfter( content ).hide() );
}
content = content.show().detach();
- $(F.wrap).bind('onReset', function () {
- content.appendTo('body').hide();
+ current.wrap.bind('onReset', function () {
+ if ($(this).find(content).length) {
+ content.hide().replaceAll( content.data(placeholder) ).data(placeholder, false);
+ }
});
}
-
- if (current.autoSize) {
- loadingBay = $('
')
- .appendTo('body')
- .css({
- minWidth : getValue(minWidth, 'w'),
- minHeight : getValue(minHeight, 'h'),
- maxWidth : getValue(maxWidth, 'w'),
- maxHeight : getValue(maxHeight, 'h')
- })
- .append(content);
-
- current.width = loadingBay.width();
- current.height = loadingBay.height();
-
- // Re-check to fix 1px bug in some browsers
- loadingBay.width( F.current.width );
-
- if (loadingBay.height() > current.height) {
- loadingBay.width(current.width + 1);
-
- current.width = loadingBay.width();
- current.height = loadingBay.height();
- }
-
- content = loadingBay.contents().detach();
-
- loadingBay.remove();
- }
-
- break;
+ break;
case 'image':
- content = current.tpl.image.replace('{href}', current.href);
-
- current.aspectRatio = true;
- break;
+ content = current.tpl.image.replace('{href}', href);
+ break;
case 'swf':
- content = current.tpl.swf.replace(/\{width\}/g, current.width).replace(/\{height\}/g, current.height).replace(/\{href\}/g, current.href);
- break;
+ content = '
';
+ break;
}
- if (type === 'image' || type === 'swf') {
- current.autoSize = false;
- current.scrolling = 'visible';
+ if (!(isQuery(content) && content.parent().is(current.inner))) {
+ current.inner.append( content );
}
- if (type === 'iframe' && current.autoSize) {
- F.showLoading();
-
- F._setDimension();
-
- F.inner.css('overflow', current.scrolling);
-
- content.bind({
- onCancel : function() {
- $(this).unbind();
-
- F._afterZoomOut();
- },
- load : function() {
- F.hideLoading();
-
- try {
- if (this.contentWindow.document.location) {
- F.current.height = $(this).contents().find('body').height();
- }
- } catch (e) {
- F.current.autoSize = false;
- }
-
- F[ F.isOpen ? '_afterZoomIn' : '_beforeShow']();
- }
- }).appendTo(F.inner);
-
- } else {
- F.inner.append(content);
-
- F._beforeShow();
- }
- },
-
- _beforeShow : function() {
- F.coming = null;
-
- //Give a chance for helpers or callbacks to update elements
+ // Give a chance for helpers or callbacks to update elements
F.trigger('beforeShow');
- //Set initial dimensions and hide
+ // Set scrolling before calculating dimensions
+ current.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
+
+ // Set initial dimensions and start position
F._setDimension();
- F.wrap.hide().removeClass('fancybox-tmp');
+
+ current.wrap.removeClass('fancybox-tmp');
+
+ current.pos = $.extend({}, current.dim, F._getPosition( true ));
+
+ F.isOpen = false;
+ F.coming = null;
F.bindEvents();
- F._preloadImages();
+ if (!F.isOpened) {
+ $('.fancybox-wrap').not( current.wrap ).stop(true).trigger('onReset').remove();
- F.transitions[ F.isOpened ? F.current.nextMethod : F.current.openMethod ]();
+ } else if (previous.prevMethod) {
+ F.transitions[ previous.prevMethod ]();
+ }
+
+ F.transitions[ F.isOpened ? current.nextMethod : current.openMethod ]();
+
+ F._preloadImages();
},
_setDimension: function () {
- var wrap = F.wrap,
- inner = F.inner,
- current = F.current,
- viewport = F.getViewport(),
- margin = current.margin,
- padding2 = current.padding * 2,
- width = current.width,
- height = current.height,
- maxWidth = current.maxWidth + padding2,
- maxHeight = current.maxHeight + padding2,
- minWidth = current.minWidth + padding2,
- minHeight = current.minHeight + padding2,
+ var viewport = F.getViewport(),
+ steps = 0,
+ canShrink = false,
+ canExpand = false,
+ wrap = F.wrap,
+ skin = F.skin,
+ inner = F.inner,
+ current = F.current,
+ width = current.width,
+ height = current.height,
+ minWidth = current.minWidth,
+ minHeight = current.minHeight,
+ maxWidth = current.maxWidth,
+ maxHeight = current.maxHeight,
+ scrolling = current.scrolling,
+ scrollOut = current.scrollOutside ? current.scrollbarWidth : 0,
+ margin = current.margin,
+ wMargin = margin[1] + margin[3],
+ hMargin = margin[0] + margin[2],
+ wPadding,
+ hPadding,
+ wSpace,
+ hSpace,
+ origWidth,
+ origHeight,
+ origMaxWidth,
+ origMaxHeight,
ratio,
- height_;
+ width_,
+ height_,
+ maxWidth_,
+ maxHeight_,
+ iframe,
+ body;
- viewport.w -= (margin[1] + margin[3]);
- viewport.h -= (margin[0] + margin[2]);
+ // Reset dimensions so we could re-check actual size
+ wrap.add(skin).add(inner).width('auto').height('auto');
- if (isPercentage(width)) {
- width = (((viewport.w - padding2) * parseFloat(width)) / 100);
+ wPadding = skin.outerWidth(true) - skin.width();
+ hPadding = skin.outerHeight(true) - skin.height();
+
+ // Any space between content and viewport (margin, padding, border, title)
+ wSpace = wMargin + wPadding;
+ hSpace = hMargin + hPadding;
+
+ origWidth = isPercentage(width) ? (viewport.w - wSpace) * getScalar(width) / 100 : width;
+ origHeight = isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100 : height;
+
+ if (current.type === 'iframe') {
+ iframe = current.content;
+
+ if (current.autoHeight && iframe.data('ready') === 1) {
+ try {
+ if (iframe[0].contentWindow.document.location) {
+ inner.width( origWidth ).height(9999);
+
+ body = iframe.contents().find('body');
+
+ if (scrollOut) {
+ body.css('overflow-x', 'hidden');
+ }
+
+ origHeight = body.height();
+ }
+
+ } catch (e) {}
+ }
+
+ } else if (current.autoWidth || current.autoHeight) {
+ inner.addClass( 'fancybox-tmp' );
+
+ // Set width or height in case we need to calculate only one dimension
+ if (!current.autoWidth) {
+ inner.width( origWidth );
+ }
+
+ if (!current.autoHeight) {
+ inner.height( origHeight );
+ }
+
+ if (current.autoWidth) {
+ origWidth = inner.width();
+ }
+
+ if (current.autoHeight) {
+ origHeight = inner.height();
+ }
+
+ inner.removeClass( 'fancybox-tmp' );
}
- if (isPercentage(height)) {
- height = (((viewport.h - padding2) * parseFloat(height)) / 100);
- }
+ width = getScalar( origWidth );
+ height = getScalar( origHeight );
- ratio = width / height;
- width += padding2;
- height += padding2;
+ ratio = origWidth / origHeight;
- if (current.fitToView) {
- maxWidth = Math.min(viewport.w, maxWidth);
- maxHeight = Math.min(viewport.h, maxHeight);
- }
+ // Calculations for the content
+ minWidth = getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace : minWidth);
+ maxWidth = getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace : maxWidth);
+
+ minHeight = getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace : minHeight);
+ maxHeight = getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace : maxHeight);
+
+ // These will be used to determine if wrap can fit in the viewport
+ origMaxWidth = maxWidth;
+ origMaxHeight = maxHeight;
+
+ maxWidth_ = viewport.w - wMargin;
+ maxHeight_ = viewport.h - hMargin;
if (current.aspectRatio) {
if (width > maxWidth) {
- width = maxWidth;
- height = ((width - padding2) / ratio) + padding2;
+ width = maxWidth;
+ height = width / ratio;
}
if (height > maxHeight) {
height = maxHeight;
- width = ((height - padding2) * ratio) + padding2;
+ width = height * ratio;
}
if (width < minWidth) {
- width = minWidth;
- height = ((width - padding2) / ratio) + padding2;
+ width = minWidth;
+ height = width / ratio;
}
if (height < minHeight) {
height = minHeight;
- width = ((height - padding2) * ratio) + padding2;
+ width = height * ratio;
}
} else {
- width = Math.max(minWidth, Math.min(width, maxWidth));
+ width = Math.max(minWidth, Math.min(width, maxWidth));
height = Math.max(minHeight, Math.min(height, maxHeight));
}
- width = Math.round(width);
- height = Math.round(height);
+ // Try to fit inside viewport (including the title)
+ if (current.fitToView) {
+ maxWidth = Math.min(viewport.w - wSpace, maxWidth);
+ maxHeight = Math.min(viewport.h - hSpace, maxHeight);
- //Reset dimensions
- $(wrap.add(inner)).width('auto').height('auto');
+ inner.width( getScalar( width ) ).height( getScalar( height ) );
- inner.width(width - padding2).height(height - padding2);
- wrap.width(width);
+ wrap.width( getScalar( width + wPadding ) );
- height_ = wrap.height(); // Real wrap height
+ // Real wrap dimensions
+ width_ = wrap.width();
+ height_ = wrap.height();
- //Fit wrapper inside
- if (width > maxWidth || height_ > maxHeight) {
- while ((width > maxWidth || height_ > maxHeight) && width > minWidth && height_ > minHeight) {
- height = height - 10;
-
- if (current.aspectRatio) {
- width = Math.round(((height - padding2) * ratio) + padding2);
-
- if (width < minWidth) {
- width = minWidth;
- height = ((width - padding2) / ratio) + padding2;
+ if (current.aspectRatio) {
+ while ((width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight) {
+ if (steps++ > 19) {
+ break;
}
- } else {
- width = width - 10;
+ height = Math.max(minHeight, Math.min(maxHeight, height - 10));
+ width = height * ratio;
+
+ if (width < minWidth) {
+ width = minWidth;
+ height = width / ratio;
+ }
+
+ if (width > maxWidth) {
+ width = maxWidth;
+ height = width / ratio;
+ }
+
+ inner.width( getScalar( width ) ).height( getScalar( height ) );
+
+ wrap.width( getScalar( width + wPadding ) );
+
+ width_ = wrap.width();
+ height_ = wrap.height();
}
- inner.width(width - padding2).height(height - padding2);
- wrap.width(width);
-
- height_ = wrap.height();
+ } else {
+ width = Math.max(minWidth, Math.min(width, width - (width_ - maxWidth_)));
+ height = Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_)));
}
}
- current.dim = {
- width : getValue(width),
- height : getValue(height_)
- };
-
- current.canGrow = current.autoSize && height > minHeight && height < maxHeight;
- current.canShrink = false;
- current.canExpand = false;
-
- if ((width - padding2) < current.width || (height - padding2) < current.height) {
- current.canExpand = true;
-
- } else if ((width > viewport.w || height_ > viewport.h) && width > minWidth && height > minHeight) {
- current.canShrink = true;
+ if (scrollOut && scrolling === 'auto' && height < origHeight && (width + wPadding + scrollOut) < maxWidth_) {
+ width += scrollOut;
}
- F.innerSpace = height_ - padding2 - inner.height();
+ inner.width( getScalar( width ) ).height( getScalar( height ) );
+
+ wrap.width( getScalar( width + wPadding ) );
+
+ width_ = wrap.width();
+ height_ = wrap.height();
+
+ canShrink = (width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight;
+ canExpand = current.aspectRatio ? (width < origMaxWidth && height < origMaxHeight && width < origWidth && height < origHeight) : ((width < origMaxWidth || height < origMaxHeight) && (width < origWidth || height < origHeight));
+
+ $.extend(current, {
+ dim : {
+ width : getValue( width_ ),
+ height : getValue( height_ )
+ },
+ origWidth : origWidth,
+ origHeight : origHeight,
+ canShrink : canShrink,
+ canExpand : canExpand,
+ wPadding : wPadding,
+ hPadding : hPadding,
+ wrapSpace : height_ - skin.outerHeight(true),
+ skinSpace : skin.height() - height
+ });
+
+ if (!iframe && current.autoHeight && height > minHeight && height < maxHeight && !canExpand) {
+ inner.height('auto');
+ }
},
_getPosition: function (onlyAbsolute) {
- var current = F.current,
- viewport = F.getViewport(),
- margin = current.margin,
- width = F.wrap.width() + margin[1] + margin[3],
- height = F.wrap.height() + margin[0] + margin[2],
- rez = {
+ var current = F.current,
+ viewport = F.getViewport(),
+ margin = current.margin,
+ width = F.wrap.width() + margin[1] + margin[3],
+ height = F.wrap.height() + margin[0] + margin[2],
+ rez = {
position: 'absolute',
- top : margin[0] + viewport.y,
- left : margin[3] + viewport.x
- };
-
- if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) {
- rez = {
- position: 'fixed',
top : margin[0],
left : margin[3]
};
+
+ if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) {
+ rez.position = 'fixed';
+
+ } else if (!current.locked) {
+ rez.top += viewport.y;
+ rez.left += viewport.x;
}
- rez.top = getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio)));
- rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * 0.5)));
+ rez.top = getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio)));
+ rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * current.leftRatio)));
return rez;
},
_afterZoomIn: function () {
- var current = F.current, scrolling = current ? current.scrolling : 'no';
+ var current = F.current;
if (!current) {
return;
@@ -1082,15 +1421,11 @@
F.isOpen = F.isOpened = true;
- F.wrap.addClass('fancybox-opened');
+ F.wrap.addClass('fancybox-opened').css('overflow', 'visible');
- F.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
+ F.reposition();
- F.trigger('afterShow');
-
- F.update();
-
- //Assign a click event
+ // Assign a click event
if (current.closeClick || current.nextClick) {
F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
@@ -1099,12 +1434,12 @@
});
}
- //Create a close button
+ // Create a close button
if (current.closeBtn) {
$(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', F.close);
}
- //Create navigation arrows
+ // Create navigation arrows
if (current.arrows && F.group.length > 1) {
if (current.loop || current.index > 0) {
$(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev);
@@ -1115,7 +1450,13 @@
}
}
- if (F.opts.autoPlay && !F.player.isActive) {
+ F.trigger('afterShow');
+
+ // Stop the slideshow if this is the last item
+ if (!current.loop && current.index === current.group.length - 1) {
+ F.play( false );
+
+ } else if (F.opts.autoPlay && !F.player.isActive) {
F.opts.autoPlay = false;
F.play();
@@ -1125,19 +1466,21 @@
_afterZoomOut: function () {
var current = F.current;
- F.wrap.trigger('onReset').remove();
+ $('.fancybox-wrap').stop(true).trigger('onReset').remove();
$.extend(F, {
- group: {},
- opts: {},
- current: null,
- isActive: false,
- isOpened: false,
- isOpen: false,
- wrap: null,
- skin: null,
- outer: null,
- inner: null
+ group : {},
+ opts : {},
+ router : false,
+ current : null,
+ isActive : false,
+ isOpened : false,
+ isOpen : false,
+ isClosing : false,
+ wrap : null,
+ skin : null,
+ outer : null,
+ inner : null
});
F.trigger('afterClose', current);
@@ -1150,123 +1493,120 @@
F.transitions = {
getOrigPosition: function () {
- var current = F.current,
- element = current.element,
- padding = current.padding,
- orig = $(current.orig),
- pos = {},
- width = 50,
- height = 50,
- viewport;
+ var current = F.current,
+ element = current.element,
+ orig = current.orig,
+ pos = {},
+ width = 50,
+ height = 50,
+ hPadding = current.hPadding,
+ wPadding = current.wPadding,
+ viewport = F.getViewport();
- if (!orig.length && current.isDom && $(element).is(':visible')) {
- orig = $(element).find('img:first');
+ if (!orig && current.isDom && element.is(':visible')) {
+ orig = element.find('img:first');
if (!orig.length) {
- orig = $(element);
+ orig = element;
}
}
- if (orig.length) {
+ if (isQuery(orig)) {
pos = orig.offset();
if (orig.is('img')) {
- width = orig.outerWidth();
+ width = orig.outerWidth();
height = orig.outerHeight();
}
} else {
- viewport = F.getViewport();
+ pos.top = viewport.y + (viewport.h - height) * current.topRatio;
+ pos.left = viewport.x + (viewport.w - width) * current.leftRatio;
+ }
- pos.top = viewport.y + (viewport.h - height) * 0.5;
- pos.left = viewport.x + (viewport.w - width) * 0.5;
+ if (current.locked) {
+ pos.top -= viewport.y;
+ pos.left -= viewport.x;
}
pos = {
- top : getValue(pos.top - padding),
- left : getValue(pos.left - padding),
- width : getValue(width + padding * 2),
- height : getValue(height + padding * 2)
+ top : getValue(pos.top - hPadding * current.topRatio),
+ left : getValue(pos.left - wPadding * current.leftRatio),
+ width : getValue(width + wPadding),
+ height : getValue(height + hPadding)
};
return pos;
},
step: function (now, fx) {
- var prop = fx.prop, value, ratio;
+ var ratio,
+ padding,
+ value,
+ prop = fx.prop,
+ current = F.current,
+ wrapSpace = current.wrapSpace,
+ skinSpace = current.skinSpace;
if (prop === 'width' || prop === 'height') {
- value = Math.ceil(now - (F.current.padding * 2));
+ ratio = fx.end === fx.start ? 1 : (now - fx.start) / (fx.end - fx.start);
- if (prop === 'height') {
- ratio = (now - fx.start) / (fx.end - fx.start);
-
- if (fx.start > fx.end) {
- ratio = 1 - ratio;
- }
-
- value -= F.innerSpace * ratio;
+ if (F.isClosing) {
+ ratio = 1 - ratio;
}
- F.inner[prop](value);
+ padding = prop === 'width' ? current.wPadding : current.hPadding;
+ value = now - padding;
+
+ F.skin[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) ) );
+ F.inner[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) - (skinSpace * ratio) ) );
}
},
zoomIn: function () {
- var wrap = F.wrap,
- current = F.current,
+ var current = F.current,
+ startPos = current.pos,
effect = current.openEffect,
elastic = effect === 'elastic',
- dim = current.dim,
- startPos = $.extend({}, dim, F._getPosition( elastic )),
endPos = $.extend({opacity : 1}, startPos);
- //Remove "position" property that breaks older IE
+ // Remove "position" property that breaks older IE
delete endPos.position;
if (elastic) {
startPos = this.getOrigPosition();
if (current.openOpacity) {
- startPos.opacity = 0;
+ startPos.opacity = 0.1;
}
- F.outer.add(F.inner).width('auto').height('auto');
-
} else if (effect === 'fade') {
- startPos.opacity = 0;
+ startPos.opacity = 0.1;
}
- wrap.css(startPos)
- .show()
- .animate(endPos, {
- duration : effect === 'none' ? 0 : current.openSpeed,
- easing : current.openEasing,
- step : elastic ? this.step : null,
- complete : F._afterZoomIn
- });
+ F.wrap.css(startPos).animate(endPos, {
+ duration : effect === 'none' ? 0 : current.openSpeed,
+ easing : current.openEasing,
+ step : elastic ? this.step : null,
+ complete : F._afterZoomIn
+ });
},
zoomOut: function () {
- var wrap = F.wrap,
- current = F.current,
- effect = current.openEffect,
+ var current = F.current,
+ effect = current.closeEffect,
elastic = effect === 'elastic',
- endPos = {opacity : 0};
+ endPos = {opacity : 0.1};
if (elastic) {
- if (wrap.css('position') === 'fixed') {
- wrap.css(F._getPosition(true));
- }
-
endPos = this.getOrigPosition();
if (current.closeOpacity) {
- endPos.opacity = 0;
+ endPos.opacity = 0.1;
}
}
- wrap.animate(endPos, {
+ F.wrap.animate(endPos, {
duration : effect === 'none' ? 0 : current.closeSpeed,
easing : current.closeEasing,
step : elastic ? this.step : null,
@@ -1275,48 +1615,59 @@
},
changeIn: function () {
- var wrap = F.wrap,
- current = F.current,
- effect = current.nextEffect,
- elastic = effect === 'elastic',
- startPos = F._getPosition( elastic ),
- endPos = { opacity : 1 };
+ var current = F.current,
+ effect = current.nextEffect,
+ startPos = current.pos,
+ endPos = { opacity : 1 },
+ direction = F.direction,
+ distance = 200,
+ field;
- startPos.opacity = 0;
+ startPos.opacity = 0.1;
- if (elastic) {
- startPos.top = getValue(parseInt(startPos.top, 10) - 200);
- endPos.top = '+=200px';
+ if (effect === 'elastic') {
+ field = direction === 'down' || direction === 'up' ? 'top' : 'left';
+
+ if (direction === 'down' || direction === 'right') {
+ startPos[ field ] = getValue(getScalar(startPos[ field ]) - distance);
+ endPos[ field ] = '+=' + distance + 'px';
+
+ } else {
+ startPos[ field ] = getValue(getScalar(startPos[ field ]) + distance);
+ endPos[ field ] = '-=' + distance + 'px';
+ }
}
- wrap.css(startPos)
- .show()
- .animate(endPos, {
- duration : effect === 'none' ? 0 : current.nextSpeed,
+ // Workaround for http://bugs.jquery.com/ticket/12273
+ if (effect === 'none') {
+ F._afterZoomIn();
+
+ } else {
+ F.wrap.css(startPos).animate(endPos, {
+ duration : current.nextSpeed,
easing : current.nextEasing,
complete : F._afterZoomIn
});
+ }
},
changeOut: function () {
- var wrap = F.wrap,
- current = F.current,
- effect = current.prevEffect,
- endPos = { opacity : 0 },
- cleanUp = function () {
- $(this).trigger('onReset').remove();
- };
-
- wrap.removeClass('fancybox-opened');
+ var previous = F.previous,
+ effect = previous.prevEffect,
+ endPos = { opacity : 0.1 },
+ direction = F.direction,
+ distance = 200;
if (effect === 'elastic') {
- endPos.top = '+=200px';
+ endPos[ direction === 'down' || direction === 'up' ? 'top' : 'left' ] = ( direction === 'up' || direction === 'left' ? '-' : '+' ) + '=' + distance + 'px';
}
- wrap.animate(endPos, {
- duration : effect === 'none' ? 0 : current.prevSpeed,
- easing : current.prevEasing,
- complete : cleanUp
+ previous.wrap.animate(endPos, {
+ duration : effect === 'none' ? 0 : previous.prevSpeed,
+ easing : previous.prevEasing,
+ complete : function () {
+ $(this).trigger('onReset').remove();
+ }
});
}
};
@@ -1329,59 +1680,103 @@
overlay: null,
update: function () {
- var width, scrollWidth, offsetWidth;
+ var width = '100%', offsetWidth;
- //Reset width/height so it will not mess
- this.overlay.width('100%').height('100%');
+ // Reset width/height so it will not mess
+ this.overlay.width(width).height('100%');
- if ($.browser.msie || isTouch) {
- scrollWidth = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);
+ // jQuery does not return reliable result for IE
+ if ($.browser.msie) {
offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
- width = scrollWidth < offsetWidth ? W.width() : scrollWidth;
+ if (D.width() > offsetWidth) {
+ width = D.width();
+ }
- } else {
+ } else if (D.width() > W.width()) {
width = D.width();
}
this.overlay.width(width).height(D.height());
},
- beforeShow: function (opts) {
- if (this.overlay) {
- return;
- }
+ // This is where we can manipulate DOM, because later it would cause iframes to reload
+ onReady: function (opts, obj) {
+ $('.fancybox-overlay').stop(true, true);
- opts = $.extend(true, {}, F.defaults.helpers.overlay, opts);
-
- this.overlay = $('
').css(opts.css).appendTo('body');
-
- if (opts.closeClick) {
- this.overlay.bind('click.fb', F.close);
- }
-
- if (F.current.fixed && !isTouch) {
- this.overlay.addClass('overlay-fixed');
-
- } else {
- this.update();
-
- this.onUpdate = function () {
- this.update();
- };
- }
-
- this.overlay.fadeTo(opts.speedIn, opts.opacity);
- },
-
- afterClose: function (opts) {
- if (this.overlay) {
- this.overlay.fadeOut(opts.speedOut || 0, function () {
- $(this).remove();
+ if (!this.overlay) {
+ $.extend(this, {
+ overlay : $('
').appendTo( obj.parent ),
+ margin : D.height() > W.height() || $('body').css('overflow-y') === 'scroll' ? $('body').css('margin-right') : false,
+ el : document.all && !document.querySelector ? $('html') : $('body')
});
}
- this.overlay = null;
+ if (obj.fixed && !isTouch) {
+ this.overlay.addClass('fancybox-overlay-fixed');
+
+ if (obj.autoCenter) {
+ this.overlay.append( obj.wrap );
+
+ obj.locked = this.overlay;
+ }
+ }
+
+ if (opts.showEarly === true) {
+ this.beforeShow.apply(this, arguments);
+ }
+ },
+
+ beforeShow : function(opts, obj) {
+ var overlay = this.overlay.unbind('.fb').width('auto').height('auto').css( opts.css );
+
+ if (opts.closeClick) {
+ overlay.bind('click.fb', function(e) {
+ if ($(e.target).hasClass('fancybox-overlay')) {
+ F.close();
+ }
+ });
+ }
+
+ if (obj.fixed && !isTouch) {
+ if (obj.locked) {
+ this.el.addClass('fancybox-lock');
+
+ if (this.margin !== false) {
+ $('body').css('margin-right', getScalar( this.margin ) + obj.scrollbarWidth);
+ }
+ }
+
+ } else {
+ this.update();
+ }
+
+ overlay.show();
+ },
+
+ onUpdate : function(opts, obj) {
+ if (!obj.fixed || isTouch) {
+ this.update();
+ }
+ },
+
+ afterClose: function (opts) {
+ var that = this,
+ speed = opts.speedOut || 0;
+
+ // Remove overlay if exists and fancyBox is not opening
+ // (e.g., it is not being open using afterClose callback)
+ if (that.overlay && !F.isActive) {
+ that.overlay.fadeOut(speed || 0, function () {
+ $('body').css('margin-right', that.margin);
+
+ that.el.removeClass('fancybox-lock');
+
+ that.overlay.remove();
+
+ that.overlay = null;
+ });
+ }
}
};
@@ -1391,43 +1786,67 @@
F.helpers.title = {
beforeShow: function (opts) {
- var title, text = F.current.title;
+ var text = F.current.title,
+ type = opts.type,
+ title,
+ target;
- if (text) {
- title = $('
' + text + '
').appendTo('body');
+ if (!isString(text) || $.trim(text) === '') {
+ return;
+ }
- if (opts.type === 'float') {
- //This helps for some browsers
- title.width(title.width());
+ title = $('
' + text + '
');
- title.wrapInner('
');
+ switch (type) {
+ case 'inside':
+ target = F.skin;
+ break;
- //Increase bottom margin so this title will also fit into viewport
- F.current.margin[2] += Math.abs(parseInt(title.css('margin-bottom'), 10));
- }
+ case 'outside':
+ target = F.wrap;
+ break;
- title.appendTo(opts.type === 'over' ? F.inner : (opts.type === 'outside' ? F.wrap : F.skin));
+ case 'over':
+ target = F.inner;
+ break;
+
+ default: // 'float'
+ target = F.skin;
+
+ title
+ .appendTo('body')
+ .width(title.width()) //This helps for some browsers
+ .wrapInner('
');
+
+ //Increase bottom margin so this title will also fit into viewport
+ F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) );
+ break;
+ }
+
+ if (opts.position === 'top') {
+ title.prependTo(target);
+
+ } else {
+ title.appendTo(target);
}
}
};
// jQuery plugin initialization
$.fn.fancybox = function (options) {
- var that = $(this),
+ var index,
+ that = $(this),
selector = this.selector || '',
- index,
run = function(e) {
- var what = this, idx = index, relType, relVal;
-
- if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !$(what).is('.fancybox-wrap')) {
- e.preventDefault();
+ var what = $(this).blur(), idx = index, relType, relVal;
+ if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !what.is('.fancybox-wrap')) {
relType = options.groupAttr || 'data-fancybox-group';
- relVal = $(what).attr(relType);
+ relVal = what.attr(relType);
if (!relVal) {
relType = 'rel';
- relVal = what[ relType ];
+ relVal = what.get(0)[ relType ];
}
if (relVal && relVal !== '' && relVal !== 'nofollow') {
@@ -1438,26 +1857,56 @@
options.index = idx;
- F.open(what, options);
+ // Stop an event from bubbling if everything is fine
+ if (F.open(what, options) !== false) {
+ e.preventDefault();
+ }
}
};
options = options || {};
index = options.index || 0;
- if (selector) {
- D.undelegate(selector, 'click.fb-start').delegate(selector, 'click.fb-start', run);
-
- } else {
+ if (!selector || options.live === false) {
that.unbind('click.fb-start').bind('click.fb-start', run);
+ } else {
+ D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run);
}
return this;
};
- // Test for fixedPosition needs a body at doc ready
- $(document).ready(function() {
- F.defaults.fixed = $.support.fixedPosition || (!($.browser.msie && $.browser.version <= 6) && !isTouch);
+ // Tests that need a body at doc ready
+ D.ready(function() {
+ if ( $.scrollbarWidth === undefined ) {
+ // http://benalman.com/projects/jquery-misc-plugins/#scrollbarwidth
+ $.scrollbarWidth = function() {
+ var parent = $('
').appendTo('body'),
+ child = parent.children(),
+ width = child.innerWidth() - child.height( 99 ).innerWidth();
+
+ parent.remove();
+
+ return width;
+ };
+ }
+
+ if ( $.support.fixedPosition === undefined ) {
+ $.support.fixedPosition = (function() {
+ var elem = $('
').appendTo('body'),
+ fixed = ( elem[0].offsetTop === 20 || elem[0].offsetTop === 15 );
+
+ elem.remove();
+
+ return fixed;
+ }());
+ }
+
+ $.extend(F.defaults, {
+ scrollbarWidth : $.scrollbarWidth(),
+ fixed : $.support.fixedPosition,
+ parent : $('body')
+ });
});
}(window, document, jQuery));
\ No newline at end of file
diff --git a/fancybox/jquery.fancybox.pack.js b/fancybox/jquery.fancybox.pack.js
index 6521c21..f39ab46 100644
--- a/fancybox/jquery.fancybox.pack.js
+++ b/fancybox/jquery.fancybox.pack.js
@@ -1,35 +1,44 @@
-/*! fancyBox v2.0.6 fancyapps.com | fancyapps.com/fancybox/#license */
-(function(s,l,d,t){var m=d(s),q=d(l),a=d.fancybox=function(){a.open.apply(this,arguments)},u=!1,k=l.createTouch!==t,o=function(a){return"string"===d.type(a)},n=function(b,c){c&&o(b)&&0
',image:'The requested content cannot be loaded.
Please try again later.
',
-closeBtn:'