mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
upLG
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
export interface HashSettings {
|
||||
/**
|
||||
* Enable/Disable hash option
|
||||
*/
|
||||
hash: boolean;
|
||||
/**
|
||||
* Unique id for each gallery.
|
||||
* @description It is mandatory when you use hash plugin for multiple galleries on the same page.
|
||||
*/
|
||||
galleryId: string;
|
||||
/**
|
||||
* Custom slide name to use in the url when hash plugin is enabled
|
||||
*/
|
||||
customSlideName: boolean;
|
||||
}
|
||||
export declare const hashSettings: HashSettings;
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import { LgQuery } from '../../lgQuery';
|
||||
import { LightGallery } from '../../lightgallery';
|
||||
import { HashSettings } from './lg-hash-settings';
|
||||
export default class Hash {
|
||||
core: LightGallery;
|
||||
settings: HashSettings;
|
||||
oldHash: string;
|
||||
private $LG;
|
||||
constructor(instance: LightGallery, $LG: LgQuery);
|
||||
init(): void;
|
||||
private onAfterSlide;
|
||||
/**
|
||||
* Get index of the slide from custom slideName. Has to be a public method. Used in hash plugin
|
||||
* @param {String} hash
|
||||
* @returns {Number} Index of the slide.
|
||||
*/
|
||||
getIndexFromUrl(hash?: string): number;
|
||||
buildFromHash(): boolean | undefined;
|
||||
private onCloseAfter;
|
||||
private onHashchange;
|
||||
closeGallery(): void;
|
||||
destroy(): void;
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
/*!
|
||||
* lightgallery | 2.9.0 | October 1st 2025
|
||||
* http://www.lightgalleryjs.com/
|
||||
* Copyright (c) 2020 Sachin Neravath;
|
||||
* @license GPLv3
|
||||
*/
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
var __assign = function() {
|
||||
__assign = Object.assign || function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* List of lightGallery events
|
||||
* All events should be documented here
|
||||
* Below interfaces are used to build the website documentations
|
||||
* */
|
||||
var lGEvents = {
|
||||
afterAppendSlide: 'lgAfterAppendSlide',
|
||||
init: 'lgInit',
|
||||
hasVideo: 'lgHasVideo',
|
||||
containerResize: 'lgContainerResize',
|
||||
updateSlides: 'lgUpdateSlides',
|
||||
afterAppendSubHtml: 'lgAfterAppendSubHtml',
|
||||
beforeOpen: 'lgBeforeOpen',
|
||||
afterOpen: 'lgAfterOpen',
|
||||
slideItemLoad: 'lgSlideItemLoad',
|
||||
beforeSlide: 'lgBeforeSlide',
|
||||
afterSlide: 'lgAfterSlide',
|
||||
posterClick: 'lgPosterClick',
|
||||
dragStart: 'lgDragStart',
|
||||
dragMove: 'lgDragMove',
|
||||
dragEnd: 'lgDragEnd',
|
||||
beforeNextSlide: 'lgBeforeNextSlide',
|
||||
beforePrevSlide: 'lgBeforePrevSlide',
|
||||
beforeClose: 'lgBeforeClose',
|
||||
afterClose: 'lgAfterClose',
|
||||
rotateLeft: 'lgRotateLeft',
|
||||
rotateRight: 'lgRotateRight',
|
||||
flipHorizontal: 'lgFlipHorizontal',
|
||||
flipVertical: 'lgFlipVertical',
|
||||
autoplay: 'lgAutoplay',
|
||||
autoplayStart: 'lgAutoplayStart',
|
||||
autoplayStop: 'lgAutoplayStop',
|
||||
};
|
||||
|
||||
var hashSettings = {
|
||||
hash: true,
|
||||
galleryId: '1',
|
||||
customSlideName: false,
|
||||
};
|
||||
|
||||
var Hash = /** @class */ (function () {
|
||||
function Hash(instance, $LG) {
|
||||
// get lightGallery core plugin instance
|
||||
this.core = instance;
|
||||
this.$LG = $LG;
|
||||
// extend module default settings with lightGallery core settings
|
||||
this.settings = __assign(__assign({}, hashSettings), this.core.settings);
|
||||
return this;
|
||||
}
|
||||
Hash.prototype.init = function () {
|
||||
var _this = this;
|
||||
if (!this.settings.hash) {
|
||||
return;
|
||||
}
|
||||
this.oldHash = window.location.hash;
|
||||
setTimeout(function () {
|
||||
_this.buildFromHash();
|
||||
}, 100);
|
||||
// Change hash value on after each slide transition
|
||||
this.core.LGel.on(lGEvents.afterSlide + ".hash", this.onAfterSlide.bind(this));
|
||||
this.core.LGel.on(lGEvents.afterClose + ".hash", this.onCloseAfter.bind(this));
|
||||
// Listen hash change and change the slide according to slide value
|
||||
this.$LG(window).on("hashchange.lg.hash.global" + this.core.lgId, this.onHashchange.bind(this));
|
||||
};
|
||||
Hash.prototype.onAfterSlide = function (event) {
|
||||
var slideName = this.core.galleryItems[event.detail.index].slideName;
|
||||
slideName = this.settings.customSlideName
|
||||
? slideName || event.detail.index
|
||||
: event.detail.index;
|
||||
if (history.replaceState) {
|
||||
history.replaceState(null, '', window.location.pathname +
|
||||
window.location.search +
|
||||
'#lg=' +
|
||||
this.settings.galleryId +
|
||||
'&slide=' +
|
||||
slideName);
|
||||
}
|
||||
else {
|
||||
window.location.hash =
|
||||
'lg=' + this.settings.galleryId + '&slide=' + slideName;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Get index of the slide from custom slideName. Has to be a public method. Used in hash plugin
|
||||
* @param {String} hash
|
||||
* @returns {Number} Index of the slide.
|
||||
*/
|
||||
Hash.prototype.getIndexFromUrl = function (hash) {
|
||||
if (hash === void 0) { hash = window.location.hash; }
|
||||
var slideName = hash.split('&slide=')[1];
|
||||
var _idx = 0;
|
||||
if (this.settings.customSlideName) {
|
||||
for (var index = 0; index < this.core.galleryItems.length; index++) {
|
||||
var dynamicEl = this.core.galleryItems[index];
|
||||
if (dynamicEl.slideName === slideName) {
|
||||
_idx = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
_idx = parseInt(slideName, 10);
|
||||
}
|
||||
return isNaN(_idx) ? 0 : _idx;
|
||||
};
|
||||
// Build Gallery if gallery id exist in the URL
|
||||
Hash.prototype.buildFromHash = function () {
|
||||
// if dynamic option is enabled execute immediately
|
||||
var _hash = window.location.hash;
|
||||
if (_hash.indexOf('lg=' + this.settings.galleryId) > 0) {
|
||||
// This class is used to remove the initial animation if galleryId present in the URL
|
||||
this.$LG(document.body).addClass('lg-from-hash');
|
||||
var index = this.getIndexFromUrl(_hash);
|
||||
this.core.openGallery(index);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
Hash.prototype.onCloseAfter = function () {
|
||||
// Reset to old hash value
|
||||
if (this.oldHash &&
|
||||
this.oldHash.indexOf('lg=' + this.settings.galleryId) < 0) {
|
||||
if (history.replaceState) {
|
||||
history.replaceState(null, '', this.oldHash);
|
||||
}
|
||||
else {
|
||||
window.location.hash = this.oldHash;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (history.replaceState) {
|
||||
history.replaceState(null, document.title, window.location.pathname + window.location.search);
|
||||
}
|
||||
else {
|
||||
window.location.hash = '';
|
||||
}
|
||||
}
|
||||
};
|
||||
Hash.prototype.onHashchange = function () {
|
||||
if (!this.core.lgOpened)
|
||||
return;
|
||||
var _hash = window.location.hash;
|
||||
var index = this.getIndexFromUrl(_hash);
|
||||
// it galleryId doesn't exist in the url close the gallery
|
||||
if (_hash.indexOf('lg=' + this.settings.galleryId) > -1) {
|
||||
this.core.slide(index, false, false);
|
||||
}
|
||||
else if (this.core.lGalleryOn) {
|
||||
this.core.closeGallery();
|
||||
}
|
||||
};
|
||||
Hash.prototype.closeGallery = function () {
|
||||
if (this.settings.hash) {
|
||||
this.$LG(document.body).removeClass('lg-from-hash');
|
||||
}
|
||||
};
|
||||
Hash.prototype.destroy = function () {
|
||||
this.core.LGel.off('.lg.hash');
|
||||
this.core.LGel.off('.hash');
|
||||
this.$LG(window).off("hashchange.lg.hash.global" + this.core.lgId);
|
||||
};
|
||||
return Hash;
|
||||
}());
|
||||
|
||||
export default Hash;
|
||||
//# sourceMappingURL=lg-hash.es5.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* lightgallery | 2.9.0 | October 1st 2025
|
||||
* http://www.lightgalleryjs.com/
|
||||
* Copyright (c) 2020 Sachin Neravath;
|
||||
* @license GPLv3
|
||||
*/
|
||||
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).lgHash=e()}(this,(function(){"use strict";var t=function(){return(t=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var s in e=arguments[i])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t}).apply(this,arguments)},e="lgAfterSlide",i="lgAfterClose",o={hash:!0,galleryId:"1",customSlideName:!1};return function(){function s(e,i){return this.core=e,this.$LG=i,this.settings=t(t({},o),this.core.settings),this}return s.prototype.init=function(){var t=this;this.settings.hash&&(this.oldHash=window.location.hash,setTimeout((function(){t.buildFromHash()}),100),this.core.LGel.on(e+".hash",this.onAfterSlide.bind(this)),this.core.LGel.on(i+".hash",this.onCloseAfter.bind(this)),this.$LG(window).on("hashchange.lg.hash.global"+this.core.lgId,this.onHashchange.bind(this)))},s.prototype.onAfterSlide=function(t){var e=this.core.galleryItems[t.detail.index].slideName;e=this.settings.customSlideName&&e||t.detail.index,history.replaceState?history.replaceState(null,"",window.location.pathname+window.location.search+"#lg="+this.settings.galleryId+"&slide="+e):window.location.hash="lg="+this.settings.galleryId+"&slide="+e},s.prototype.getIndexFromUrl=function(t){void 0===t&&(t=window.location.hash);var e=t.split("&slide=")[1],i=0;if(this.settings.customSlideName)for(var o=0;o<this.core.galleryItems.length;o++){if(this.core.galleryItems[o].slideName===e){i=o;break}}else i=parseInt(e,10);return isNaN(i)?0:i},s.prototype.buildFromHash=function(){var t=window.location.hash;if(t.indexOf("lg="+this.settings.galleryId)>0){this.$LG(document.body).addClass("lg-from-hash");var e=this.getIndexFromUrl(t);return this.core.openGallery(e),!0}},s.prototype.onCloseAfter=function(){this.oldHash&&this.oldHash.indexOf("lg="+this.settings.galleryId)<0?history.replaceState?history.replaceState(null,"",this.oldHash):window.location.hash=this.oldHash:history.replaceState?history.replaceState(null,document.title,window.location.pathname+window.location.search):window.location.hash=""},s.prototype.onHashchange=function(){if(this.core.lgOpened){var t=window.location.hash,e=this.getIndexFromUrl(t);t.indexOf("lg="+this.settings.galleryId)>-1?this.core.slide(e,!1,!1):this.core.lGalleryOn&&this.core.closeGallery()}},s.prototype.closeGallery=function(){this.settings.hash&&this.$LG(document.body).removeClass("lg-from-hash")},s.prototype.destroy=function(){this.core.LGel.off(".lg.hash"),this.core.LGel.off(".hash"),this.$LG(window).off("hashchange.lg.hash.global"+this.core.lgId)},s}()}));
|
||||
@@ -0,0 +1,206 @@
|
||||
/*!
|
||||
* lightgallery | 2.9.0 | October 1st 2025
|
||||
* http://www.lightgalleryjs.com/
|
||||
* Copyright (c) 2020 Sachin Neravath;
|
||||
* @license GPLv3
|
||||
*/
|
||||
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.lgHash = factory());
|
||||
}(this, (function () { 'use strict';
|
||||
|
||||
/*! *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
var __assign = function() {
|
||||
__assign = Object.assign || function __assign(t) {
|
||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||
s = arguments[i];
|
||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
||||
}
|
||||
return t;
|
||||
};
|
||||
return __assign.apply(this, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* List of lightGallery events
|
||||
* All events should be documented here
|
||||
* Below interfaces are used to build the website documentations
|
||||
* */
|
||||
var lGEvents = {
|
||||
afterAppendSlide: 'lgAfterAppendSlide',
|
||||
init: 'lgInit',
|
||||
hasVideo: 'lgHasVideo',
|
||||
containerResize: 'lgContainerResize',
|
||||
updateSlides: 'lgUpdateSlides',
|
||||
afterAppendSubHtml: 'lgAfterAppendSubHtml',
|
||||
beforeOpen: 'lgBeforeOpen',
|
||||
afterOpen: 'lgAfterOpen',
|
||||
slideItemLoad: 'lgSlideItemLoad',
|
||||
beforeSlide: 'lgBeforeSlide',
|
||||
afterSlide: 'lgAfterSlide',
|
||||
posterClick: 'lgPosterClick',
|
||||
dragStart: 'lgDragStart',
|
||||
dragMove: 'lgDragMove',
|
||||
dragEnd: 'lgDragEnd',
|
||||
beforeNextSlide: 'lgBeforeNextSlide',
|
||||
beforePrevSlide: 'lgBeforePrevSlide',
|
||||
beforeClose: 'lgBeforeClose',
|
||||
afterClose: 'lgAfterClose',
|
||||
rotateLeft: 'lgRotateLeft',
|
||||
rotateRight: 'lgRotateRight',
|
||||
flipHorizontal: 'lgFlipHorizontal',
|
||||
flipVertical: 'lgFlipVertical',
|
||||
autoplay: 'lgAutoplay',
|
||||
autoplayStart: 'lgAutoplayStart',
|
||||
autoplayStop: 'lgAutoplayStop',
|
||||
};
|
||||
|
||||
var hashSettings = {
|
||||
hash: true,
|
||||
galleryId: '1',
|
||||
customSlideName: false,
|
||||
};
|
||||
|
||||
var Hash = /** @class */ (function () {
|
||||
function Hash(instance, $LG) {
|
||||
// get lightGallery core plugin instance
|
||||
this.core = instance;
|
||||
this.$LG = $LG;
|
||||
// extend module default settings with lightGallery core settings
|
||||
this.settings = __assign(__assign({}, hashSettings), this.core.settings);
|
||||
return this;
|
||||
}
|
||||
Hash.prototype.init = function () {
|
||||
var _this = this;
|
||||
if (!this.settings.hash) {
|
||||
return;
|
||||
}
|
||||
this.oldHash = window.location.hash;
|
||||
setTimeout(function () {
|
||||
_this.buildFromHash();
|
||||
}, 100);
|
||||
// Change hash value on after each slide transition
|
||||
this.core.LGel.on(lGEvents.afterSlide + ".hash", this.onAfterSlide.bind(this));
|
||||
this.core.LGel.on(lGEvents.afterClose + ".hash", this.onCloseAfter.bind(this));
|
||||
// Listen hash change and change the slide according to slide value
|
||||
this.$LG(window).on("hashchange.lg.hash.global" + this.core.lgId, this.onHashchange.bind(this));
|
||||
};
|
||||
Hash.prototype.onAfterSlide = function (event) {
|
||||
var slideName = this.core.galleryItems[event.detail.index].slideName;
|
||||
slideName = this.settings.customSlideName
|
||||
? slideName || event.detail.index
|
||||
: event.detail.index;
|
||||
if (history.replaceState) {
|
||||
history.replaceState(null, '', window.location.pathname +
|
||||
window.location.search +
|
||||
'#lg=' +
|
||||
this.settings.galleryId +
|
||||
'&slide=' +
|
||||
slideName);
|
||||
}
|
||||
else {
|
||||
window.location.hash =
|
||||
'lg=' + this.settings.galleryId + '&slide=' + slideName;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Get index of the slide from custom slideName. Has to be a public method. Used in hash plugin
|
||||
* @param {String} hash
|
||||
* @returns {Number} Index of the slide.
|
||||
*/
|
||||
Hash.prototype.getIndexFromUrl = function (hash) {
|
||||
if (hash === void 0) { hash = window.location.hash; }
|
||||
var slideName = hash.split('&slide=')[1];
|
||||
var _idx = 0;
|
||||
if (this.settings.customSlideName) {
|
||||
for (var index = 0; index < this.core.galleryItems.length; index++) {
|
||||
var dynamicEl = this.core.galleryItems[index];
|
||||
if (dynamicEl.slideName === slideName) {
|
||||
_idx = index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
_idx = parseInt(slideName, 10);
|
||||
}
|
||||
return isNaN(_idx) ? 0 : _idx;
|
||||
};
|
||||
// Build Gallery if gallery id exist in the URL
|
||||
Hash.prototype.buildFromHash = function () {
|
||||
// if dynamic option is enabled execute immediately
|
||||
var _hash = window.location.hash;
|
||||
if (_hash.indexOf('lg=' + this.settings.galleryId) > 0) {
|
||||
// This class is used to remove the initial animation if galleryId present in the URL
|
||||
this.$LG(document.body).addClass('lg-from-hash');
|
||||
var index = this.getIndexFromUrl(_hash);
|
||||
this.core.openGallery(index);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
Hash.prototype.onCloseAfter = function () {
|
||||
// Reset to old hash value
|
||||
if (this.oldHash &&
|
||||
this.oldHash.indexOf('lg=' + this.settings.galleryId) < 0) {
|
||||
if (history.replaceState) {
|
||||
history.replaceState(null, '', this.oldHash);
|
||||
}
|
||||
else {
|
||||
window.location.hash = this.oldHash;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (history.replaceState) {
|
||||
history.replaceState(null, document.title, window.location.pathname + window.location.search);
|
||||
}
|
||||
else {
|
||||
window.location.hash = '';
|
||||
}
|
||||
}
|
||||
};
|
||||
Hash.prototype.onHashchange = function () {
|
||||
if (!this.core.lgOpened)
|
||||
return;
|
||||
var _hash = window.location.hash;
|
||||
var index = this.getIndexFromUrl(_hash);
|
||||
// it galleryId doesn't exist in the url close the gallery
|
||||
if (_hash.indexOf('lg=' + this.settings.galleryId) > -1) {
|
||||
this.core.slide(index, false, false);
|
||||
}
|
||||
else if (this.core.lGalleryOn) {
|
||||
this.core.closeGallery();
|
||||
}
|
||||
};
|
||||
Hash.prototype.closeGallery = function () {
|
||||
if (this.settings.hash) {
|
||||
this.$LG(document.body).removeClass('lg-from-hash');
|
||||
}
|
||||
};
|
||||
Hash.prototype.destroy = function () {
|
||||
this.core.LGel.off('.lg.hash');
|
||||
this.core.LGel.off('.hash');
|
||||
this.$LG(window).off("hashchange.lg.hash.global" + this.core.lgId);
|
||||
};
|
||||
return Hash;
|
||||
}());
|
||||
|
||||
return Hash;
|
||||
|
||||
})));
|
||||
//# sourceMappingURL=lg-hash.umd.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "lightgallery/plugins/hash",
|
||||
"private": true,
|
||||
"main": "lg-hash.umd.js",
|
||||
"module": "lg-hash.es5.js",
|
||||
"typings": "lg-hash.d.ts"
|
||||
}
|
||||
Reference in New Issue
Block a user