lightgallery
Version:
lightGallery is a feature-rich, modular JavaScript gallery plugin for building beautiful image and video galleries for the web and the mobile
2 lines (1 loc) • 2.68 kB
JavaScript
!function(e,l){"object"==typeof exports&&"undefined"!=typeof module?module.exports=l():"function"==typeof define&&define.amd?define(l):(e="undefined"!=typeof globalThis?globalThis:e||self).lgFullscreen=l()}(this,function(){"use strict";const e={fullscreen:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M598 724.667h212v-212h-84v128h-128v84zM726 212.667v128h84v-212h-212v84h128zM214 512.667v212h212v-84h-128v-128h-84zM298 340.667v-128h128v-84h-212v212h84z"/></svg>',fullscreenExit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024" fill="currentColor"><path transform="translate(0, 960) scale(1, -1)" d="M682 596.667h128v-84h-212v212h84v-128zM598 128.667v212h212v-84h-128v-128h-84zM342 596.667v128h84v-212h-212v84h128zM214 256.667v84h212v-212h-84v128h-128z"/></svg>'},l={fullScreen:!0};var t=Object.defineProperty,n=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,c=(e,l,n)=>l in e?t(e,l,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[l]=n,o=(e,l)=>{for(var t in l||(l={}))s.call(l,t)&&c(e,t,l[t]);if(n)for(var t of n(l))r.call(l,t)&&c(e,t,l[t]);return e};return class{constructor(e,t){return this.core=e,this.$LG=t,this.settings=o(o({},l),this.core.settings),this}init(){var l,t;this.core.registerDefaultIcons(e);let n="";if(this.settings.fullScreen){if(!document.fullscreenEnabled&&!document.webkitFullscreenEnabled)return;n=`<button type="button" aria-label="${null!=(t=null==(l=this.settings.fullscreenPluginStrings)?void 0:l.toggleFullscreen)?t:this.core.settings.strings.toggleFullscreen}" class="lg-fullscreen lg-icon"></button>`,this.core.$toolbar.append(n),this.fullScreen()}}isFullScreen(){return document.fullscreenElement||document.webkitFullscreenElement}requestFullscreen(){const e=document.documentElement;e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen()}exitFullscreen(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen()}fullScreen(){this.$LG(document).on(`fullscreenchange.lg.global${this.core.lgId} \n webkitfullscreenchange.lg.global${this.core.lgId}`,()=>{this.core.lgOpened&&this.core.outer.toggleClass("lg-fullscreen-on")}),this.core.outer.find(".lg-fullscreen").first().on("click.lg",()=>{this.isFullScreen()?this.exitFullscreen():this.requestFullscreen()})}closeGallery(){this.isFullScreen()&&this.exitFullscreen()}destroy(){this.$LG(document).off(`fullscreenchange.lg.global${this.core.lgId} \n webkitfullscreenchange.lg.global${this.core.lgId}`)}}});