Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updating FancyBox to version 2.1.3

  • Loading branch information...
commit 511e1c418cf6c58e1d7339729027b010e91c591d 1 parent a4c9c37
Pascal Ehlert authored
15 vendor/assets/javascripts/jquery.fancybox-buttons.js
View
@@ -1,6 +1,6 @@
/*!
* Buttons helper for fancyBox
- * version: 1.0.3
+ * version: 1.0.5 (Mon, 15 Oct 2012)
* @requires fancyBox v2.0 or later
*
* Usage:
@@ -12,10 +12,6 @@
* }
* });
*
- * Options:
- * tpl - HTML template
- * position - 'top' or 'bottom'
- *
*/
(function ($) {
//Shortcut for fancyBox object
@@ -23,7 +19,12 @@
//Add helper object
F.helpers.buttons = {
- tpl : '<div id="fancybox-buttons"><ul><li><a class="btnPrev" title="Previous" href="javascript:;"></a></li><li><a class="btnPlay" title="Start slideshow" href="javascript:;"></a></li><li><a class="btnNext" title="Next" href="javascript:;"></a></li><li><a class="btnToggle" title="Toggle size" href="javascript:;"></a></li><li><a class="btnClose" title="Close" href="javascript:jQuery.fancybox.close();"></a></li></ul></div>',
+ defaults : {
+ skipSingle : false, // disables if gallery contains single image
+ position : 'top', // 'top' or 'bottom'
+ tpl : '<div id="fancybox-buttons"><ul><li><a class="btnPrev" title="Previous" href="javascript:;"></a></li><li><a class="btnPlay" title="Start slideshow" href="javascript:;"></a></li><li><a class="btnNext" title="Next" href="javascript:;"></a></li><li><a class="btnToggle" title="Toggle size" href="javascript:;"></a></li><li><a class="btnClose" title="Close" href="javascript:jQuery.fancybox.close();"></a></li></ul></div>'
+ },
+
list : null,
buttons: null,
@@ -57,7 +58,7 @@
var buttons = this.buttons;
if (!buttons) {
- this.list = $(opts.tpl || this.tpl).addClass(opts.position || 'top').appendTo('body');
+ this.list = $(opts.tpl).addClass(opts.position).appendTo('body');
buttons = {
prev : this.list.find('.btnPrev').click( F.prev ),
12 vendor/assets/javascripts/jquery.fancybox-media.js
View
@@ -1,6 +1,6 @@
/*!
* Media helper for fancyBox
- * version: 1.0.3 (Mon, 13 Aug 2012)
+ * version: 1.0.5 (Tue, 23 Oct 2012)
* @requires fancyBox v2.0 or later
*
* Usage:
@@ -37,6 +37,7 @@
*
* Youtube
* http://www.youtube.com/watch?v=opj24KnzrWo
+ * http://www.youtube.com/embed/opj24KnzrWo
* http://youtu.be/opj24KnzrWo
* Vimeo
* http://vimeo.com/40648169
@@ -85,9 +86,9 @@
//Add helper object
F.helpers.media = {
- types : {
+ defaults : {
youtube : {
- matcher : /(youtube\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed)?([\w-]{11}|\?listType=(.*)&list=(.*)).*/i,
+ matcher : /(youtube\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed\/?)?(videoseries\?list=(.*)|[\w-]{11}|\?listType=(.*)&list=(.*)).*/i,
params : {
autoplay : 1,
autohide : 1,
@@ -108,7 +109,6 @@
show_title : 1,
show_byline : 1,
show_portrait : 0,
- color : '',
fullscreen : 1
},
type : 'iframe',
@@ -170,8 +170,8 @@
rez,
params;
- for (what in this.types) {
- item = this.types[ what ];
+ for (what in opts) {
+ item = opts[ what ];
rez = url.match( item.matcher );
if (rez) {
50 vendor/assets/javascripts/jquery.fancybox-thumbs.js
View
@@ -1,6 +1,6 @@
/*!
* Thumbnail helper for fancyBox
- * version: 1.0.6
+ * version: 1.0.7 (Mon, 01 Oct 2012)
* @requires fancyBox v2.0 or later
*
* Usage:
@@ -13,12 +13,6 @@
* }
* });
*
- * Options:
- * width - thumbnail width
- * height - thumbnail height
- * source - function to obtain the URL of the thumbnail image
- * position - 'top' or 'bottom'
- *
*/
(function ($) {
//Shortcut for fancyBox object
@@ -26,31 +20,35 @@
//Add helper object
F.helpers.thumbs = {
- wrap : null,
- list : null,
- width : 0,
-
- //Default function to obtain the URL of the thumbnail image
- source: function ( item ) {
- var href;
+ defaults : {
+ width : 50, // thumbnail width
+ height : 50, // thumbnail height
+ position : 'bottom', // 'top' or 'bottom'
+ source : function ( item ) { // function to obtain the URL of the thumbnail image
+ var href;
+
+ if (item.element) {
+ href = $(item.element).find('img').attr('src');
+ }
- if (item.element) {
- href = $(item.element).find('img').attr('src');
- }
+ if (!href && item.type === 'image' && item.href) {
+ href = item.href;
+ }
- if (!href && item.type === 'image' && item.href) {
- href = item.href;
+ return href;
}
-
- return href;
},
+ wrap : null,
+ list : null,
+ width : 0,
+
init: function (opts, obj) {
var that = this,
list,
- thumbWidth = opts.width || 50,
- thumbHeight = opts.height || 50,
- thumbSource = opts.source || this.source;
+ thumbWidth = opts.width,
+ thumbHeight = opts.height,
+ thumbSource = opts.source;
//Build list structure
list = '';
@@ -59,7 +57,7 @@
list += '<li><a style="width:' + thumbWidth + 'px;height:' + thumbHeight + 'px;" href="javascript:jQuery.fancybox.jumpto(' + n + ');"></a></li>';
}
- this.wrap = $('<div id="fancybox-thumbs"></div>').addClass(opts.position || 'bottom').appendTo('body');
+ this.wrap = $('<div id="fancybox-thumbs"></div>').addClass(opts.position).appendTo('body');
this.list = $('<ul>' + list + '</ul>').appendTo(this.wrap);
//Load each thumbnail
@@ -125,7 +123,7 @@
}
//Increase bottom margin to give space for thumbs
- obj.margin[ opts.position === 'top' ? 0 : 2 ] += ((opts.height || 50) + 15);
+ obj.margin[ opts.position === 'top' ? 0 : 2 ] += ((opts.height) + 15);
},
afterShow: function (opts, obj) {
409 vendor/assets/javascripts/jquery.fancybox.js
View
@@ -1,6 +1,6 @@
/*!
* fancyBox - jQuery Plugin
- * version: 2.1.0 (Mon, 20 Aug 2012)
+ * version: 2.1.3 (Tue, 23 Oct 2012)
* @requires jQuery v1.6 or later
*
* Examples at http://fancyapps.com/fancybox/
@@ -33,14 +33,14 @@
isScrollable = function(el) {
return (el && !(el.style.overflow && el.style.overflow === 'hidden') && ((el.clientWidth && el.scrollWidth > el.clientWidth) || (el.clientHeight && el.scrollHeight > el.clientHeight)));
},
- getScalar = function(value, dim) {
- var value_ = parseInt(value, 10);
+ getScalar = function(orig, dim) {
+ var value = parseInt(orig, 10) || 0;
- if (dim && isPercentage(value)) {
- value_ = F.getViewport()[ dim ] / 100 * value_;
+ if (dim && isPercentage(orig)) {
+ value = F.getViewport()[ dim ] / 100 * value;
}
- return Math.ceil(value_);
+ return Math.ceil(value);
},
getValue = function(value, dim) {
return getScalar(value, dim) + 'px';
@@ -48,7 +48,7 @@
$.extend(F, {
// The current version of fancyBox
- version: '2.1.0',
+ version: '2.1.3',
defaults: {
padding : 15,
@@ -65,7 +65,7 @@
autoHeight : false,
autoWidth : false,
- autoResize : !isTouch,
+ autoResize : true,
autoCenter : !isTouch,
fitToView : true,
aspectRatio : false,
@@ -136,7 +136,7 @@
tpl: {
wrap : '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',
image : '<img class="fancybox-image" src="{href}" alt="" />',
- iframe : '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0"' + ($.browser.msie ? ' allowtransparency="true"' : '') + '></iframe>',
+ iframe : '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen' + ($.browser.msie ? ' allowtransparency="true"' : '') + '></iframe>',
error : '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',
next : '<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
@@ -170,17 +170,10 @@
prevEasing : 'swing',
prevMethod : 'changeOut',
- // Enabled helpers
+ // Enable default helpers
helpers : {
- overlay : {
- closeClick : true,
- speedOut : 200,
- showEarly : true,
- css : {}
- },
- title : {
- type : 'float' // 'float', 'inside', 'outside' or 'over'
- }
+ overlay : true,
+ title : true
},
// Callbacks
@@ -264,8 +257,8 @@
if (isQuery(element)) {
obj = {
- href : element.attr('href'),
- title : element.attr('title'),
+ href : element.data('fancybox-href') || element.attr('href'),
+ title : element.data('fancybox-title') || element.attr('title'),
isDom : true,
element : element
};
@@ -383,20 +376,20 @@
F.imgPreload.onload = F.imgPreload.onerror = null;
}
- // If the first item has been canceled, then clear everything
if (coming.wrap) {
- coming.wrap.stop(true).trigger('onReset').remove();
+ coming.wrap.stop(true, true).trigger('onReset').remove();
}
+ F.coming = null;
+
+ // If the first item has been canceled, then clear everything
if (!F.current) {
- F.trigger('afterClose');
+ F._afterZoomOut( coming );
}
-
- F.coming = null;
},
// Start closing animation if is open; remove immediately if opening/closing
- close: function (immediately) {
+ close: function (event) {
F.cancel();
if (false === F.trigger('beforeClose')) {
@@ -405,7 +398,11 @@
F.unbindEvents();
- if (!F.isOpen || immediately === true) {
+ if (!F.isActive) {
+ return;
+ }
+
+ if (!F.isOpen || event === true) {
$('.fancybox-wrap').stop(true).trigger('onReset').remove();
F._afterZoomOut();
@@ -418,10 +415,6 @@
F.wrap.stop(true, true).removeClass('fancybox-opened');
- if (F.wrap.css('position') === 'fixed') {
- F.wrap.css(F._getPosition( true ));
- }
-
F.transitions[ F.current.closeMethod ]();
}
},
@@ -529,18 +522,22 @@
// Center inside viewport and toggle position type to fixed or absolute if needed
reposition: function (e, onlyAbsolute) {
- var pos;
+ var current = F.current,
+ wrap = current ? current.wrap : null,
+ pos;
- if (F.isOpen) {
+ if (wrap) {
pos = F._getPosition(onlyAbsolute);
if (e && e.type === 'scroll') {
delete pos.position;
- F.wrap.stop(true, true).animate(pos, 200);
+ wrap.stop(true, true).animate(pos, 200);
} else {
- F.wrap.css(pos);
+ wrap.css(pos);
+
+ current.pos = $.extend({}, current.dim, pos);
}
}
},
@@ -559,23 +556,16 @@
return;
}
- // Help browser to restore document dimensions
- if (anyway || isTouch) {
- F.wrap.removeAttr('style').addClass('fancybox-tmp');
-
- F.trigger('onUpdate');
- }
-
didUpdate = setTimeout(function() {
var current = F.current;
- if (!current) {
+ if (!current || F.isClosing) {
return;
}
F.wrap.removeClass('fancybox-tmp');
- if (type !== 'scroll') {
+ if (anyway || type === 'load' || (type === 'resize' && current.autoResize)) {
F._setDimension();
}
@@ -587,7 +577,7 @@
didUpdate = null;
- }, (isTouch ? 500 : (anyway ? 20 : 300)));
+ }, (anyway && !isTouch ? 0 : 300));
},
// Shrink content to fit inside viewport or restore if resized
@@ -595,12 +585,19 @@
if (F.isOpen) {
F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView;
+ // Help browser to restore document dimensions
+ if (isTouch) {
+ F.wrap.removeAttr('style').addClass('fancybox-tmp');
+
+ F.trigger('onUpdate');
+ }
+
F.update();
}
},
hideLoading: function () {
- D.unbind('keypress.fb');
+ D.unbind('.loading');
$('#fancybox-loading').remove();
},
@@ -610,16 +607,17 @@
F.hideLoading();
+ el = $('<div id="fancybox-loading"><div></div></div>').click(F.cancel).appendTo('body');
+
// If user will press the escape-button, the request will be canceled
- D.bind('keypress.fb', function(e) {
+ D.bind('keydown.loading', function(e) {
if ((e.which || e.keyCode) === 27) {
e.preventDefault();
+
F.cancel();
}
});
- el = $('<div id="fancybox-loading"><div></div></div>').click(F.cancel).appendTo('body');
-
if (!F.defaults.fixed) {
viewport = F.getViewport();
@@ -632,15 +630,15 @@
},
getViewport: function () {
- var lock = F.current ? F.current.locked : false,
- rez = {
+ var locked = (F.current && F.current.locked) || false,
+ rez = {
x: W.scrollLeft(),
y: W.scrollTop()
};
- if (lock) {
- rez.w = lock[0].clientWidth;
- rez.h = lock[0].clientHeight;
+ if (locked) {
+ rez.w = locked[0].clientWidth;
+ rez.h = locked[0].clientHeight;
} else {
// See http://bugs.jquery.com/ticket/6724
@@ -671,7 +669,7 @@
// Changing document height on iOS devices triggers a 'resize' event,
// that can change document height... repeating infinitely
- W.bind('orientationchange.fb' + (isTouch ? '' : ' resize.fb' ) + (current.autoCenter && !current.locked ? ' scroll.fb' : ''), F.update);
+ W.bind('orientationchange.fb' + (isTouch ? '' : ' resize.fb') + (current.autoCenter && !current.locked ? ' scroll.fb' : ''), F.update);
keys = current.keys;
@@ -680,6 +678,11 @@
var code = e.which || e.keyCode,
target = e.target || e.srcElement;
+ // Skip esc key if loading, because showLoading will cancel preloading
+ if (code === 27 && F.coming) {
+ return false;
+ }
+
// Ignore key combinations and key events within form elements
if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) {
$.each(keys, function(i, val) {
@@ -747,13 +750,11 @@
return false;
}
- if (event === 'onCancel' && !F.isOpened) {
- F.isActive = false;
- }
-
if (obj.helpers) {
$.each(obj.helpers, function (helper, opts) {
if (opts && F.helpers[helper] && $.isFunction(F.helpers[helper][event])) {
+ opts = $.extend(true, {}, F.helpers[helper].defaults, opts);
+
F.helpers[helper][event](opts, obj);
}
});
@@ -763,7 +764,7 @@
},
isImage: function (str) {
- return isString(str) && str.match(/\.(jp(e|g|eg)|gif|png|bmp|webp)((\?|#).*)?$/i);
+ return isString(str) && str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp)((\?|#).*)?$)/i);
},
isSWF: function (str) {
@@ -880,7 +881,7 @@
}
// Build the neccessary markup
- coming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent );
+ coming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent || 'body' );
$.extend(coming, {
skin : $('.fancybox-skin', coming.wrap),
@@ -954,7 +955,7 @@
img.src = F.coming.href;
- if (img.complete === undefined || !img.complete) {
+ if (img.complete !== true) {
F.showLoading();
}
},
@@ -1072,10 +1073,6 @@
previous.wrap.stop(true).removeClass('fancybox-opened')
.find('.fancybox-item, .fancybox-nav')
.remove();
-
- if (previous.wrap.css('position') === 'fixed') {
- previous.wrap.css(F._getPosition( true ));
- }
}
F.unbindEvents();
@@ -1123,7 +1120,7 @@
break;
case 'swf':
- content = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="' + href + '"></param>';
+ content = '<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="' + href + '"></param>';
embed = '';
$.each(current.swf, function(name, val) {
@@ -1148,9 +1145,7 @@
// Set initial dimensions and start position
F._setDimension();
- current.wrap.removeClass('fancybox-tmp');
-
- current.pos = $.extend({}, current.dim, F._getPosition( true ));
+ F.reposition();
F.isOpen = false;
F.coming = null;
@@ -1187,8 +1182,8 @@
scrolling = current.scrolling,
scrollOut = current.scrollOutside ? current.scrollbarWidth : 0,
margin = current.margin,
- wMargin = margin[1] + margin[3],
- hMargin = margin[0] + margin[2],
+ wMargin = getScalar(margin[1] + margin[3]),
+ hMargin = getScalar(margin[0] + margin[2]),
wPadding,
hPadding,
wSpace,
@@ -1206,10 +1201,10 @@
body;
// Reset dimensions so we could re-check actual size
- wrap.add(skin).add(inner).width('auto').height('auto');
+ wrap.add(skin).add(inner).width('auto').height('auto').removeClass('fancybox-tmp');
- wPadding = skin.outerWidth(true) - skin.width();
- hPadding = skin.outerHeight(true) - skin.height();
+ wPadding = getScalar(skin.outerWidth(true) - skin.width());
+ hPadding = getScalar(skin.outerHeight(true) - skin.height());
// Any space between content and viewport (margin, padding, border, title)
wSpace = wMargin + wPadding;
@@ -1277,43 +1272,52 @@
origMaxWidth = maxWidth;
origMaxHeight = maxHeight;
+ if (current.fitToView) {
+ maxWidth = Math.min(viewport.w - wSpace, maxWidth);
+ maxHeight = Math.min(viewport.h - hSpace, maxHeight);
+ }
+
maxWidth_ = viewport.w - wMargin;
maxHeight_ = viewport.h - hMargin;
if (current.aspectRatio) {
if (width > maxWidth) {
width = maxWidth;
- height = width / ratio;
+ height = getScalar(width / ratio);
}
if (height > maxHeight) {
height = maxHeight;
- width = height * ratio;
+ width = getScalar(height * ratio);
}
if (width < minWidth) {
width = minWidth;
- height = width / ratio;
+ height = getScalar(width / ratio);
}
if (height < minHeight) {
height = minHeight;
- width = height * ratio;
+ width = getScalar(height * ratio);
}
} else {
- width = Math.max(minWidth, Math.min(width, maxWidth));
+ width = Math.max(minWidth, Math.min(width, maxWidth));
+
+ if (current.autoHeight && current.type !== 'iframe') {
+ inner.width( width );
+
+ height = inner.height();
+ }
+
height = Math.max(minHeight, Math.min(height, maxHeight));
}
// 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);
+ inner.width( width ).height( height );
- inner.width( getScalar( width ) ).height( getScalar( height ) );
-
- wrap.width( getScalar( width + wPadding ) );
+ wrap.width( width + wPadding );
// Real wrap dimensions
width_ = wrap.width();
@@ -1326,21 +1330,21 @@
}
height = Math.max(minHeight, Math.min(maxHeight, height - 10));
- width = height * ratio;
+ width = getScalar(height * ratio);
if (width < minWidth) {
width = minWidth;
- height = width / ratio;
+ height = getScalar(width / ratio);
}
if (width > maxWidth) {
width = maxWidth;
- height = width / ratio;
+ height = getScalar(width / ratio);
}
- inner.width( getScalar( width ) ).height( getScalar( height ) );
+ inner.width( width ).height( height );
- wrap.width( getScalar( width + wPadding ) );
+ wrap.width( width + wPadding );
width_ = wrap.width();
height_ = wrap.height();
@@ -1356,9 +1360,9 @@
width += scrollOut;
}
- inner.width( getScalar( width ) ).height( getScalar( height ) );
+ inner.width( width ).height( height );
- wrap.width( getScalar( width + wPadding ) );
+ wrap.width( width + wPadding );
width_ = wrap.width();
height_ = wrap.height();
@@ -1421,14 +1425,16 @@
F.isOpen = F.isOpened = true;
- F.wrap.addClass('fancybox-opened').css('overflow', 'visible');
+ F.wrap.css('overflow', 'visible').addClass('fancybox-opened');
- F.reposition();
+ F.update();
// Assign a click event
- if (current.closeClick || current.nextClick) {
+ if ( current.closeClick || (current.nextClick && F.group.length > 1) ) {
F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
+ e.preventDefault();
+
F[ current.closeClick ? 'close' : 'next' ]();
}
});
@@ -1436,7 +1442,11 @@
// Create a close button
if (current.closeBtn) {
- $(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', F.close);
+ $(current.tpl.closeBtn).appendTo(F.skin).bind( isTouch ? 'touchstart.fb' : 'click.fb', function(e) {
+ e.preventDefault();
+
+ F.close();
+ });
}
// Create navigation arrows
@@ -1463,10 +1473,10 @@
}
},
- _afterZoomOut: function () {
- var current = F.current;
+ _afterZoomOut: function ( obj ) {
+ obj = obj || F.current;
- $('.fancybox-wrap').stop(true).trigger('onReset').remove();
+ $('.fancybox-wrap').trigger('onReset').remove();
$.extend(F, {
group : {},
@@ -1483,7 +1493,7 @@
inner : null
});
- F.trigger('afterClose', current);
+ F.trigger('afterClose', obj);
}
});
@@ -1524,7 +1534,7 @@
pos.left = viewport.x + (viewport.w - width) * current.leftRatio;
}
- if (current.locked) {
+ if (F.wrap.css('position') === 'fixed' || current.locked) {
pos.top -= viewport.y;
pos.left -= viewport.x;
}
@@ -1646,7 +1656,10 @@
F.wrap.css(startPos).animate(endPos, {
duration : current.nextSpeed,
easing : current.nextEasing,
- complete : F._afterZoomIn
+ complete : function() {
+ // This helps FireFox to properly render the box
+ setTimeout(F._afterZoomIn, 20);
+ }
});
}
},
@@ -1677,9 +1690,90 @@
*/
F.helpers.overlay = {
- overlay: null,
+ defaults : {
+ closeClick : true, // if true, fancyBox will be closed when user clicks on the overlay
+ speedOut : 200, // duration of fadeOut animation
+ showEarly : true, // indicates if should be opened immediately or wait until the content is ready
+ css : {}, // custom CSS properties
+ locked : !isTouch, // if true, the content will be locked into overlay
+ fixed : true // if false, the overlay CSS position property will not be set to "fixed"
+ },
- update: function () {
+ overlay : null, // current handle
+ fixed : false, // indicates if the overlay has position "fixed"
+
+ // Public methods
+ create : function(opts) {
+ opts = $.extend({}, this.defaults, opts);
+
+ if (this.overlay) {
+ this.close();
+ }
+
+ this.overlay = $('<div class="fancybox-overlay"></div>').appendTo( 'body' );
+ this.fixed = false;
+
+ if (opts.fixed && F.defaults.fixed) {
+ this.overlay.addClass('fancybox-overlay-fixed');
+
+ this.fixed = true;
+ }
+ },
+
+ open : function(opts) {
+ var that = this;
+
+ opts = $.extend({}, this.defaults, opts);
+
+ if (this.overlay) {
+ this.overlay.unbind('.overlay').width('auto').height('auto');
+
+ } else {
+ this.create(opts);
+ }
+
+ if (!this.fixed) {
+ W.bind('resize.overlay', $.proxy( this.update, this) );
+
+ this.update();
+ }
+
+ if (opts.closeClick) {
+ this.overlay.bind('click.overlay', function(e) {
+ if ($(e.target).hasClass('fancybox-overlay')) {
+ if (F.isActive) {
+ F.close();
+ } else {
+ that.close();
+ }
+ }
+ });
+ }
+
+ this.overlay.css( opts.css ).show();
+ },
+
+ close : function() {
+ $('.fancybox-overlay').remove();
+
+ W.unbind('resize.overlay');
+
+ this.overlay = null;
+
+ if (this.margin !== false) {
+ $('body').css('margin-right', this.margin);
+
+ this.margin = false;
+ }
+
+ if (this.el) {
+ this.el.removeClass('fancybox-lock');
+ }
+ },
+
+ // Private, callbacks
+
+ update : function () {
var width = '100%', offsetWidth;
// Reset width/height so it will not mess
@@ -1701,25 +1795,19 @@
},
// This is where we can manipulate DOM, because later it would cause iframes to reload
- onReady: function (opts, obj) {
+ onReady : function (opts, obj) {
$('.fancybox-overlay').stop(true, true);
if (!this.overlay) {
- $.extend(this, {
- overlay : $('<div class="fancybox-overlay"></div>').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.margin = D.height() > W.height() || $('body').css('overflow-y') === 'scroll' ? $('body').css('margin-right') : false;
+ this.el = document.all && !document.querySelector ? $('html') : $('body');
- if (obj.fixed && !isTouch) {
- this.overlay.addClass('fancybox-overlay-fixed');
-
- if (obj.autoCenter) {
- this.overlay.append( obj.wrap );
+ this.create(opts);
+ }
- obj.locked = this.overlay;
- }
+ if (opts.locked && this.fixed) {
+ obj.locked = this.overlay.append( obj.wrap );
+ obj.fixed = false;
}
if (opts.showEarly === true) {
@@ -1728,54 +1816,28 @@
},
beforeShow : function(opts, obj) {
- var overlay = this.overlay.unbind('.fb').width('auto').height('auto').css( opts.css );
+ if (obj.locked) {
+ this.el.addClass('fancybox-lock');
- 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);
- }
+ if (this.margin !== false) {
+ $('body').css('margin-right', getScalar( this.margin ) + obj.scrollbarWidth);
}
-
- } else {
- this.update();
}
- overlay.show();
+ this.open(opts);
},
- onUpdate : function(opts, obj) {
- if (!obj.fixed || isTouch) {
+ onUpdate : function() {
+ if (!this.fixed) {
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;
- });
+ if (this.overlay && !F.isActive) {
+ this.overlay.fadeOut(opts.speedOut, $.proxy( this.close, this ));
}
}
};
@@ -1785,12 +1847,22 @@
*/
F.helpers.title = {
+ defaults : {
+ type : 'float', // 'float', 'inside', 'outside' or 'over',
+ position : 'bottom' // 'top' or 'bottom'
+ },
+
beforeShow: function (opts) {
- var text = F.current.title,
- type = opts.type,
+ var current = F.current,
+ text = current.title,
+ type = opts.type,
title,
target;
+ if ($.isFunction(text)) {
+ text = text.call(current.element, current);
+ }
+
if (!isString(text) || $.trim(text) === '') {
return;
}
@@ -1813,22 +1885,20 @@
default: // 'float'
target = F.skin;
- title
- .appendTo('body')
- .width(title.width()) //This helps for some browsers
- .wrapInner('<span class="child"></span>');
+ title.appendTo('body');
- //Increase bottom margin so this title will also fit into viewport
- F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) );
- break;
- }
+ if ($.browser.msie) {
+ title.width( title.width() );
+ }
- if (opts.position === 'top') {
- title.prependTo(target);
+ title.wrapInner('<span class="child"></span>');
- } else {
- title.appendTo(target);
+ //Increase bottom margin so this title will also fit into viewport
+ F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) );
+ break;
}
+
+ title[ (opts.position === 'top' ? 'prependTo' : 'appendTo') ](target);
}
};
@@ -1869,10 +1939,13 @@
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);
}
+ this.filter('[data-fancybox-start=1]').trigger('click');
+
return this;
};
9 vendor/assets/stylesheets/jquery.fancybox.css.erb
View
@@ -1,4 +1,4 @@
-/*! fancyBox v2.1.0 fancyapps.com | fancyapps.com/fancybox/#license */
+/*! fancyBox v2.1.3 fancyapps.com | fancyapps.com/fancybox/#license */
.fancybox-wrap,
.fancybox-skin,
.fancybox-outer,
@@ -154,9 +154,12 @@
.fancybox-tmp {
position: absolute;
- top: -9999px;
- left: -9999px;
+ top: -99999px;
+ left: -99999px;
visibility: hidden;
+ max-width: 99999px;
+ max-height: 99999px;
+ overflow: visible !important;
}
/* Overlay helper */
Please sign in to comment.
Something went wrong with that request. Please try again.