diff --git a/bookdetail.php b/bookdetail.php index 5e86287..2529834 100644 --- a/bookdetail.php +++ b/bookdetail.php @@ -78,6 +78,6 @@ $book->getLinkArray ();

-
getComment (false) ?>
+
getComment (false) ?>

\ No newline at end of file diff --git a/fancybox/fancybox_overlay.png b/fancybox/fancybox_overlay.png new file mode 100644 index 0000000..74e0ea1 Binary files /dev/null and b/fancybox/fancybox_overlay.png differ diff --git a/fancybox/fancybox_sprite.png b/fancybox/fancybox_sprite.png index a1aae1a..fd8d5ca 100644 Binary files a/fancybox/fancybox_sprite.png and b/fancybox/fancybox_sprite.png differ diff --git a/fancybox/helpers/fancybox_buttons.png b/fancybox/helpers/fancybox_buttons.png index e0e1ea8..0787207 100644 Binary files a/fancybox/helpers/fancybox_buttons.png and b/fancybox/helpers/fancybox_buttons.png differ diff --git a/fancybox/helpers/jquery.fancybox-buttons.css b/fancybox/helpers/jquery.fancybox-buttons.css index 0cff8a3..9453b46 100644 --- a/fancybox/helpers/jquery.fancybox-buttons.css +++ b/fancybox/helpers/jquery.fancybox-buttons.css @@ -15,17 +15,24 @@ #fancybox-buttons ul { display: block; - width: 170px; + width: 166px; height: 30px; margin: 0 auto; padding: 0; list-style: none; - background: #111; - -webkit-box-shadow: 0 1px 3px #000,0 0 0 1px rgba(0,0,0,.7),inset 0 0 0 1px rgba(255,255,255,.05); - -moz-box-shadow: 0 1px 3px #000,0 0 0 1px rgba(0,0,0,.7),inset 0 0 0 1px rgba(255,255,255,.05); - background: #111 -webkit-gradient(linear,0% 0%,0% 100%,from(rgba(255,255,255,.2)),color-stop(.5,rgba(255,255,255,.15)),color-stop(.5,rgba(255,255,255,.1)),to(rgba(255,255,255,.15))); - background: #111 -moz-linear-gradient(top,rgba(255,255,255,.2) 0%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.1) 50%,rgba(255,255,255,.15) 100%); + border: 1px solid #111; border-radius: 3px; + -webkit-box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); + -moz-box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); + box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); + background: rgb(50,50,50); + background: -moz-linear-gradient(top, rgb(68,68,68) 0%, rgb(52,52,52) 50%, rgb(41,41,41) 50%, rgb(51,51,51) 100%); + background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgb(68,68,68)), color-stop(50%,rgb(52,52,52)), color-stop(50%,rgb(41,41,41)), color-stop(100%,rgb(51,51,51))); + background: -webkit-linear-gradient(top, rgb(68,68,68) 0%,rgb(52,52,52) 50%,rgb(41,41,41) 50%,rgb(51,51,51) 100%); + background: -o-linear-gradient(top, rgb(68,68,68) 0%,rgb(52,52,52) 50%,rgb(41,41,41) 50%,rgb(51,51,51) 100%); + background: -ms-linear-gradient(top, rgb(68,68,68) 0%,rgb(52,52,52) 50%,rgb(41,41,41) 50%,rgb(51,51,51) 100%); + background: linear-gradient(top, rgb(68,68,68) 0%,rgb(52,52,52) 50%,rgb(41,41,41) 50%,rgb(51,51,51) 100%); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#444444', endColorstr='#222222',GradientType=0 ); } #fancybox-buttons ul li { @@ -42,11 +49,15 @@ background-image: url('fancybox_buttons.png'); background-repeat: no-repeat; outline: none; + opacity: 0.8; +} + +#fancybox-buttons a:hover { + opacity: 1; } #fancybox-buttons a.btnPrev { - width: 32px; - background-position: 6px 0; + background-position: 5px 0; } #fancybox-buttons a.btnNext { @@ -75,11 +86,11 @@ #fancybox-buttons a.btnClose { border-left: 1px solid #111; - width: 38px; - background-position: -57px 0px; + width: 35px; + background-position: -56px 0px; } #fancybox-buttons a.btnDisabled { - opacity : 0.5; + opacity : 0.4; cursor: default; } \ No newline at end of file diff --git a/fancybox/helpers/jquery.fancybox-buttons.js b/fancybox/helpers/jquery.fancybox-buttons.js index e116e38..7ba560c 100644 --- a/fancybox/helpers/jquery.fancybox-buttons.js +++ b/fancybox/helpers/jquery.fancybox-buttons.js @@ -1,19 +1,21 @@ /*! * Buttons helper for fancyBox - * version: 1.0.2 + * version: 1.0.3 * @requires fancyBox v2.0 or later * - * Usage: + * Usage: * $(".fancybox").fancybox({ - * buttons: { - * position : 'top' + * helpers : { + * buttons: { + * position : 'top' + * } * } * }); - * + * * Options: * tpl - HTML template * position - 'top' or 'bottom' - * + * */ (function ($) { //Shortcut for fancyBox object @@ -21,72 +23,59 @@ //Add helper object F.helpers.buttons = { - tpl: '
', - list: null, - buttons: {}, + tpl : '
', + list : null, + buttons: null, - update: function () { - var toggle = this.buttons.toggle.removeClass('btnDisabled btnToggleOn'); - - //Size toggle button - if (F.current.canShrink) { - toggle.addClass('btnToggleOn'); - - } else if (!F.current.canExpand) { - toggle.addClass('btnDisabled'); - } - }, - - beforeLoad: function (opts) { + beforeLoad: function (opts, obj) { //Remove self if gallery do not have at least two items - if (F.group.length < 2) { - F.coming.helpers.buttons = false; - F.coming.closeBtn = true; + + if (opts.skipSingle && obj.group.length < 2) { + obj.helpers.buttons = false; + obj.closeBtn = true; return; } //Increase top margin to give space for buttons - F.coming.margin[ opts.position === 'bottom' ? 2 : 0 ] += 30; + obj.margin[ opts.position === 'bottom' ? 2 : 0 ] += 30; }, onPlayStart: function () { - if (this.list) { + if (this.buttons) { this.buttons.play.attr('title', 'Pause slideshow').addClass('btnPlayOn'); } }, onPlayEnd: function () { - if (this.list) { + if (this.buttons) { this.buttons.play.attr('title', 'Start slideshow').removeClass('btnPlayOn'); } }, - afterShow: function (opts) { - var buttons; + afterShow: function (opts, obj) { + var buttons = this.buttons; - if (!this.list) { + if (!buttons) { this.list = $(opts.tpl || this.tpl).addClass(opts.position || 'top').appendTo('body'); - this.buttons = { - prev : this.list.find('.btnPrev').click( F.prev ), - next : this.list.find('.btnNext').click( F.next ), - play : this.list.find('.btnPlay').click( F.play ), + buttons = { + prev : this.list.find('.btnPrev').click( F.prev ), + next : this.list.find('.btnNext').click( F.next ), + play : this.list.find('.btnPlay').click( F.play ), toggle : this.list.find('.btnToggle').click( F.toggle ) } } - buttons = this.buttons; - //Prev - if (F.current.index > 0 || F.current.loop) { + if (obj.index > 0 || obj.loop) { buttons.prev.removeClass('btnDisabled'); } else { buttons.prev.addClass('btnDisabled'); } //Next / Play - if (F.current.loop || F.current.index < F.group.length - 1) { + if (obj.loop || obj.index < obj.group.length - 1) { buttons.next.removeClass('btnDisabled'); buttons.play.removeClass('btnDisabled'); @@ -95,11 +84,27 @@ buttons.play.addClass('btnDisabled'); } - this.update(); + this.buttons = buttons; + + this.onUpdate(opts, obj); }, - onUpdate: function () { - this.update(); + onUpdate: function (opts, obj) { + var toggle; + + if (!this.buttons) { + return; + } + + toggle = this.buttons.toggle.removeClass('btnDisabled btnToggleOn'); + + //Size toggle button + if (obj.canShrink) { + toggle.addClass('btnToggleOn'); + + } else if (!obj.canExpand) { + toggle.addClass('btnDisabled'); + } }, beforeClose: function () { @@ -107,8 +112,8 @@ this.list.remove(); } - this.list = null; - this.buttons = {}; + this.list = null; + this.buttons = null; } }; diff --git a/fancybox/helpers/jquery.fancybox-media.js b/fancybox/helpers/jquery.fancybox-media.js index be5f586..d066294 100644 --- a/fancybox/helpers/jquery.fancybox-media.js +++ b/fancybox/helpers/jquery.fancybox-media.js @@ -1,19 +1,48 @@ - /*! +/*! * Media helper for fancyBox - * version: 1.0.0 + * version: 1.0.3 (Mon, 13 Aug 2012) * @requires fancyBox v2.0 or later * * Usage: * $(".fancybox").fancybox({ - * media: {} + * helpers : { + * media: true + * } + * }); + * + * Set custom URL parameters: + * $(".fancybox").fancybox({ + * helpers : { + * media: { + * youtube : { + * params : { + * autoplay : 0 + * } + * } + * } + * } + * }); + * + * Or: + * $(".fancybox").fancybox({, + * helpers : { + * media: true + * }, + * youtube : { + * autoplay: 0 + * } * }); * * Supports: + * * Youtube * http://www.youtube.com/watch?v=opj24KnzrWo * http://youtu.be/opj24KnzrWo * Vimeo - * http://vimeo.com/25634903 + * http://vimeo.com/40648169 + * http://vimeo.com/channels/staffpicks/38843628 + * http://vimeo.com/groups/surrealism/videos/36516384 + * http://player.vimeo.com/video/45074303 * Metacafe * http://www.metacafe.com/watch/7635964/dr_seuss_the_lorax_movie_trailer/ * http://www.metacafe.com/watch/7635964/ @@ -32,54 +61,136 @@ * http://maps.google.com/?ll=48.859463,2.292626&spn=0.000965,0.002642&t=m&z=19&layer=c&cbll=48.859524,2.292532&panoid=YJ0lq28OOy3VT2IqIuVY0g&cbp=12,151.58,,0,-15.56 */ (function ($) { + "use strict"; + //Shortcut for fancyBox object - var F = $.fancybox; + var F = $.fancybox, + format = function( url, rez, params ) { + params = params || ''; + + if ( $.type( params ) === "object" ) { + params = $.param(params, true); + } + + $.each(rez, function(key, value) { + url = url.replace( '$' + key, value || '' ); + }); + + if (params.length) { + url += ( url.indexOf('?') > 0 ? '&' : '?' ) + params; + } + + return url; + }; //Add helper object F.helpers.media = { + types : { + youtube : { + matcher : /(youtube\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed)?([\w-]{11}|\?listType=(.*)&list=(.*)).*/i, + params : { + autoplay : 1, + autohide : 1, + fs : 1, + rel : 0, + hd : 1, + wmode : 'opaque', + enablejsapi : 1 + }, + type : 'iframe', + url : '//www.youtube.com/embed/$3' + }, + vimeo : { + matcher : /(?:vimeo(?:pro)?.com)\/(?:[^\d]+)?(\d+)(?:.*)/, + params : { + autoplay : 1, + hd : 1, + show_title : 1, + show_byline : 1, + show_portrait : 0, + color : '', + fullscreen : 1 + }, + type : 'iframe', + url : '//player.vimeo.com/video/$1' + }, + metacafe : { + matcher : /metacafe.com\/(?:watch|fplayer)\/([\w\-]{1,10})/, + params : { + autoPlay : 'yes' + }, + type : 'swf', + url : function( rez, params, obj ) { + obj.swf.flashVars = 'playerVars=' + $.param( params, true ); + + return '//www.metacafe.com/fplayer/' + rez[1] + '/.swf'; + } + }, + dailymotion : { + matcher : /dailymotion.com\/video\/(.*)\/?(.*)/, + params : { + additionalInfos : 0, + autoStart : 1 + }, + type : 'swf', + url : '//www.dailymotion.com/swf/video/$1' + }, + twitvid : { + matcher : /twitvid\.com\/([a-zA-Z0-9_\-\?\=]+)/i, + params : { + autoplay : 0 + }, + type : 'iframe', + url : '//www.twitvid.com/embed.php?guid=$1' + }, + twitpic : { + matcher : /twitpic\.com\/(?!(?:place|photos|events)\/)([a-zA-Z0-9\?\=\-]+)/i, + type : 'image', + url : '//twitpic.com/show/full/$1/' + }, + instagram : { + matcher : /(instagr\.am|instagram\.com)\/p\/([a-zA-Z0-9_\-]+)\/?/i, + type : 'image', + url : '//$1/p/$2/media/' + }, + google_maps : { + matcher : /maps\.google\.([a-z]{2,3}(\.[a-z]{2})?)\/(\?ll=|maps\?)(.*)/i, + type : 'iframe', + url : function( rez ) { + return '//maps.google.' + rez[1] + '/' + rez[3] + '' + rez[4] + '&output=' + (rez[4].indexOf('layer=c') > 0 ? 'svembed' : 'embed'); + } + } + }, + beforeLoad : function(opts, obj) { - var href = obj.href || '', - type = false, - rez; + var url = obj.href || '', + type = false, + what, + item, + rez, + params; - if ((rez = href.match(/(youtube\.com|youtu\.be)\/(v\/|u\/|embed\/|watch\?v=)?([^#\&\?]*).*/i))) { - href = '//www.youtube.com/embed/' + rez[3] + '?autoplay=1&autohide=1&fs=1&rel=0&enablejsapi=1'; - type = 'iframe'; + for (what in this.types) { + item = this.types[ what ]; + rez = url.match( item.matcher ); - } else if ((rez = href.match(/vimeo.com\/(\d+)\/?(.*)/))) { - href = '//player.vimeo.com/video/' + rez[1] + '?hd=1&autoplay=1&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1'; - type = 'iframe'; + if (rez) { + type = item.type; + params = $.extend(true, {}, item.params, obj[ what ] || ($.isPlainObject(opts[ what ]) ? opts[ what ].params : null)); - } else if ((rez = href.match(/metacafe.com\/watch\/(\d+)\/?(.*)/))) { - href = '//www.metacafe.com/fplayer/' + rez[1] + '/.swf?playerVars=autoPlay=yes'; - type = 'swf'; + url = $.type( item.url ) === "function" ? item.url.call( this, rez, params, obj ) : format( item.url, rez, params ); - } else if ((rez = href.match(/dailymotion.com\/video\/(.*)\/?(.*)/))) { - href = '//www.dailymotion.com/swf/video/' + rez[1] + '?additionalInfos=0&autoStart=1'; - type = 'swf'; - - } else if ((rez = href.match(/twitvid\.com\/([a-zA-Z0-9_\-\?\=]+)/i))) { - href = '//www.twitvid.com/embed.php?autoplay=0&guid=' + rez[1]; - type = 'iframe'; - - } else if ((rez = href.match(/twitpic\.com\/(?!(?:place|photos|events)\/)([a-zA-Z0-9\?\=\-]+)/i))) { - href = '//twitpic.com/show/full/' + rez[1]; - type = 'image'; - - } else if ((rez = href.match(/(instagr\.am|instagram\.com)\/p\/([a-zA-Z0-9_\-]+)\/?/i))) { - href = '//' + rez[1] + '/p/' + rez[2] + '/media/?size=l'; - type = 'image'; - - } else if ((rez = href.match(/maps\.google\.com\/(\?ll=|maps\/?\?q=)(.*)/i))) { - href = '//maps.google.com/' + rez[1] + '' + rez[2] + '&output=' + (rez[2].indexOf('layer=c') ? 'svembed' : 'embed'); - type = 'iframe'; + break; + } } if (type) { - obj.href = href; + obj.href = url; obj.type = type; + + obj.autoHeight = false; } } - } + }; }(jQuery)); \ No newline at end of file diff --git a/fancybox/helpers/jquery.fancybox-thumbs.js b/fancybox/helpers/jquery.fancybox-thumbs.js index a1b2bb7..df00ebe 100644 --- a/fancybox/helpers/jquery.fancybox-thumbs.js +++ b/fancybox/helpers/jquery.fancybox-thumbs.js @@ -1,13 +1,15 @@ /*! * Thumbnail helper for fancyBox - * version: 1.0.4 + * version: 1.0.6 * @requires fancyBox v2.0 or later * * Usage: * $(".fancybox").fancybox({ - * thumbs: { - * width : 50, - * height : 50 + * helpers : { + * thumbs: { + * width : 50, + * height : 50 + * } * } * }); * @@ -24,34 +26,36 @@ //Add helper object F.helpers.thumbs = { - wrap: null, - list: null, - width: 0, + wrap : null, + list : null, + width : 0, //Default function to obtain the URL of the thumbnail image - source: function (el) { - var img; + source: function ( item ) { + var href; - if ($.type(el) === 'string') { - return el; + if (item.element) { + href = $(item.element).find('img').attr('src'); } - img = $(el).find('img'); + if (!href && item.type === 'image' && item.href) { + href = item.href; + } - return img.length ? img.attr('src') : el.href; + return href; }, - init: function (opts) { + init: function (opts, obj) { var that = this, list, - thumbWidth = opts.width || 50, + thumbWidth = opts.width || 50, thumbHeight = opts.height || 50, thumbSource = opts.source || this.source; //Build list structure list = ''; - for (var n = 0; n < F.group.length; n++) { + for (var n = 0; n < obj.group.length; n++) { list += '
  • '; } @@ -59,9 +63,15 @@ this.list = $('').appendTo(this.wrap); //Load each thumbnail - $.each(F.group, function (i) { + $.each(obj.group, function (i) { + var href = thumbSource( obj.group[ i ] ); + + if (!href) { + return; + } + $("").load(function () { - var width = this.width, + var width = this.width, height = this.height, widthRatio, heightRatio, parent; @@ -70,77 +80,74 @@ } //Calculate thumbnail width/height and center it - widthRatio = width / thumbWidth; + widthRatio = width / thumbWidth; heightRatio = height / thumbHeight; + parent = that.list.children().eq(i).find('a'); if (widthRatio >= 1 && heightRatio >= 1) { if (widthRatio > heightRatio) { - width = Math.floor(width / heightRatio); + width = Math.floor(width / heightRatio); height = thumbHeight; } else { - width = thumbWidth; + width = thumbWidth; height = Math.floor(height / widthRatio); } } $(this).css({ - width: width, - height: height, - top: Math.floor(thumbHeight / 2 - height / 2), - left: Math.floor(thumbWidth / 2 - width / 2) + width : width, + height : height, + top : Math.floor(thumbHeight / 2 - height / 2), + left : Math.floor(thumbWidth / 2 - width / 2) }); parent.width(thumbWidth).height(thumbHeight); $(this).hide().appendTo(parent).fadeIn(300); - }).attr('src', thumbSource( F.group[ i ] )); + }).attr('src', href); }); //Set initial width this.width = this.list.children().eq(0).outerWidth(true); - this.list.width(this.width * (F.group.length + 1)).css('left', Math.floor($(window).width() * 0.5 - (F.current.index * this.width + this.width * 0.5))); + this.list.width(this.width * (obj.group.length + 1)).css('left', Math.floor($(window).width() * 0.5 - (obj.index * this.width + this.width * 0.5))); }, - //Center list - update: function (opts) { - if (this.list) { - this.list.stop(true).animate({ - 'left': Math.floor($(window).width() * 0.5 - (F.current.index * this.width + this.width * 0.5)) - }, 150); - } - }, - - beforeLoad: function (opts) { + beforeLoad: function (opts, obj) { //Remove self if gallery do not have at least two items - if (F.group.length < 2) { - F.coming.helpers.thumbs = false; + if (obj.group.length < 2) { + obj.helpers.thumbs = false; return; } //Increase bottom margin to give space for thumbs - F.coming.margin[ opts.position === 'top' ? 0 : 2 ] = opts.height + 30; + obj.margin[ opts.position === 'top' ? 0 : 2 ] += ((opts.height || 50) + 15); }, - afterShow: function (opts) { + afterShow: function (opts, obj) { //Check if exists and create or update list if (this.list) { - this.update(opts); + this.onUpdate(opts, obj); } else { - this.init(opts); + this.init(opts, obj); } //Set active element - this.list.children().removeClass('active').eq(F.current.index).addClass('active'); + this.list.children().removeClass('active').eq(obj.index).addClass('active'); }, - onUpdate: function () { - this.update(); + //Center list + onUpdate: function (opts, obj) { + if (this.list) { + this.list.stop(true).animate({ + 'left': Math.floor($(window).width() * 0.5 - (obj.index * this.width + this.width * 0.5)) + }, 150); + } }, beforeClose: function () { @@ -148,8 +155,8 @@ this.wrap.remove(); } - this.wrap = null; - this.list = null; + this.wrap = null; + this.list = null; this.width = 0; } } diff --git a/fancybox/jquery.fancybox.css b/fancybox/jquery.fancybox.css index 783d02f..b1d4c02 100644 --- a/fancybox/jquery.fancybox.css +++ b/fancybox/jquery.fancybox.css @@ -1,8 +1,20 @@ -/*! fancyBox v2.0.6 fancyapps.com | fancyapps.com/fancybox/#license */ -.fancybox-tmp iframe, .fancybox-tmp object { - vertical-align: top; +/*! fancyBox v2.1.0 fancyapps.com | fancyapps.com/fancybox/#license */ +.fancybox-wrap, +.fancybox-skin, +.fancybox-outer, +.fancybox-inner, +.fancybox-image, +.fancybox-wrap iframe, +.fancybox-wrap object, +.fancybox-nav, +.fancybox-nav span, +.fancybox-tmp +{ padding: 0; margin: 0; + border: 0; + outline: none; + vertical-align: top; } .fancybox-wrap { @@ -14,8 +26,6 @@ .fancybox-skin { position: relative; - padding: 0; - margin: 0; background: #f9f9f9; color: #444; text-shadow: none; @@ -35,10 +45,7 @@ } .fancybox-outer, .fancybox-inner { - padding: 0; - margin: 0; position: relative; - outline: none; } .fancybox-inner { @@ -53,17 +60,14 @@ color: #444; font: 14px/20px "Helvetica Neue",Helvetica,Arial,sans-serif; margin: 0; - padding: 10px; + padding: 15px; + white-space: nowrap; } .fancybox-image, .fancybox-iframe { display: block; width: 100%; height: 100%; - border: 0; - padding: 0; - margin: 0; - vertical-align: top; } .fancybox-image { @@ -84,7 +88,7 @@ background-position: 0 -108px; opacity: 0.8; cursor: pointer; - z-index: 8020; + z-index: 8060; } #fancybox-loading div { @@ -109,6 +113,7 @@ width: 40%; height: 100%; cursor: pointer; + text-decoration: none; background: transparent url('blank.gif'); /* helps IE */ -webkit-tap-highlight-color: rgba(0,0,0,0); z-index: 8040; @@ -134,12 +139,12 @@ } .fancybox-prev span { - left: 20px; + left: 10px; background-position: 0 -36px; } .fancybox-next span { - right: 20px; + right: 10px; background-position: 0 -72px; } @@ -151,29 +156,36 @@ position: absolute; top: -9999px; left: -9999px; - padding: 0; - overflow: visible; visibility: hidden; } /* Overlay helper */ -#fancybox-overlay { +.fancybox-lock { + overflow: hidden; +} + +.fancybox-overlay { position: absolute; top: 0; left: 0; overflow: hidden; display: none; z-index: 8010; - background: #000; + background: url('fancybox_overlay.png'); } -#fancybox-overlay.overlay-fixed { +.fancybox-overlay-fixed { position: fixed; bottom: 0; right: 0; } +.fancybox-lock .fancybox-overlay { + overflow: auto; + overflow-y: scroll; +} + /* Title helper */ .fancybox-title { @@ -193,7 +205,7 @@ bottom: 0; right: 50%; margin-bottom: -35px; - z-index: 8030; + z-index: 8050; text-align: center; } @@ -220,7 +232,7 @@ } .fancybox-title-inside-wrap { - margin-top: 10px; + padding-top: 10px; } .fancybox-title-over-wrap { diff --git a/fancybox/jquery.fancybox.js b/fancybox/jquery.fancybox.js index 704d95c..911ca76 100644 --- a/fancybox/jquery.fancybox.js +++ b/fancybox/jquery.fancybox.js @@ -1,6 +1,6 @@ /*! * fancyBox - jQuery Plugin - * version: 2.0.6 (16/04/2012) + * version: 2.1.0 (Mon, 20 Aug 2012) * @requires jQuery v1.6 or later * * Examples at http://fancyapps.com/fancybox/ @@ -18,199 +18,359 @@ F = $.fancybox = function () { F.open.apply( this, arguments ); }, - didResize = false, - resizeTimer = null, - isTouch = document.createTouch !== undefined, - isString = function(str) { - return $.type(str) === "string"; + didUpdate = null, + isTouch = document.createTouch !== undefined, + + isQuery = function(obj) { + return obj && obj.hasOwnProperty && obj instanceof $; + }, + isString = function(str) { + return str && $.type(str) === "string"; }, isPercentage = function(str) { return isString(str) && str.indexOf('%') > 0; }, - getValue = function(value, dim) { + 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); + if (dim && isPercentage(value)) { - value = F.getViewport()[ dim ] / 100 * parseInt(value, 10); + value_ = F.getViewport()[ dim ] / 100 * value_; } - return Math.round(value) + 'px'; + return Math.ceil(value_); + }, + getValue = function(value, dim) { + return getScalar(value, dim) + 'px'; }; $.extend(F, { // The current version of fancyBox - version: '2.0.5', + version: '2.1.0', defaults: { - padding: 15, - margin: 20, + padding : 15, + margin : 20, - width: 800, - height: 600, - minWidth: 100, - minHeight: 100, - maxWidth: 9999, - maxHeight: 9999, + width : 800, + height : 600, + minWidth : 100, + minHeight : 100, + maxWidth : 9999, + maxHeight : 9999, - autoSize: true, - autoResize: !isTouch, - autoCenter : !isTouch, - fitToView: true, - aspectRatio: false, - topRatio: 0.5, + autoSize : true, + autoHeight : false, + autoWidth : false, - fixed: false, - scrolling: 'auto', // 'auto', 'yes' or 'no' - wrapCSS: '', + autoResize : !isTouch, + autoCenter : !isTouch, + fitToView : true, + aspectRatio : false, + topRatio : 0.5, + leftRatio : 0.5, - arrows: true, - closeBtn: true, - closeClick: false, - nextClick : false, - mouseWheel: true, - autoPlay: false, - playSpeed: 3000, - preload : 3, + scrolling : 'auto', // 'auto', 'yes' or 'no' + wrapCSS : '', - modal: false, - loop: true, - ajax: { dataType: 'html', headers: { 'X-fancyBox': true } }, - keys: { - next: [13, 32, 34, 39, 40], // enter, space, page down, right arrow, down arrow - prev: [8, 33, 37, 38], // backspace, page up, left arrow, up arrow - close: [27] // escape key + arrows : true, + closeBtn : true, + closeClick : false, + nextClick : false, + mouseWheel : true, + autoPlay : false, + playSpeed : 3000, + preload : 3, + modal : false, + loop : true, + + ajax : { + dataType : 'html', + headers : { 'X-fancyBox': true } + }, + iframe : { + scrolling : 'auto', + preload : true + }, + swf : { + wmode: 'transparent', + allowfullscreen : 'true', + allowscriptaccess : 'always' }, + keys : { + next : { + 13 : 'left', // enter + 34 : 'up', // page down + 39 : 'left', // right arrow + 40 : 'up' // down arrow + }, + prev : { + 8 : 'right', // backspace + 33 : 'down', // page up + 37 : 'right', // left arrow + 38 : 'down' // up arrow + }, + close : [27], // escape key + play : [32], // space - start/stop slideshow + toggle : [70] // letter "f" - toggle fullscreen + }, + + direction : { + next : 'left', + prev : 'right' + }, + + scrollOutside : true, + // Override some properties - index: 0, - type: null, - href: null, - content: null, - title: null, + index : 0, + type : null, + href : null, + content : null, + title : null, // HTML templates tpl: { - wrap: '
    ', - image: '', - iframe: '', - swf: '', - error: '

    The requested content cannot be loaded.
    Please try again later.

    ', - closeBtn: '
    ', - next: '', - prev: '' + wrap : '
    ', + image : '', + iframe : '', + error : '

    The requested content cannot be loaded.
    Please try again later.

    ', + closeBtn : '', + next : '', + prev : '' }, // Properties for each animation type // Opening fancyBox - openEffect: 'fade', // 'elastic', 'fade' or 'none' - openSpeed: 300, - openEasing: 'swing', - openOpacity: true, - openMethod: 'zoomIn', + openEffect : 'fade', // 'elastic', 'fade' or 'none' + openSpeed : 250, + openEasing : 'swing', + openOpacity : true, + openMethod : 'zoomIn', // Closing fancyBox - closeEffect: 'fade', // 'elastic', 'fade' or 'none' - closeSpeed: 300, - closeEasing: 'swing', - closeOpacity: true, - closeMethod: 'zoomOut', + closeEffect : 'fade', // 'elastic', 'fade' or 'none' + closeSpeed : 250, + closeEasing : 'swing', + closeOpacity : true, + closeMethod : 'zoomOut', // Changing next gallery item - nextEffect: 'elastic', // 'elastic', 'fade' or 'none' - nextSpeed: 300, - nextEasing: 'swing', - nextMethod: 'changeIn', + nextEffect : 'elastic', // 'elastic', 'fade' or 'none' + nextSpeed : 250, + nextEasing : 'swing', + nextMethod : 'changeIn', // Changing previous gallery item - prevEffect: 'elastic', // 'elastic', 'fade' or 'none' - prevSpeed: 300, - prevEasing: 'swing', - prevMethod: 'changeOut', + prevEffect : 'elastic', // 'elastic', 'fade' or 'none' + prevSpeed : 250, + prevEasing : 'swing', + prevMethod : 'changeOut', // Enabled helpers - helpers: { - overlay: { - speedIn: 0, - speedOut: 300, - opacity: 0.8, - css: { - cursor: 'pointer' - }, - closeClick: true + helpers : { + overlay : { + closeClick : true, + speedOut : 200, + showEarly : true, + css : {} }, - title: { - type: 'float' // 'float', 'inside', 'outside' or 'over' + title : { + type : 'float' // 'float', 'inside', 'outside' or 'over' } }, // Callbacks - onCancel: $.noop, // If canceling - beforeLoad: $.noop, // Before loading - afterLoad: $.noop, // After loading - beforeShow: $.noop, // Before changing in current item - afterShow: $.noop, // After opening - beforeClose: $.noop, // Before closing - afterClose: $.noop // After closing + onCancel : $.noop, // If canceling + beforeLoad : $.noop, // Before loading + afterLoad : $.noop, // After loading + beforeShow : $.noop, // Before changing in current item + afterShow : $.noop, // After opening + beforeChange : $.noop, // Before changing gallery item + beforeClose : $.noop, // Before closing + afterClose : $.noop // After closing }, //Current state - group: {}, // Selected group - opts: {}, // Group options - coming: null, // Element being loaded - current: null, // Currently loaded element - isOpen: false, // Is currently open - isOpened: false, // Have been fully opened at least once - wrap: null, - skin: null, - outer: null, - inner: null, + group : {}, // Selected group + opts : {}, // Group options + previous : null, // Previous element + coming : null, // Element being loaded + current : null, // Currently loaded element + isActive : false, // Is activated + isOpen : false, // Is currently open + isOpened : false, // Have been fully opened at least once - player: { - timer: null, - isActive: false + wrap : null, + skin : null, + outer : null, + inner : null, + + player : { + timer : null, + isActive : false }, // Loaders - ajaxLoad: null, - imgPreload: null, + ajaxLoad : null, + imgPreload : null, // Some collections - transitions: {}, - helpers: {}, + transitions : {}, + helpers : {}, /* * Static methods */ open: function (group, opts) { - //Kill existing instances - F.close(true); - - //Normalize group - if (group && !$.isArray(group)) { - group = group instanceof $ ? $(group).get() : [group]; + if (!group) { + return; } - F.isActive = true; + if (!$.isPlainObject(opts)) { + opts = {}; + } - //Extend the defaults + // Close if already active + if (false === F.close(true)) { + return; + } + + // Normalize group + if (!$.isArray(group)) { + group = isQuery(group) ? $(group).get() : [group]; + } + + // Recheck if the type of each element is `object` and set content type (image, ajax, etc) + $.each(group, function(i, element) { + var obj = {}, + href, + title, + content, + type, + rez, + hrefParts, + selector; + + if ($.type(element) === "object") { + // Check if is DOM element + if (element.nodeType) { + element = $(element); + } + + if (isQuery(element)) { + obj = { + href : element.attr('href'), + title : element.attr('title'), + isDom : true, + element : element + }; + + if ($.metadata) { + $.extend(true, obj, element.metadata()); + } + + } else { + obj = element; + } + } + + href = opts.href || obj.href || (isString(element) ? element : null); + title = opts.title !== undefined ? opts.title : obj.title || ''; + + content = opts.content || obj.content; + type = content ? 'html' : (opts.type || obj.type); + + if (!type && obj.isDom) { + type = element.data('fancybox-type'); + + if (!type) { + rez = element.prop('class').match(/fancybox\.(\w+)/); + type = rez ? rez[1] : null; + } + } + + if (isString(href)) { + // Try to guess the content type + if (!type) { + if (F.isImage(href)) { + type = 'image'; + + } else if (F.isSWF(href)) { + type = 'swf'; + + } else if (href.charAt(0) === '#') { + type = 'inline'; + + } else if (isString(element)) { + type = 'html'; + content = element; + } + } + + // Split url into two pieces with source url and content selector, e.g, + // "/mypage.html #my_id" will load "/mypage.html" and display element having id "my_id" + if (type === 'ajax') { + hrefParts = href.split(/\s+/, 2); + href = hrefParts.shift(); + selector = hrefParts.shift(); + } + } + + if (!content) { + if (type === 'inline') { + if (href) { + content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7 + + } else if (obj.isDom) { + content = element; + } + + } else if (type === 'html') { + content = href; + + } else if (!type && !href && obj.isDom) { + type = 'inline'; + content = element; + } + } + + $.extend(obj, { + href : href, + type : type, + content : content, + title : title, + selector : selector + }); + + group[ i ] = obj; + }); + + // Extend the defaults F.opts = $.extend(true, {}, F.defaults, opts); - //All options are merged recursive except keys - if ($.isPlainObject(opts) && opts.keys !== undefined) { + // All options are merged recursive except keys + if (opts.keys !== undefined) { F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false; } F.group = group; - F._start(F.opts.index || 0); + return F._start(F.opts.index); }, + // Cancel image loading or abort ajax request cancel: function () { - if (F.coming && false === F.trigger('onCancel')) { + var coming = F.coming; + + if (!coming || false === F.trigger('onCancel')) { return; } - F.coming = null; - F.hideLoading(); if (F.ajaxLoad) { @@ -220,39 +380,57 @@ F.ajaxLoad = null; if (F.imgPreload) { - F.imgPreload.onload = F.imgPreload.onabort = F.imgPreload.onerror = null; + 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(); + } + + if (!F.current) { + F.trigger('afterClose'); + } + + F.coming = null; }, - close: function (a) { + // Start closing animation if is open; remove immediately if opening/closing + close: function (immediately) { F.cancel(); - if (!F.current || false === F.trigger('beforeClose')) { + if (false === F.trigger('beforeClose')) { return; } F.unbindEvents(); - //If forced or is still opening then remove immediately - if (!F.isOpen || (a && a[0] === true)) { - $('.fancybox-wrap').stop().trigger('onReset').remove(); + if (!F.isOpen || immediately === true) { + $('.fancybox-wrap').stop(true).trigger('onReset').remove(); F._afterZoomOut(); } else { F.isOpen = F.isOpened = false; + F.isClosing = true; $('.fancybox-item, .fancybox-nav').remove(); - F.wrap.stop(true).removeClass('fancybox-opened'); - F.inner.css('overflow', 'hidden'); + F.wrap.stop(true, true).removeClass('fancybox-opened'); - F.transitions[F.current.closeMethod](); + if (F.wrap.css('position') === 'fixed') { + F.wrap.css(F._getPosition( true )); + } + + F.transitions[ F.current.closeMethod ](); } }, - // Start/stop slideshow - play: function (a) { + // Manage slideshow: + // $.fancybox.play(); - toggle slideshow + // $.fancybox.play( true ); - start + // $.fancybox.play( false ); - stop + play: function ( action ) { var clear = function () { clearTimeout(F.player.timer); }, @@ -277,9 +455,9 @@ F.player.isActive = true; $('body').bind({ - 'afterShow.player onUpdate.player': set, - 'onCancel.player beforeClose.player': stop, - 'beforeLoad.player': clear + 'afterShow.player onUpdate.player' : set, + 'onCancel.player beforeClose.player' : stop, + 'beforeLoad.player' : clear }); set(); @@ -288,48 +466,68 @@ } }; - if (F.player.isActive || (a && a[0] === false)) { - stop(); - } else { + if (action === true || (!F.player.isActive && action !== false)) { start(); + } else { + stop(); } }, - next: function () { - if (F.current) { - F.jumpto(F.current.index + 1); + // Navigate to next gallery item + next: function ( direction ) { + var current = F.current; + + if (current) { + if (!isString(direction)) { + direction = current.direction.next; + } + + F.jumpto(current.index + 1, direction, 'next'); } }, - prev: function () { - if (F.current) { - F.jumpto(F.current.index - 1); + // Navigate to previous gallery item + prev: function ( direction ) { + var current = F.current; + + if (current) { + if (!isString(direction)) { + direction = current.direction.prev; + } + + F.jumpto(current.index - 1, direction, 'prev'); } }, - jumpto: function (index) { - if (!F.current) { + // Navigate to gallery item by index + jumpto: function ( index, direction, router ) { + var current = F.current; + + if (!current) { return; } - index = parseInt(index, 10); + index = getScalar(index); - if (F.group.length > 1 && F.current.loop) { - if (index >= F.group.length) { - index = 0; + F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ]; + F.router = router || 'jumpto'; - } else if (index < 0) { - index = F.group.length - 1; + if (current.loop) { + if (index < 0) { + index = current.group.length + (index % current.group.length); } + + index = index % current.group.length; } - if (F.group[index] !== undefined) { + if (current.group[ index ] !== undefined) { F.cancel(); F._start(index); } }, + // Center inside viewport and toggle position type to fixed or absolute if needed reposition: function (e, onlyAbsolute) { var pos; @@ -348,52 +546,54 @@ }, update: function (e) { - if (!F.isOpen) { + var type = (e && e.type), + anyway = !type || type === 'orientationchange'; + + if (anyway) { + clearTimeout(didUpdate); + + didUpdate = null; + } + + if (!F.isOpen || didUpdate) { return; } - // Run this code after a delay for better performance - if (!didResize) { - resizeTimer = setTimeout(function () { - var current = F.current, anyway = !e || (e && e.type === 'orientationchange'); + // Help browser to restore document dimensions + if (anyway || isTouch) { + F.wrap.removeAttr('style').addClass('fancybox-tmp'); - if (didResize) { - didResize = false; - - if (!current) { - return; - } - - if ((!e || e.type !== 'scroll') || anyway) { - if (current.autoSize && current.type !== 'iframe') { - F.inner.height('auto'); - current.height = F.inner.height(); - } - - if (current.autoResize || anyway) { - F._setDimension(); - } - - if (current.canGrow && current.type !== 'iframe') { - F.inner.height('auto'); - } - } - - if (current.autoCenter || anyway) { - F.reposition(e); - } - - F.trigger('onUpdate'); - } - }, 200); + F.trigger('onUpdate'); } - didResize = true; + didUpdate = setTimeout(function() { + var current = F.current; + + if (!current) { + return; + } + + F.wrap.removeClass('fancybox-tmp'); + + if (type !== 'scroll') { + F._setDimension(); + } + + if (!(type === 'scroll' && current.canShrink)) { + F.reposition(e); + } + + F.trigger('onUpdate'); + + didUpdate = null; + + }, (isTouch ? 500 : (anyway ? 20 : 300))); }, - toggle: function () { + // Shrink content to fit inside viewport or restore if resized + toggle: function ( action ) { if (F.isOpen) { - F.current.fitToView = !F.current.fitToView; + F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView; F.update(); } @@ -406,32 +606,54 @@ }, showLoading: function () { + var el, viewport; + F.hideLoading(); - //If user will press the escape-button, the request will be canceled + // If user will press the escape-button, the request will be canceled D.bind('keypress.fb', function(e) { - if (e.keyCode === 27) { + if ((e.which || e.keyCode) === 27) { e.preventDefault(); F.cancel(); } }); - $('
    ').click(F.cancel).appendTo('body'); + el = $('
    ').click(F.cancel).appendTo('body'); + + if (!F.defaults.fixed) { + viewport = F.getViewport(); + + el.css({ + position : 'absolute', + top : (viewport.h * 0.5) + viewport.y, + left : (viewport.w * 0.5) + viewport.x + }); + } }, getViewport: function () { - // See http://bugs.jquery.com/ticket/6724 - return { - x: W.scrollLeft(), - y: W.scrollTop(), - w: isTouch && window.innerWidth ? window.innerWidth : W.width(), - h: isTouch && window.innerHeight ? window.innerHeight : W.height() - }; + var lock = 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; + + } else { + // See http://bugs.jquery.com/ticket/6724 + rez.w = isTouch && window.innerWidth ? window.innerWidth : W.width(); + rez.h = isTouch && window.innerHeight ? window.innerHeight : W.height(); + } + + return rez; }, // Unbind the keyboard / clicking actions unbindEvents: function () { - if (F.wrap) { + if (F.wrap && isQuery(F.wrap)) { F.wrap.unbind('.fb'); } @@ -441,53 +663,77 @@ bindEvents: function () { var current = F.current, - keys = current.keys; + keys; if (!current) { return; } - W.bind('resize.fb orientationchange.fb' + (current.autoCenter && !current.fixed ? ' scroll.fb' : ''), F.update); + // 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); + + keys = current.keys; if (keys) { D.bind('keydown.fb', function (e) { - var code, target = e.target || e.srcElement; + var code = e.which || e.keyCode, + target = e.target || e.srcElement; // Ignore key combinations and key events within form elements if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) { - code = e.keyCode; + $.each(keys, function(i, val) { + if (current.group.length > 1 && val[ code ] !== undefined) { + F[ i ]( val[ code ] ); - if ($.inArray(code, keys.close) > -1) { - F.close(); - e.preventDefault(); + e.preventDefault(); + return false; + } - } else if ($.inArray(code, keys.next) > -1) { - F.next(); - e.preventDefault(); + if ($.inArray(code, val) > -1) { + F[ i ] (); - } else if ($.inArray(code, keys.prev) > -1) { - F.prev(); - e.preventDefault(); - } + e.preventDefault(); + return false; + } + }); } }); } - if ($.fn.mousewheel && current.mouseWheel && F.group.length > 1) { - F.wrap.bind('mousewheel.fb', function (e, delta) { - var target = e.target || null; + if ($.fn.mousewheel && current.mouseWheel) { + F.wrap.bind('mousewheel.fb', function (e, delta, deltaX, deltaY) { + var target = e.target || null, + parent = $(target), + canScroll = false; - if (delta !== 0 && (!target || target.clientHeight === 0 || (target.scrollHeight === target.clientHeight && target.scrollWidth === target.clientWidth))) { - e.preventDefault(); + while (parent.length) { + if (canScroll || parent.is('.fancybox-skin') || parent.is('.fancybox-wrap')) { + break; + } - F[delta > 0 ? 'prev' : 'next'](); + canScroll = isScrollable( parent[0] ); + parent = $(parent).parent(); + } + + if (delta !== 0 && !canScroll) { + if (F.group.length > 1 && !current.canShrink) { + if (deltaY > 0 || deltaX > 0) { + F.prev( deltaY > 0 ? 'down' : 'left' ); + + } else if (deltaY < 0 || deltaX < 0) { + F.next( deltaY < 0 ? 'up' : 'right' ); + } + + e.preventDefault(); + } } }); } }, trigger: function (event, o) { - var ret, obj = o || F[ $.inArray(event, ['onCancel', 'beforeLoad', 'afterLoad']) > -1 ? 'coming' : 'current' ]; + var ret, obj = o || F.coming || F.current; if (!obj) { return; @@ -501,9 +747,13 @@ return false; } + if (event === 'onCancel' && !F.isOpened) { + F.isActive = false; + } + if (obj.helpers) { $.each(obj.helpers, function (helper, opts) { - if (opts && $.isPlainObject(F.helpers[helper]) && $.isFunction(F.helpers[helper][event])) { + if (opts && F.helpers[helper] && $.isFunction(F.helpers[helper][event])) { F.helpers[helper][event](opts, obj); } }); @@ -513,7 +763,7 @@ }, isImage: function (str) { - return isString(str) && str.match(/\.(jpe?g|gif|png|bmp)((\?|#).*)?$/i); + return isString(str) && str.match(/\.(jp(e|g|eg)|gif|png|bmp|webp)((\?|#).*)?$/i); }, isSWF: function (str) { @@ -522,112 +772,61 @@ _start: function (index) { var coming = {}, - element = F.group[index] || null, - isDom, + obj, href, type, - rez, - hrefParts; + margin, + padding; - if (element && (element.nodeType || element instanceof $)) { - isDom = true; + index = getScalar( index ); + obj = F.group[ index ] || null; - if ($.metadata) { - coming = $(element).metadata(); - } + if (!obj) { + return false; } - coming = $.extend(true, {}, F.opts, {index : index, element : element}, ($.isPlainObject(element) ? element : coming)); + coming = $.extend(true, {}, F.opts, obj); - // Re-check overridable options - $.each(['href', 'title', 'content', 'type'], function(i,v) { - coming[v] = F.opts[ v ] || (isDom && $(element).attr( v )) || coming[ v ] || null; - }); + // Convert margin and padding properties to array - top, right, bottom, left + margin = coming.margin; + padding = coming.padding; - // Convert margin property to array - top, right, bottom, left - if (typeof coming.margin === 'number') { - coming.margin = [coming.margin, coming.margin, coming.margin, coming.margin]; + if ($.type(margin) === 'number') { + coming.margin = [margin, margin, margin, margin]; + } + + if ($.type(padding) === 'number') { + coming.padding = [padding, padding, padding, padding]; } // 'modal' propery is just a shortcut if (coming.modal) { $.extend(true, coming, { - closeBtn : false, - closeClick: false, - nextClick : false, - arrows : false, + closeBtn : false, + closeClick : false, + nextClick : false, + arrows : false, mouseWheel : false, - keys : null, + keys : null, helpers: { overlay : { - css: { - cursor : 'auto' - }, closeClick : false } } }); } - //Give a chance for callback or helpers to update coming item (type, title, etc) - F.coming = coming; - - if (false === F.trigger('beforeLoad')) { - F.coming = null; - return; + // 'autoSize' property is a shortcut, too + if (coming.autoSize) { + coming.autoWidth = coming.autoHeight = true; } - type = coming.type; - href = coming.href || element; - - ///Check if content type is set, if not, try to get - if (!type) { - if (isDom) { - type = $(element).data('fancybox-type'); - - if (!type) { - rez = element.className.match(/fancybox\.(\w+)/); - type = rez ? rez[1] : null; - } - } - - if (!type && isString(href)) { - if (F.isImage(href)) { - type = 'image'; - - } else if (F.isSWF(href)) { - type = 'swf'; - - } else if (href.match(/^#/)) { - type = 'inline'; - } - } - - // ...if not - display element itself - if (!type) { - type = isDom ? 'inline' : 'html'; - } - - coming.type = type; + if (coming.width === 'auto') { + coming.autoWidth = true; } - // Check before try to load; 'inline' and 'html' types need content, others - href - if (type === 'inline' || type === 'html') { - if (!coming.content) { - if (type === 'inline') { - coming.content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7 - - } else { - coming.content = element; - } - } - - if (!coming.content || !coming.content.length) { - type = null; - } - - } else if (!href) { - type = null; + if (coming.height === 'auto') { + coming.autoHeight = true; } /* @@ -637,49 +836,98 @@ * } */ - if (type === 'ajax' && isString(href)) { - hrefParts = href.split(/\s+/, 2); + coming.group = F.group; + coming.index = index; - href = hrefParts.shift(); - coming.selector = hrefParts.shift(); + // Give a chance for callback or helpers to update coming item (type, title, etc) + F.coming = coming; + + if (false === F.trigger('beforeLoad')) { + F.coming = null; + + return; } - coming.href = href; - coming.group = F.group; - coming.isDom = isDom; + type = coming.type; + href = coming.href; - switch (type) { - case 'image': - F._loadImage(); - break; + if (!type) { + F.coming = null; - case 'ajax': - F._loadAjax(); - break; + //If we can not determine content type then drop silently or display next/prev item if looping through gallery + if (F.current && F.router && F.router !== 'jumpto') { + F.current.index = index; - case 'inline': - case 'iframe': - case 'swf': - case 'html': - F._afterLoad(); - break; + return F[ F.router ]( F.direction ); + } - default: - F._error( 'type' ); + return false; + } + + F.isActive = true; + + if (type === 'image' || type === 'swf') { + coming.autoHeight = coming.autoWidth = false; + coming.scrolling = 'visible'; + } + + if (type === 'image') { + coming.aspectRatio = true; + } + + if (type === 'iframe' && isTouch) { + coming.scrolling = 'scroll'; + } + + // Build the neccessary markup + coming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent ); + + $.extend(coming, { + skin : $('.fancybox-skin', coming.wrap), + outer : $('.fancybox-outer', coming.wrap), + inner : $('.fancybox-inner', coming.wrap) + }); + + $.each(["Top", "Right", "Bottom", "Left"], function(i, v) { + coming.skin.css('padding' + v, getValue(coming.padding[ i ])); + }); + + F.trigger('onReady'); + + // Check before try to load; 'inline' and 'html' types need content, others - href + if (type === 'inline' || type === 'html') { + if (!coming.content || !coming.content.length) { + return F._error( 'content' ); + } + + } else if (!href) { + return F._error( 'href' ); + } + + if (type === 'image') { + F._loadImage(); + + } else if (type === 'ajax') { + F._loadAjax(); + + } else if (type === 'iframe') { + F._loadIframe(); + + } else { + F._afterLoad(); } }, _error: function ( type ) { - F.hideLoading(); - $.extend(F.coming, { - type : 'html', - autoSize : true, - minWidth : 0, - minHeight : 0, - padding : 15, - hasError : type, - content : F.coming.tpl.error + type : 'html', + autoWidth : true, + autoHeight : true, + minWidth : 0, + minHeight : 0, + scrolling : 'no', + hasError : type, + content : F.coming.tpl.error }); F._afterLoad(); @@ -712,10 +960,12 @@ }, _loadAjax: function () { + var coming = F.coming; + F.showLoading(); - F.ajaxLoad = $.ajax($.extend({}, F.coming.ajax, { - url: F.coming.href, + F.ajaxLoad = $.ajax($.extend({}, coming.ajax, { + url: coming.href, error: function (jqXHR, textStatus) { if (F.coming && textStatus !== 'abort') { F._error( 'ajax', jqXHR ); @@ -726,7 +976,7 @@ }, success: function (data, textStatus) { if (textStatus === 'success') { - F.coming.content = data; + coming.content = data; F._afterLoad(); } @@ -734,75 +984,117 @@ })); }, - _preloadImages: function() { - var group = F.group, - current = F.current, - len = group.length, - item, - href, - i, - cnt = Math.min(current.preload, len - 1); + _loadIframe: function() { + var coming = F.coming, + iframe = $(coming.tpl.iframe.replace(/\{rnd\}/g, new Date().getTime())) + .attr('scrolling', isTouch ? 'auto' : coming.iframe.scrolling) + .attr('src', coming.href); - if (!current.preload || group.length < 2) { - return; + // This helps IE + $(coming.wrap).bind('onReset', function () { + try { + $(this).find('iframe').hide().attr('src', '//about:blank').end().empty(); + } catch (e) {} + }); + + if (coming.iframe.preload) { + F.showLoading(); + + iframe.one('load', function() { + $(this).data('ready', 1); + + // iOS will lose scrolling if we resize + if (!isTouch) { + $(this).bind('load.fb', F.update); + } + + // Without this trick: + // - iframe won't scroll on iOS devices + // - IE7 sometimes displays empty iframe + $(this).parents('.fancybox-wrap').width('100%').removeClass('fancybox-tmp').show(); + + F._afterLoad(); + }); } + coming.content = iframe.appendTo( coming.inner ); + + if (!coming.iframe.preload) { + F._afterLoad(); + } + }, + + _preloadImages: function() { + var group = F.group, + current = F.current, + len = group.length, + cnt = current.preload ? Math.min(current.preload, len - 1) : 0, + item, + i; + for (i = 1; i <= cnt; i += 1) { item = group[ (current.index + i ) % len ]; - href = item.href || $( item ).attr('href') || item; - if (item.type === 'image' || F.isImage(href)) { - new Image().src = href; + if (item.type === 'image' && item.href) { + new Image().src = item.href; } } }, _afterLoad: function () { + var coming = F.coming, + previous = F.current, + placeholder = 'fancybox-placeholder', + current, + content, + type, + scrolling, + href, + embed; + F.hideLoading(); - if (!F.coming || false === F.trigger('afterLoad', F.current)) { - F.coming = false; + if (!coming || F.isActive === false) { + return; + } + + if (false === F.trigger('afterLoad', coming, previous)) { + coming.wrap.stop(true).trigger('onReset').remove(); + + F.coming = null; return; } - if (F.isOpened) { - $('.fancybox-item, .fancybox-nav').remove(); + if (previous) { + F.trigger('beforeChange', previous); - F.wrap.stop(true).removeClass('fancybox-opened'); - F.inner.css('overflow', 'hidden'); + previous.wrap.stop(true).removeClass('fancybox-opened') + .find('.fancybox-item, .fancybox-nav') + .remove(); - F.transitions[F.current.prevMethod](); - - } else { - $('.fancybox-wrap').stop().trigger('onReset').remove(); - - F.trigger('afterClose'); + if (previous.wrap.css('position') === 'fixed') { + previous.wrap.css(F._getPosition( true )); + } } F.unbindEvents(); - F.isOpen = false; - F.current = F.coming; + current = coming; + content = coming.content; + type = coming.type; + scrolling = coming.scrolling; - //Build the neccessary markup - F.wrap = $(F.current.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + F.current.type + ' fancybox-tmp ' + F.current.wrapCSS).appendTo('body'); - F.skin = $('.fancybox-skin', F.wrap).css('padding', getValue(F.current.padding)); - F.outer = $('.fancybox-outer', F.wrap); - F.inner = $('.fancybox-inner', F.wrap); + $.extend(F, { + wrap : current.wrap, + skin : current.skin, + outer : current.outer, + inner : current.inner, + current : current, + previous : previous + }); - F._setContent(); - }, - - _setContent: function () { - var current = F.current, - content = current.content, - type = current.type, - minWidth = current.minWidth, - minHeight = current.minHeight, - maxWidth = current.maxWidth, - maxHeight = current.maxHeight, - loadingBay; + href = current.href; switch (type) { case 'inline': @@ -811,270 +1103,317 @@ if (current.selector) { content = $('
    ').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 = ''; + embed = ''; - case 'iframe': - content = $(current.tpl.iframe.replace('{rnd}', new Date().getTime()) ) - .attr('scrolling', current.scrolling) - .attr('src', current.href); + $.each(current.swf, function(name, val) { + content += ''; + embed += ' ' + name + '="' + val + '"'; + }); - current.scrolling = isTouch ? 'scroll' : 'auto'; - - 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:'',iframe:'",swf:'',error:'

    The requested content cannot be loaded.
    Please try again later.

    ', -closeBtn:'
    ',next:'',prev:''},openEffect:"fade",openSpeed:300,openEasing:"swing",openOpacity:!0,openMethod:"zoomIn",closeEffect:"fade",closeSpeed:300,closeEasing:"swing",closeOpacity:!0,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:300,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic", -prevSpeed:300,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:{speedIn:0,speedOut:300,opacity:0.8,css:{cursor:"pointer"},closeClick:!0},title:{type:"float"}}},group:{},opts:{},coming:null,current:null,isOpen:!1,isOpened:!1,player:{timer:null,isActive:!1},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(b,c){a.close(!0);b&&!d.isArray(b)&&(b=b instanceof d?d(b).get():[b]);a.isActive=!0;a.opts=d.extend(!0,{},a.defaults,c);d.isPlainObject(c)&&c.keys!==t&&(a.opts.keys=c.keys? -d.extend({},a.defaults.keys,c.keys):!1);a.group=b;a._start(a.opts.index||0)},cancel:function(){a.coming&&!1===a.trigger("onCancel")||(a.coming=null,a.hideLoading(),a.ajaxLoad&&a.ajaxLoad.abort(),a.ajaxLoad=null,a.imgPreload&&(a.imgPreload.onload=a.imgPreload.onabort=a.imgPreload.onerror=null))},close:function(b){a.cancel();a.current&&!1!==a.trigger("beforeClose")&&(a.unbindEvents(),!a.isOpen||b&&!0===b[0]?(d(".fancybox-wrap").stop().trigger("onReset").remove(),a._afterZoomOut()):(a.isOpen=a.isOpened= -!1,d(".fancybox-item, .fancybox-nav").remove(),a.wrap.stop(!0).removeClass("fancybox-opened"),a.inner.css("overflow","hidden"),a.transitions[a.current.closeMethod]()))},play:function(b){var c=function(){clearTimeout(a.player.timer)},e=function(){c();a.current&&a.player.isActive&&(a.player.timer=setTimeout(a.next,a.current.playSpeed))},f=function(){c();d("body").unbind(".player");a.player.isActive=!1;a.trigger("onPlayEnd")};if(a.player.isActive||b&&!1===b[0])f();else if(a.current&&(a.current.loop|| -a.current.index=a.group.length?b=0:0>b&&(b=a.group.length-1)),a.group[b]!==t&&(a.cancel(),a._start(b)))},reposition:function(b, -c){var e;a.isOpen&&(e=a._getPosition(c),b&&"scroll"===b.type?(delete e.position,a.wrap.stop(!0,!0).animate(e,200)):a.wrap.css(e))},update:function(b){a.isOpen&&(u||setTimeout(function(){var c=a.current,e=!b||b&&"orientationchange"===b.type;if(u&&(u=!1,c)){if(!b||"scroll"!==b.type||e)c.autoSize&&"iframe"!==c.type&&(a.inner.height("auto"),c.height=a.inner.height()),(c.autoResize||e)&&a._setDimension(),c.canGrow&&"iframe"!==c.type&&a.inner.height("auto");(c.autoCenter||e)&&a.reposition(b);a.trigger("onUpdate")}}, -200),u=!0)},toggle:function(){a.isOpen&&(a.current.fitToView=!a.current.fitToView,a.update())},hideLoading:function(){q.unbind("keypress.fb");d("#fancybox-loading").remove()},showLoading:function(){a.hideLoading();q.bind("keypress.fb",function(b){27===b.keyCode&&(b.preventDefault(),a.cancel())});d('
    ').click(a.cancel).appendTo("body")},getViewport:function(){return{x:m.scrollLeft(),y:m.scrollTop(),w:k&&s.innerWidth?s.innerWidth:m.width(),h:k&&s.innerHeight? -s.innerHeight:m.height()}},unbindEvents:function(){a.wrap&&a.wrap.unbind(".fb");q.unbind(".fb");m.unbind(".fb")},bindEvents:function(){var b=a.current,c=b.keys;b&&(m.bind("resize.fb orientationchange.fb"+(b.autoCenter&&!b.fixed?" scroll.fb":""),a.update),c&&q.bind("keydown.fb",function(b){var f;f=b.target||b.srcElement;if(!b.ctrlKey&&!b.altKey&&!b.shiftKey&&!b.metaKey&&(!f||!f.type&&!d(f).is("[contenteditable]")))f=b.keyCode,-1b.length))for(i=1;i<=h;i+=1)if(f=b[(c.index+i)%e],g=f.href||d(f).attr("href")||f,"image"===f.type||a.isImage(g))(new Image).src=g},_afterLoad:function(){a.hideLoading(); -!a.coming||!1===a.trigger("afterLoad",a.current)?a.coming=!1:(a.isOpened?(d(".fancybox-item, .fancybox-nav").remove(),a.wrap.stop(!0).removeClass("fancybox-opened"),a.inner.css("overflow","hidden"),a.transitions[a.current.prevMethod]()):(d(".fancybox-wrap").stop().trigger("onReset").remove(),a.trigger("afterClose")),a.unbindEvents(),a.isOpen=!1,a.current=a.coming,a.wrap=d(a.current.tpl.wrap).addClass("fancybox-"+(k?"mobile":"desktop")+" fancybox-type-"+a.current.type+" fancybox-tmp "+a.current.wrapCSS).appendTo("body"), -a.skin=d(".fancybox-skin",a.wrap).css("padding",n(a.current.padding)),a.outer=d(".fancybox-outer",a.wrap),a.inner=d(".fancybox-inner",a.wrap),a._setContent())},_setContent:function(){var b=a.current,c=b.content,e=b.type,f=b.minWidth,g=b.minHeight,i=b.maxWidth,h=b.maxHeight;switch(e){case "inline":case "ajax":case "html":b.selector?c=d("
    ").html(c).find(b.selector):c instanceof d&&(c.parent().hasClass("fancybox-inner")&&c.parents(".fancybox-wrap").unbind("onReset"),c=c.show().detach(),d(a.wrap).bind("onReset", -function(){c.appendTo("body").hide()}));b.autoSize&&(f=d('
    ').appendTo("body").css({minWidth:n(f,"w"),minHeight:n(g,"h"),maxWidth:n(i,"w"),maxHeight:n(h,"h")}).append(c),b.width=f.width(),b.height=f.height(),f.width(a.current.width),f.height()>b.height&&(f.width(b.width+1),b.width=f.width(),b.height=f.height()),c=f.contents().detach(),f.remove());break;case "image":c=b.tpl.image.replace("{href}",b.href);b.aspectRatio=!0;break;case "swf":c= -b.tpl.swf.replace(/\{width\}/g,b.width).replace(/\{height\}/g,b.height).replace(/\{href\}/g,b.href);break;case "iframe":c=d(b.tpl.iframe.replace("{rnd}",(new Date).getTime())).attr("scrolling",b.scrolling).attr("src",b.href),b.scrolling=k?"scroll":"auto"}if("image"===e||"swf"===e)b.autoSize=!1,b.scrolling="visible";"iframe"===e&&b.autoSize?(a.showLoading(),a._setDimension(),a.inner.css("overflow",b.scrolling),c.bind({onCancel:function(){d(this).unbind();a._afterZoomOut()},load:function(){a.hideLoading(); -try{this.contentWindow.document.location&&(a.current.height=d(this).contents().find("body").height())}catch(b){a.current.autoSize=!1}a[a.isOpen?"_afterZoomIn":"_beforeShow"]()}}).appendTo(a.inner)):(a.inner.append(c),a._beforeShow())},_beforeShow:function(){a.coming=null;a.trigger("beforeShow");a._setDimension();a.wrap.hide().removeClass("fancybox-tmp");a.bindEvents();a._preloadImages();a.transitions[a.isOpened?a.current.nextMethod:a.current.openMethod]()},_setDimension:function(){var b=a.wrap,c= -a.inner,e=a.current,f=a.getViewport(),g=e.margin,i=2*e.padding,h=e.width,j=e.height,r=e.maxWidth+i,k=e.maxHeight+i,l=e.minWidth+i,m=e.minHeight+i,p;f.w-=g[1]+g[3];f.h-=g[0]+g[2];o(h)&&0r&&(h=r,j=(h-i)/g+i),j>k&&(j=k,h=(j-i)*g+i),hr||p>k)for(;(h>r||p>k)&&h>l&&p>m;)j-=10,e.aspectRatio?(h=Math.round((j-i)*g+i),hm&&jf.w||p>f.h)&&h>l&&j>m)e.canShrink=!0;a.innerSpace=p-i- -c.height()},_getPosition:function(b){var c=a.current,e=a.getViewport(),f=c.margin,d=a.wrap.width()+f[1]+f[3],i=a.wrap.height()+f[0]+f[2],h={position:"absolute",top:f[0]+e.y,left:f[3]+e.x};c.autoCenter&&c.fixed&&!b&&i<=e.h&&d<=e.w&&(h={position:"fixed",top:f[0],left:f[3]});h.top=n(Math.max(h.top,h.top+(e.h-i)*c.topRatio));h.left=n(Math.max(h.left,h.left+0.5*(e.w-d)));return h},_afterZoomIn:function(){var b=a.current,c=b?b.scrolling:"no";if(b&&(a.isOpen=a.isOpened=!0,a.wrap.addClass("fancybox-opened"), -a.inner.css("overflow","yes"===c?"scroll":"no"===c?"hidden":c),a.trigger("afterShow"),a.update(),(b.closeClick||b.nextClick)&&a.inner.css("cursor","pointer").bind("click.fb",function(c){if(!d(c.target).is("a")&&!d(c.target).parent().is("a"))a[b.closeClick?"close":"next"]()}),b.closeBtn&&d(b.tpl.closeBtn).appendTo(a.skin).bind("click.fb",a.close),b.arrows&&1c.end&&(g=1-g),d-=a.innerSpace*g),a.inner[e](d)},zoomIn:function(){var b=a.wrap,c=a.current,e=c.openEffect,f="elastic"===e,g=d.extend({},c.dim, -a._getPosition(f)),i=d.extend({opacity:1},g);delete i.position;f?(g=this.getOrigPosition(),c.openOpacity&&(g.opacity=0),a.outer.add(a.inner).width("auto").height("auto")):"fade"===e&&(g.opacity=0);b.css(g).show().animate(i,{duration:"none"===e?0:c.openSpeed,easing:c.openEasing,step:f?this.step:null,complete:a._afterZoomIn})},zoomOut:function(){var b=a.wrap,c=a.current,d=c.openEffect,f="elastic"===d,g={opacity:0};f&&("fixed"===b.css("position")&&b.css(a._getPosition(!0)),g=this.getOrigPosition(),c.closeOpacity&& -(g.opacity=0));b.animate(g,{duration:"none"===d?0:c.closeSpeed,easing:c.closeEasing,step:f?this.step:null,complete:a._afterZoomOut})},changeIn:function(){var b=a.wrap,c=a.current,d=c.nextEffect,f="elastic"===d,g=a._getPosition(f),i={opacity:1};g.opacity=0;f&&(g.top=n(parseInt(g.top,10)-200),i.top="+=200px");b.css(g).show().animate(i,{duration:"none"===d?0:c.nextSpeed,easing:c.nextEasing,complete:a._afterZoomIn})},changeOut:function(){var b=a.wrap,c=a.current,e=c.prevEffect,f={opacity:0};b.removeClass("fancybox-opened"); -"elastic"===e&&(f.top="+=200px");b.animate(f,{duration:"none"===e?0:c.prevSpeed,easing:c.prevEasing,complete:function(){d(this).trigger("onReset").remove()}})}};a.helpers.overlay={overlay:null,update:function(){var a,c;this.overlay.width("100%").height("100%");d.browser.msie||k?(a=Math.max(l.documentElement.scrollWidth,l.body.scrollWidth),c=Math.max(l.documentElement.offsetWidth,l.body.offsetWidth),a=a
    ').css(b.css).appendTo("body"),b.closeClick&&this.overlay.bind("click.fb",a.close),a.current.fixed&&!k?this.overlay.addClass("overlay-fixed"):(this.update(),this.onUpdate=function(){this.update()}),this.overlay.fadeTo(b.speedIn,b.opacity))},afterClose:function(a){this.overlay&&this.overlay.fadeOut(a.speedOut||0,function(){d(this).remove()});this.overlay=null}};a.helpers.title={beforeShow:function(b){var c; -if(c=a.current.title)c=d('
    '+c+"
    ").appendTo("body"),"float"===b.type&&(c.width(c.width()),c.wrapInner(''),a.current.margin[2]+=Math.abs(parseInt(c.css("margin-bottom"),10))),c.appendTo("over"===b.type?a.inner:"outside"===b.type?a.wrap:a.skin)}};d.fn.fancybox=function(b){var c=d(this),e=this.selector||"",f,g=function(g){var h=this,j=f,k;!g.ctrlKey&&!g.altKey&&!g.shiftKey&&!g.metaKey&&!d(h).is(".fancybox-wrap")&& -(g.preventDefault(),g=b.groupAttr||"data-fancybox-group",k=d(h).attr(g),k||(g="rel",k=h[g]),k&&""!==k&&"nofollow"!==k&&(h=e.length?d(e):c,h=h.filter("["+g+'="'+k+'"]'),j=h.index(this)),b.index=j,a.open(h,b))},b=b||{};f=b.index||0;e?q.undelegate(e,"click.fb-start").delegate(e,"click.fb-start",g):c.unbind("click.fb-start").bind("click.fb-start",g);return this};d(l).ready(function(){a.defaults.fixed=d.support.fixedPosition||!(d.browser.msie&&6>=d.browser.version)&&!k})})(window,document,jQuery); \ No newline at end of file +/*! fancyBox v2.1.0 fancyapps.com | fancyapps.com/fancybox/#license */ +(function(u,p,f,q){var o=f(u),n=f(p),b=f.fancybox=function(){b.open.apply(this,arguments)},z=null,m=p.createTouch!==q,x=function(a){return a&&a.hasOwnProperty&&a instanceof f},s=function(a){return a&&"string"===f.type(a)},C=function(a){return s(a)&&0
    ',image:'',iframe:'",error:'

    The requested content cannot be loaded.
    Please try again later.

    ',closeBtn:'',next:'',prev:''},openEffect:"fade",openSpeed:250,openEasing:"swing", +openOpacity:!0,openMethod:"zoomIn",closeEffect:"fade",closeSpeed:250,closeEasing:"swing",closeOpacity:!0,closeMethod:"zoomOut",nextEffect:"elastic",nextSpeed:250,nextEasing:"swing",nextMethod:"changeIn",prevEffect:"elastic",prevSpeed:250,prevEasing:"swing",prevMethod:"changeOut",helpers:{overlay:{closeClick:!0,speedOut:200,showEarly:!0,css:{}},title:{type:"float"}},onCancel:f.noop,beforeLoad:f.noop,afterLoad:f.noop,beforeShow:f.noop,afterShow:f.noop,beforeChange:f.noop,beforeClose:f.noop,afterClose:f.noop}, +group:{},opts:{},previous:null,coming:null,current:null,isActive:!1,isOpen:!1,isOpened:!1,wrap:null,skin:null,outer:null,inner:null,player:{timer:null,isActive:!1},ajaxLoad:null,imgPreload:null,transitions:{},helpers:{},open:function(a,c){if(a&&(f.isPlainObject(c)||(c={}),!1!==b.close(!0)))return f.isArray(a)||(a=x(a)?f(a).get():[a]),f.each(a,function(e,d){var j={},g,h,i,l,k;"object"===f.type(d)&&(d.nodeType&&(d=f(d)),x(d)?(j={href:d.attr("href"),title:d.attr("title"),isDom:!0,element:d},f.metadata&& +f.extend(!0,j,d.metadata())):j=d);g=c.href||j.href||(s(d)?d:null);h=c.title!==q?c.title:j.title||"";l=(i=c.content||j.content)?"html":c.type||j.type;!l&&j.isDom&&(l=d.data("fancybox-type"),l||(l=(l=d.prop("class").match(/fancybox\.(\w+)/))?l[1]:null));if(s(g)&&(l||(b.isImage(g)?l="image":b.isSWF(g)?l="swf":"#"===g.charAt(0)?l="inline":s(d)&&(l="html",i=d)),"ajax"===l))k=g.split(/\s+/,2),g=k.shift(),k=k.shift();i||("inline"===l?g?i=f(s(g)?g.replace(/.*(?=#[^\s]+$)/,""):g):j.isDom&&(i=d):"html"===l? +i=g:!l&&(!g&&j.isDom)&&(l="inline",i=d));f.extend(j,{href:g,type:l,content:i,title:h,selector:k});a[e]=j}),b.opts=f.extend(!0,{},b.defaults,c),c.keys!==q&&(b.opts.keys=c.keys?f.extend({},b.defaults.keys,c.keys):!1),b.group=a,b._start(b.opts.index)},cancel:function(){var a=b.coming;a&&!1!==b.trigger("onCancel")&&(b.hideLoading(),b.ajaxLoad&&b.ajaxLoad.abort(),b.ajaxLoad=null,b.imgPreload&&(b.imgPreload.onload=b.imgPreload.onerror=null),a.wrap&&a.wrap.stop(!0).trigger("onReset").remove(),b.current|| +b.trigger("afterClose"),b.coming=null)},close:function(a){b.cancel();!1!==b.trigger("beforeClose")&&(b.unbindEvents(),!b.isOpen||!0===a?(f(".fancybox-wrap").stop(!0).trigger("onReset").remove(),b._afterZoomOut()):(b.isOpen=b.isOpened=!1,b.isClosing=!0,f(".fancybox-item, .fancybox-nav").remove(),b.wrap.stop(!0,!0).removeClass("fancybox-opened"),"fixed"===b.wrap.css("position")&&b.wrap.css(b._getPosition(!0)),b.transitions[b.current.closeMethod]()))},play:function(a){var c=function(){clearTimeout(b.player.timer)}, +e=function(){c();b.current&&b.player.isActive&&(b.player.timer=setTimeout(b.next,b.current.playSpeed))},d=function(){c();f("body").unbind(".player");b.player.isActive=!1;b.trigger("onPlayEnd")};if(!0===a||!b.player.isActive&&!1!==a){if(b.current&&(b.current.loop||b.current.index=d.index?"next":"prev"],b.router=e||"jumpto",d.loop&&(0>a&&(a=d.group.length+a%d.group.length),a%=d.group.length),d.group[a]!==q))b.cancel(),b._start(a)},reposition:function(a,c){var e;b.isOpen&&(e=b._getPosition(c),a&&"scroll"===a.type?(delete e.position,b.wrap.stop(!0, +!0).animate(e,200)):b.wrap.css(e))},update:function(a){var c=a&&a.type,e=!c||"orientationchange"===c;e&&(clearTimeout(z),z=null);if(b.isOpen&&!z){if(e||m)b.wrap.removeAttr("style").addClass("fancybox-tmp"),b.trigger("onUpdate");z=setTimeout(function(){var d=b.current;if(d){b.wrap.removeClass("fancybox-tmp");c!=="scroll"&&b._setDimension();c==="scroll"&&d.canShrink||b.reposition(a);b.trigger("onUpdate");z=null}},m?500:e?20:300)}},toggle:function(a){b.isOpen&&(b.current.fitToView="boolean"===f.type(a)? +a:!b.current.fitToView,b.update())},hideLoading:function(){n.unbind("keypress.fb");f("#fancybox-loading").remove()},showLoading:function(){var a,c;b.hideLoading();n.bind("keypress.fb",function(a){if(27===(a.which||a.keyCode))a.preventDefault(),b.cancel()});a=f('
    ').click(b.cancel).appendTo("body");b.defaults.fixed||(c=b.getViewport(),a.css({position:"absolute",top:0.5*c.h+c.y,left:0.5*c.w+c.x}))},getViewport:function(){var a=b.current?b.current.locked:!1, +c={x:o.scrollLeft(),y:o.scrollTop()};a?(c.w=a[0].clientWidth,c.h=a[0].clientHeight):(c.w=m&&u.innerWidth?u.innerWidth:o.width(),c.h=m&&u.innerHeight?u.innerHeight:o.height());return c},unbindEvents:function(){b.wrap&&x(b.wrap)&&b.wrap.unbind(".fb");n.unbind(".fb");o.unbind(".fb")},bindEvents:function(){var a=b.current,c;a&&(o.bind("orientationchange.fb"+(m?"":" resize.fb")+(a.autoCenter&&!a.locked?" scroll.fb":""),b.update),(c=a.keys)&&n.bind("keydown.fb",function(e){var d=e.which||e.keyCode,j=e.target|| +e.srcElement;!e.ctrlKey&&(!e.altKey&&!e.shiftKey&&!e.metaKey&&(!j||!j.type&&!f(j).is("[contenteditable]")))&&f.each(c,function(c,j){if(1h[0].clientWidth||h[0].clientHeight&&h[0].scrollHeight>h[0].clientHeight),h=f(h).parent();if(0!==d&&!i&&1g||0>j)b.next(0>g?"up":"right");c.preventDefault()}}))},trigger:function(a,c){var e,d=c||b.coming||b.current;if(d){f.isFunction(d[a])&&(e=d[a].apply(d,Array.prototype.slice.call(arguments,1)));if(!1===e)return!1;"onCancel"===a&&!b.isOpened&&(b.isActive=!1);d.helpers&&f.each(d.helpers, +function(c,e){if(e&&b.helpers[c]&&f.isFunction(b.helpers[c][a]))b.helpers[c][a](e,d)});f.event.trigger(a+".fb")}},isImage:function(a){return s(a)&&a.match(/\.(jp(e|g|eg)|gif|png|bmp|webp)((\?|#).*)?$/i)},isSWF:function(a){return s(a)&&a.match(/\.(swf)((\?|#).*)?$/i)},_start:function(a){var c={},e,d,a=k(a);e=b.group[a]||null;if(!e)return!1;c=f.extend(!0,{},b.opts,e);e=c.margin;d=c.padding;"number"===f.type(e)&&(c.margin=[e,e,e,e]);"number"===f.type(d)&&(c.padding=[d,d,d,d]);c.modal&&f.extend(!0,c, +{closeBtn:!1,closeClick:!1,nextClick:!1,arrows:!1,mouseWheel:!1,keys:null,helpers:{overlay:{closeClick:!1}}});c.autoSize&&(c.autoWidth=c.autoHeight=!0);"auto"===c.width&&(c.autoWidth=!0);"auto"===c.height&&(c.autoHeight=!0);c.group=b.group;c.index=a;b.coming=c;if(!1===b.trigger("beforeLoad"))b.coming=null;else{d=c.type;e=c.href;if(!d)return b.coming=null,b.current&&b.router&&"jumpto"!==b.router?(b.current.index=a,b[b.router](b.direction)):!1;b.isActive=!0;if("image"===d||"swf"===d)c.autoHeight=c.autoWidth= +!1,c.scrolling="visible";"image"===d&&(c.aspectRatio=!0);"iframe"===d&&m&&(c.scrolling="scroll");c.wrap=f(c.tpl.wrap).addClass("fancybox-"+(m?"mobile":"desktop")+" fancybox-type-"+d+" fancybox-tmp "+c.wrapCSS).appendTo(c.parent);f.extend(c,{skin:f(".fancybox-skin",c.wrap),outer:f(".fancybox-outer",c.wrap),inner:f(".fancybox-inner",c.wrap)});f.each(["Top","Right","Bottom","Left"],function(a,b){c.skin.css("padding"+b,v(c.padding[a]))});b.trigger("onReady");if("inline"===d||"html"===d){if(!c.content|| +!c.content.length)return b._error("content")}else if(!e)return b._error("href");"image"===d?b._loadImage():"ajax"===d?b._loadAjax():"iframe"===d?b._loadIframe():b._afterLoad()}},_error:function(a){f.extend(b.coming,{type:"html",autoWidth:!0,autoHeight:!0,minWidth:0,minHeight:0,scrolling:"no",hasError:a,content:b.coming.tpl.error});b._afterLoad()},_loadImage:function(){var a=b.imgPreload=new Image;a.onload=function(){this.onload=this.onerror=null;b.coming.width=this.width;b.coming.height=this.height; +b._afterLoad()};a.onerror=function(){this.onload=this.onerror=null;b._error("image")};a.src=b.coming.href;(a.complete===q||!a.complete)&&b.showLoading()},_loadAjax:function(){var a=b.coming;b.showLoading();b.ajaxLoad=f.ajax(f.extend({},a.ajax,{url:a.href,error:function(a,e){b.coming&&"abort"!==e?b._error("ajax",a):b.hideLoading()},success:function(c,e){"success"===e&&(a.content=c,b._afterLoad())}}))},_loadIframe:function(){var a=b.coming,c=f(a.tpl.iframe.replace(/\{rnd\}/g,(new Date).getTime())).attr("scrolling", +m?"auto":a.iframe.scrolling).attr("src",a.href);f(a.wrap).bind("onReset",function(){try{f(this).find("iframe").hide().attr("src","//about:blank").end().empty()}catch(a){}});a.iframe.preload&&(b.showLoading(),c.one("load",function(){f(this).data("ready",1);m||f(this).bind("load.fb",b.update);f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();b._afterLoad()}));a.content=c.appendTo(a.inner);a.iframe.preload||b._afterLoad()},_preloadImages:function(){var a=b.group,c=b.current, +e=a.length,d=c.preload?Math.min(c.preload,e-1):0,f,g;for(g=1;g<=d;g+=1)f=a[(c.index+g)%e],"image"===f.type&&f.href&&((new Image).src=f.href)},_afterLoad:function(){var a=b.coming,c=b.current,e,d,j,g,h;b.hideLoading();if(a&&!1!==b.isActive)if(!1===b.trigger("afterLoad",a,c))a.wrap.stop(!0).trigger("onReset").remove(),b.coming=null;else{c&&(b.trigger("beforeChange",c),c.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove(),"fixed"===c.wrap.css("position")&&c.wrap.css(b._getPosition(!0))); +b.unbindEvents();e=a.content;d=a.type;j=a.scrolling;f.extend(b,{wrap:a.wrap,skin:a.skin,outer:a.outer,inner:a.inner,current:a,previous:c});g=a.href;switch(d){case "inline":case "ajax":case "html":a.selector?e=f("
    ").html(e).find(a.selector):x(e)&&(e.data("fancybox-placeholder")||e.data("fancybox-placeholder",f('
    ').insertAfter(e).hide()),e=e.show().detach(),a.wrap.bind("onReset",function(){f(this).find(e).length&&e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder", +false)}));break;case "image":e=a.tpl.image.replace("{href}",g);break;case "swf":e='',h="",f.each(a.swf,function(a,b){e=e+('');h=h+(" "+a+'="'+b+'"')}),e+='"}(!x(e)||!e.parent().is(a.inner))&&a.inner.append(e);b.trigger("beforeShow"); +a.inner.css("overflow","yes"===j?"scroll":"no"===j?"hidden":j);b._setDimension();a.wrap.removeClass("fancybox-tmp");a.pos=f.extend({},a.dim,b._getPosition(!0));b.isOpen=!1;b.coming=null;b.bindEvents();if(b.isOpened){if(c.prevMethod)b.transitions[c.prevMethod]()}else f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove();b.transitions[b.isOpened?a.nextMethod:a.openMethod]();b._preloadImages()}},_setDimension:function(){var a=b.getViewport(),c=0,e=!1,d=!1,e=b.wrap,j=b.skin,g=b.inner,h= +b.current,d=h.width,i=h.height,l=h.minWidth,t=h.minHeight,m=h.maxWidth,n=h.maxHeight,s=h.scrolling,q=h.scrollOutside?h.scrollbarWidth:0,w=h.margin,o=w[1]+w[3],p=w[0]+w[2],x,r,u,A,y,D,z,B,E;e.add(j).add(g).width("auto").height("auto");w=j.outerWidth(!0)-j.width();x=j.outerHeight(!0)-j.height();r=o+w;u=p+x;A=C(d)?(a.w-r)*k(d)/100:d;y=C(i)?(a.h-u)*k(i)/100:i;if("iframe"===h.type){if(E=h.content,h.autoHeight&&1===E.data("ready"))try{E[0].contentWindow.document.location&&(g.width(A).height(9999),D=E.contents().find("body"), +q&&D.css("overflow-x","hidden"),y=D.height())}catch(F){}}else if(h.autoWidth||h.autoHeight)g.addClass("fancybox-tmp"),h.autoWidth||g.width(A),h.autoHeight||g.height(y),h.autoWidth&&(A=g.width()),h.autoHeight&&(y=g.height()),g.removeClass("fancybox-tmp");d=k(A);i=k(y);B=A/y;l=k(C(l)?k(l,"w")-r:l);m=k(C(m)?k(m,"w")-r:m);t=k(C(t)?k(t,"h")-u:t);n=k(C(n)?k(n,"h")-u:n);D=m;z=n;o=a.w-o;p=a.h-p;if(h.aspectRatio){if(d>m&&(d=m,i=d/B),i>n&&(i=n,d=i*B),do||r>p)&&(d>l&&i>t)&&!(19m&&(d=m,i=d/B),g.width(k(d)).height(k(i)),e.width(k(d+w)),a=e.width(),r=e.height();else d=Math.max(l,Math.min(d,d-(a-o))),i=Math.max(t,Math.min(i,i-(r-p)));q&&("auto"===s&&io||r>p)&&d>l&&i>t;d=h.aspectRatio?dt&&ib&&(a=n.width())):n.width()>o.width()&&(a=n.width());this.overlay.width(a).height(n.height())},onReady:function(a, +b){f(".fancybox-overlay").stop(!0,!0);this.overlay||f.extend(this,{overlay:f('
    ').appendTo(b.parent),margin:n.height()>o.height()||"scroll"===f("body").css("overflow-y")?f("body").css("margin-right"):!1,el:p.all&&!p.querySelector?f("html"):f("body")});b.fixed&&!m&&(this.overlay.addClass("fancybox-overlay-fixed"),b.autoCenter&&(this.overlay.append(b.wrap),b.locked=this.overlay));!0===a.showEarly&&this.beforeShow.apply(this,arguments)},beforeShow:function(a,c){var e= +this.overlay.unbind(".fb").width("auto").height("auto").css(a.css);a.closeClick&&e.bind("click.fb",function(a){f(a.target).hasClass("fancybox-overlay")&&b.close()});c.fixed&&!m?c.locked&&(this.el.addClass("fancybox-lock"),!1!==this.margin&&f("body").css("margin-right",k(this.margin)+c.scrollbarWidth)):this.update();e.show()},onUpdate:function(a,b){(!b.fixed||m)&&this.update()},afterClose:function(a){var c=this,a=a.speedOut||0;c.overlay&&!b.isActive&&c.overlay.fadeOut(a||0,function(){f("body").css("margin-right", +c.margin);c.el.removeClass("fancybox-lock");c.overlay.remove();c.overlay=null})}};b.helpers.title={beforeShow:function(a){var c=b.current.title,e=a.type;if(s(c)&&""!==f.trim(c)){c=f('
    '+c+"
    ");switch(e){case "inside":e=b.skin;break;case "outside":e=b.wrap;break;case "over":e=b.inner;break;default:e=b.skin,c.appendTo("body").width(c.width()).wrapInner(''),b.current.margin[2]+=Math.abs(k(c.css("margin-bottom")))}"top"=== +a.position?c.prependTo(e):c.appendTo(e)}}};f.fn.fancybox=function(a){var c,e=f(this),d=this.selector||"",j=function(g){var h=f(this).blur(),i=c,j,k;!g.ctrlKey&&(!g.altKey&&!g.shiftKey&&!g.metaKey)&&!h.is(".fancybox-wrap")&&(j=a.groupAttr||"data-fancybox-group",k=h.attr(j),k||(j="rel",k=h.get(0)[j]),k&&(""!==k&&"nofollow"!==k)&&(h=d.length?f(d):e,h=h.filter("["+j+'="'+k+'"]'),i=h.index(this)),a.index=i,!1!==b.open(h,a)&&g.preventDefault())},a=a||{};c=a.index||0;!d||!1===a.live?e.unbind("click.fb-start").bind("click.fb-start", +j):n.undelegate(d,"click.fb-start").delegate(d+":not('.fancybox-item, .fancybox-nav')","click.fb-start",j);return this};n.ready(function(){f.scrollbarWidth===q&&(f.scrollbarWidth=function(){var a=f('
    ').appendTo("body"),b=a.children(),b=b.innerWidth()-b.height(99).innerWidth();a.remove();return b});if(f.support.fixedPosition===q){var a=f.support,c=f('
    ').appendTo("body"),e=20===c[0].offsetTop|| +15===c[0].offsetTop;c.remove();a.fixedPosition=e}f.extend(b.defaults,{scrollbarWidth:f.scrollbarWidth(),fixed:f.support.fixedPosition,parent:f("body")})})})(window,document,jQuery); \ No newline at end of file diff --git a/index.php b/index.php index 04ab840..a827ece 100644 --- a/index.php +++ b/index.php @@ -52,9 +52,9 @@ <?php echo htmlspecialchars ($currentPage->title) ?> - + - + " media="screen" />