1/*! PhotoSwipe Default UI - 4.1.3 - 2019-01-08 2* http://photoswipe.com 3* Copyright (c) 2019 Dmitry Semenov; */ 4/** 5* 6* UI on top of main sliding area (caption, arrows, close button, etc.). 7* Built just using public methods/properties of PhotoSwipe. 8* 9*/ 10(function (root, factory) { 11 if (typeof define === 'function' && define.amd) { 12 define(factory); 13 } else if (typeof exports === 'object') { 14 module.exports = factory(); 15 } else { 16 root.PhotoSwipeUI_Default = factory(); 17 } 18})(this, function () { 19 20 'use strict'; 21 22 23 24var PhotoSwipeUI_Default = 25 function(pswp, framework) { 26 27 var ui = this; 28 var _overlayUIUpdated = false, 29 _controlsVisible = true, 30 _fullscrenAPI, 31 _controls, 32 _captionContainer, 33 _fakeCaptionContainer, 34 _indexIndicator, 35 _shareButton, 36 _shareModal, 37 _shareModalHidden = true, 38 _initalCloseOnScrollValue, 39 _isIdle, 40 _listen, 41 42 _loadingIndicator, 43 _loadingIndicatorHidden, 44 _loadingIndicatorTimeout, 45 46 _galleryHasOneSlide, 47 48 _options, 49 _defaultUIOptions = { 50 barsSize: {top:44, bottom:'auto'}, 51 closeElClasses: ['item', 'caption', 'zoom-wrap', 'ui', 'top-bar'], 52 timeToIdle: 4000, 53 timeToIdleOutside: 1000, 54 loadingIndicatorDelay: 1000, // 2s 55 56 addCaptionHTMLFn: function(item, captionEl /*, isFake */) { 57 if(!item.title) { 58 captionEl.children[0].innerHTML = ''; 59 return false; 60 } 61 captionEl.children[0].innerHTML = item.title; 62 return true; 63 }, 64 65 closeEl:true, 66 captionEl: true, 67 fullscreenEl: true, 68 zoomEl: true, 69 shareEl: true, 70 counterEl: true, 71 arrowEl: true, 72 preloaderEl: true, 73 74 tapToClose: false, 75 tapToToggleControls: true, 76 77 clickToCloseNonZoomable: true, 78 79 shareButtons: [ 80 {id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}}'}, 81 {id:'twitter', label:'Tweet', url:'https://twitter.com/intent/tweet?text={{text}}&url={{url}}'}, 82 {id:'pinterest', label:'Pin it', url:'http://www.pinterest.com/pin/create/button/'+ 83 '?url={{url}}&media={{image_url}}&description={{text}}'}, 84 {id:'download', label:'Download image', url:'{{raw_image_url}}', download:true} 85 ], 86 getImageURLForShare: function( /* shareButtonData */ ) { 87 return pswp.currItem.src || ''; 88 }, 89 getPageURLForShare: function( /* shareButtonData */ ) { 90 return window.location.href; 91 }, 92 getTextForShare: function( /* shareButtonData */ ) { 93 return pswp.currItem.title || ''; 94 }, 95 96 indexIndicatorSep: ' / ', 97 fitControlsWidth: 1200 98 99 }, 100 _blockControlsTap, 101 _blockControlsTapTimeout; 102 103 104 105 var _onControlsTap = function(e) { 106 if(_blockControlsTap) { 107 return true; 108 } 109 110 111 e = e || window.event; 112 113 if(_options.timeToIdle && _options.mouseUsed && !_isIdle) { 114 // reset idle timer 115 _onIdleMouseMove(); 116 } 117 118 119 var target = e.target || e.srcElement; 120 if ($(target).closest('.pswp__button').length > 0) { 121 target = $(target).closest('.pswp__button').get(0); 122 } 123 var uiElement, 124 clickedClass = target.getAttribute('class') || '', 125 found; 126 127 for(var i = 0; i < _uiElements.length; i++) { 128 uiElement = _uiElements[i]; 129 if(uiElement.onTap && clickedClass.indexOf('pswp__' + uiElement.name ) > -1 ) { 130 uiElement.onTap(); 131 found = true; 132 133 } 134 } 135 136 if(found) { 137 if(e.stopPropagation) { 138 e.stopPropagation(); 139 } 140 _blockControlsTap = true; 141 142 // Some versions of Android don't prevent ghost click event 143 // when preventDefault() was called on touchstart and/or touchend. 144 // 145 // This happens on v4.3, 4.2, 4.1, 146 // older versions strangely work correctly, 147 // but just in case we add delay on all of them) 148 var tapDelay = framework.features.isOldAndroid ? 600 : 30; 149 _blockControlsTapTimeout = setTimeout(function() { 150 _blockControlsTap = false; 151 }, tapDelay); 152 } 153 154 }, 155 _fitControlsInViewport = function() { 156 return !pswp.likelyTouchDevice || _options.mouseUsed || screen.width > _options.fitControlsWidth; 157 }, 158 _togglePswpClass = function(el, cName, add) { 159 framework[ (add ? 'add' : 'remove') + 'Class' ](el, 'pswp__' + cName); 160 }, 161 162 // add class when there is just one item in the gallery 163 // (by default it hides left/right arrows and 1ofX counter) 164 _countNumItems = function() { 165 var hasOneSlide = (_options.getNumItemsFn() === 1); 166 167 if(hasOneSlide !== _galleryHasOneSlide) { 168 _togglePswpClass(_controls, 'ui--one-slide', hasOneSlide); 169 _galleryHasOneSlide = hasOneSlide; 170 } 171 }, 172 _toggleShareModalClass = function() { 173 _togglePswpClass(_shareModal, 'share-modal--hidden', _shareModalHidden); 174 }, 175 _toggleShareModal = function() { 176 177 _shareModalHidden = !_shareModalHidden; 178 179 180 if(!_shareModalHidden) { 181 _toggleShareModalClass(); 182 setTimeout(function() { 183 if(!_shareModalHidden) { 184 framework.addClass(_shareModal, 'pswp__share-modal--fade-in'); 185 } 186 }, 30); 187 } else { 188 framework.removeClass(_shareModal, 'pswp__share-modal--fade-in'); 189 setTimeout(function() { 190 if(_shareModalHidden) { 191 _toggleShareModalClass(); 192 } 193 }, 300); 194 } 195 196 if(!_shareModalHidden) { 197 _updateShareURLs(); 198 } 199 return false;
200 }, 201 202 _openWindowPopup = function(e) { 203 e = e || window.event; 204 var target = e.target || e.srcElement; 205 206 pswp.shout('shareLinkClick', e, target); 207 208 if(!target.href) { 209 return false; 210 } 211 212 if( target.hasAttribute('download') ) { 213 return true; 214 } 215 216 window.open(target.href, 'pswp_share', 'scrollbars=yes,resizable=yes,toolbar=no,'+ 217 'location=yes,width=550,height=420,top=100,left=' + 218 (window.screen ? Math.round(screen.width / 2 - 275) : 100) ); 219 220 if(!_shareModalHidden) { 221 _toggleShareModal(); 222 } 223 224 return false; 225 }, 226 _updateShareURLs = function() { 227 var shareButtonOut = '', 228 shareButtonData, 229 shareURL, 230 image_url, 231 page_url, 232 share_text; 233 234 for(var i = 0; i < _options.shareButtons.length; i++) { 235 shareButtonData = _options.shareButtons[i]; 236 237 image_url = _options.getImageURLForShare(shareButtonData); 238 page_url = _options.getPageURLForShare(shareButtonData); 239 share_text = _options.getTextForShare(shareButtonData); 240 241 shareURL = shareButtonData.url.replace('{{url}}', encodeURIComponent(page_url) ) 242 .replace('{{image_url}}', encodeURIComponent(image_url) ) 243 .replace('{{raw_image_url}}', image_url ) 244 .replace('{{text}}', encodeURIComponent(share_text) ); 245 246 shareButtonOut += '<a href="' + shareURL + '" target="_blank" '+ 247 'class="pswp__share--' + shareButtonData.id + '"' + 248 (shareButtonData.download ? 'download' : '') + '>' + 249 shareButtonData.label + '</a>'; 250 251 if(_options.parseShareButtonOut) { 252 shareButtonOut = _options.parseShareButtonOut(shareButtonData, shareButtonOut); 253 } 254 } 255 _shareModal.children[0].innerHTML = shareButtonOut; 256 _shareModal.children[0].onclick = _openWindowPopup; 257 258 }, 259 _hasCloseClass = function(target) { 260 for(var i = 0; i < _options.closeElClasses.length; i++) { 261 if( framework.hasClass(target, 'pswp__' + _options.closeElClasses[i]) ) { 262 return true; 263 } 264 } 265 }, 266 _idleInterval, 267 _idleTimer, 268 _idleIncrement = 0, 269 _onIdleMouseMove = function() { 270 clearTimeout(_idleTimer); 271 _idleIncrement = 0; 272 if(_isIdle) { 273 ui.setIdle(false); 274 } 275 }, 276 _onMouseLeaveWindow = function(e) { 277 e = e ? e : window.event; 278 var from = e.relatedTarget || e.toElement; 279 if (!from || from.nodeName === 'HTML') { 280 clearTimeout(_idleTimer); 281 _idleTimer = setTimeout(function() { 282 ui.setIdle(true); 283 }, _options.timeToIdleOutside); 284 } 285 }, 286 _setupFullscreenAPI = function() { 287 if(_options.fullscreenEl) { 288 if(!_fullscrenAPI) { 289 _fullscrenAPI = ui.getFullscreenAPI(); 290 } 291 if(_fullscrenAPI) { 292 framework.bind(document, _fullscrenAPI.eventK, ui.updateFullscreen); 293 ui.updateFullscreen(); 294 framework.addClass(pswp.template, 'pswp--supports-fs'); 295 } else { 296 framework.removeClass(pswp.template, 'pswp--supports-fs'); 297 } 298 } 299 }, 300 _setupLoadingIndicator = function() { 301 // Setup loading indicator 302 if(_options.preloaderEl) { 303 304 _toggleLoadingIndicator(true); 305 306 _listen('beforeChange', function() { 307 308 clearTimeout(_loadingIndicatorTimeout); 309 310 // display loading indicator with delay 311 _loadingIndicatorTimeout = setTimeout(function() { 312 313 if(pswp.currItem && pswp.currItem.loading) { 314 315 if( !pswp.allowProgressiveImg() || (pswp.currItem.img && !pswp.currItem.img.naturalWidth) ) { 316 // show preloader if progressive loading is not enabled, 317 // or image width is not defined yet (because of slow connection) 318 _toggleLoadingIndicator(false); 319 // items-controller.js function allowProgressiveImg 320 } 321 322 } else { 323 _toggleLoadingIndicator(true); // hide preloader 324 } 325 326 }, _options.loadingIndicatorDelay); 327 328 }); 329 _listen('imageLoadComplete', function(index, item) { 330 if(pswp.currItem === item) { 331 _toggleLoadingIndicator(true); 332 } 333 }); 334 335 } 336 }, 337 _toggleLoadingIndicator = function(hide) { 338 if( _loadingIndicatorHidden !== hide ) { 339 _togglePswpClass(_loadingIndicator, 'preloader--active', !hide); 340 _loadingIndicatorHidden = hide; 341 } 342 }, 343 _applyNavBarGaps = function(item) { 344 var gap = item.vGap; 345 346 if( _fitControlsInViewport() ) { 347 348 var bars = _options.barsSize; 349 if(_options.captionEl && bars.bottom === 'auto') { 350 if(!_fakeCaptionContainer) { 351 _fakeCaptionContainer = framework.createEl('pswp__caption pswp__caption--fake'); 352 _fakeCaptionContainer.appendChild( framework.createEl('pswp__caption__center') ); 353 _controls.insertBefore(_fakeCaptionContainer, _captionContainer); 354 framework.addClass(_controls, 'pswp__ui--fit'); 355 } 356 if( _options.addCaptionHTMLFn(item, _fakeCaptionContainer, true) ) { 357 358 var captionSize = _fakeCaptionContainer.clientHeight; 359 gap.bottom = parseInt(captionSize,10) || 44; 360 } else { 361 gap.bottom = bars.top;
361 // if no caption, set size of bottom gap to size of top 362 } 363 } else { 364 gap.bottom = bars.bottom === 'auto' ? 0 : bars.bottom; 365 } 366 367 // height of top bar is static, no need to calculate it 368 gap.top = bars.top; 369 } else { 370 gap.top = gap.bottom = 0; 371 } 372 }, 373 _setupIdle = function() { 374 // Hide controls when mouse is used 375 if(_options.timeToIdle) { 376 _listen('mouseUsed', function() { 377 378 framework.bind(document, 'mousemove', _onIdleMouseMove); 379 framework.bind(document, 'mouseout', _onMouseLeaveWindow); 380 381 _idleInterval = setInterval(function() { 382 _idleIncrement++; 383 if(_idleIncrement === 2) { 384 ui.setIdle(true); 385 } 386 }, _options.timeToIdle / 2); 387 }); 388 } 389 }, 390 _setupHidingControlsDuringGestures = function() { 391 392 // Hide controls on vertical drag 393 _listen('onVerticalDrag', function(now) { 394 if(_controlsVisible && now < 0.95) { 395 ui.hideControls(); 396 } else if(!_controlsVisible && now >= 0.95) { 397 ui.showControls(); 398 } 399 }); 400 401 // Hide controls when pinching to close 402 var pinchControlsHidden; 403 _listen('onPinchClose' , function(now) { 404 if(_controlsVisible && now < 0.9) { 405 ui.hideControls(); 406 pinchControlsHidden = true; 407 } else if(pinchControlsHidden && !_controlsVisible && now > 0.9) { 408 ui.showControls(); 409 } 410 }); 411 412 _listen('zoomGestureEnded', function() { 413 pinchControlsHidden = false; 414 if(pinchControlsHidden && !_controlsVisible) { 415 ui.showControls(); 416 } 417 }); 418 419 }; 420 421 422 423 var _uiElements = [ 424 { 425 name: 'caption', 426 option: 'captionEl', 427 onInit: function(el) { 428 _captionContainer = el; 429 } 430 }, 431 { 432 name: 'share-modal', 433 option: 'shareEl', 434 onInit: function(el) { 435 _shareModal = el; 436 }, 437 onTap: function() { 438 _toggleShareModal(); 439 } 440 }, 441 { 442 name: 'button--share', 443 option: 'shareEl', 444 onInit: function(el) { 445 _shareButton = el; 446 }, 447 onTap: function() { 448 _toggleShareModal(); 449 } 450 }, 451 { 452 name: 'button--zoom', 453 option: 'zoomEl', 454 onTap: pswp.toggleDesktopZoom 455 }, 456 { 457 name: 'counter', 458 option: 'counterEl', 459 onInit: function(el) { 460 _indexIndicator = el; 461 } 462 }, 463 { 464 name: 'button--close', 465 option: 'closeEl', 466 onTap: function() { 467 setTimeout(function() { 468 pswp.close(); 469 },20); 470 } 471 }, 472 { 473 name: 'button--arrow--left', 474 option: 'arrowEl', 475 onTap: pswp.prev 476 }, 477 { 478 name: 'button--arrow--right', 479 option: 'arrowEl', 480 onTap: pswp.next 481 }, 482 { 483 name: 'button--fs', 484 option: 'fullscreenEl', 485 onTap: function() { 486 if(_fullscrenAPI.isFullscreen()) { 487 _fullscrenAPI.exit(); 488 } else { 489 _fullscrenAPI.enter(); 490 } 491 } 492 }, 493 { 494 name: 'preloader', 495 option: 'preloaderEl', 496 onInit: function(el) { 497 _loadingIndicator = el; 498 } 499 } 500 501 ]; 502 503 var _setupUIElements = function() { 504 var item, 505 classAttr, 506 uiElement; 507 508 var loopThroughChildElements = function(sChildren) { 509 if(!sChildren) { 510 return; 511 } 512 513 var l = sChildren.length; 514 for(var i = 0; i < l; i++) { 515 item = sChildren[i]; 516 classAttr = item.className; 517 518 for(var a = 0; a < _uiElements.length; a++) { 519 uiElement = _uiElements[a]; 520 521 if(classAttr.indexOf('pswp__' + uiElement.name) > -1 ) { 522 523 if( _options[uiElement.option] ) { // if element is not disabled from options 524 525 framework.removeClass(item, 'pswp__element--disabled'); 526 if(uiElement.onInit) { 527 uiElement.onInit(item); 528 } 529 530 //item.style.display = 'block'; 531 } else { 532 framework.addClass(item, 'pswp__element--disabled'); 533 //item.style.display = 'none'; 534 } 535 } 536 } 537 } 538 }; 539 loopThroughChildElements(_controls.children); 540 541 var topBar = framework.getChildByClass(_controls, 'pswp__top-bar'); 542 if(topBar) { 543 loopThroughChildElements( topBar.children ); 544 } 545 }; 546 547 548 549 550 ui.init = function() { 551 552 // extend options 553 framework.extend(pswp.options, _defaultUIOptions, true); 554 555 // create local link for fast access 556 _options = pswp.options; 557 558 // find pswp__ui element 559 _controls = framework.getChildByClass(pswp.scrollWrap, 'pswp__ui'); 560 561 // create local link 562 _listen = pswp.listen; 563 564 565 _setupHidingControlsDuringGestures(); 566 567 // update controls when slides change 568 _listen('beforeChange', ui.update); 569 570 // toggle zoom on double-tap 571 _listen('doubleTap', function(point) {
572 var initialZoomLevel = pswp.currItem.initialZoomLevel; 573 if(pswp.getZoomLevel() !== initialZoomLevel) { 574 pswp.zoomTo(initialZoomLevel, point, 333); 575 } else { 576 pswp.zoomTo(_options.getDoubleTapZoom(false, pswp.currItem), point, 333); 577 } 578 }); 579 580 // Allow text selection in caption 581 _listen('preventDragEvent', function(e, isDown, preventObj) { 582 var t = e.target || e.srcElement; 583 if( 584 t && 585 t.getAttribute('class') && e.type.indexOf('mouse') > -1 && 586 ( t.getAttribute('class').indexOf('__caption') > 0 || (/(SMALL|STRONG|EM)/i).test(t.tagName) ) 587 ) { 588 preventObj.prevent = false; 589 } 590 }); 591 592 // bind events for UI 593 _listen('bindEvents', function() { 594 framework.bind(_controls, 'pswpTap click', _onControlsTap); 595 framework.bind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap); 596 597 if(!pswp.likelyTouchDevice) { 598 framework.bind(pswp.scrollWrap, 'mouseover', ui.onMouseOver); 599 } 600 }); 601 602 // unbind events for UI 603 _listen('unbindEvents', function() { 604 if(!_shareModalHidden) { 605 _toggleShareModal(); 606 } 607 608 if(_idleInterval) { 609 clearInterval(_idleInterval); 610 } 611 framework.unbind(document, 'mouseout', _onMouseLeaveWindow); 612 framework.unbind(document, 'mousemove', _onIdleMouseMove); 613 framework.unbind(_controls, 'pswpTap click', _onControlsTap); 614 framework.unbind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap); 615 framework.unbind(pswp.scrollWrap, 'mouseover', ui.onMouseOver); 616 617 if(_fullscrenAPI) { 618 framework.unbind(document, _fullscrenAPI.eventK, ui.updateFullscreen); 619 if(_fullscrenAPI.isFullscreen() && !_options.wasFullScreenBefore) { 620 _options.hideAnimationDuration = 0; 621 _fullscrenAPI.exit(); 622 } 623 _fullscrenAPI = null; 624 } 625 }); 626 627 628 // clean up things when gallery is destroyed 629 _listen('destroy', function() { 630 if(_options.captionEl) { 631 if(_fakeCaptionContainer) { 632 _controls.removeChild(_fakeCaptionContainer); 633 } 634 framework.removeClass(_captionContainer, 'pswp__caption--empty'); 635 } 636 637 if(_shareModal) { 638 _shareModal.children[0].onclick = null; 639 } 640 framework.removeClass(_controls, 'pswp__ui--over-close'); 641 framework.addClass( _controls, 'pswp__ui--hidden'); 642 ui.setIdle(false); 643 }); 644 645 646 if(!_options.showAnimationDuration) { 647 framework.removeClass( _controls, 'pswp__ui--hidden'); 648 } 649 _listen('initialZoomIn', function() { 650 if(_options.showAnimationDuration) { 651 framework.removeClass( _controls, 'pswp__ui--hidden'); 652 } 653 }); 654 _listen('initialZoomOut', function() { 655 framework.addClass( _controls, 'pswp__ui--hidden'); 656 }); 657 658 _listen('parseVerticalMargin', _applyNavBarGaps); 659 660 _setupUIElements(); 661 662 if(_options.shareEl && _shareButton && _shareModal) { 663 _shareModalHidden = true; 664 } 665 666 _countNumItems(); 667 668 _setupIdle(); 669 670 _setupFullscreenAPI(); 671 672 _setupLoadingIndicator(); 673 }; 674 675 ui.setIdle = function(isIdle) { 676 _isIdle = isIdle; 677 _togglePswpClass(_controls, 'ui--idle', isIdle); 678 }; 679 680 ui.update = function() { 681 // Don't update UI if it's hidden 682 if(_controlsVisible && pswp.currItem) { 683 684 ui.updateIndexIndicator(); 685 686 if(_options.captionEl) { 687 _options.addCaptionHTMLFn(pswp.currItem, _captionContainer); 688 689 _togglePswpClass(_captionContainer, 'caption--empty', !pswp.currItem.title); 690 } 691 692 _overlayUIUpdated = true; 693 694 } else { 695 _overlayUIUpdated = false; 696 } 697 698 if(!_shareModalHidden) { 699 _toggleShareModal(); 700 } 701 702 _countNumItems(); 703 }; 704 705 ui.updateFullscreen = function(e) { 706 707 if(e) { 708 // some browsers change window scroll position during the fullscreen 709 // so PhotoSwipe updates it just in case 710 setTimeout(function() { 711 pswp.setScrollOffset( 0, framework.getScrollY() ); 712 }, 50); 713 } 714 715 // toogle pswp--fs class on root element 716 framework[ (_fullscrenAPI.isFullscreen() ? 'add' : 'remove') + 'Class' ](pswp.template, 'pswp--fs'); 717 }; 718 719 ui.updateIndexIndicator = function() { 720 if(_options.counterEl) { 721 _indexIndicator.innerHTML = (pswp.getCurrentIndex()+1) + 722 _options.indexIndicatorSep + 723 _options.getNumItemsFn(); 724 } 725 }; 726 727 ui.onGlobalTap = function(e) { 728 e = e || window.event; 729 var target = e.target || e.srcElement; 730 731 if(_blockControlsTap) { 732 return; 733 } 734 735 if(e.detail && e.detail.pointerType === 'mouse') { 736 737 // close gallery if clicked outside of the image 738 if(_hasCloseClass(target) && _options.tapToClose) { 739 pswp.close(); 740 return; 741 } 742 743 if(framework.hasClass(target, 'pswp__img')) { 744 if(pswp.getZoomLevel() === 1 && pswp.getZoomLevel() <= pswp.currItem.fitRatio) { 745 if(_options.clickToCloseNonZoomable) { 746 pswp.close(); 747 } 748 } else { 749 pswp.toggleDesktopZoom(e.detail.releasePoint); 750 } 751 } 752 753 } else { 754 if ($(e.target).closest('.pswp__button').length > 0) { 755 return; 756 } 757 // tap anywhere (except buttons) to toggle visibility of controls 758 if(_options.tapToToggleControls) { 759 if(_controlsVisible) { 760 ui.hideControls(); 761 } else { 762 ui.showControls(); 763 } 764 } 765 766 // tap to close gallery 767 if(_options.tapToClose && (framework.hasClass(target, 'pswp__img') || _hasCloseClass(target)) ) { 768 pswp.close(); 769 return; 770 } 771 772 } 773 }; 774 ui.onMouseOver = function(e) { 775 e = e || window.event; 776 var target = e.target || e.srcElement; 777 778 // add class when mouse is over an element that should close the gallery 779 _togglePswpClass(_controls, 'ui--over-close', _hasCloseClass(target)); 780 }; 781 782 ui.hideControls = function() { 783 framework.addClass(_controls,'pswp__ui--hidden'); 784 _controlsVisible = false;
785 }; 786 787 ui.showControls = function() { 788 _controlsVisible = true; 789 if(!_overlayUIUpdated) { 790 ui.update(); 791 } 792 framework.removeClass(_controls,'pswp__ui--hidden'); 793 }; 794 795 ui.supportsFullscreen = function() { 796 var d = document; 797 return !!(d.exitFullscreen || d.mozCancelFullScreen || d.webkitExitFullscreen || d.msExitFullscreen); 798 }; 799 800 ui.getFullscreenAPI = function() { 801 var dE = document.documentElement, 802 api, 803 tF = 'fullscreenchange'; 804 805 if (dE.requestFullscreen) { 806 api = { 807 enterK: 'requestFullscreen', 808 exitK: 'exitFullscreen', 809 elementK: 'fullscreenElement', 810 eventK: tF 811 }; 812 813 } else if(dE.mozRequestFullScreen ) { 814 api = { 815 enterK: 'mozRequestFullScreen', 816 exitK: 'mozCancelFullScreen', 817 elementK: 'mozFullScreenElement', 818 eventK: 'moz' + tF 819 }; 820 821 822 823 } else if(dE.webkitRequestFullscreen) { 824 api = { 825 enterK: 'webkitRequestFullscreen', 826 exitK: 'webkitExitFullscreen', 827 elementK: 'webkitFullscreenElement', 828 eventK: 'webkit' + tF 829 }; 830 831 } else if(dE.msRequestFullscreen) { 832 api = { 833 enterK: 'msRequestFullscreen', 834 exitK: 'msExitFullscreen', 835 elementK: 'msFullscreenElement', 836 eventK: 'MSFullscreenChange' 837 }; 838 } 839 840 841 if (MobileAppBridge.isActive() && api) { 842 if (!api) { 843 api = { 844 enterK: 'requestFullscreen', 845 exitK: 'exitFullscreen', 846 elementK: 'fullscreenElement', 847 eventK: tF 848 }; 849 } 850 api.eventK = 'fullscreenchange'; 851 api.enter = function() { 852 setTimeout(function() { 853 if (!window.ascFullscreenOpened) { 854 MobileAppBridge.runFlexMethod('fullScreenOpen',{}); 855 window.ascFullscreenOpened = true; 856 857 setTimeout(function() { 858 $(window).resize(); 859 pswp.updateSize(true); 860 },100); 861 862 document.dispatchEvent(new Event(api.eventK)); 863 } 864 },100); 865 } 866 api.exit = function() { 867 setTimeout(function() { 868 if (window.ascFullscreenOpened) { 869 window.ascFullscreenOpened = false; 870 MobileAppBridge.runFlexMethod('fullScreenClose',{}); 871 872 setTimeout(function() { 873 $(window).resize(); 874 pswp.updateSize(true); 875 },100); 876 877 document.dispatchEvent(new Event(api.eventK)); 878 } 879 },100); 880 } 881 api.isFullscreen = function() { return !!window.ascFullscreenOpened; }; 882 } else 883 if(api) { 884 api.enter = function() { 885 // disable close-on-scroll in fullscreen 886 _initalCloseOnScrollValue = _options.closeOnScroll; 887 _options.closeOnScroll = false; 888 889 if(this.enterK === 'webkitRequestFullscreen') { 890 pswp.template[this.enterK]( Element.ALLOW_KEYBOARD_INPUT ); 891 } else { 892 return pswp.template[this.enterK](); 893 } 894 }; 895 api.exit = function() { 896 _options.closeOnScroll = _initalCloseOnScrollValue; 897 898 return document[this.exitK](); 899 900 }; 901 api.isFullscreen = function() { return document[this.elementK]; }; 902 } 903 904 905 906 return api; 907 }; 908 909 910 911}; 912return PhotoSwipeUI_Default; 913 914 915});
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.