2
* fancyBox - jQuery Plugin
3
* version: 2.0.6 (16/04/2012)
4
* @requires jQuery v1.6 or later
6
* Examples at http://fancyapps.com/fancybox/
7
* License: www.fancyapps.com/fancybox/#license
9
* Copyright 2012 Janis Skarnelis - janis@fancyapps.com
13
(function (window, document, $, undefined) {
18
F = $.fancybox = function () {
19
F.open.apply( this, arguments );
23
isTouch = document.createTouch !== undefined,
24
isString = function(str) {
25
return $.type(str) === "string";
27
isPercentage = function(str) {
28
return isString(str) && str.indexOf('%') > 0;
30
getValue = function(value, dim) {
31
if (dim && isPercentage(value)) {
32
value = F.getViewport()[ dim ] / 100 * parseInt(value, 10);
35
return Math.round(value) + 'px';
39
// The current version of fancyBox
55
autoCenter : !isTouch,
61
scrolling: 'auto', // 'auto', 'yes' or 'no'
75
ajax: { dataType: 'html', headers: { 'X-fancyBox': true } },
77
next: [13, 32, 34, 39, 40], // enter, space, page down, right arrow, down arrow
78
prev: [8, 33, 37, 38], // backspace, page up, left arrow, up arrow
79
close: [27] // escape key
82
// Override some properties
91
wrap: '<div class="fancybox-wrap"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',
92
image: '<img class="fancybox-image" src="{href}" alt="" />',
93
iframe: '<iframe class="fancybox-iframe" name="fancybox-frame{rnd}" frameborder="0" hspace="0"' + ($.browser.msie ? ' allowtransparency="true"' : '') + '></iframe>',
94
swf: '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="wmode" value="transparent" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{href}" /><embed src="{href}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="100%" height="100%" wmode="transparent"></embed></object>',
95
error: '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
96
closeBtn: '<div title="Close" class="fancybox-item fancybox-close"></div>',
97
next: '<a title="Next" class="fancybox-nav fancybox-next"><span></span></a>',
98
prev: '<a title="Previous" class="fancybox-nav fancybox-prev"><span></span></a>'
101
// Properties for each animation type
103
openEffect: 'fade', // 'elastic', 'fade' or 'none'
107
openMethod: 'zoomIn',
110
closeEffect: 'fade', // 'elastic', 'fade' or 'none'
112
closeEasing: 'swing',
114
closeMethod: 'zoomOut',
116
// Changing next gallery item
117
nextEffect: 'elastic', // 'elastic', 'fade' or 'none'
120
nextMethod: 'changeIn',
122
// Changing previous gallery item
123
prevEffect: 'elastic', // 'elastic', 'fade' or 'none'
126
prevMethod: 'changeOut',
140
type: 'float' // 'float', 'inside', 'outside' or 'over'
145
onCancel: $.noop, // If canceling
146
beforeLoad: $.noop, // Before loading
147
afterLoad: $.noop, // After loading
148
beforeShow: $.noop, // Before changing in current item
149
afterShow: $.noop, // After opening
150
beforeClose: $.noop, // Before closing
151
afterClose: $.noop // After closing
155
group: {}, // Selected group
156
opts: {}, // Group options
157
coming: null, // Element being loaded
158
current: null, // Currently loaded element
159
isOpen: false, // Is currently open
160
isOpened: false, // Have been fully opened at least once
183
open: function (group, opts) {
184
//Kill existing instances
188
if (group && !$.isArray(group)) {
189
group = group instanceof $ ? $(group).get() : [group];
194
//Extend the defaults
195
F.opts = $.extend(true, {}, F.defaults, opts);
197
//All options are merged recursive except keys
198
if ($.isPlainObject(opts) && opts.keys !== undefined) {
199
F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false;
204
F._start(F.opts.index || 0);
207
cancel: function () {
208
if (F.coming && false === F.trigger('onCancel')) {
223
F.imgPreload.onload = F.imgPreload.onabort = F.imgPreload.onerror = null;
227
close: function (a) {
230
if (!F.current || false === F.trigger('beforeClose')) {
236
//If forced or is still opening then remove immediately
237
if (!F.isOpen || (a && a[0] === true)) {
238
$('.fancybox-wrap').stop().trigger('onReset').remove();
243
F.isOpen = F.isOpened = false;
245
$('.fancybox-item, .fancybox-nav').remove();
247
F.wrap.stop(true).removeClass('fancybox-opened');
248
F.inner.css('overflow', 'hidden');
250
F.transitions[F.current.closeMethod]();
254
// Start/stop slideshow
256
var clear = function () {
257
clearTimeout(F.player.timer);
262
if (F.current && F.player.isActive) {
263
F.player.timer = setTimeout(F.next, F.current.playSpeed);
269
$('body').unbind('.player');
271
F.player.isActive = false;
273
F.trigger('onPlayEnd');
275
start = function () {
276
if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) {
277
F.player.isActive = true;
280
'afterShow.player onUpdate.player': set,
281
'onCancel.player beforeClose.player': stop,
282
'beforeLoad.player': clear
287
F.trigger('onPlayStart');
291
if (F.player.isActive || (a && a[0] === false)) {
300
F.jumpto(F.current.index + 1);
306
F.jumpto(F.current.index - 1);
310
jumpto: function (index) {
315
index = parseInt(index, 10);
317
if (F.group.length > 1 && F.current.loop) {
318
if (index >= F.group.length) {
321
} else if (index < 0) {
322
index = F.group.length - 1;
326
if (F.group[index] !== undefined) {
333
reposition: function (e, onlyAbsolute) {
337
pos = F._getPosition(onlyAbsolute);
339
if (e && e.type === 'scroll') {
342
F.wrap.stop(true, true).animate(pos, 200);
350
update: function (e) {
355
// Run this code after a delay for better performance
357
resizeTimer = setTimeout(function () {
358
var current = F.current, anyway = !e || (e && e.type === 'orientationchange');
367
if ((!e || e.type !== 'scroll') || anyway) {
368
if (current.autoSize && current.type !== 'iframe') {
369
F.inner.height('auto');
370
current.height = F.inner.height();
373
if (current.autoResize || anyway) {
377
if (current.canGrow && current.type !== 'iframe') {
378
F.inner.height('auto');
382
if (current.autoCenter || anyway) {
386
F.trigger('onUpdate');
394
toggle: function () {
396
F.current.fitToView = !F.current.fitToView;
402
hideLoading: function () {
403
D.unbind('keypress.fb');
405
$('#fancybox-loading').remove();
408
showLoading: function () {
411
//If user will press the escape-button, the request will be canceled
412
D.bind('keypress.fb', function(e) {
413
if (e.keyCode === 27) {
419
$('<div id="fancybox-loading"><div></div></div>').click(F.cancel).appendTo('body');
422
getViewport: function () {
423
// See http://bugs.jquery.com/ticket/6724
427
w: isTouch && window.innerWidth ? window.innerWidth : W.width(),
428
h: isTouch && window.innerHeight ? window.innerHeight : W.height()
432
// Unbind the keyboard / clicking actions
433
unbindEvents: function () {
435
F.wrap.unbind('.fb');
442
bindEvents: function () {
443
var current = F.current,
450
W.bind('resize.fb orientationchange.fb' + (current.autoCenter && !current.fixed ? ' scroll.fb' : ''), F.update);
453
D.bind('keydown.fb', function (e) {
454
var code, target = e.target || e.srcElement;
456
// Ignore key combinations and key events within form elements
457
if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) {
460
if ($.inArray(code, keys.close) > -1) {
464
} else if ($.inArray(code, keys.next) > -1) {
468
} else if ($.inArray(code, keys.prev) > -1) {
476
if ($.fn.mousewheel && current.mouseWheel && F.group.length > 1) {
477
F.wrap.bind('mousewheel.fb', function (e, delta) {
478
var target = e.target || null;
480
if (delta !== 0 && (!target || target.clientHeight === 0 || (target.scrollHeight === target.clientHeight && target.scrollWidth === target.clientWidth))) {
483
F[delta > 0 ? 'prev' : 'next']();
489
trigger: function (event, o) {
490
var ret, obj = o || F[ $.inArray(event, ['onCancel', 'beforeLoad', 'afterLoad']) > -1 ? 'coming' : 'current' ];
496
if ($.isFunction( obj[event] )) {
497
ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1));
505
$.each(obj.helpers, function (helper, opts) {
506
if (opts && $.isPlainObject(F.helpers[helper]) && $.isFunction(F.helpers[helper][event])) {
507
F.helpers[helper][event](opts, obj);
512
$.event.trigger(event + '.fb');
515
isImage: function (str) {
516
return isString(str) && str.match(/\.(jpe?g|gif|png|bmp)((\?|#).*)?$/i);
519
isSWF: function (str) {
520
return isString(str) && str.match(/\.(swf)((\?|#).*)?$/i);
523
_start: function (index) {
525
element = F.group[index] || null,
532
if (element && (element.nodeType || element instanceof $)) {
536
coming = $(element).metadata();
540
coming = $.extend(true, {}, F.opts, {index : index, element : element}, ($.isPlainObject(element) ? element : coming));
542
// Re-check overridable options
543
$.each(['href', 'title', 'content', 'type'], function(i,v) {
544
coming[v] = F.opts[ v ] || (isDom && $(element).attr( v )) || coming[ v ] || null;
547
// Convert margin property to array - top, right, bottom, left
548
if (typeof coming.margin === 'number') {
549
coming.margin = [coming.margin, coming.margin, coming.margin, coming.margin];
552
// 'modal' propery is just a shortcut
554
$.extend(true, coming, {
572
//Give a chance for callback or helpers to update coming item (type, title, etc)
575
if (false === F.trigger('beforeLoad')) {
581
href = coming.href || element;
583
///Check if content type is set, if not, try to get
586
type = $(element).data('fancybox-type');
589
rez = element.className.match(/fancybox\.(\w+)/);
590
type = rez ? rez[1] : null;
594
if (!type && isString(href)) {
595
if (F.isImage(href)) {
598
} else if (F.isSWF(href)) {
601
} else if (href.match(/^#/)) {
606
// ...if not - display element itself
608
type = isDom ? 'inline' : 'html';
614
// Check before try to load; 'inline' and 'html' types need content, others - href
615
if (type === 'inline' || type === 'html') {
616
if (!coming.content) {
617
if (type === 'inline') {
618
coming.content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7
621
coming.content = element;
625
if (!coming.content || !coming.content.length) {
634
* Add reference to the group, so it`s possible to access from callbacks, example:
635
* afterLoad : function() {
636
* this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
640
if (type === 'ajax' && isString(href)) {
641
hrefParts = href.split(/\s+/, 2);
643
href = hrefParts.shift();
644
coming.selector = hrefParts.shift();
648
coming.group = F.group;
649
coming.isDom = isDom;
672
_error: function ( type ) {
682
content : F.coming.tpl.error
688
_loadImage: function () {
689
// Reset preload image so it is later possible to check "complete" property
690
var img = F.imgPreload = new Image();
692
img.onload = function () {
693
this.onload = this.onerror = null;
695
F.coming.width = this.width;
696
F.coming.height = this.height;
701
img.onerror = function () {
702
this.onload = this.onerror = null;
707
img.src = F.coming.href;
709
if (img.complete === undefined || !img.complete) {
714
_loadAjax: function () {
717
F.ajaxLoad = $.ajax($.extend({}, F.coming.ajax, {
719
error: function (jqXHR, textStatus) {
720
if (F.coming && textStatus !== 'abort') {
721
F._error( 'ajax', jqXHR );
727
success: function (data, textStatus) {
728
if (textStatus === 'success') {
729
F.coming.content = data;
737
_preloadImages: function() {
744
cnt = Math.min(current.preload, len - 1);
746
if (!current.preload || group.length < 2) {
750
for (i = 1; i <= cnt; i += 1) {
751
item = group[ (current.index + i ) % len ];
752
href = item.href || $( item ).attr('href') || item;
754
if (item.type === 'image' || F.isImage(href)) {
755
new Image().src = href;
760
_afterLoad: function () {
763
if (!F.coming || false === F.trigger('afterLoad', F.current)) {
770
$('.fancybox-item, .fancybox-nav').remove();
772
F.wrap.stop(true).removeClass('fancybox-opened');
773
F.inner.css('overflow', 'hidden');
775
F.transitions[F.current.prevMethod]();
778
$('.fancybox-wrap').stop().trigger('onReset').remove();
780
F.trigger('afterClose');
786
F.current = F.coming;
788
//Build the neccessary markup
789
F.wrap = $(F.current.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + F.current.type + ' fancybox-tmp ' + F.current.wrapCSS).appendTo('body');
790
F.skin = $('.fancybox-skin', F.wrap).css('padding', getValue(F.current.padding));
791
F.outer = $('.fancybox-outer', F.wrap);
792
F.inner = $('.fancybox-inner', F.wrap);
797
_setContent: function () {
798
var current = F.current,
799
content = current.content,
801
minWidth = current.minWidth,
802
minHeight = current.minHeight,
803
maxWidth = current.maxWidth,
804
maxHeight = current.maxHeight,
811
if (current.selector) {
812
content = $('<div>').html(content).find(current.selector);
814
} else if (content instanceof $) {
815
if (content.parent().hasClass('fancybox-inner')) {
816
content.parents('.fancybox-wrap').unbind('onReset');
819
content = content.show().detach();
821
$(F.wrap).bind('onReset', function () {
822
content.appendTo('body').hide();
826
if (current.autoSize) {
827
loadingBay = $('<div class="fancybox-wrap ' + F.current.wrapCSS + ' fancybox-tmp"></div>')
830
minWidth : getValue(minWidth, 'w'),
831
minHeight : getValue(minHeight, 'h'),
832
maxWidth : getValue(maxWidth, 'w'),
833
maxHeight : getValue(maxHeight, 'h')
837
current.width = loadingBay.width();
838
current.height = loadingBay.height();
840
// Re-check to fix 1px bug in some browsers
841
loadingBay.width( F.current.width );
843
if (loadingBay.height() > current.height) {
844
loadingBay.width(current.width + 1);
846
current.width = loadingBay.width();
847
current.height = loadingBay.height();
850
content = loadingBay.contents().detach();
858
content = current.tpl.image.replace('{href}', current.href);
860
current.aspectRatio = true;
864
content = current.tpl.swf.replace(/\{width\}/g, current.width).replace(/\{height\}/g, current.height).replace(/\{href\}/g, current.href);
868
content = $(current.tpl.iframe.replace('{rnd}', new Date().getTime()) )
869
.attr('scrolling', current.scrolling)
870
.attr('src', current.href);
872
current.scrolling = isTouch ? 'scroll' : 'auto';
877
if (type === 'image' || type === 'swf') {
878
current.autoSize = false;
879
current.scrolling = 'visible';
882
if (type === 'iframe' && current.autoSize) {
887
F.inner.css('overflow', current.scrolling);
890
onCancel : function() {
899
if (this.contentWindow.document.location) {
900
F.current.height = $(this).contents().find('body').height();
903
F.current.autoSize = false;
906
F[ F.isOpen ? '_afterZoomIn' : '_beforeShow']();
908
}).appendTo(F.inner);
911
F.inner.append(content);
917
_beforeShow : function() {
920
//Give a chance for helpers or callbacks to update elements
921
F.trigger('beforeShow');
923
//Set initial dimensions and hide
925
F.wrap.hide().removeClass('fancybox-tmp');
931
F.transitions[ F.isOpened ? F.current.nextMethod : F.current.openMethod ]();
934
_setDimension: function () {
938
viewport = F.getViewport(),
939
margin = current.margin,
940
padding2 = current.padding * 2,
941
width = current.width,
942
height = current.height,
943
maxWidth = current.maxWidth + padding2,
944
maxHeight = current.maxHeight + padding2,
945
minWidth = current.minWidth + padding2,
946
minHeight = current.minHeight + padding2,
950
viewport.w -= (margin[1] + margin[3]);
951
viewport.h -= (margin[0] + margin[2]);
953
if (isPercentage(width)) {
954
width = (((viewport.w - padding2) * parseFloat(width)) / 100);
957
if (isPercentage(height)) {
958
height = (((viewport.h - padding2) * parseFloat(height)) / 100);
961
ratio = width / height;
965
if (current.fitToView) {
966
maxWidth = Math.min(viewport.w, maxWidth);
967
maxHeight = Math.min(viewport.h, maxHeight);
970
if (current.aspectRatio) {
971
if (width > maxWidth) {
973
height = ((width - padding2) / ratio) + padding2;
976
if (height > maxHeight) {
978
width = ((height - padding2) * ratio) + padding2;
981
if (width < minWidth) {
983
height = ((width - padding2) / ratio) + padding2;
986
if (height < minHeight) {
988
width = ((height - padding2) * ratio) + padding2;
992
width = Math.max(minWidth, Math.min(width, maxWidth));
993
height = Math.max(minHeight, Math.min(height, maxHeight));
996
width = Math.round(width);
997
height = Math.round(height);
1000
$(wrap.add(inner)).width('auto').height('auto');
1002
inner.width(width - padding2).height(height - padding2);
1005
height_ = wrap.height(); // Real wrap height
1007
//Fit wrapper inside
1008
if (width > maxWidth || height_ > maxHeight) {
1009
while ((width > maxWidth || height_ > maxHeight) && width > minWidth && height_ > minHeight) {
1010
height = height - 10;
1012
if (current.aspectRatio) {
1013
width = Math.round(((height - padding2) * ratio) + padding2);
1015
if (width < minWidth) {
1017
height = ((width - padding2) / ratio) + padding2;
1024
inner.width(width - padding2).height(height - padding2);
1027
height_ = wrap.height();
1032
width : getValue(width),
1033
height : getValue(height_)
1036
current.canGrow = current.autoSize && height > minHeight && height < maxHeight;
1037
current.canShrink = false;
1038
current.canExpand = false;
1040
if ((width - padding2) < current.width || (height - padding2) < current.height) {
1041
current.canExpand = true;
1043
} else if ((width > viewport.w || height_ > viewport.h) && width > minWidth && height > minHeight) {
1044
current.canShrink = true;
1047
F.innerSpace = height_ - padding2 - inner.height();
1050
_getPosition: function (onlyAbsolute) {
1051
var current = F.current,
1052
viewport = F.getViewport(),
1053
margin = current.margin,
1054
width = F.wrap.width() + margin[1] + margin[3],
1055
height = F.wrap.height() + margin[0] + margin[2],
1057
position: 'absolute',
1058
top : margin[0] + viewport.y,
1059
left : margin[3] + viewport.x
1062
if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) {
1070
rez.top = getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio)));
1071
rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * 0.5)));
1076
_afterZoomIn: function () {
1077
var current = F.current, scrolling = current ? current.scrolling : 'no';
1083
F.isOpen = F.isOpened = true;
1085
F.wrap.addClass('fancybox-opened');
1087
F.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
1089
F.trigger('afterShow');
1093
//Assign a click event
1094
if (current.closeClick || current.nextClick) {
1095
F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
1096
if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
1097
F[ current.closeClick ? 'close' : 'next' ]();
1102
//Create a close button
1103
if (current.closeBtn) {
1104
$(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', F.close);
1107
//Create navigation arrows
1108
if (current.arrows && F.group.length > 1) {
1109
if (current.loop || current.index > 0) {
1110
$(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev);
1113
if (current.loop || current.index < F.group.length - 1) {
1114
$(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next);
1118
if (F.opts.autoPlay && !F.player.isActive) {
1119
F.opts.autoPlay = false;
1125
_afterZoomOut: function () {
1126
var current = F.current;
1128
F.wrap.trigger('onReset').remove();
1143
F.trigger('afterClose', current);
1148
* Default transitions
1152
getOrigPosition: function () {
1153
var current = F.current,
1154
element = current.element,
1155
padding = current.padding,
1156
orig = $(current.orig),
1162
if (!orig.length && current.isDom && $(element).is(':visible')) {
1163
orig = $(element).find('img:first');
1171
pos = orig.offset();
1173
if (orig.is('img')) {
1174
width = orig.outerWidth();
1175
height = orig.outerHeight();
1179
viewport = F.getViewport();
1181
pos.top = viewport.y + (viewport.h - height) * 0.5;
1182
pos.left = viewport.x + (viewport.w - width) * 0.5;
1186
top : getValue(pos.top - padding),
1187
left : getValue(pos.left - padding),
1188
width : getValue(width + padding * 2),
1189
height : getValue(height + padding * 2)
1195
step: function (now, fx) {
1196
var prop = fx.prop, value, ratio;
1198
if (prop === 'width' || prop === 'height') {
1199
value = Math.ceil(now - (F.current.padding * 2));
1201
if (prop === 'height') {
1202
ratio = (now - fx.start) / (fx.end - fx.start);
1204
if (fx.start > fx.end) {
1208
value -= F.innerSpace * ratio;
1211
F.inner[prop](value);
1215
zoomIn: function () {
1217
current = F.current,
1218
effect = current.openEffect,
1219
elastic = effect === 'elastic',
1221
startPos = $.extend({}, dim, F._getPosition( elastic )),
1222
endPos = $.extend({opacity : 1}, startPos);
1224
//Remove "position" property that breaks older IE
1225
delete endPos.position;
1228
startPos = this.getOrigPosition();
1230
if (current.openOpacity) {
1231
startPos.opacity = 0;
1234
F.outer.add(F.inner).width('auto').height('auto');
1236
} else if (effect === 'fade') {
1237
startPos.opacity = 0;
1243
duration : effect === 'none' ? 0 : current.openSpeed,
1244
easing : current.openEasing,
1245
step : elastic ? this.step : null,
1246
complete : F._afterZoomIn
1250
zoomOut: function () {
1252
current = F.current,
1253
effect = current.openEffect,
1254
elastic = effect === 'elastic',
1255
endPos = {opacity : 0};
1258
if (wrap.css('position') === 'fixed') {
1259
wrap.css(F._getPosition(true));
1262
endPos = this.getOrigPosition();
1264
if (current.closeOpacity) {
1269
wrap.animate(endPos, {
1270
duration : effect === 'none' ? 0 : current.closeSpeed,
1271
easing : current.closeEasing,
1272
step : elastic ? this.step : null,
1273
complete : F._afterZoomOut
1277
changeIn: function () {
1279
current = F.current,
1280
effect = current.nextEffect,
1281
elastic = effect === 'elastic',
1282
startPos = F._getPosition( elastic ),
1283
endPos = { opacity : 1 };
1285
startPos.opacity = 0;
1288
startPos.top = getValue(parseInt(startPos.top, 10) - 200);
1289
endPos.top = '+=200px';
1295
duration : effect === 'none' ? 0 : current.nextSpeed,
1296
easing : current.nextEasing,
1297
complete : F._afterZoomIn
1301
changeOut: function () {
1303
current = F.current,
1304
effect = current.prevEffect,
1305
endPos = { opacity : 0 },
1306
cleanUp = function () {
1307
$(this).trigger('onReset').remove();
1310
wrap.removeClass('fancybox-opened');
1312
if (effect === 'elastic') {
1313
endPos.top = '+=200px';
1316
wrap.animate(endPos, {
1317
duration : effect === 'none' ? 0 : current.prevSpeed,
1318
easing : current.prevEasing,
1328
F.helpers.overlay = {
1331
update: function () {
1332
var width, scrollWidth, offsetWidth;
1334
//Reset width/height so it will not mess
1335
this.overlay.width('100%').height('100%');
1337
if ($.browser.msie || isTouch) {
1338
scrollWidth = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);
1339
offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
1341
width = scrollWidth < offsetWidth ? W.width() : scrollWidth;
1347
this.overlay.width(width).height(D.height());
1350
beforeShow: function (opts) {
1355
opts = $.extend(true, {}, F.defaults.helpers.overlay, opts);
1357
this.overlay = $('<div id="fancybox-overlay"></div>').css(opts.css).appendTo('body');
1359
if (opts.closeClick) {
1360
this.overlay.bind('click.fb', F.close);
1363
if (F.current.fixed && !isTouch) {
1364
this.overlay.addClass('overlay-fixed');
1369
this.onUpdate = function () {
1374
this.overlay.fadeTo(opts.speedIn, opts.opacity);
1377
afterClose: function (opts) {
1379
this.overlay.fadeOut(opts.speedOut || 0, function () {
1384
this.overlay = null;
1393
beforeShow: function (opts) {
1394
var title, text = F.current.title;
1397
title = $('<div class="fancybox-title fancybox-title-' + opts.type + '-wrap">' + text + '</div>').appendTo('body');
1399
if (opts.type === 'float') {
1400
//This helps for some browsers
1401
title.width(title.width());
1403
title.wrapInner('<span class="child"></span>');
1405
//Increase bottom margin so this title will also fit into viewport
1406
F.current.margin[2] += Math.abs(parseInt(title.css('margin-bottom'), 10));
1409
title.appendTo(opts.type === 'over' ? F.inner : (opts.type === 'outside' ? F.wrap : F.skin));
1414
// jQuery plugin initialization
1415
$.fn.fancybox = function (options) {
1417
selector = this.selector || '',
1420
var what = this, idx = index, relType, relVal;
1422
if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !$(what).is('.fancybox-wrap')) {
1425
relType = options.groupAttr || 'data-fancybox-group';
1426
relVal = $(what).attr(relType);
1430
relVal = what[ relType ];
1433
if (relVal && relVal !== '' && relVal !== 'nofollow') {
1434
what = selector.length ? $(selector) : that;
1435
what = what.filter('[' + relType + '="' + relVal + '"]');
1436
idx = what.index(this);
1439
options.index = idx;
1441
F.open(what, options);
1445
options = options || {};
1446
index = options.index || 0;
1449
D.undelegate(selector, 'click.fb-start').delegate(selector, 'click.fb-start', run);
1452
that.unbind('click.fb-start').bind('click.fb-start', run);
1458
// Test for fixedPosition needs a body at doc ready
1459
$(document).ready(function() {
1460
F.defaults.fixed = $.support.fixedPosition || (!($.browser.msie && $.browser.version <= 6) && !isTouch);
1463
}(window, document, jQuery));
b'\\ No newline at end of file'