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