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