1/*! 2 * lightgallery | 2.5.0 | June 13th 2022 3 * http://www.lightgalleryjs.com/ 4 * Copyright (c) 2020 Sachin Neravath; 5 * @license GPLv3 6 */ 7 8(function (global, factory) { 9 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 10 typeof define === 'function' && define.amd ? define(factory) : 11 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.lgHash = factory()); 12}(this, (function () { 'use strict'; 13 14 /*! ***************************************************************************** 15 Copyright (c) Microsoft Corporation. 16 17 Permission to use, copy, modify, and/or distribute this software for any 18 purpose with or without fee is hereby granted. 19 20 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 21 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 22 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 23 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 24 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 25 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 26 PERFORMANCE OF THIS SOFTWARE. 27 ***************************************************************************** */ 28 29 var __assign = function() { 30 __assign = Object.assign || function __assign(t) { 31 for (var s, i = 1, n = arguments.length; i < n; i++) { 32 s = arguments[i]; 33 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 34 } 35 return t; 36 }; 37 return __assign.apply(this, arguments); 38 }; 39 40 /** 41 * List of lightGallery events 42 * All events should be documented here 43 * Below interfaces are used to build the website documentations 44 * */ 45 var lGEvents = { 46 afterAppendSlide: 'lgAfterAppendSlide', 47 init: 'lgInit', 48 hasVideo: 'lgHasVideo', 49 containerResize: 'lgContainerResize', 50 updateSlides: 'lgUpdateSlides', 51 afterAppendSubHtml: 'lgAfterAppendSubHtml', 52 beforeOpen: 'lgBeforeOpen', 53 afterOpen: 'lgAfterOpen', 54 slideItemLoad: 'lgSlideItemLoad', 55 beforeSlide: 'lgBeforeSlide', 56 afterSlide: 'lgAfterSlide', 57 posterClick: 'lgPosterClick', 58 dragStart: 'lgDragStart', 59 dragMove: 'lgDragMove', 60 dragEnd: 'lgDragEnd', 61 beforeNextSlide: 'lgBeforeNextSlide', 62 beforePrevSlide: 'lgBeforePrevSlide', 63 beforeClose: 'lgBeforeClose', 64 afterClose: 'lgAfterClose', 65 rotateLeft: 'lgRotateLeft', 66 rotateRight: 'lgRotateRight', 67 flipHorizontal: 'lgFlipHorizontal', 68 flipVertical: 'lgFlipVertical', 69 autoplay: 'lgAutoplay', 70 autoplayStart: 'lgAutoplayStart', 71 autoplayStop: 'lgAutoplayStop', 72 }; 73 74 var hashSettings = { 75 hash: true, 76 galleryId: '1', 77 customSlideName: false, 78 }; 79 80 var Hash = /** @class */ (function () { 81 function Hash(instance, $LG) { 82 // get lightGallery core plugin instance 83 this.core = instance; 84 this.$LG = $LG; 85 // extend module default settings with lightGallery core settings 86 this.settings = __assign(__assign({}, hashSettings), this.core.settings); 87 return this; 88 } 89 Hash.prototype.init = function () { 90 var _this = this; 91 if (!this.settings.hash) { 92 return; 93 } 94 this.oldHash = window.location.hash; 95 setTimeout(function () { 96 _this.buildFromHash(); 97 }, 100); 98 // Change hash value on after each slide transition 99 this.core.LGel.on(lGEvents.afterSlide + ".hash", this.onAfterSlide.bind(this)); 100 this.core.LGel.on(lGEvents.afterClose + ".hash", this.onCloseAfter.bind(this)); 101 // Listen hash change and change the slide according to slide value 102 this.$LG(window).on("hashchange.lg.hash.global" + this.core.lgId, this.onHashchange.bind(this)); 103 }; 104 Hash.prototype.onAfterSlide = function (event) { 105 var slideName = this.core.galleryItems[event.detail.index].slideName; 106 slideName = this.settings.customSlideName 107 ? slideName || event.detail.index 108 : event.detail.index; 109 if (history.replaceState) { 110 history.replaceState(null, '', window.location.pathname + 111 window.location.search + 112 '#lg=' + 113 this.settings.galleryId + 114 '&slide=' + 115 slideName); 116 } 117 else { 118 window.location.hash = 119 'lg=' + this.settings.galleryId + '&slide=' + slideName; 120 } 121 }; 122 /** 123 * Get index of the slide from custom slideName. Has to be a public method. Used in hash plugin 124 * @param {String} hash 125 * @returns {Number} Index of the slide. 126 */
127 Hash.prototype.getIndexFromUrl = function (hash) { 128 if (hash === void 0) { hash = window.location.hash; } 129 var slideName = hash.split('&slide=')[1]; 130 var _idx = 0; 131 if (this.settings.customSlideName) { 132 for (var index = 0; index < this.core.galleryItems.length; index++) { 133 var dynamicEl = this.core.galleryItems[index]; 134 if (dynamicEl.slideName === slideName) { 135 _idx = index; 136 break; 137 } 138 } 139 } 140 else { 141 _idx = parseInt(slideName, 10); 142 } 143 return isNaN(_idx) ? 0 : _idx; 144 }; 145 // Build Gallery if gallery id exist in the URL 146 Hash.prototype.buildFromHash = function () { 147 // if dynamic option is enabled execute immediately 148 var _hash = window.location.hash; 149 //Uncode edit ##START## 150 // if (_hash.indexOf('lg=' + this.settings.galleryId) > 0) { 151 if (_hash.indexOf('lg=' + this.settings.galleryId + '&') > 0) { 152 //Uncode edit ##END## 153 // This class is used to remove the initial animation if galleryId present in the URL 154 this.$LG(document.body).addClass('lg-from-hash'); 155 var index = this.getIndexFromUrl(_hash); 156 this.core.openGallery(index); 157 return true; 158 } 159 }; 160 Hash.prototype.onCloseAfter = function () { 161 // Reset to old hash value 162 if (this.oldHash && 163 this.oldHash.indexOf('lg=' + this.settings.galleryId) < 0) { 164 if (history.replaceState) { 165 history.replaceState(null, '', this.oldHash); 166 } 167 else { 168 window.location.hash = this.oldHash; 169 } 170 } 171 else { 172 if (history.replaceState) { 173 history.replaceState(null, document.title, window.location.pathname + window.location.search); 174 } 175 else { 176 window.location.hash = ''; 177 } 178 } 179 }; 180 Hash.prototype.onHashchange = function () { 181 if (!this.core.lgOpened) 182 return; 183 var _hash = window.location.hash; 184 var index = this.getIndexFromUrl(_hash); 185 // it galleryId doesn't exist in the url close the gallery 186 if (_hash.indexOf('lg=' + this.settings.galleryId) > -1) { 187 this.core.slide(index, false, false); 188 } 189 else if (this.core.lGalleryOn) { 190 this.core.closeGallery(); 191 } 192 }; 193 Hash.prototype.closeGallery = function () { 194 if (this.settings.hash) { 195 this.$LG(document.body).removeClass('lg-from-hash'); 196 } 197 }; 198 Hash.prototype.destroy = function () { 199 this.core.LGel.off('.lg.hash'); 200 this.core.LGel.off('.hash'); 201 this.$LG(window).off("hashchange.lg.hash.global" + this.core.lgId); 202 }; 203 return Hash; 204 }()); 205 206 return Hash; 207 208})));
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.