Fraenkiman 20b210f02d Squashed commit of the following:
commit a4711e7017e918d3568c3eeaa1f91281e559fd58
Author: Fraenkiman <frank.pcn@gmail.com>
Date:   Mon Aug 21 00:41:09 2023 +0200

    other small adjustments

    - BBcode-Facebook-Viedo now uses the latest video player API and the lazy loading mechanism of the browser
    - Added background-attachment: fix workaround for mobile devices
    - small fixes to be valid with CSS3

commit 00c0e3740349996823fb31ec80be79dceccae61d
Author: Fraenkiman <frank.pcn@gmail.com>
Date:   Fri Aug 18 20:14:05 2023 +0200

    Update plugin.bbcode.php

    - BBcode-Facebook-Viedo now uses the latest video player API and the lazy loading mechanism of the browser

commit d8688ab2f22a855461142b4533cffd553d6283ee
Author: Fraenkiman <frank.pcn@gmail.com>
Date:   Fri Aug 18 00:18:19 2023 +0200

    Update plugin.fpprotect.php

    - FP-Protect allows full-screen playback of embedded videos

commit b4ccc4a021e6437db0c78ceebe2d257760ebe454
Author: Fraenkiman <frank.pcn@gmail.com>
Date:   Tue Aug 15 23:46:57 2023 +0200

    Update common.css

    - center BBcode video if screen < 960px

commit ff3f9d84708f774736bf29ebdf0c5f34c6c8936a
Author: Fraenkiman <frank.pcn@gmail.com>
Date:   Sat Aug 12 13:31:51 2023 +0200

    Update common.css

    - BBcode video is displayed larger on larger screens

commit 9c2235729a7b34c640a55b7d0c075a36bac567dd
Author: Fraenkiman <frank.pcn@gmail.com>
Date:   Tue Aug 8 00:54:31 2023 +0200

    Update admin.css

    - now also fits the entry preview on a smartphone

commit b531da308131482dc355525daec5b4ea8e640542
Author: Fraenkiman <frank.pcn@gmail.com>
Date:   Mon Aug 7 23:41:45 2023 +0200

    Squashed commit of the following:

    commit b8c94ecac23abec830543ad9e928e62d0e02d96d
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Mon Aug 7 23:23:21 2023 +0200

        Media queries were created for individual device classes

        - Media queries were created for individual device classes (smartphone, netbook, laptop and PC) in order to

    commit e2258bf4b52212074d98d08c65f7b62989478ade
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Thu Aug 3 00:16:22 2023 +0200

        Use full width on small screens

        Mobile devices are increasingly replacing the classic PC.
        So it is all the more important to make the theme and the administration area more accessible for today's mobile devices.
        - With a screen width of up to 768px, the full width is utilized.
        - The theme is no longer compressed vertically on small screens from 720px to 768px.

    commit ff76513e2b8b8ada1bc4dc2b395911e3f6c0f95e
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Wed Aug 2 00:13:36 2023 +0200

        Update admin.css

    commit 8140761f7fa1dde2395bee101e2df16332f5ff08
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Tue Aug 1 01:03:39 2023 +0200

        the minimum width removed from the body-container

        - the minimum width removed from the body-container entirely

    commit eb651c586dd0401a1edceb5ef2e867003692f8cd
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Tue Aug 1 00:15:30 2023 +0200

        reduced the minimum width to 720px

        - reduced the minimum width to 720px for better viewing with a mobile device in landscape mode

    commit 2ce9fc605ebb83c43e49ce15ecb531695c10dbd6
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Sun Jul 30 18:57:11 2023 +0200

        Fixes a problem in the admin area when rendering font-sizes

        - Fixes a problem in the admin panel when displaying font sizes in the mobile version of Firefox and Chrome.

    commit c8d4ee702791591d3557c51ef457c7bd9bad4d2d
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Sun Jul 30 18:25:02 2023 +0200

        Fixes a problem in the admin area when rendering font-sizes

        Fixes a problem in the admin panel when displaying font sizes in the mobile version of Firefox and Chrome.

    commit 451a960dc9543cac5ebbbe51d4084b85e86ca2b7
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Sat Jul 29 03:08:33 2023 +0200

        Removes obsolete acronym element, Fixes a problem when rendering font-sizes in Safari

        - Removes obsolete acronym element in the language files and replaces it with the appr element

        - Fixes a problem in the admin area when rendering font-sizes in Safari (iPhone/iPad). #256

        The Safari version used in iOS (iPhone/iPad) sometimes "ignores" the font sizes defined with font-size when rendering web pages or adjusts them automatically to improve readability.
        In certain places this is not bad, but it can also lead to unattractive changes in the design of the admin area.

    commit a844073bdb2e199ec1338f2b7fea27422c167db6
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Mon Jul 24 00:21:37 2023 +0200

        Update common.css

        - Width of comment and contact text field defined

    commit 5c3cc4348ced03d319c72477c8a660ac4bc4632f
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Wed Jul 19 01:16:39 2023 +0200

        Fixed more CSS/Glitches

        - Vertical alignment of the BBcode toolbar
        - placed missing label elements in config panel for consistent alignment

    commit fec38755ba9929a0c5dfc614757ee8df7393d351
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Sat Jul 15 17:59:31 2023 +0200

        Update admin.css

         - fixed vertical alignment of BBCode toolbar in write panel

    commit ef13f5488fdc48efe2101fe6f1e35a103ff08b1d
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Fri Jul 14 00:25:50 2023 +0200

        Configuration panel revised

        - In the admin area, the configuration panel has been revised

    commit 54232c3dd325027926ea78592e007475798d1fd0
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Tue Jul 11 21:57:18 2023 +0200

        PhotoSwipe 4.1.3 included

        This upgrades PhotoSwipe to the January 8, 2019 release level and is the last version before rewriting to ES6. Fixed the following:

        Fixes an issue with devices that have multiple input types and PhotoSwipe does not wipe.
        Fixes an issue where the layout does not update after an alignment change in some cases.
        Previous FlatPress-specific fixes have been considered and incorporated.
        Details can be found here:
        https://github.com/dimsemenov/PhotoSwipe/releases

        With best regards
        Frank

    commit 1179f307ffa0c8b27fe10ccb47a4dfce516a1bf2
    Merge: b735135 1aab02c
    Author: Frank Hochmuth <frank.pcn@gmail.com>
    Date:   Mon Jul 10 01:29:20 2023 +0200

        Merge branch 'master' into upstream/makup-Leggero-Theme

    commit b735135a7f5911c34eee4e01b4ef56db95d6ac06
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Mon Jul 10 01:12:32 2023 +0200

        Fresh makeup for Leggero-v2 style

        This elevates the Leggero-v2 style to a more modern design.
        In most situations in life, first impressions count. The FlatPress Leggero-v2 style is what the user sees first after performing the setup.
        Potential new users may not immediately find their way to the wiki to see the variety of themes there - and hastily delete FlatPress again. Therefore I made a few small changes to the style:

        - Adjusted the alignment of the calendar widget and the search widget.
        - A single PhotoSwipe image or a whole gallery is now centered in the responsive design. #150
        - BBcode videos are no longer chopped off in responsive design, but adjusted to the width and center aligned.
        - The overall appearance is now not so angular/edgy.
        - A BBcode embedded Facebook video now has localized languages with language tag. #252
          (https://developers.facebook.com/docs/javascript/internationalization).
        - BBcode: Removed reference to an active lightbox plugin, as PhotoSwipe can be used as an alternative.
        - Fixed an error in the HTML code of PhotoSwipe-Plugin. #253
        - Lucida Console [code] ... [/code]is now correct as a font in the CSS file.
        - Admin area now has Leggero-v2 style background instead of white background.

        With best regards
        Frank

    commit f8c66f5c0b8527cc0913f85b5a10ee2e7b673d74
    Author: Fraenkiman <frank.pcn@gmail.com>
    Date:   Mon Jul 3 01:20:07 2023 +0200

        Fresh makeup for Leggero-v2 Style

        This elevates the style Leggero-v2 to a more modern looking design.

        Details:
         * IE compatibility removed
         * fixed some minor layout/CSS glitches
         * a single photoswipe image or a whole gallery is now centered in RESPONSIVE DESIGN.
         * The appearance is now not so canny and has been adapted to the body.
2023-08-21 01:10:21 +02:00

862 lines
21 KiB
JavaScript

/*! PhotoSwipe Default UI - 4.1.3 - 2019-01-08
* http://photoswipe.com
* Copyright (c) 2019 Dmitry Semenov; */
/**
*
* UI on top of main sliding area (caption, arrows, close button, etc.).
* Built just using public methods/properties of PhotoSwipe.
*
*/
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.PhotoSwipeUI_Default = factory();
}
})(this, function () {
'use strict';
var PhotoSwipeUI_Default =
function(pswp, framework) {
var ui = this;
var _overlayUIUpdated = false,
_controlsVisible = true,
_fullscrenAPI,
_controls,
_captionContainer,
_fakeCaptionContainer,
_indexIndicator,
_shareButton,
_shareModal,
_shareModalHidden = true,
_initalCloseOnScrollValue,
_isIdle,
_listen,
_loadingIndicator,
_loadingIndicatorHidden,
_loadingIndicatorTimeout,
_galleryHasOneSlide,
_options,
_defaultUIOptions = {
barsSize: {top:44, bottom:'auto'},
closeElClasses: ['item', 'caption', 'zoom-wrap', 'ui', 'top-bar'],
timeToIdle: 4000,
timeToIdleOutside: 1000,
loadingIndicatorDelay: 1000, // 2s
addCaptionHTMLFn: function(item, captionEl /*, isFake */) {
if(!item.title) {
captionEl.children[0].innerHTML = '';
return false;
}
captionEl.children[0].innerHTML = item.title;
return true;
},
closeEl:true,
captionEl: true,
fullscreenEl: true,
zoomEl: true,
shareEl: true,
counterEl: true,
arrowEl: true,
preloaderEl: true,
tapToClose: false,
tapToToggleControls: true,
clickToCloseNonZoomable: true,
shareButtons: [
{id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u={{url}}'},
{id:'twitter', label:'Tweet', url:'https://twitter.com/intent/tweet?text={{text}}&url={{url}}'},
{id:'pinterest', label:'Pin it', url:'http://www.pinterest.com/pin/create/button/'+
'?url={{url}}&media={{image_url}}&description={{text}}'},
{id:'download', label:'Download image', url:'{{raw_image_url}}', download:true}
],
getImageURLForShare: function( /* shareButtonData */ ) {
return pswp.currItem.src || '';
},
getPageURLForShare: function( /* shareButtonData */ ) {
return window.location.href;
},
getTextForShare: function( /* shareButtonData */ ) {
return pswp.currItem.title || '';
},
indexIndicatorSep: ' / ',
fitControlsWidth: 1200
},
_blockControlsTap,
_blockControlsTapTimeout;
var _onControlsTap = function(e) {
if(_blockControlsTap) {
return true;
}
e = e || window.event;
if(_options.timeToIdle && _options.mouseUsed && !_isIdle) {
// reset idle timer
_onIdleMouseMove();
}
var target = e.target || e.srcElement,
uiElement,
clickedClass = target.getAttribute('class') || '',
found;
for(var i = 0; i < _uiElements.length; i++) {
uiElement = _uiElements[i];
if(uiElement.onTap && clickedClass.indexOf('pswp__' + uiElement.name ) > -1 ) {
uiElement.onTap();
found = true;
}
}
if(found) {
if(e.stopPropagation) {
e.stopPropagation();
}
_blockControlsTap = true;
// Some versions of Android don't prevent ghost click event
// when preventDefault() was called on touchstart and/or touchend.
//
// This happens on v4.3, 4.2, 4.1,
// older versions strangely work correctly,
// but just in case we add delay on all of them)
var tapDelay = framework.features.isOldAndroid ? 600 : 30;
_blockControlsTapTimeout = setTimeout(function() {
_blockControlsTap = false;
}, tapDelay);
}
},
_fitControlsInViewport = function() {
return !pswp.likelyTouchDevice || _options.mouseUsed || screen.width > _options.fitControlsWidth;
},
_togglePswpClass = function(el, cName, add) {
framework[ (add ? 'add' : 'remove') + 'Class' ](el, 'pswp__' + cName);
},
// add class when there is just one item in the gallery
// (by default it hides left/right arrows and 1ofX counter)
_countNumItems = function() {
var hasOneSlide = (_options.getNumItemsFn() === 1);
if(hasOneSlide !== _galleryHasOneSlide) {
_togglePswpClass(_controls, 'ui--one-slide', hasOneSlide);
_galleryHasOneSlide = hasOneSlide;
}
},
_toggleShareModalClass = function() {
_togglePswpClass(_shareModal, 'share-modal--hidden', _shareModalHidden);
},
_toggleShareModal = function() {
_shareModalHidden = !_shareModalHidden;
if(!_shareModalHidden) {
_toggleShareModalClass();
setTimeout(function() {
if(!_shareModalHidden) {
framework.addClass(_shareModal, 'pswp__share-modal--fade-in');
}
}, 30);
} else {
framework.removeClass(_shareModal, 'pswp__share-modal--fade-in');
setTimeout(function() {
if(_shareModalHidden) {
_toggleShareModalClass();
}
}, 300);
}
if(!_shareModalHidden) {
_updateShareURLs();
}
return false;
},
_openWindowPopup = function(e) {
e = e || window.event;
var target = e.target || e.srcElement;
pswp.shout('shareLinkClick', e, target);
if(!target.href) {
return false;
}
if( target.hasAttribute('download') ) {
return true;
}
window.open(target.href, 'pswp_share', 'scrollbars=yes,resizable=yes,toolbar=no,'+
'location=yes,width=550,height=420,top=100,left=' +
(window.screen ? Math.round(screen.width / 2 - 275) : 100) );
if(!_shareModalHidden) {
_toggleShareModal();
}
return false;
},
_updateShareURLs = function() {
var shareButtonOut = '',
shareButtonData,
shareURL,
image_url,
page_url,
share_text;
for(var i = 0; i < _options.shareButtons.length; i++) {
shareButtonData = _options.shareButtons[i];
image_url = _options.getImageURLForShare(shareButtonData);
page_url = _options.getPageURLForShare(shareButtonData);
share_text = _options.getTextForShare(shareButtonData);
shareURL = shareButtonData.url.replace('{{url}}', encodeURIComponent(page_url) )
.replace('{{image_url}}', encodeURIComponent(image_url) )
.replace('{{raw_image_url}}', image_url )
.replace('{{text}}', encodeURIComponent(share_text) );
shareButtonOut += '<a href="' + shareURL + '" target="_blank" '+
'class="pswp__share--' + shareButtonData.id + '"' +
(shareButtonData.download ? 'download' : '') + '>' +
shareButtonData.label + '</a>';
if(_options.parseShareButtonOut) {
shareButtonOut = _options.parseShareButtonOut(shareButtonData, shareButtonOut);
}
}
_shareModal.children[0].innerHTML = shareButtonOut;
_shareModal.children[0].onclick = _openWindowPopup;
},
_hasCloseClass = function(target) {
for(var i = 0; i < _options.closeElClasses.length; i++) {
if( framework.hasClass(target, 'pswp__' + _options.closeElClasses[i]) ) {
return true;
}
}
},
_idleInterval,
_idleTimer,
_idleIncrement = 0,
_onIdleMouseMove = function() {
clearTimeout(_idleTimer);
_idleIncrement = 0;
if(_isIdle) {
ui.setIdle(false);
}
},
_onMouseLeaveWindow = function(e) {
e = e ? e : window.event;
var from = e.relatedTarget || e.toElement;
if (!from || from.nodeName === 'HTML') {
clearTimeout(_idleTimer);
_idleTimer = setTimeout(function() {
ui.setIdle(true);
}, _options.timeToIdleOutside);
}
},
_setupFullscreenAPI = function() {
if(_options.fullscreenEl && !framework.features.isOldAndroid) {
if(!_fullscrenAPI) {
_fullscrenAPI = ui.getFullscreenAPI();
}
if(_fullscrenAPI) {
framework.bind(document, _fullscrenAPI.eventK, ui.updateFullscreen);
ui.updateFullscreen();
framework.addClass(pswp.template, 'pswp--supports-fs');
} else {
framework.removeClass(pswp.template, 'pswp--supports-fs');
}
}
},
_setupLoadingIndicator = function() {
// Setup loading indicator
if(_options.preloaderEl) {
_toggleLoadingIndicator(true);
_listen('beforeChange', function() {
clearTimeout(_loadingIndicatorTimeout);
// display loading indicator with delay
_loadingIndicatorTimeout = setTimeout(function() {
if(pswp.currItem && pswp.currItem.loading) {
if( !pswp.allowProgressiveImg() || (pswp.currItem.img && !pswp.currItem.img.naturalWidth) ) {
// show preloader if progressive loading is not enabled,
// or image width is not defined yet (because of slow connection)
_toggleLoadingIndicator(false);
// items-controller.js function allowProgressiveImg
}
} else {
_toggleLoadingIndicator(true); // hide preloader
}
}, _options.loadingIndicatorDelay);
});
_listen('imageLoadComplete', function(index, item) {
if(pswp.currItem === item) {
_toggleLoadingIndicator(true);
}
});
}
},
_toggleLoadingIndicator = function(hide) {
if( _loadingIndicatorHidden !== hide ) {
_togglePswpClass(_loadingIndicator, 'preloader--active', !hide);
_loadingIndicatorHidden = hide;
}
},
_applyNavBarGaps = function(item) {
var gap = item.vGap;
if( _fitControlsInViewport() ) {
var bars = _options.barsSize;
if(_options.captionEl && bars.bottom === 'auto') {
if(!_fakeCaptionContainer) {
_fakeCaptionContainer = framework.createEl('pswp__caption pswp__caption--fake');
_fakeCaptionContainer.appendChild( framework.createEl('pswp__caption__center') );
_controls.insertBefore(_fakeCaptionContainer, _captionContainer);
framework.addClass(_controls, 'pswp__ui--fit');
}
if( _options.addCaptionHTMLFn(item, _fakeCaptionContainer, true) ) {
var captionSize = _fakeCaptionContainer.clientHeight;
gap.bottom = parseInt(captionSize,10) || 44;
} else {
gap.bottom = bars.top; // if no caption, set size of bottom gap to size of top
}
} else {
gap.bottom = bars.bottom === 'auto' ? 0 : bars.bottom;
}
// height of top bar is static, no need to calculate it
gap.top = bars.top;
} else {
gap.top = gap.bottom = 0;
}
},
_setupIdle = function() {
// Hide controls when mouse is used
if(_options.timeToIdle) {
_listen('mouseUsed', function() {
framework.bind(document, 'mousemove', _onIdleMouseMove);
framework.bind(document, 'mouseout', _onMouseLeaveWindow);
_idleInterval = setInterval(function() {
_idleIncrement++;
if(_idleIncrement === 2) {
ui.setIdle(true);
}
}, _options.timeToIdle / 2);
});
}
},
_setupHidingControlsDuringGestures = function() {
// Hide controls on vertical drag
_listen('onVerticalDrag', function(now) {
if(_controlsVisible && now < 0.95) {
ui.hideControls();
} else if(!_controlsVisible && now >= 0.95) {
ui.showControls();
}
});
// Hide controls when pinching to close
var pinchControlsHidden;
_listen('onPinchClose' , function(now) {
if(_controlsVisible && now < 0.9) {
ui.hideControls();
pinchControlsHidden = true;
} else if(pinchControlsHidden && !_controlsVisible && now > 0.9) {
ui.showControls();
}
});
_listen('zoomGestureEnded', function() {
pinchControlsHidden = false;
if(pinchControlsHidden && !_controlsVisible) {
ui.showControls();
}
});
};
var _uiElements = [
{
name: 'caption',
option: 'captionEl',
onInit: function(el) {
_captionContainer = el;
}
},
{
name: 'share-modal',
option: 'shareEl',
onInit: function(el) {
_shareModal = el;
},
onTap: function() {
_toggleShareModal();
}
},
{
name: 'button--share',
option: 'shareEl',
onInit: function(el) {
_shareButton = el;
},
onTap: function() {
_toggleShareModal();
}
},
{
name: 'button--zoom',
option: 'zoomEl',
onTap: pswp.toggleDesktopZoom
},
{
name: 'counter',
option: 'counterEl',
onInit: function(el) {
_indexIndicator = el;
}
},
{
name: 'button--close',
option: 'closeEl',
onTap: pswp.close
},
{
name: 'button--arrow--left',
option: 'arrowEl',
onTap: pswp.prev
},
{
name: 'button--arrow--right',
option: 'arrowEl',
onTap: pswp.next
},
{
name: 'button--fs',
option: 'fullscreenEl',
onTap: function() {
if(_fullscrenAPI.isFullscreen()) {
_fullscrenAPI.exit();
} else {
_fullscrenAPI.enter();
}
}
},
{
name: 'preloader',
option: 'preloaderEl',
onInit: function(el) {
_loadingIndicator = el;
}
}
];
var _setupUIElements = function() {
var item,
classAttr,
uiElement;
var loopThroughChildElements = function(sChildren) {
if(!sChildren) {
return;
}
var l = sChildren.length;
for(var i = 0; i < l; i++) {
item = sChildren[i];
classAttr = item.className;
for(var a = 0; a < _uiElements.length; a++) {
uiElement = _uiElements[a];
if(classAttr.indexOf('pswp__' + uiElement.name) > -1 ) {
if( _options[uiElement.option] ) { // if element is not disabled from options
framework.removeClass(item, 'pswp__element--disabled');
if(uiElement.onInit) {
uiElement.onInit(item);
}
//item.style.display = 'block';
} else {
framework.addClass(item, 'pswp__element--disabled');
//item.style.display = 'none';
}
}
}
}
};
loopThroughChildElements(_controls.children);
var topBar = framework.getChildByClass(_controls, 'pswp__top-bar');
if(topBar) {
loopThroughChildElements( topBar.children );
}
};
ui.init = function() {
// extend options
framework.extend(pswp.options, _defaultUIOptions, true);
// create local link for fast access
_options = pswp.options;
// find pswp__ui element
_controls = framework.getChildByClass(pswp.scrollWrap, 'pswp__ui');
// create local link
_listen = pswp.listen;
_setupHidingControlsDuringGestures();
// update controls when slides change
_listen('beforeChange', ui.update);
// toggle zoom on double-tap
_listen('doubleTap', function(point) {
var initialZoomLevel = pswp.currItem.initialZoomLevel;
if(pswp.getZoomLevel() !== initialZoomLevel) {
pswp.zoomTo(initialZoomLevel, point, 333);
} else {
pswp.zoomTo(_options.getDoubleTapZoom(false, pswp.currItem), point, 333);
}
});
// Allow text selection in caption
_listen('preventDragEvent', function(e, isDown, preventObj) {
var t = e.target || e.srcElement;
if(
t &&
t.getAttribute('class') && e.type.indexOf('mouse') > -1 &&
( t.getAttribute('class').indexOf('__caption') > 0 || (/(SMALL|STRONG|EM)/i).test(t.tagName) )
) {
preventObj.prevent = false;
}
});
// bind events for UI
_listen('bindEvents', function() {
framework.bind(_controls, 'pswpTap click', _onControlsTap);
framework.bind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap);
if(!pswp.likelyTouchDevice) {
framework.bind(pswp.scrollWrap, 'mouseover', ui.onMouseOver);
}
});
// unbind events for UI
_listen('unbindEvents', function() {
if(!_shareModalHidden) {
_toggleShareModal();
}
if(_idleInterval) {
clearInterval(_idleInterval);
}
framework.unbind(document, 'mouseout', _onMouseLeaveWindow);
framework.unbind(document, 'mousemove', _onIdleMouseMove);
framework.unbind(_controls, 'pswpTap click', _onControlsTap);
framework.unbind(pswp.scrollWrap, 'pswpTap', ui.onGlobalTap);
framework.unbind(pswp.scrollWrap, 'mouseover', ui.onMouseOver);
if(_fullscrenAPI) {
framework.unbind(document, _fullscrenAPI.eventK, ui.updateFullscreen);
if(_fullscrenAPI.isFullscreen()) {
_options.hideAnimationDuration = 0;
_fullscrenAPI.exit();
}
_fullscrenAPI = null;
}
});
// clean up things when gallery is destroyed
_listen('destroy', function() {
if(_options.captionEl) {
if(_fakeCaptionContainer) {
_controls.removeChild(_fakeCaptionContainer);
}
framework.removeClass(_captionContainer, 'pswp__caption--empty');
}
if(_shareModal) {
_shareModal.children[0].onclick = null;
}
framework.removeClass(_controls, 'pswp__ui--over-close');
framework.addClass( _controls, 'pswp__ui--hidden');
ui.setIdle(false);
});
if(!_options.showAnimationDuration) {
framework.removeClass( _controls, 'pswp__ui--hidden');
}
_listen('initialZoomIn', function() {
if(_options.showAnimationDuration) {
framework.removeClass( _controls, 'pswp__ui--hidden');
}
});
_listen('initialZoomOut', function() {
framework.addClass( _controls, 'pswp__ui--hidden');
});
_listen('parseVerticalMargin', _applyNavBarGaps);
_setupUIElements();
if(_options.shareEl && _shareButton && _shareModal) {
_shareModalHidden = true;
}
_countNumItems();
_setupIdle();
_setupFullscreenAPI();
_setupLoadingIndicator();
};
ui.setIdle = function(isIdle) {
_isIdle = isIdle;
_togglePswpClass(_controls, 'ui--idle', isIdle);
};
ui.update = function() {
// Don't update UI if it's hidden
if(_controlsVisible && pswp.currItem) {
ui.updateIndexIndicator();
if(_options.captionEl) {
_options.addCaptionHTMLFn(pswp.currItem, _captionContainer);
_togglePswpClass(_captionContainer, 'caption--empty', !pswp.currItem.title);
}
_overlayUIUpdated = true;
} else {
_overlayUIUpdated = false;
}
if(!_shareModalHidden) {
_toggleShareModal();
}
_countNumItems();
};
ui.updateFullscreen = function(e) {
if(e) {
// some browsers change window scroll position during the fullscreen
// so PhotoSwipe updates it just in case
setTimeout(function() {
pswp.setScrollOffset( 0, framework.getScrollY() );
}, 50);
}
// toogle pswp--fs class on root element
framework[ (_fullscrenAPI.isFullscreen() ? 'add' : 'remove') + 'Class' ](pswp.template, 'pswp--fs');
};
ui.updateIndexIndicator = function() {
if(_options.counterEl) {
_indexIndicator.innerHTML = (pswp.getCurrentIndex()+1) +
_options.indexIndicatorSep +
_options.getNumItemsFn();
}
};
ui.onGlobalTap = function(e) {
e = e || window.event;
var target = e.target || e.srcElement;
if(_blockControlsTap) {
return;
}
if(e.detail && e.detail.pointerType === 'mouse') {
// close gallery if clicked outside of the image
if(_hasCloseClass(target)) {
pswp.close();
return;
}
if(framework.hasClass(target, 'pswp__img')) {
if(pswp.getZoomLevel() === 1 && pswp.getZoomLevel() <= pswp.currItem.fitRatio) {
if(_options.clickToCloseNonZoomable) {
pswp.close();
}
} else {
pswp.toggleDesktopZoom(e.detail.releasePoint);
}
}
} else {
// tap anywhere (except buttons) to toggle visibility of controls
if(_options.tapToToggleControls) {
if(_controlsVisible) {
ui.hideControls();
} else {
ui.showControls();
}
}
// tap to close gallery
if(_options.tapToClose && (framework.hasClass(target, 'pswp__img') || _hasCloseClass(target)) ) {
pswp.close();
return;
}
}
};
ui.onMouseOver = function(e) {
e = e || window.event;
var target = e.target || e.srcElement;
// add class when mouse is over an element that should close the gallery
_togglePswpClass(_controls, 'ui--over-close', _hasCloseClass(target));
};
ui.hideControls = function() {
framework.addClass(_controls,'pswp__ui--hidden');
_controlsVisible = false;
};
ui.showControls = function() {
_controlsVisible = true;
if(!_overlayUIUpdated) {
ui.update();
}
framework.removeClass(_controls,'pswp__ui--hidden');
};
ui.supportsFullscreen = function() {
var d = document;
return !!(d.exitFullscreen || d.mozCancelFullScreen || d.webkitExitFullscreen || d.msExitFullscreen);
};
ui.getFullscreenAPI = function() {
var dE = document.documentElement,
api,
tF = 'fullscreenchange';
if (dE.requestFullscreen) {
api = {
enterK: 'requestFullscreen',
exitK: 'exitFullscreen',
elementK: 'fullscreenElement',
eventK: tF
};
} else if(dE.mozRequestFullScreen ) {
api = {
enterK: 'mozRequestFullScreen',
exitK: 'mozCancelFullScreen',
elementK: 'mozFullScreenElement',
eventK: 'moz' + tF
};
} else if(dE.webkitRequestFullscreen) {
api = {
enterK: 'webkitRequestFullscreen',
exitK: 'webkitExitFullscreen',
elementK: 'webkitFullscreenElement',
eventK: 'webkit' + tF
};
} else if(dE.msRequestFullscreen) {
api = {
enterK: 'msRequestFullscreen',
exitK: 'msExitFullscreen',
elementK: 'msFullscreenElement',
eventK: 'MSFullscreenChange'
};
}
if(api) {
api.enter = function() {
// disable close-on-scroll in fullscreen
_initalCloseOnScrollValue = _options.closeOnScroll;
_options.closeOnScroll = false;
if(this.enterK === 'webkitRequestFullscreen') {
pswp.template[this.enterK]( Element.ALLOW_KEYBOARD_INPUT );
} else {
return pswp.template[this.enterK]();
}
};
api.exit = function() {
_options.closeOnScroll = _initalCloseOnScrollValue;
return document[this.exitK]();
};
api.isFullscreen = function() { return document[this.elementK]; };
}
return api;
};
};
return PhotoSwipeUI_Default;
});