vendor: 8,300 bytes, lines 1-292
1/*! 2 * fancyBox - jQuery Plugin 3 * version: 2.1.5 (Fri, 14 Jun 2013) 4 * @requires jQuery v1.6 or later 5 * 6 * Examples at http://fancyapps.com/fancybox/ 7 * License: www.fancyapps.com/fancybox/#license 8 * 9 * Copyright 2012 Janis Skarnelis - [email protected] 10 * 11 * Custom Tab Focus at https://gist.github.com/etienned/5218834 12 * In this script, we have set tabFocus option default to true 13 * and call base_focusable_elements at runtime of fancybox. 14 * CF Gist Tab Focus @ https://gist.github.com/josisusan/9757711 15 * 16 */ 17 18(function (window, document, $, undefined) { 19 "use strict"; 20 21 var H = $("html"), 22 W = $(window), 23 D = $(document), 24 base_focusable_elements, 25 26 F = $.fancybox = function () { 27 F.open.apply( this, arguments ); 28 }, 29 IE = navigator.userAgent.match(/msie/i), 30 didUpdate = null, 31 isTouch = document.createTouch !== undefined, 32 33 isQuery = function(obj) { 34 return obj && obj.hasOwnProperty && obj instanceof $; 35 }, 36 isString = function(str) { 37 return str && $.type(str) === "string"; 38 }, 39 isPercentage = function(str) { 40 return isString(str) && str.indexOf('%') > 0; 41 }, 42 isScrollable = function(el) { 43 return (el && !(el.style.overflow && el.style.overflow === 'hidden') && ((el.clientWidth && el.scrollWidth > el.clientWidth) || (el.clientHeight && el.scrollHeight > el.clientHeight))); 44 }, 45 getScalar = function(orig, dim) { 46 var value = parseInt(orig, 10) || 0; 47 48 if (dim && isPercentage(orig)) { 49 value = F.getViewport()[ dim ] / 100 * value; 50 } 51 52 return Math.ceil(value); 53 }, 54 getValue = function(value, dim) { 55 return getScalar(value, dim) + 'px'; 56 }; 57 58 $.extend(F, { 59 // The current version of fancyBox 60 version: '2.1.5', 61 62 defaults: { 63 padding : 15, 64 margin : 20, 65 66 width : 800, 67 height : 600, 68 minWidth : 100, 69 minHeight : 100, 70 maxWidth : 9999, 71 maxHeight : 9999, 72 pixelRatio: 1, // Set to 2 for retina display support 73 74 autoSize : true, 75 autoHeight : false, 76 autoWidth : false, 77 78 autoResize : true, 79 autoCenter : !isTouch, 80 fitToView : true, 81 aspectRatio : false, 82 topRatio : 0.5, 83 leftRatio : 0.5, 84 85 scrolling : 'auto', // 'auto', 'yes' or 'no' 86 wrapCSS : '', 87 88 arrows : true, 89 closeBtn : true, 90 closeClick : false, 91 nextClick : false, 92 mouseWheel : true, 93 autoPlay : false, 94 playSpeed : 3000, 95 preload : 3, 96 modal : false, 97 loop : true, 98 99 ajax : { 100 dataType : 'html', 101 headers : { 'X-fancyBox': true } 102 }, 103 iframe : { 104 scrolling : 'auto', 105 preload : true 106 }, 107 swf : { 108 wmode: 'transparent', 109 allowfullscreen : 'true', 110 allowscriptaccess : 'always' 111 }, 112 113 keys : { 114 next : { 115 13 : 'left', // enter 116 34 : 'up', // page down 117 39 : 'left', // right arrow 118 40 : 'up', // down arrow 119 78 : 'n' // n key 120 }, 121 prev : { 122 8 : 'right', // backspace 123 33 : 'down', // page up 124 37 : 'right', // left arrow 125 38 : 'down', // up arrow 126 80 : 'p' // p key 127 }, 128 close : [27], // escape key 129 play : [32], // space - start/stop slideshow 130 toggle : [70] // letter "f" - toggle fullscreen 131 }, 132 133 direction : { 134 next : 'left', 135 prev : 'right' 136 }, 137 138 scrollOutside : true, 139 140 // Override some properties 141 index : 0, 142 type : null, 143 href : null, 144 content : null, 145 title : null, 146 147 // HTML templates 148 tpl: { 149 wrap : '<div class="fancybox-wrap" tabIndex="2"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>', 150 image : '<img class="fancybox-image" src="{href}" alt="" />', 151 iframe : '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen' + (IE ? ' allowtransparency="true"' : '') + '></iframe>', 152 error : '<p class="fancybox-error">Nie można zaÅadowa zawartoÅci<br/>ProszÄ spróbowaÄ ponownie</p>', 153 closeBtn : '<a title="Zamknij" class="fancybox-item fancybox-close" href="javascript:;"></a>', 154 next : '<a title="NastÄpne" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>', 155 prev : '<a title="Poprzednie" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>' 156 }, 157 158 // Properties for each animation type 159 // Opening fancyBox 160 openEffect : 'fade', // 'elastic', 'fade' or 'none' 161 openSpeed : 250, 162 openEasing : 'swing', 163 openOpacity : true, 164 openMethod : 'zoomIn', 165 166 // Closing fancyBox 167 closeEffect : 'fade', // 'elastic', 'fade' or 'none' 168 closeSpeed : 250, 169 closeEasing : 'swing', 170 closeOpacity : true, 171 closeMethod : 'zoomOut', 172 173 // Changing next gallery item 174 nextEffect : 'elastic', // 'elastic', 'fade' or 'none' 175 nextSpeed : 250, 176 nextEasing : 'swing', 177 nextMethod : 'changeIn', 178 179 // Changing previous gallery item 180 prevEffect : 'elastic', // 'elastic', 'fade' or 'none' 181 prevSpeed : 250, 182 prevEasing : 'swing', 183 prevMethod : 'changeOut', 184 185 // Disable tab key navigation on prev, next, close (used for accessibility) 186 tabFocus : true, 187 188 // Enable default helpers 189 helpers : { 190 overlay : true, 191 title : true 192 }, 193 194 // Callbacks 195 onCancel : $.noop, // If canceling 196 beforeLoad : $.noop, // Before loading 197 afterLoad : $.noop, // After loading 198 beforeShow : $.noop, // Before changing in current item 199 afterShow : $.noop, // After opening 200 beforeChange : $.noop, // Before changing gallery item 201 beforeClose : $.noop, // Before closing 202 afterClose : $.noop // After closing 203 }, 204 205 //Current state 206 group : {}, // Selected group 207 opts : {}, // Group options 208 previous : null, // Previous element 209 coming : null, // Element being loaded 210 current : null, // Currently loaded element 211 isActive : false, // Is activated 212 isOpen : false, // Is currently open 213 isOpened : false, // Have been fully opened at least once 214 215 wrap : null, 216 skin : null, 217 outer : null, 218 inner : null, 219 220 player : { 221 timer : null, 222 isActive : false 223 }, 224 225 // Loaders 226 ajaxLoad : null, 227 imgPreload : null, 228 229 // Some collections 230 transitions : {}, 231 helpers : {}, 232 233 /* 234 * Static methods 235 */ 236 237 open: function (group, opts) { 238 if (!group) { 239 return; 240 } 241 242 if (!$.isPlainObject(opts)) { 243 opts = {}; 244 } 245 246 // Close if already active 247 if (false === F.close(true)) { 248 return; 249 } 250 251 // Normalize group 252 if (!$.isArray(group)) { 253 group = isQuery(group) ? $(group).get() : [group]; 254 } 255 256 // Recheck if the type of each element is `object` and set content type (image, ajax, etc) 257 $.each(group, function(i, element) { 258 var obj = {}, 259 href, 260 title, 261 content, 262 type, 263 rez, 264 hrefParts, 265 selector; 266 267 if ($.type(element) === "object") { 268 // Check if is DOM element 269 if (element.nodeType) { 270 element = $(element); 271 } 272 273 if (isQuery(element)) { 274 obj = { 275 href : element.data('fancybox-href') || element.attr('href'), 276 title : element.data('fancybox-title') || element.attr('title'), 277 isDom : true, 278 element : element 279 }; 280 281 if ($.metadata) { 282 $.extend(true, obj, element.metadata()); 283 } 284 285 } else { 286 obj = element; 287 } 288 } 289 290 href = opts.href || obj.href || (isString(element) ? element : null); 291 title = opts.title !== undefined ? opts.title : obj.title || ''; 292
vendor: 44,921 bytes, lines 293-1958
293 content = opts.content || obj.content; 294 type = content ? 'html' : (opts.type || obj.type); 295 296 if (!type && obj.isDom) { 297 type = element.data('fancybox-type'); 298 299 if (!type) { 300 rez = element.prop('class').match(/fancybox\.(\w+)/); 301 type = rez ? rez[1] : null; 302 } 303 } 304 305 if (isString(href)) { 306 // Try to guess the content type 307 if (!type) { 308 if (F.isImage(href)) { 309 type = 'image'; 310 311 } else if (F.isSWF(href)) { 312 type = 'swf'; 313 314 } else if (href.charAt(0) === '#') { 315 type = 'inline'; 316 317 } else if (isString(element)) { 318 type = 'html'; 319 content = element; 320 } 321 } 322 323 // Split url into two pieces with source url and content selector, e.g, 324 // "/mypage.html #my_id" will load "/mypage.html" and display element having id "my_id" 325 if (type === 'ajax') { 326 hrefParts = href.split(/\s+/, 2); 327 href = hrefParts.shift(); 328 selector = hrefParts.shift(); 329 } 330 } 331 332 if (!content) { 333 if (type === 'inline') { 334 if (href) { 335 content = $( isString(href) ? href.replace(/.*(?=#[^\s]+$)/, '') : href ); //strip for ie7 336 337 } else if (obj.isDom) { 338 content = element; 339 } 340 341 } else if (type === 'html') { 342 content = href; 343 344 } else if (!type && !href && obj.isDom) { 345 type = 'inline'; 346 content = element; 347 } 348 } 349 350 $.extend(obj, { 351 href : href, 352 type : type, 353 content : content, 354 title : title, 355 selector : selector 356 }); 357 358 group[ i ] = obj; 359 }); 360 361 // Extend the defaults 362 F.opts = $.extend(true, {}, F.defaults, opts); 363 364 // All options are merged recursive except keys 365 if (opts.keys !== undefined) { 366 F.opts.keys = opts.keys ? $.extend({}, F.defaults.keys, opts.keys) : false; 367 } 368 369 F.group = group; 370 371 if (F.opts && F.opts.tabFocus) { 372 // Remove enter key for next so it can be use to trigger 373 // focused navigation element 374 delete F.opts.keys.next[13]; 375 F.fancybox_disable_base_elements(); 376 } 377 378 return F._start(F.opts.index); 379 }, 380 381 // Cancel image loading or abort ajax request 382 cancel: function () { 383 var coming = F.coming; 384 385 if (!coming || false === F.trigger('onCancel')) { 386 return; 387 } 388 389 F.hideLoading(); 390 391 if (F.ajaxLoad) { 392 F.ajaxLoad.abort(); 393 } 394 395 F.ajaxLoad = null; 396 397 if (F.imgPreload) { 398 F.imgPreload.onload = F.imgPreload.onerror = null; 399 } 400 401 if (coming.wrap) { 402 coming.wrap.stop(true, true).trigger('onReset').remove(); 403 } 404 405 F.coming = null; 406 407 // If the first item has been canceled, then clear everything 408 if (!F.current) { 409 F._afterZoomOut( coming ); 410 } 411 }, 412 413 // Start closing animation if is open; remove immediately if opening/closing 414 close: function (event) { 415 416 417 F.cancel(); 418 419 if (false === F.trigger('beforeClose')) { 420 return; 421 } 422 423 F.unbindEvents(); 424 425 if (!F.isActive) { 426 return; 427 } 428 429 if (!F.isOpen || event === true) { 430 $('.fancybox-wrap').stop(true).trigger('onReset').remove(); 431 432 F._afterZoomOut(); 433 434 435 setTimeout(function(){ jQuery('.fancybox-close').focus(); }, 1000); 436 jQuery('.fancybox-close').focus(); 437 } else { 438 439 jQuery('body').removeClass('fancybox_actives'); 440 441 F.isOpen = F.isOpened = false; 442 F.isClosing = true; 443 444 $('.fancybox-item, .fancybox-nav').remove(); 445 446 F.wrap.stop(true, true).removeClass('fancybox-opened'); 447 448 F.transitions[ F.current.closeMethod ](); 449 450 if (F.current && F.current.tabFocus) { 451 F.fancybox_enable_base_elements(); 452 } 453 454 } 455 }, 456 457 // Manage slideshow: 458 // $.fancybox.play(); - toggle slideshow 459 // $.fancybox.play( true ); - start 460 // $.fancybox.play( false ); - stop 461 play: function ( action ) { 462 var clear = function () { 463 clearTimeout(F.player.timer); 464 }, 465 set = function () { 466 clear(); 467 468 if (F.current && F.player.isActive) { 469 F.player.timer = setTimeout(F.next, F.current.playSpeed); 470 } 471 }, 472 stop = function () { 473 clear(); 474 475 D.unbind('.player'); 476 477 F.player.isActive = false; 478 479 F.trigger('onPlayEnd'); 480 }, 481 start = function () { 482 if (F.current && (F.current.loop || F.current.index < F.group.length - 1)) { 483 F.player.isActive = true; 484 485 D.bind({ 486 'onCancel.player beforeClose.player' : stop, 487 'onUpdate.player' : set, 488 'beforeLoad.player' : clear 489 }); 490 491 set(); 492 493 F.trigger('onPlayStart'); 494 } 495 }; 496 497 if (action === true || (!F.player.isActive && action !== false)) { 498 start(); 499 } else { 500 stop(); 501 } 502 }, 503 504 // Navigate to next gallery item 505 next: function ( direction ) { 506 var current = F.current; 507 508 if (current) { 509 if (!isString(direction)) { 510 direction = current.direction.next; 511 } 512 513 F.jumpto(current.index + 1, direction, 'next'); 514 } 515 }, 516 517 // Navigate to previous gallery item 518 prev: function ( direction ) { 519 var current = F.current; 520 521 if (current) { 522 if (!isString(direction)) { 523 direction = current.direction.prev; 524 } 525 526 F.jumpto(current.index - 1, direction, 'prev'); 527 } 528 }, 529 530 // Navigate to gallery item by index 531 jumpto: function ( index, direction, router ) { 532 var current = F.current; 533 534 if (!current) { 535 return; 536 } 537 538 index = getScalar(index); 539 540 F.direction = direction || current.direction[ (index >= current.index ? 'next' : 'prev') ]; 541 F.router = router || 'jumpto'; 542 543 if (current.loop) { 544 if (index < 0) { 545 index = current.group.length + (index % current.group.length); 546 } 547 548 index = index % current.group.length; 549 } 550 551 if (current.group[ index ] !== undefined) { 552 F.cancel(); 553 554 F._start(index); 555 } 556 }, 557 558 // Center inside viewport and toggle position type to fixed or absolute if needed 559 reposition: function (e, onlyAbsolute) { 560 var current = F.current, 561 wrap = current ? current.wrap : null, 562 pos; 563 564 if (wrap) { 565 pos = F._getPosition(onlyAbsolute); 566 567 if (e && e.type === 'scroll') { 568 delete pos.position; 569 570 wrap.stop(true, true).animate(pos, 200); 571 572 } else { 573 wrap.css(pos); 574 575 current.pos = $.extend({}, current.dim, pos); 576 } 577 } 578 }, 579 580 update: function (e) { 581 var type = (e && e.type), 582 anyway = !type || type === 'orientationchange'; 583 584 if (anyway) { 585 clearTimeout(didUpdate); 586 587 didUpdate = null; 588 } 589 590 if (!F.isOpen || didUpdate) { 591 return; 592 } 593 594 didUpdate = setTimeout(function() { 595 var current = F.current; 596 597 if (!current || F.isClosing) { 598 return; 599 } 600 601 F.wrap.removeClass('fancybox-tmp'); 602 603 if (anyway || type === 'load' || (type === 'resize' && current.autoResize)) { 604 F._setDimension(); 605 } 606 607 if (!(type === 'scroll' && current.canShrink)) { 608 F.reposition(e); 609 } 610 611 F.trigger('onUpdate'); 612 613 didUpdate = null; 614 615 }, (anyway && !isTouch ? 0 : 300)); 616 }, 617 618 // Shrink content to fit inside viewport or restore if resized 619 toggle: function ( action ) { 620 if (F.isOpen) { 621 F.current.fitToView = $.type(action) === "boolean" ? action : !F.current.fitToView; 622 623 // Help browser to restore document dimensions 624 if (isTouch) { 625 F.wrap.removeAttr('style').addClass('fancybox-tmp'); 626 627 F.trigger('onUpdate'); 628 } 629 630 F.update(); 631 } 632 }, 633 634 hideLoading: function () { 635 D.unbind('.loading'); 636 637 $('#fancybox-loading').remove(); 638 }, 639 640 showLoading: function () { 641 var el, viewport; 642 643 F.hideLoading(); 644 645 el = $('<div id="fancybox-loading"><div></div></div>').click(F.cancel).appendTo('body'); 646 647 // If user will press the escape-button, the request will be canceled 648 D.bind('keydown.loading', function(e) { 649 if ((e.which || e.keyCode) === 27) { 650 e.preventDefault(); 651 652 F.cancel(); 653 } 654 }); 655 656 if (!F.defaults.fixed) { 657 viewport = F.getViewport(); 658 659 el.css({ 660 position : 'absolute', 661 top : (viewport.h * 0.5) + viewport.y, 662 left : (viewport.w * 0.5) + viewport.x 663 }); 664 } 665 }, 666 667 getViewport: function () { 668 var locked = (F.current && F.current.locked) || false, 669 rez = { 670 x: W.scrollLeft(), 671 y: W.scrollTop() 672 }; 673 674 if (locked) { 675 rez.w = locked[0].clientWidth; 676 rez.h = locked[0].clientHeight; 677 678 } else { 679 // See http://bugs.jquery.com/ticket/6724 680 rez.w = isTouch && window.innerWidth ? window.innerWidth : W.width(); 681 rez.h = isTouch && window.innerHeight ? window.innerHeight : W.height(); 682 } 683 684 return rez; 685 }, 686 687 // Unbind the keyboard / clicking actions 688 unbindEvents: function () { 689 if (F.wrap && isQuery(F.wrap)) { 690 F.wrap.unbind('.fb'); 691 } 692 693 D.unbind('.fb'); 694 W.unbind('.fb'); 695 }, 696 697 bindEvents: function () { 698 var current = F.current, 699 keys; 700 701 if (!current) { 702 return; 703 } 704 705 // Changing document height on iOS devices triggers a 'resize' event, 706 // that can change document height... repeating infinitely 707 W.bind('orientationchange.fb' + (isTouch ? '' : ' resize.fb') + (current.autoCenter && !current.locked ? ' scroll.fb' : ''), F.update); 708 709 keys = current.keys; 710 711 if (keys) { 712 D.bind('keydown.fb', function (e) { 713 var code = e.which || e.keyCode, 714 target = e.target || e.srcElement; 715 716 // Skip esc key if loading, because showLoading will cancel preloading 717 if (code === 27 && F.coming) { 718 return false; 719 } 720 721 // Ignore key combinations and key events within form elements 722 if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && !(target && (target.type || $(target).is('[contenteditable]')))) { 723 $.each(keys, function(i, val) { 724 if (current.group.length > 1 && val[ code ] !== undefined) { 725 F[ i ]( val[ code ] ); 726 727 e.preventDefault(); 728 return false; 729 } 730 731 if ($.inArray(code, val) > -1) { 732 F[ i ] (); 733 734 e.preventDefault(); 735 return false; 736 } 737 }); 738 } 739 }); 740 } 741 742 if ($.fn.mousewheel && current.mouseWheel) { 743 F.wrap.bind('mousewheel.fb', function (e, delta, deltaX, deltaY) { 744 var target = e.target || null, 745 parent = $(target), 746 canScroll = false; 747 748 while (parent.length) { 749 if (canScroll || parent.is('.fancybox-skin') || parent.is('.fancybox-wrap')) { 750 break; 751 } 752 753 canScroll = isScrollable( parent[0] ); 754 parent = $(parent).parent(); 755 } 756 757 if (delta !== 0 && !canScroll) { 758 if (F.group.length > 1 && !current.canShrink) { 759 if (deltaY > 0 || deltaX > 0) { 760 F.prev( deltaY > 0 ? 'down' : 'left' ); 761 762 } else if (deltaY < 0 || deltaX < 0) { 763 F.next( deltaY < 0 ? 'up' : 'right' ); 764 } 765 766 e.preventDefault(); 767 } 768 } 769 }); 770 } 771 }, 772 773 trigger: function (event, o) { 774 var ret, obj = o || F.coming || F.current; 775 776 if (!obj) { 777 return; 778 } 779 780 if ($.isFunction( obj[event] )) { 781 ret = obj[event].apply(obj, Array.prototype.slice.call(arguments, 1)); 782 } 783 784 if (ret === false) { 785 return false; 786 } 787 788 if (obj.helpers) { 789 $.each(obj.helpers, function (helper, opts) { 790 if (opts && F.helpers[helper] && $.isFunction(F.helpers[helper][event])) { 791 F.helpers[helper][event]($.extend(true, {}, F.helpers[helper].defaults, opts), obj); 792 } 793 }); 794 } 795 796 D.trigger(event); 797 }, 798 799 fancybox_disable_base_elements: function() { 800 // Special Credit and Thanks to whatcould's edit for fancyBox 1 801 // https://github.com/whatcould/fancybox/commit/231087ba1399d84589e29488cb98a2acb9e84624 802 base_focusable_elements = $('a, input, button, select, textarea, iframe'); 803 base_focusable_elements.each(function(){ 804 // push the previous tab-index into a data attrib 805 var el = $(this); 806 var prev_tabindex = el.attr('tabindex'); 807 if(prev_tabindex === undefined) 808 prev_tabindex = null; 809 el.data('prev-tabindex', prev_tabindex); 810 if(!(el.parents(":hidden").length > 0)) { 811 el.attr('tabindex', '1'); 812 } 813 }); 814 }, 815 816 fancybox_enable_base_elements: function() { 817 // reset the tabindex back to what we put in the data-attrib. 818 base_focusable_elements = $('a, input, button, select, textarea, iframe'); 819 base_focusable_elements.each(function(){ 820 var el = $(this); 821 el.attr('tabindex', el.data('prev-tabindex')); 822 }); 823 }, 824 825 isImage: function (str) { 826 return isString(str) && str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i); 827 }, 828 829 isSWF: function (str) { 830 return isString(str) && str.match(/\.(swf)((\?|#).*)?$/i); 831 }, 832 833 _start: function (index) { 834 var coming = {}, 835 obj, 836 href, 837 type, 838 margin, 839 padding; 840 841 index = getScalar( index ); 842 obj = F.group[ index ] || null; 843 844 if (!obj) { 845 return false; 846 } 847 848 coming = $.extend(true, {}, F.opts, obj); 849 850 // Convert margin and padding properties to array - top, right, bottom, left 851 margin = coming.margin; 852 padding = coming.padding; 853 854 if ($.type(margin) === 'number') { 855 coming.margin = [margin, margin, margin, margin]; 856 } 857 858 if ($.type(padding) === 'number') { 859 coming.padding = [padding, padding, padding, padding]; 860 } 861 862 // 'modal' propery is just a shortcut 863 if (coming.modal) { 864 $.extend(true, coming, { 865 closeBtn : false, 866 closeClick : false, 867 nextClick : false, 868 arrows : false, 869 mouseWheel : false, 870 keys : null, 871 helpers: { 872 overlay : { 873 closeClick : false 874 } 875 } 876 }); 877 } 878 879 // 'autoSize' property is a shortcut, too 880 if (coming.autoSize) { 881 coming.autoWidth = coming.autoHeight = true; 882 } 883 884 if (coming.width === 'auto') { 885 coming.autoWidth = true; 886 } 887 888 if (coming.height === 'auto') { 889 coming.autoHeight = true; 890 } 891 892 /* 893 * Add reference to the group, so it`s possible to access from callbacks, example: 894 * afterLoad : function() { 895 * this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : ''); 896 * } 897 */ 898 899 coming.group = F.group; 900 coming.index = index; 901 902 // Give a chance for callback or helpers to update coming item (type, title, etc) 903 F.coming = coming; 904 905 if (false === F.trigger('beforeLoad')) { 906 F.coming = null; 907 908 return; 909 } 910 911 type = coming.type; 912 href = coming.href; 913 914 if (!type) { 915 F.coming = null; 916 917 //If we can not determine content type then drop silently or display next/prev item if looping through gallery 918 if (F.current && F.router && F.router !== 'jumpto') { 919 F.current.index = index; 920 921 return F[ F.router ]( F.direction ); 922 } 923 924 return false; 925 } 926 927 F.isActive = true; 928 929 if (type === 'image' || type === 'swf') { 930 coming.autoHeight = coming.autoWidth = false; 931 coming.scrolling = 'visible'; 932 } 933 934 if (type === 'image') { 935 coming.aspectRatio = true; 936 } 937 938 if (type === 'iframe' && isTouch) { 939 coming.scrolling = 'scroll'; 940 } 941 942 // Build the neccessary markup 943 coming.wrap = $(coming.tpl.wrap).addClass('fancybox-' + (isTouch ? 'mobile' : 'desktop') + ' fancybox-type-' + type + ' fancybox-tmp ' + coming.wrapCSS).appendTo( coming.parent || 'body' ); 944 945 $.extend(coming, { 946 skin : $('.fancybox-skin', coming.wrap), 947 outer : $('.fancybox-outer', coming.wrap), 948 inner : $('.fancybox-inner', coming.wrap) 949 }); 950 951 $.each(["Top", "Right", "Bottom", "Left"], function(i, v) { 952 coming.skin.css('padding' + v, getValue(coming.padding[ i ])); 953 }); 954 955 F.trigger('onReady'); 956 957 // Check before try to load; 'inline' and 'html' types need content, others - href 958 if (type === 'inline' || type === 'html') { 959 if (!coming.content || !coming.content.length) { 960 return F._error( 'content' ); 961 } 962 963 } else if (!href) { 964 return F._error( 'href' ); 965 } 966 967 if (type === 'image') { 968 F._loadImage(); 969 970 } else if (type === 'ajax') { 971 F._loadAjax(); 972 973 } else if (type === 'iframe') { 974 F._loadIframe(); 975 976 } else { 977 F._afterLoad(); 978 } 979 }, 980 981 _error: function ( type ) { 982 $.extend(F.coming, { 983 type : 'html', 984 autoWidth : true, 985 autoHeight : true, 986 minWidth : 0, 987 minHeight : 0, 988 scrolling : 'no', 989 hasError : type, 990 content : F.coming.tpl.error 991 }); 992 993 F._afterLoad(); 994 }, 995 996 _loadImage: function () { 997 // Reset preload image so it is later possible to check "complete" property 998 var img = F.imgPreload = new Image(); 999 1000 img.onload = function () { 1001 this.onload = this.onerror = null; 1002 1003 F.coming.width = this.width / F.opts.pixelRatio; 1004 F.coming.height = this.height / F.opts.pixelRatio; 1005 1006 F._afterLoad(); 1007 }; 1008 1009 img.onerror = function () { 1010 this.onload = this.onerror = null; 1011 1012 F._error( 'image' ); 1013 }; 1014 1015 img.src = F.coming.href; 1016 1017 if (img.complete !== true) { 1018 F.showLoading(); 1019 } 1020 }, 1021 1022 _loadAjax: function () { 1023 var coming = F.coming; 1024 1025 F.showLoading(); 1026 1027 F.ajaxLoad = $.ajax($.extend({}, coming.ajax, { 1028 url: coming.href, 1029 error: function (jqXHR, textStatus) { 1030 if (F.coming && textStatus !== 'abort') { 1031 F._error( 'ajax', jqXHR ); 1032 1033 } else { 1034 F.hideLoading(); 1035 } 1036 }, 1037 success: function (data, textStatus) { 1038 if (textStatus === 'success') { 1039 coming.content = data; 1040 1041 F._afterLoad(); 1042 } 1043 } 1044 })); 1045 }, 1046 1047 _loadIframe: function() { 1048 var coming = F.coming, 1049 iframe = $(coming.tpl.iframe.replace(/\{rnd\}/g, new Date().getTime())) 1050 .attr('scrolling', isTouch ? 'auto' : coming.iframe.scrolling) 1051 .attr('src', coming.href); 1052 1053 // This helps IE 1054 $(coming.wrap).bind('onReset', function () { 1055 try { 1056 $(this).find('iframe').hide().attr('src', '//about:blank').end().empty(); 1057 } catch (e) {} 1058 }); 1059 1060 if (coming.iframe.preload) { 1061 F.showLoading(); 1062 1063 iframe.one('load', function() { 1064 $(this).data('ready', 1); 1065 1066 // iOS will lose scrolling if we resize 1067 if (!isTouch) { 1068 $(this).bind('load.fb', F.update); 1069 } 1070 1071 // Without this trick: 1072 // - iframe won't scroll on iOS devices 1073 // - IE7 sometimes displays empty iframe 1074 $(this).parents('.fancybox-wrap').width('100%').removeClass('fancybox-tmp').show(); 1075 1076 F._afterLoad(); 1077 }); 1078 } 1079 1080 coming.content = iframe.appendTo( coming.inner ); 1081 1082 if (!coming.iframe.preload) { 1083 F._afterLoad(); 1084 } 1085 }, 1086 1087 _preloadImages: function() { 1088 var group = F.group, 1089 current = F.current, 1090 len = group.length, 1091 cnt = current.preload ? Math.min(current.preload, len - 1) : 0, 1092 item, 1093 i; 1094 1095 for (i = 1; i <= cnt; i += 1) { 1096 item = group[ (current.index + i ) % len ]; 1097 1098 if (item.type === 'image' && item.href) { 1099 new Image().src = item.href; 1100 } 1101 } 1102 }, 1103 1104 _afterLoad: function () { 1105 var coming = F.coming, 1106 previous = F.current, 1107 placeholder = 'fancybox-placeholder', 1108 current, 1109 content, 1110 type, 1111 scrolling, 1112 href, 1113 embed; 1114 1115 F.hideLoading(); 1116 1117 if (!coming || F.isActive === false) { 1118 return; 1119 } 1120 1121 if (false === F.trigger('afterLoad', coming, previous)) { 1122 coming.wrap.stop(true).trigger('onReset').remove(); 1123 1124 F.coming = null; 1125 1126 return; 1127 } 1128 1129 if (previous) { 1130 F.trigger('beforeChange', previous); 1131 1132 previous.wrap.stop(true).removeClass('fancybox-opened') 1133 .find('.fancybox-item, .fancybox-nav') 1134 .remove(); 1135 } 1136 1137 F.unbindEvents(); 1138 1139 current = coming; 1140 content = coming.content; 1141 type = coming.type; 1142 scrolling = coming.scrolling; 1143 1144 $.extend(F, { 1145 wrap : current.wrap, 1146 skin : current.skin, 1147 outer : current.outer, 1148 inner : current.inner, 1149 current : current, 1150 previous : previous 1151 }); 1152 1153 href = current.href; 1154 1155 switch (type) { 1156 case 'inline': 1157 case 'ajax': 1158 case 'html': 1159 if (current.selector) { 1160 content = $('<div>').html(content).find(current.selector); 1161 1162 } else if (isQuery(content)) { 1163 if (!content.data(placeholder)) { 1164 content.data(placeholder, $('<div class="' + placeholder + '"></div>').insertAfter( content ).hide() ); 1165 } 1166 1167 content = content.show().detach(); 1168 1169 current.wrap.bind('onReset', function () { 1170 if ($(this).find(content).length) { 1171 content.hide().replaceAll( content.data(placeholder) ).data(placeholder, false); 1172 } 1173 }); 1174 } 1175 break; 1176 1177 case 'image': 1178 content = current.tpl.image.replace('{href}', href); 1179 break; 1180 1181 case 'swf': 1182 content = '<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="' + href + '"></param>'; 1183 embed = ''; 1184 1185 $.each(current.swf, function(name, val) { 1186 content += '<param name="' + name + '" value="' + val + '"></param>'; 1187 embed += ' ' + name + '="' + val + '"'; 1188 }); 1189 1190 content += '<embed src="' + href + '" type="application/x-shockwave-flash" width="100%" height="100%"' + embed + '></embed></object>'; 1191 break; 1192 } 1193 1194 if (!(isQuery(content) && content.parent().is(current.inner))) { 1195 current.inner.append( content ); 1196 } 1197 1198 // Give a chance for helpers or callbacks to update elements 1199 F.trigger('beforeShow'); 1200 1201 // Set scrolling before calculating dimensions 1202 current.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling)); 1203 1204 // Set initial dimensions and start position 1205 F._setDimension(); 1206 1207 F.reposition(); 1208 1209 F.isOpen = false; 1210 F.coming = null; 1211 1212 F.bindEvents(); 1213 1214 if (!F.isOpened) { 1215 $('.fancybox-wrap').not( current.wrap ).stop(true).trigger('onReset').remove(); 1216 1217 } else if (previous.prevMethod) { 1218 F.transitions[ previous.prevMethod ](); 1219 } 1220 1221 F.transitions[ F.isOpened ? current.nextMethod : current.openMethod ](); 1222 1223 F._preloadImages(); 1224 }, 1225 1226 _setDimension: function () { 1227 var viewport = F.getViewport(), 1228 steps = 0, 1229 canShrink = false, 1230 canExpand = false, 1231 wrap = F.wrap, 1232 skin = F.skin, 1233 inner = F.inner, 1234 current = F.current, 1235 width = current.width, 1236 height = current.height, 1237 minWidth = current.minWidth, 1238 minHeight = current.minHeight, 1239 maxWidth = current.maxWidth, 1240 maxHeight = current.maxHeight, 1241 scrolling = current.scrolling, 1242 scrollOut = current.scrollOutside ? current.scrollbarWidth : 0, 1243 margin = current.margin, 1244 wMargin = getScalar(margin[1] + margin[3]), 1245 hMargin = getScalar(margin[0] + margin[2]), 1246 wPadding, 1247 hPadding, 1248 wSpace, 1249 hSpace, 1250 origWidth, 1251 origHeight, 1252 origMaxWidth, 1253 origMaxHeight, 1254 ratio, 1255 width_, 1256 height_, 1257 maxWidth_, 1258 maxHeight_, 1259 iframe, 1260 body; 1261 1262 // Reset dimensions so we could re-check actual size 1263 wrap.add(skin).add(inner).width('auto').height('auto').removeClass('fancybox-tmp'); 1264 1265 wPadding = getScalar(skin.outerWidth(true) - skin.width()); 1266 hPadding = getScalar(skin.outerHeight(true) - skin.height()); 1267 1268 // Any space between content and viewport (margin, padding, border, title) 1269 wSpace = wMargin + wPadding; 1270 hSpace = hMargin + hPadding; 1271 1272 origWidth = isPercentage(width) ? (viewport.w - wSpace) * getScalar(width) / 100 : width; 1273 origHeight = isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100 : height; 1274 1275 if (current.type === 'iframe') { 1276 iframe = current.content; 1277 1278 if (current.autoHeight && iframe.data('ready') === 1) { 1279 try { 1280 if (iframe[0].contentWindow.document.location) { 1281 inner.width( origWidth ).height(9999); 1282 1283 body = iframe.contents().find('body'); 1284 1285 if (scrollOut) { 1286 body.css('overflow-x', 'hidden'); 1287 } 1288 1289 origHeight = body.outerHeight(true); 1290 } 1291 1292 } catch (e) {} 1293 } 1294 1295 } else if (current.autoWidth || current.autoHeight) { 1296 inner.addClass( 'fancybox-tmp' ); 1297 1298 // Set width or height in case we need to calculate only one dimension 1299 if (!current.autoWidth) { 1300 inner.width( origWidth ); 1301 } 1302 1303 if (!current.autoHeight) { 1304 inner.height( origHeight ); 1305 } 1306 1307 if (current.autoWidth) { 1308 origWidth = inner.width(); 1309 } 1310 1311 if (current.autoHeight) { 1312 origHeight = inner.height(); 1313 } 1314 1315 inner.removeClass( 'fancybox-tmp' ); 1316 } 1317 1318 width = getScalar( origWidth ); 1319 height = getScalar( origHeight ); 1320 1321 ratio = origWidth / origHeight; 1322 1323 // Calculations for the content 1324 minWidth = getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace : minWidth); 1325 maxWidth = getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace : maxWidth); 1326 1327 minHeight = getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace : minHeight); 1328 maxHeight = getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace : maxHeight); 1329 1330 // These will be used to determine if wrap can fit in the viewport 1331 origMaxWidth = maxWidth; 1332 origMaxHeight = maxHeight; 1333 1334 if (current.fitToView) { 1335 maxWidth = Math.min(viewport.w - wSpace, maxWidth); 1336 maxHeight = Math.min(viewport.h - hSpace, maxHeight); 1337 } 1338 1339 maxWidth_ = viewport.w - wMargin; 1340 maxHeight_ = viewport.h - hMargin; 1341 1342 if (current.aspectRatio) { 1343 if (width > maxWidth) { 1344 width = maxWidth; 1345 height = getScalar(width / ratio); 1346 } 1347 1348 if (height > maxHeight) { 1349 height = maxHeight; 1350 width = getScalar(height * ratio); 1351 } 1352 1353 if (width < minWidth) { 1354 width = minWidth; 1355 height = getScalar(width / ratio); 1356 } 1357 1358 if (height < minHeight) { 1359 height = minHeight; 1360 width = getScalar(height * ratio); 1361 } 1362 1363 } else { 1364 width = Math.max(minWidth, Math.min(width, maxWidth)); 1365 1366 if (current.autoHeight && current.type !== 'iframe') { 1367 inner.width( width ); 1368 1369 height = inner.height(); 1370 } 1371 1372 height = Math.max(minHeight, Math.min(height, maxHeight)); 1373 } 1374 1375 // Try to fit inside viewport (including the title) 1376 if (current.fitToView) { 1377 inner.width( width ).height( height ); 1378 1379 wrap.width( width + wPadding ); 1380 1381 // Real wrap dimensions 1382 width_ = wrap.width(); 1383 height_ = wrap.height(); 1384 1385 if (current.aspectRatio) { 1386 while ((width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight) { 1387 if (steps++ > 19) { 1388 break; 1389 } 1390 1391 height = Math.max(minHeight, Math.min(maxHeight, height - 10)); 1392 width = getScalar(height * ratio); 1393 1394 if (width < minWidth) { 1395 width = minWidth; 1396 height = getScalar(width / ratio); 1397 } 1398 1399 if (width > maxWidth) { 1400 width = maxWidth; 1401 height = getScalar(width / ratio); 1402 } 1403 1404 inner.width( width ).height( height ); 1405 1406 wrap.width( width + wPadding ); 1407 1408 width_ = wrap.width(); 1409 height_ = wrap.height(); 1410 } 1411 1412 } else { 1413 width = Math.max(minWidth, Math.min(width, width - (width_ - maxWidth_))); 1414 height = Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_))); 1415 } 1416 } 1417 1418 if (scrollOut && scrolling === 'auto' && height < origHeight && (width + wPadding + scrollOut) < maxWidth_) { 1419 width += scrollOut; 1420 } 1421 1422 inner.width( width ).height( height ); 1423 1424 wrap.width( width + wPadding ); 1425 1426 width_ = wrap.width(); 1427 height_ = wrap.height(); 1428 1429 canShrink = (width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight; 1430 canExpand = current.aspectRatio ? (width < origMaxWidth && height < origMaxHeight && width < origWidth && height < origHeight) : ((width < origMaxWidth || height < origMaxHeight) && (width < origWidth || height < origHeight)); 1431 1432 $.extend(current, { 1433 dim : { 1434 width : getValue( width_ ), 1435 height : getValue( height_ ) 1436 }, 1437 origWidth : origWidth, 1438 origHeight : origHeight, 1439 canShrink : canShrink, 1440 canExpand : canExpand, 1441 wPadding : wPadding, 1442 hPadding : hPadding, 1443 wrapSpace : height_ - skin.outerHeight(true), 1444 skinSpace : skin.height() - height 1445 }); 1446 1447 if (!iframe && current.autoHeight && height > minHeight && height < maxHeight && !canExpand) { 1448 inner.height('auto'); 1449 } 1450 }, 1451 1452 _getPosition: function (onlyAbsolute) { 1453 var current = F.current, 1454 viewport = F.getViewport(), 1455 margin = current.margin, 1456 width = F.wrap.width() + margin[1] + margin[3], 1457 height = F.wrap.height() + margin[0] + margin[2], 1458 rez = { 1459 position: 'absolute', 1460 top : margin[0], 1461 left : margin[3] 1462 }; 1463 1464 if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) { 1465 rez.position = 'fixed'; 1466 1467 } else if (!current.locked) { 1468 rez.top += viewport.y; 1469 rez.left += viewport.x; 1470 } 1471 1472 rez.top = getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio))); 1473 rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * current.leftRatio))); 1474 1475 return rez; 1476 }, 1477 1478 _afterZoomIn: function () { 1479 var current = F.current; 1480 1481 if (!current) { 1482 return; 1483 } 1484 1485 F.isOpen = F.isOpened = true; 1486 1487 F.wrap.css('overflow', 'visible').addClass('fancybox-opened'); 1488 1489 F.update(); 1490 1491 // Assign a click event 1492 if ( current.closeClick || (current.nextClick && F.group.length > 1) ) { 1493 F.inner.css('cursor', 'pointer').bind('click.fb', function(e) { 1494 if (!$(e.target).is('a') && !$(e.target).parent().is('a')) { 1495 e.preventDefault(); 1496 1497 F[ current.closeClick ? 'close' : 'next' ](); 1498 } 1499 }); 1500 } 1501 1502 // Create a close button 1503 if (current.closeBtn) { 1504 $(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) { 1505 e.preventDefault(); 1506 1507 F.close(); 1508 }); 1509 } 1510 1511 // Create navigation arrows 1512 if (current.arrows && F.group.length > 1) { 1513 if (current.loop || current.index > 0) { 1514 $(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev); 1515 } 1516 1517 if (current.loop || current.index < F.group.length - 1) { 1518 $(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next); 1519 } 1520 } 1521 1522 F.trigger('afterShow'); 1523 1524 // Stop the slideshow if this is the last item 1525 if (!current.loop && current.index === current.group.length - 1) { 1526 F.play( false ); 1527 1528 } else if (F.opts.autoPlay && !F.player.isActive) { 1529 F.opts.autoPlay = false; 1530 1531 F.play(); 1532 } 1533 }, 1534 1535 _afterZoomOut: function ( obj ) { 1536 obj = obj || F.current; 1537 1538 $('.fancybox-wrap').trigger('onReset').remove(); 1539 1540 $.extend(F, { 1541 group : {}, 1542 opts : {}, 1543 router : false, 1544 current : null, 1545 isActive : false, 1546 isOpened : false, 1547 isOpen : false, 1548 isClosing : false, 1549 wrap : null, 1550 skin : null, 1551 outer : null, 1552 inner : null 1553 }); 1554 1555 if (obj.tabFocus) { 1556 $(obj.element).focus(); 1557 } 1558 1559 F.trigger('afterClose', obj); 1560 } 1561 }); 1562 1563 /* 1564 * Default transitions 1565 */ 1566 1567 F.transitions = { 1568 getOrigPosition: function () { 1569 var current = F.current, 1570 element = current.element, 1571 orig = current.orig, 1572 pos = {}, 1573 width = 50, 1574 height = 50, 1575 hPadding = current.hPadding, 1576 wPadding = current.wPadding, 1577 viewport = F.getViewport(); 1578 1579 if (!orig && current.isDom && element.is(':visible')) { 1580 orig = element.find('img:first'); 1581 1582 if (!orig.length) { 1583 orig = element; 1584 } 1585 } 1586 1587 if (isQuery(orig)) { 1588 pos = orig.offset(); 1589 1590 if (orig.is('img')) { 1591 width = orig.outerWidth(); 1592 height = orig.outerHeight(); 1593 } 1594 1595 } else { 1596 pos.top = viewport.y + (viewport.h - height) * current.topRatio; 1597 pos.left = viewport.x + (viewport.w - width) * current.leftRatio; 1598 } 1599 1600 if (F.wrap.css('position') === 'fixed' || current.locked) { 1601 pos.top -= viewport.y; 1602 pos.left -= viewport.x; 1603 } 1604 1605 pos = { 1606 top : getValue(pos.top - hPadding * current.topRatio), 1607 left : getValue(pos.left - wPadding * current.leftRatio), 1608 width : getValue(width + wPadding), 1609 height : getValue(height + hPadding) 1610 }; 1611 1612 return pos; 1613 }, 1614 1615 step: function (now, fx) { 1616 var ratio, 1617 padding, 1618 value, 1619 prop = fx.prop, 1620 current = F.current, 1621 wrapSpace = current.wrapSpace, 1622 skinSpace = current.skinSpace; 1623 1624 if (prop === 'width' || prop === 'height') { 1625 ratio = fx.end === fx.start ? 1 : (now - fx.start) / (fx.end - fx.start); 1626 1627 if (F.isClosing) { 1628 ratio = 1 - ratio; 1629 } 1630 1631 padding = prop === 'width' ? current.wPadding : current.hPadding; 1632 value = now - padding; 1633 1634 F.skin[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) ) ); 1635 F.inner[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) - (skinSpace * ratio) ) ); 1636 } 1637 }, 1638 1639 zoomIn: function () { 1640 var current = F.current, 1641 startPos = current.pos, 1642 effect = current.openEffect, 1643 elastic = effect === 'elastic', 1644 endPos = $.extend({opacity : 1}, startPos); 1645 1646 // Remove "position" property that breaks older IE 1647 delete endPos.position; 1648 1649 if (elastic) { 1650 startPos = this.getOrigPosition(); 1651 1652 if (current.openOpacity) { 1653 startPos.opacity = 0.1; 1654 } 1655 1656 } else if (effect === 'fade') { 1657 startPos.opacity = 0.1; 1658 } 1659 1660 F.wrap.css(startPos).animate(endPos, { 1661 duration : effect === 'none' ? 0 : current.openSpeed, 1662 easing : current.openEasing, 1663 step : elastic ? this.step : null, 1664 complete : F._afterZoomIn 1665 }); 1666 }, 1667 1668 zoomOut: function () { 1669 var current = F.current, 1670 effect = current.closeEffect, 1671 elastic = effect === 'elastic', 1672 endPos = {opacity : 0.1}; 1673 1674 if (elastic) { 1675 endPos = this.getOrigPosition(); 1676 1677 if (current.closeOpacity) { 1678 endPos.opacity = 0.1; 1679 } 1680 } 1681 1682 F.wrap.animate(endPos, { 1683 duration : effect === 'none' ? 0 : current.closeSpeed, 1684 easing : current.closeEasing, 1685 step : elastic ? this.step : null, 1686 complete : F._afterZoomOut 1687 }); 1688 }, 1689 1690 changeIn: function () { 1691 var current = F.current, 1692 effect = current.nextEffect, 1693 startPos = current.pos, 1694 endPos = { opacity : 1 }, 1695 direction = F.direction, 1696 distance = 200, 1697 field; 1698 1699 startPos.opacity = 0.1; 1700 1701 if (effect === 'elastic') { 1702 field = direction === 'down' || direction === 'up' ? 'top' : 'left'; 1703 1704 if (direction === 'down' || direction === 'right') { 1705 startPos[ field ] = getValue(getScalar(startPos[ field ]) - distance); 1706 endPos[ field ] = '+=' + distance + 'px'; 1707 1708 } else { 1709 startPos[ field ] = getValue(getScalar(startPos[ field ]) + distance); 1710 endPos[ field ] = '-=' + distance + 'px'; 1711 } 1712 } 1713 1714 // Workaround for http://bugs.jquery.com/ticket/12273 1715 if (effect === 'none') { 1716 F._afterZoomIn(); 1717 1718 } else { 1719 F.wrap.css(startPos).animate(endPos, { 1720 duration : current.nextSpeed, 1721 easing : current.nextEasing, 1722 complete : F._afterZoomIn 1723 }); 1724 } 1725 }, 1726 1727 changeOut: function () { 1728 var previous = F.previous, 1729 effect = previous.prevEffect, 1730 endPos = { opacity : 0.1 }, 1731 direction = F.direction, 1732 distance = 200; 1733 1734 if (effect === 'elastic') { 1735 endPos[ direction === 'down' || direction === 'up' ? 'top' : 'left' ] = ( direction === 'up' || direction === 'left' ? '-' : '+' ) + '=' + distance + 'px'; 1736 } 1737 1738 previous.wrap.animate(endPos, { 1739 duration : effect === 'none' ? 0 : previous.prevSpeed, 1740 easing : previous.prevEasing, 1741 complete : function () { 1742 $(this).trigger('onReset').remove(); 1743 } 1744 }); 1745 } 1746 }; 1747 1748 /* 1749 * Overlay helper 1750 */ 1751 1752 F.helpers.overlay = { 1753 defaults : { 1754 closeClick : true, // if true, fancyBox will be closed when user clicks on the overlay 1755 speedOut : 200, // duration of fadeOut animation 1756 showEarly : true, // indicates if should be opened immediately or wait until the content is ready 1757 css : {}, // custom CSS properties 1758 locked : !isTouch, // if true, the content will be locked into overlay 1759 fixed : true // if false, the overlay CSS position property will not be set to "fixed" 1760 }, 1761 1762 overlay : null, // current handle 1763 fixed : false, // indicates if the overlay has position "fixed" 1764 el : $('html'), // element that contains "the lock" 1765 1766 // Public methods 1767 create : function(opts) { 1768 opts = $.extend({}, this.defaults, opts); 1769 1770 if (this.overlay) { 1771 this.close(); 1772 } 1773 1774 this.overlay = $('<div class="fancybox-overlay"></div>').appendTo( F.coming ? F.coming.parent : opts.parent ); 1775 this.fixed = false; 1776 1777 if (opts.fixed && F.defaults.fixed) { 1778 this.overlay.addClass('fancybox-overlay-fixed'); 1779 1780 this.fixed = true; 1781 } 1782 }, 1783 1784 open : function(opts) { 1785 var that = this; 1786 1787 opts = $.extend({}, this.defaults, opts); 1788 1789 if (this.overlay) { 1790 this.overlay.unbind('.overlay').width('auto').height('auto'); 1791 1792 } else { 1793 this.create(opts); 1794 } 1795 1796 if (!this.fixed) { 1797 W.bind('resize.overlay', $.proxy( this.update, this) ); 1798 1799 this.update(); 1800 } 1801 1802 if (opts.closeClick) { 1803 this.overlay.bind('click.overlay', function(e) { 1804 if ($(e.target).hasClass('fancybox-overlay')) { 1805 if (F.isActive) { 1806 F.close(); 1807 } else { 1808 that.close(); 1809 } 1810 1811 return false; 1812 } 1813 }); 1814 } 1815 1816 this.overlay.css( opts.css ).show(); 1817 }, 1818 1819 close : function() { 1820 var scrollV, scrollH; 1821 1822 W.unbind('resize.overlay'); 1823 1824 if (this.el.hasClass('fancybox-lock')) { 1825 $('.fancybox-margin').removeClass('fancybox-margin'); 1826 1827 scrollV = W.scrollTop(); 1828 scrollH = W.scrollLeft(); 1829 1830 this.el.removeClass('fancybox-lock'); 1831 1832 W.scrollTop( scrollV ).scrollLeft( scrollH ); 1833 } 1834 1835 $('.fancybox-overlay').remove().hide(); 1836 1837 $.extend(this, { 1838 overlay : null, 1839 fixed : false 1840 }); 1841 1842 /* zamykacz fancybox i wywolanie funkcji adjustBoxes */ 1843 adjustBoxes(); 1844 1845 }, 1846 1847 // Private, callbacks 1848 1849 update : function () { 1850 var width = '100%', offsetWidth; 1851 1852 // Reset width/height so it will not mess 1853 this.overlay.width(width).height('100%'); 1854 1855 // jQuery does not return reliable result for IE 1856 if (IE) { 1857 offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth); 1858 1859 if (D.width() > offsetWidth) { 1860 width = D.width(); 1861 } 1862 1863 } else if (D.width() > W.width()) { 1864 width = D.width(); 1865 } 1866 1867 this.overlay.width(width).height(D.height()); 1868 }, 1869 1870 // This is where we can manipulate DOM, because later it would cause iframes to reload 1871 onReady : function (opts, obj) { 1872 var overlay = this.overlay; 1873 1874 $('.fancybox-overlay').stop(true, true); 1875 1876 if (!overlay) { 1877 this.create(opts); 1878 } 1879 1880 if (opts.locked && this.fixed && obj.fixed) { 1881 if (!overlay) { 1882 this.margin = D.height() > W.height() ? $('html').css('margin-right').replace("px", "") : false; 1883 } 1884 1885 obj.locked = this.overlay.append( obj.wrap ); 1886 obj.fixed = false; 1887 } 1888 1889 if (opts.showEarly === true) { 1890 this.beforeShow.apply(this, arguments); 1891 } 1892 }, 1893 1894 beforeShow : function(opts, obj) { 1895 var scrollV, scrollH; 1896 1897 if (obj.locked) { 1898 if (this.margin !== false) { 1899 $('*').filter(function(){ 1900 return ($(this).css('position') === 'fixed' && !$(this).hasClass("fancybox-overlay") && !$(this).hasClass("fancybox-wrap") ); 1901 }).addClass('fancybox-margin'); 1902 1903 this.el.addClass('fancybox-margin'); 1904 } 1905 1906 scrollV = W.scrollTop(); 1907 scrollH = W.scrollLeft(); 1908 1909 this.el.addClass('fancybox-lock'); 1910 1911 W.scrollTop( scrollV ).scrollLeft( scrollH ); 1912 } 1913 1914 this.open(opts); 1915 }, 1916 1917 onUpdate : function() { 1918 if (!this.fixed) { 1919 this.update(); 1920 } 1921 }, 1922 1923 afterClose: function (opts) { 1924 // Remove overlay if exists and fancyBox is not opening 1925 // (e.g., it is not being open using afterClose callback) 1926 //if (this.overlay && !F.isActive) { 1927 if (this.overlay && !F.coming) { 1928 this.overlay.fadeOut(opts.speedOut, $.proxy( this.close, this )); 1929 } 1930 } 1931 }; 1932 1933 /* 1934 * Title helper 1935 */ 1936 1937 F.helpers.title = { 1938 defaults : { 1939 type : 'float', // 'float', 'inside', 'outside' or 'over', 1940 position : 'bottom' // 'top' or 'bottom' 1941 }, 1942 1943 beforeShow: function (opts) { 1944 var current = F.current, 1945 text = current.title, 1946 type = opts.type, 1947 title, 1948 target; 1949 1950 if ($.isFunction(text)) { 1951 text = text.call(current.element, current); 1952 } 1953 1954 if (!isString(text) || $.trim(text) === '') { 1955 return; 1956 } 1957 1958 title = $('<div class="fancybox-title fancybox-title-' + type + '-wrap">
vendor: 3,488 bytes, lines 1958-2086
1958' + text + '</div>'); 1959 1960 switch (type) { 1961 case 'inside': 1962 target = F.skin; 1963 break; 1964 1965 case 'outside': 1966 target = F.wrap; 1967 break; 1968 1969 case 'over': 1970 target = F.inner; 1971 break; 1972 1973 default: // 'float' 1974 target = F.skin; 1975 1976 title.appendTo('body'); 1977 1978 if (IE) { 1979 title.width( title.width() ); 1980 } 1981 1982 title.wrapInner('<span class="child"></span>'); 1983 1984 //Increase bottom margin so this title will also fit into viewport 1985 F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) ); 1986 break; 1987 } 1988 1989 title[ (opts.position === 'top' ? 'prependTo' : 'appendTo') ](target); 1990 } 1991 }; 1992 1993 // jQuery plugin initialization 1994 $.fn.fancybox = function (options) { 1995 var index, 1996 that = $(this), 1997 selector = this.selector || '', 1998 run = function(e) { 1999 var what = $(this).blur(), idx = index, relType, relVal; 2000 2001 if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !what.is('.fancybox-wrap')) { 2002 relType = options.groupAttr || 'data-fancybox-group'; 2003 relVal = what.attr(relType); 2004 2005 if (!relVal) { 2006 relType = 'rel'; 2007 relVal = what.get(0)[ relType ]; 2008 } 2009 2010 if (relVal && relVal !== '' && relVal !== 'nofollow') { 2011 what = selector.length ? $(selector) : that; 2012 what = what.filter('[' + relType + '="' + relVal + '"]'); 2013 idx = what.index(this); 2014 } 2015 2016 options.index = idx; 2017 2018 // Stop an event from bubbling if everything is fine 2019 if (F.open(what, options) !== false) { 2020 e.preventDefault(); 2021 } 2022 } 2023 }; 2024 2025 options = options || {}; 2026 index = options.index || 0; 2027 2028 if (!selector || options.live === false) { 2029 that.unbind('click.fb-start').bind('click.fb-start', run); 2030 2031 } else { 2032 D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run); 2033 } 2034 2035 this.filter('[data-fancybox-start=1]').trigger('click'); 2036 2037 return this; 2038 }; 2039 2040 // Tests that need a body at doc ready 2041 D.ready(function() { 2042 var w1, w2; 2043 2044 if ( $.scrollbarWidth === undefined ) { 2045 // http://benalman.com/projects/jquery-misc-plugins/#scrollbarwidth 2046 $.scrollbarWidth = function() { 2047 var parent = $('<div style="width:50px;height:50px;overflow:auto"><div/></div>').appendTo('body'), 2048 child = parent.children(), 2049 width = child.innerWidth() - child.height( 99 ).innerWidth(); 2050 2051 parent.remove(); 2052 2053 return width; 2054 }; 2055 } 2056 2057 if ( $.support.fixedPosition === undefined ) { 2058 $.support.fixedPosition = (function() { 2059 var elem = $('<div style="position:fixed;top:20px;"></div>').appendTo('body'), 2060 fixed = ( elem[0].offsetTop === 20 || elem[0].offsetTop === 15 ); 2061 2062 elem.remove(); 2063 2064 return fixed; 2065 }()); 2066 } 2067 2068 $.extend(F.defaults, { 2069 scrollbarWidth : $.scrollbarWidth(), 2070 fixed : $.support.fixedPosition, 2071 parent : $('body') 2072 }); 2073 2074 //Get real width of page scroll-bar 2075 w1 = $(window).width(); 2076 2077 H.addClass('fancybox-lock-test'); 2078 2079 w2 = $(window).width(); 2080 2081 H.removeClass('fancybox-lock-test'); 2082 2083 $("<style type='text/css'>.fancybox-margin{margin-right:" + (w2 - w1) + "px;}</style>").appendTo("head"); 2084 }); 2085 2086}(window, document, jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.