Socket
Socket
Sign inDemoInstall

hes-gallery

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.4.11 to 1.4.12

package-lock.json

288

dist/hes-gallery.js
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/*!
HesGallery v1.4.11
HesGallery v1.4.12

@@ -14,5 +16,4 @@ Copyright (c) 2018-2019 Artur Medrygal <medrygal.artur@gmail.com>

var HesGallery = {
version: '1.4.12',
options: {
// Default settings
// Global

@@ -28,191 +29,198 @@ disableScrolling: false,

wrapAround: false,
showImageCount: true
showImageCount: true,
// set to true if images are nested in links
linkNested: false
},
version: '1.4.11'
};
function HesSingleGallery(index, root) {
var _this = this;
setOptions: function setOptions() {
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
this.root = root;
this.index = index;
this.imgPaths = [];
this.subTexts = [];
this.altTexts = [];
for (var key in values) {
this.options[key] = values[key];
}
},
init: function init(options) {
var _this = this;
this.options = {};
this.setOptions(options);
var gallery = document.getElementsByClassName('hes-gallery')[this.index];
if (!this.executed) this.createDOM();
this.options.wrapAround = gallery.hasAttribute('data-wrap') ? gallery.dataset.wrap == 'true' : this.root.options.wrapAround;
this.options.showImageCount = gallery.hasAttribute('data-img-count') ? gallery.dataset.imgCount == 'true' : this.root.options.showImageCount;
if (this.options.animations) this.elements.pic_cont.classList = 'hg-transition';else this.elements.pic_cont.classList = '';
var disabledCount = 0;
gallery.querySelectorAll('img').forEach(function (image, i) {
if (image.hasAttribute('data-disabled')) disabledCount++;else {
if (image.hasAttribute('data-fullsize')) _this.imgPaths.push(image.dataset.fullsize || '');else _this.imgPaths.push(image.src || '');
_this.subTexts.push(image.dataset.subtext || '');
_this.altTexts.push(image.alt || '');
this.count = document.querySelectorAll('.hes-gallery').length;
// image.setAttribute('onclick', `HesGallery.show(${this.index},${i - disabledCount})`)
image.onclick = function () {
_this.root.show(_this.index, i - disabledCount);
};
this.galleries = [];
for (var i = 0; i < this.count; i++) {
// Creates a galleries
this.galleries[i] = new this.HesSingleGallery(i, this);
}
});
this.count = this.imgPaths.length;
}
// KeyDown event listener
if (this.options.keyboardControl && !this.keydownEventListener) {
addEventListener('keydown', function (_ref) {
var keyCode = _ref.keyCode;
HesGallery.setOptions = function () {
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
if (keyCode == 39 && _this.open && _this.options.keyboardControl) _this.next();
if (keyCode == 37 && _this.open && _this.options.keyboardControl) _this.prev();
if (keyCode == 27 && _this.open && _this.options.keyboardControl) _this.hide();
});
this.keydownEventListener = true;
}
for (var key in values) {
this.options[key] = values[key];
}
};
return 'HesGallery initiated!';
},
replaceImages: function replaceImages(gallery) {
gallery.querySelectorAll('a.hg-image').forEach(function (imageLink) {
image = imageLink.getElementsByTagName('img')[0];
image.setAttribute('data-fullsize', imageLink.href.trim());
imageLink.replaceWith(image);
});
},
createDOM: function createDOM() {
var _this2 = this;
HesGallery.init = function (options) {
var _this2 = this;
// Creates DOM Elements for gallery
this.elements = {};
this.setOptions(options);
if (this.options.hostedStyles) document.head.innerHTML += "<link rel='stylesheet' href='https://unpkg.com/hes-gallery/dist/hes-gallery.min.css'>";
if (!this.executed) this.createDOM();
var gallery = document.createElement('div');
gallery.id = 'hgallery';
gallery.setAttribute('style', 'visibility:hidden;');
if (this.options.animations) this.elements.pic_cont.classList = 'hg-transition';else this.elements.pic_cont.classList = '';
this.elements.gallery = gallery; // Whole gallery
this.count = document.querySelectorAll('.hes-gallery').length;
this.elements.gallery.innerHTML += '\n <div id=\'hg-bg\'></div>\n <div id=\'hg-pic-cont\'>\n <img id=\'hg-pic\' />\n <div id=\'hg-prev-onpic\'></div>\n <div id=\'hg-next-onpic\'></div>\n <div id=\'hg-subtext\'></div>\n <div id=\'hg-howmany\'></div>\n </div>\n <button id=\'hg-prev\' title="Previous" aria-label="Next">\n <img src="data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjZmZmZmZmIiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgICA8cGF0aCBkPSJNOC41OSAxNi4zNGw0LjU4LTQuNTktNC41OC00LjU5TDEwIDUuNzVsNiA2LTYgNnoiLz4NCiAgICA8cGF0aCBkPSJNMC0uMjVoMjR2MjRIMHoiIGZpbGw9Im5vbmUiLz4NCjwvc3ZnPg==" alt="Previous" />\n </button>\n <button id=\'hg-next\' title="Next" aria-label="Previous">\n <img src="data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjZmZmZmZmIiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgICA8cGF0aCBkPSJNOC41OSAxNi4zNGw0LjU4LTQuNTktNC41OC00LjU5TDEwIDUuNzVsNiA2LTYgNnoiLz4NCiAgICA8cGF0aCBkPSJNMC0uMjVoMjR2MjRIMHoiIGZpbGw9Im5vbmUiLz4NCjwvc3ZnPg==" alt="Next" />\n </button>\n ';
this.galleries = [];
document.body.appendChild(gallery);
for (var i = 0; i < this.count; i++) {
// Creates a galleries
this.galleries[i] = new HesSingleGallery(i, this);
}
this.elements.b_prev = document.getElementById('hg-prev');
this.elements.b_next = document.getElementById('hg-next');
// KeyDown event listener
if (this.options.keyboardControl && !this.keydownEventListener) {
addEventListener('keydown', function (_ref) {
var keyCode = _ref.keyCode;
this.elements.pic_cont = document.getElementById('hg-pic-cont');
if (keyCode == 39 && _this2.open && _this2.options.keyboardControl) _this2.next();
if (keyCode == 37 && _this2.open && _this2.options.keyboardControl) _this2.prev();
if (keyCode == 27 && _this2.open && _this2.options.keyboardControl) _this2.hide();
});
this.keydownEventListener = true;
}
this.elements.b_next_onpic = document.getElementById('hg-next-onpic');
this.elements.b_prev_onpic = document.getElementById('hg-prev-onpic');
return 'HesGallery initiated!';
};
this.elements.b_prev.onclick = this.elements.b_prev_onpic.onclick = function () {
_this2.prev();
};
HesGallery.createDOM = function () {
var _this3 = this;
this.elements.b_next.onclick = this.elements.b_next_onpic.onclick = function () {
_this2.next();
};
// Creates DOM Elements for gallery
this.elements = {};
document.getElementById('hg-bg').onclick = function () {
_this2.hide();
};
if (this.options.hostedStyles) document.head.innerHTML += "<link rel='stylesheet' href='https://unpkg.com/hes-gallery/dist/hes-gallery.min.css'>";
this.executed = true;
},
show: function show(g, i) {
if (innerWidth < this.options.minResolution) return false; // If browser width is less than min resolution in settings
var gal = document.createElement('div');
gal.id = 'hgallery';
gal.setAttribute('style', 'visibility:hidden;');
this.currentImg = i;
this.currentGal = g;
this.elements.galery = gal; // Whole gallery
this.open = true;
this.elements.galery.innerHTML += '\n <div id=\'hg-bg\'></div>\n <div id=\'hg-pic-cont\'>\n <img id=\'hg-pic\' />\n <div id=\'hg-prev-onpic\'></div>\n <div id=\'hg-next-onpic\'></div>\n <div id=\'hg-subtext\'></div>\n <div id=\'hg-howmany\'></div>\n </div>\n <button id=\'hg-prev\'></button>\n <button id=\'hg-next\'></button>\n ';
if (this.options.animations || this.elements.pic_cont.classList == 'hg-transition') this.elements.pic_cont.classList.remove('hg-transition');
document.body.appendChild(gal);
document.getElementById('hg-pic').setAttribute('src', this.galleries[g].imgPaths[i]); // Sets the path to image
this.elements.b_prev = document.getElementById('hg-prev');
this.elements.b_next = document.getElementById('hg-next');
document.getElementById('hg-pic').alt = this.galleries[g].altTexts[i]; // Sets alt attribute
this.elements.pic_cont = document.getElementById('hg-pic-cont');
this.elements.gallery.classList.add('open');
this.elements.b_next_onpic = document.getElementById('hg-next-onpic');
this.elements.b_prev_onpic = document.getElementById('hg-prev-onpic');
document.getElementById('hg-subtext').innerHTML = this.galleries[g].subTexts[i];
this.elements.b_prev.onclick = this.elements.b_prev_onpic.onclick = function () {
_this3.prev();
};
if (this.galleries[this.currentGal].options.showImageCount && this.galleries[this.currentGal].imgPaths.length != 1) document.getElementById('hg-howmany').innerHTML = this.currentImg + 1 + '/' + this.galleries[g].count;else document.getElementById('hg-howmany').innerHTML = '';
this.elements.b_next.onclick = this.elements.b_next_onpic.onclick = function () {
_this3.next();
};
// Visibility of next/before buttons in gallery
if (this.galleries[this.currentGal].imgPaths.length == 1) {
// One image in gallery
this.elements.b_prev.classList = 'hg-unvisible';
this.elements.b_prev_onpic.classList = 'hg-unvisible';
this.elements.b_next.classList = 'hg-unvisible';
this.elements.b_next_onpic.classList = 'hg-unvisible';
} else if (this.currentImg + 1 == 1 && !this.galleries[this.currentGal].options.wrapAround) {
// First photo
this.elements.b_prev.classList = 'hg-unvisible';
this.elements.b_prev_onpic.classList = 'hg-unvisible';
document.getElementById('hg-bg').onclick = function () {
_this3.hide();
};
this.elements.b_next.classList = '';
this.elements.b_next_onpic.classList = '';
} else if (this.currentImg + 1 == this.galleries[this.currentGal].count && !this.galleries[this.currentGal].options.wrapAround) {
// Last photo
this.elements.b_next.classList = 'hg-unvisible';
this.elements.b_next_onpic.classList = 'hg-unvisible';
this.executed = true;
};
this.elements.b_prev.classList = '';
this.elements.b_prev_onpic.classList = '';
} else {
//Dowolne zdjęcie
this.elements.b_next.classList = '';
this.elements.b_next_onpic.classList = '';
HesGallery.show = function (g, i) {
if (innerWidth < this.options.minResolution) return false; // If browser width is less than min resolution in settings
this.elements.b_prev.classList = '';
this.elements.b_prev_onpic.classList = '';
}
this.currentImg = i;
this.currentGal = g;
if (this.options.disableScrolling) document.body.classList += ' hg-disable-scrolling'; // Disable scroll
},
hide: function hide() {
if (this.options.animations) this.elements.pic_cont.classList.add('hg-transition');
this.open = true;
this.elements.gallery.classList.remove('open');
this.open = false;
if (this.options.disableScrolling) document.body.classList.remove('hg-disable-scrolling'); // Enable scroll
},
next: function next() {
if (this.galleries[this.currentGal].options.wrapAround && this.currentImg == this.galleries[this.currentGal].count - 1) this.show(this.currentGal, 0);else if (this.currentImg + 1 < this.galleries[this.currentGal].count) this.show(this.currentGal, this.currentImg + 1);
},
prev: function prev() {
if (this.galleries[this.currentGal].options.wrapAround && this.currentImg == 0) this.show(this.currentGal, this.galleries[this.currentGal].count - 1);else if (this.currentImg + 1 > 1) this.show(this.currentGal, this.currentImg - 1);
},
if (this.options.animations || this.elements.pic_cont.classList == 'hg-transition') this.elements.pic_cont.classList.remove('hg-transition');
document.getElementById('hg-pic').setAttribute('src', this.galleries[g].imgPaths[i]); // Sets the path to image
HesSingleGallery: function HesSingleGallery(index, root) {
var _this3 = this;
document.getElementById('hg-pic').alt = this.galleries[g].altTexts[i]; // Sets alt attribute
_classCallCheck(this, HesSingleGallery);
this.elements.galery.classList.add('open');
this.root = root;
this.index = index;
this.imgPaths = [];
this.subTexts = [];
this.altTexts = [];
document.getElementById('hg-subtext').innerHTML = this.galleries[g].subTexts[i];
this.options = {};
if (this.galleries[this.currentGal].options.showImageCount && this.galleries[this.currentGal].imgPaths.length != 1) document.getElementById('hg-howmany').innerHTML = this.currentImg + 1 + '/' + this.galleries[g].count;else document.getElementById('hg-howmany').innerHTML = '';
var gallery = document.getElementsByClassName('hes-gallery')[this.index];
// Visibility of next/before buttons in gallery
if (this.galleries[this.currentGal].imgPaths.length == 1) {
// One image in gallery
this.elements.b_prev.classList = 'hg-unvisible';
this.elements.b_prev_onpic.classList = 'hg-unvisible';
this.elements.b_next.classList = 'hg-unvisible';
this.elements.b_next_onpic.classList = 'hg-unvisible';
} else if (this.currentImg + 1 == 1 && !this.galleries[this.currentGal].options.wrapAround) {
// First photo
this.elements.b_prev.classList = 'hg-unvisible';
this.elements.b_prev_onpic.classList = 'hg-unvisible';
if (this.root.options.linkNested) this.root.replaceImages(gallery);
this.elements.b_next.classList = '';
this.elements.b_next_onpic.classList = '';
} else if (this.currentImg + 1 == this.galleries[this.currentGal].count && !this.galleries[this.currentGal].options.wrapAround) {
// Last photo
this.elements.b_next.classList = 'hg-unvisible';
this.elements.b_next_onpic.classList = 'hg-unvisible';
this.options.wrapAround = gallery.hasAttribute('data-wrap') ? gallery.dataset.wrap == 'true' : this.root.options.wrapAround;
this.options.showImageCount = gallery.hasAttribute('data-img-count') ? gallery.dataset.imgCount == 'true' : this.root.options.showImageCount;
this.elements.b_prev.classList = '';
this.elements.b_prev_onpic.classList = '';
} else {
//Dowolne zdjęcie
this.elements.b_next.classList = '';
this.elements.b_next_onpic.classList = '';
var disabledCount = 0;
gallery.querySelectorAll('img').forEach(function (image, i) {
if (image.hasAttribute('data-disabled')) disabledCount++;else {
if (image.hasAttribute('data-fullsize')) _this3.imgPaths.push(image.dataset.fullsize || '');else _this3.imgPaths.push(image.src || '');
_this3.subTexts.push(image.dataset.subtext || '');
_this3.altTexts.push(image.alt || '');
this.elements.b_prev.classList = '';
this.elements.b_prev_onpic.classList = '';
image.onclick = function () {
_this3.root.show(_this3.index, i - disabledCount);
};
}
});
this.count = this.imgPaths.length;
}
if (this.options.disableScrolling) document.body.classList += ' hg-disable-scrolling'; // Disable scroll
};
HesGallery.hide = function () {
if (this.options.animations) this.elements.pic_cont.classList.add('hg-transition');
this.elements.galery.classList.remove('open');
this.open = false;
if (this.options.disableScrolling) document.body.classList.remove('hg-disable-scrolling'); // Enable scroll
};
HesGallery.next = function () {
if (this.galleries[this.currentGal].options.wrapAround && this.currentImg == this.galleries[this.currentGal].count - 1) this.show(this.currentGal, 0);else if (this.currentImg + 1 < this.galleries[this.currentGal].count) this.show(this.currentGal, this.currentImg + 1);
};
HesGallery.prev = function () {
if (this.galleries[this.currentGal].options.wrapAround && this.currentImg == 0) this.show(this.currentGal, this.galleries[this.currentGal].count - 1);else if (this.currentImg + 1 > 1) this.show(this.currentGal, this.currentImg - 1);
};
document.addEventListener('DOMContentLoaded', function () {

@@ -219,0 +227,0 @@ if (HesGallery.options.autoInit) HesGallery.init();

@@ -1,5 +0,5 @@

var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},HesGallery={options:{disableScrolling:!1,hostedStyles:!0,animations:!0,keyboardControl:!0,minResolution:0,autoInit:!0,wrapAround:!1,showImageCount:!0},version:"1.4.11"};
var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}
/*!
HesGallery v1.4.11
HesGallery v1.4.12

@@ -10,2 +10,2 @@ Copyright (c) 2018-2019 Artur Medrygal <medrygal.artur@gmail.com>

*/function HesSingleGallery(t,e){var s=this;this.root=e,this.index=t,this.imgPaths=[],this.subTexts=[],this.altTexts=[],this.options={};var i=document.getElementsByClassName("hes-gallery")[this.index];this.options.wrapAround=i.hasAttribute("data-wrap")?"true"==i.dataset.wrap:this.root.options.wrapAround,this.options.showImageCount=i.hasAttribute("data-img-count")?"true"==i.dataset.imgCount:this.root.options.showImageCount;var n=0;i.querySelectorAll("img").forEach(function(t,e){t.hasAttribute("data-disabled")?n++:(t.hasAttribute("data-fullsize")?s.imgPaths.push(t.dataset.fullsize||""):s.imgPaths.push(t.src||""),s.subTexts.push(t.dataset.subtext||""),s.altTexts.push(t.alt||""),t.onclick=function(){s.root.show(s.index,e-n)})}),this.count=this.imgPaths.length}HesGallery.setOptions=function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};for(var e in t)this.options[e]=t[e]},HesGallery.init=function(t){var s=this;this.setOptions(t),this.executed||this.createDOM(),this.options.animations?this.elements.pic_cont.classList="hg-transition":this.elements.pic_cont.classList="",this.count=document.querySelectorAll(".hes-gallery").length,this.galleries=[];for(var e=0;e<this.count;e++)this.galleries[e]=new HesSingleGallery(e,this);return this.options.keyboardControl&&!this.keydownEventListener&&(addEventListener("keydown",function(t){var e=t.keyCode;39==e&&s.open&&s.options.keyboardControl&&s.next(),37==e&&s.open&&s.options.keyboardControl&&s.prev(),27==e&&s.open&&s.options.keyboardControl&&s.hide()}),this.keydownEventListener=!0),"HesGallery initiated!"},HesGallery.createDOM=function(){var t=this;this.elements={},this.options.hostedStyles&&(document.head.innerHTML+="<link rel='stylesheet' href='https://unpkg.com/hes-gallery/dist/hes-gallery.min.css'>");var e=document.createElement("div");e.id="hgallery",e.setAttribute("style","visibility:hidden;"),this.elements.galery=e,this.elements.galery.innerHTML+="\n <div id='hg-bg'></div>\n <div id='hg-pic-cont'>\n <img id='hg-pic' />\n <div id='hg-prev-onpic'></div>\n <div id='hg-next-onpic'></div>\n <div id='hg-subtext'></div>\n <div id='hg-howmany'></div>\n </div>\n <button id='hg-prev'></button>\n <button id='hg-next'></button>\n ",document.body.appendChild(e),this.elements.b_prev=document.getElementById("hg-prev"),this.elements.b_next=document.getElementById("hg-next"),this.elements.pic_cont=document.getElementById("hg-pic-cont"),this.elements.b_next_onpic=document.getElementById("hg-next-onpic"),this.elements.b_prev_onpic=document.getElementById("hg-prev-onpic"),this.elements.b_prev.onclick=this.elements.b_prev_onpic.onclick=function(){t.prev()},this.elements.b_next.onclick=this.elements.b_next_onpic.onclick=function(){t.next()},document.getElementById("hg-bg").onclick=function(){t.hide()},this.executed=!0},HesGallery.show=function(t,e){if(innerWidth<this.options.minResolution)return!1;this.currentImg=e,this.currentGal=t,this.open=!0,!this.options.animations&&"hg-transition"!=this.elements.pic_cont.classList||this.elements.pic_cont.classList.remove("hg-transition"),document.getElementById("hg-pic").setAttribute("src",this.galleries[t].imgPaths[e]),document.getElementById("hg-pic").alt=this.galleries[t].altTexts[e],this.elements.galery.classList.add("open"),document.getElementById("hg-subtext").innerHTML=this.galleries[t].subTexts[e],this.galleries[this.currentGal].options.showImageCount&&1!=this.galleries[this.currentGal].imgPaths.length?document.getElementById("hg-howmany").innerHTML=this.currentImg+1+"/"+this.galleries[t].count:document.getElementById("hg-howmany").innerHTML="",1==this.galleries[this.currentGal].imgPaths.length?(this.elements.b_prev.classList="hg-unvisible",this.elements.b_prev_onpic.classList="hg-unvisible",this.elements.b_next.classList="hg-unvisible",this.elements.b_next_onpic.classList="hg-unvisible"):this.currentImg+1!=1||this.galleries[this.currentGal].options.wrapAround?(this.currentImg+1!=this.galleries[this.currentGal].count||this.galleries[this.currentGal].options.wrapAround?(this.elements.b_next.classList="",this.elements.b_next_onpic.classList=""):(this.elements.b_next.classList="hg-unvisible",this.elements.b_next_onpic.classList="hg-unvisible"),this.elements.b_prev.classList="",this.elements.b_prev_onpic.classList=""):(this.elements.b_prev.classList="hg-unvisible",this.elements.b_prev_onpic.classList="hg-unvisible",this.elements.b_next.classList="",this.elements.b_next_onpic.classList=""),this.options.disableScrolling&&(document.body.classList+=" hg-disable-scrolling")},HesGallery.hide=function(){this.options.animations&&this.elements.pic_cont.classList.add("hg-transition"),this.elements.galery.classList.remove("open"),this.open=!1,this.options.disableScrolling&&document.body.classList.remove("hg-disable-scrolling")},HesGallery.next=function(){this.galleries[this.currentGal].options.wrapAround&&this.currentImg==this.galleries[this.currentGal].count-1?this.show(this.currentGal,0):this.currentImg+1<this.galleries[this.currentGal].count&&this.show(this.currentGal,this.currentImg+1)},HesGallery.prev=function(){this.galleries[this.currentGal].options.wrapAround&&0==this.currentImg?this.show(this.currentGal,this.galleries[this.currentGal].count-1):1<this.currentImg+1&&this.show(this.currentGal,this.currentImg-1)},document.addEventListener("DOMContentLoaded",function(){HesGallery.options.autoInit&&HesGallery.init()}),"object"==("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module&&(module.exports=HesGallery),"undefined"!=typeof NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);
*/var HesGallery={version:"1.4.12",options:{disableScrolling:!1,hostedStyles:!0,animations:!0,keyboardControl:!0,minResolution:0,autoInit:!0,wrapAround:!1,showImageCount:!0,linkNested:!1},setOptions:function(){var t,e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};for(t in e)this.options[t]=e[t]},init:function(t){var e=this;this.setOptions(t),this.executed||this.createDOM(),this.options.animations?this.elements.pic_cont.classList="hg-transition":this.elements.pic_cont.classList="",this.count=document.querySelectorAll(".hes-gallery").length,this.galleries=[];for(var i=0;i<this.count;i++)this.galleries[i]=new this.HesSingleGallery(i,this);return this.options.keyboardControl&&!this.keydownEventListener&&(addEventListener("keydown",function(t){t=t.keyCode;39==t&&e.open&&e.options.keyboardControl&&e.next(),37==t&&e.open&&e.options.keyboardControl&&e.prev(),27==t&&e.open&&e.options.keyboardControl&&e.hide()}),this.keydownEventListener=!0),"HesGallery initiated!"},replaceImages:function(t){t.querySelectorAll("a.hg-image").forEach(function(t){image=t.getElementsByTagName("img")[0],image.setAttribute("data-fullsize",t.href.trim()),t.replaceWith(image)})},createDOM:function(){var t=this;this.elements={},this.options.hostedStyles&&(document.head.innerHTML+="<link rel='stylesheet' href='https://unpkg.com/hes-gallery/dist/hes-gallery.min.css'>");var e=document.createElement("div");e.id="hgallery",e.setAttribute("style","visibility:hidden;"),this.elements.gallery=e,this.elements.gallery.innerHTML+="\n <div id='hg-bg'></div>\n <div id='hg-pic-cont'>\n <img id='hg-pic' />\n <div id='hg-prev-onpic'></div>\n <div id='hg-next-onpic'></div>\n <div id='hg-subtext'></div>\n <div id='hg-howmany'></div>\n </div>\n <button id='hg-prev' title=\"Previous\" aria-label=\"Next\">\n <img src=\"data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjZmZmZmZmIiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgICA8cGF0aCBkPSJNOC41OSAxNi4zNGw0LjU4LTQuNTktNC41OC00LjU5TDEwIDUuNzVsNiA2LTYgNnoiLz4NCiAgICA8cGF0aCBkPSJNMC0uMjVoMjR2MjRIMHoiIGZpbGw9Im5vbmUiLz4NCjwvc3ZnPg==\" alt=\"Previous\" />\n </button>\n <button id='hg-next' title=\"Next\" aria-label=\"Previous\">\n <img src=\"data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjZmZmZmZmIiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIHdpZHRoPSIyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgICA8cGF0aCBkPSJNOC41OSAxNi4zNGw0LjU4LTQuNTktNC41OC00LjU5TDEwIDUuNzVsNiA2LTYgNnoiLz4NCiAgICA8cGF0aCBkPSJNMC0uMjVoMjR2MjRIMHoiIGZpbGw9Im5vbmUiLz4NCjwvc3ZnPg==\" alt=\"Next\" />\n </button>\n ",document.body.appendChild(e),this.elements.b_prev=document.getElementById("hg-prev"),this.elements.b_next=document.getElementById("hg-next"),this.elements.pic_cont=document.getElementById("hg-pic-cont"),this.elements.b_next_onpic=document.getElementById("hg-next-onpic"),this.elements.b_prev_onpic=document.getElementById("hg-prev-onpic"),this.elements.b_prev.onclick=this.elements.b_prev_onpic.onclick=function(){t.prev()},this.elements.b_next.onclick=this.elements.b_next_onpic.onclick=function(){t.next()},document.getElementById("hg-bg").onclick=function(){t.hide()},this.executed=!0},show:function(t,e){if(innerWidth<this.options.minResolution)return!1;this.currentImg=e,this.currentGal=t,this.open=!0,!this.options.animations&&"hg-transition"!=this.elements.pic_cont.classList||this.elements.pic_cont.classList.remove("hg-transition"),document.getElementById("hg-pic").setAttribute("src",this.galleries[t].imgPaths[e]),document.getElementById("hg-pic").alt=this.galleries[t].altTexts[e],this.elements.gallery.classList.add("open"),document.getElementById("hg-subtext").innerHTML=this.galleries[t].subTexts[e],this.galleries[this.currentGal].options.showImageCount&&1!=this.galleries[this.currentGal].imgPaths.length?document.getElementById("hg-howmany").innerHTML=this.currentImg+1+"/"+this.galleries[t].count:document.getElementById("hg-howmany").innerHTML="",1==this.galleries[this.currentGal].imgPaths.length?(this.elements.b_prev.classList="hg-unvisible",this.elements.b_prev_onpic.classList="hg-unvisible",this.elements.b_next.classList="hg-unvisible",this.elements.b_next_onpic.classList="hg-unvisible"):this.currentImg+1!=1||this.galleries[this.currentGal].options.wrapAround?(this.currentImg+1!=this.galleries[this.currentGal].count||this.galleries[this.currentGal].options.wrapAround?(this.elements.b_next.classList="",this.elements.b_next_onpic.classList=""):(this.elements.b_next.classList="hg-unvisible",this.elements.b_next_onpic.classList="hg-unvisible"),this.elements.b_prev.classList="",this.elements.b_prev_onpic.classList=""):(this.elements.b_prev.classList="hg-unvisible",this.elements.b_prev_onpic.classList="hg-unvisible",this.elements.b_next.classList="",this.elements.b_next_onpic.classList=""),this.options.disableScrolling&&(document.body.classList+=" hg-disable-scrolling")},hide:function(){this.options.animations&&this.elements.pic_cont.classList.add("hg-transition"),this.elements.gallery.classList.remove("open"),this.open=!1,this.options.disableScrolling&&document.body.classList.remove("hg-disable-scrolling")},next:function(){this.galleries[this.currentGal].options.wrapAround&&this.currentImg==this.galleries[this.currentGal].count-1?this.show(this.currentGal,0):this.currentImg+1<this.galleries[this.currentGal].count&&this.show(this.currentGal,this.currentImg+1)},prev:function(){this.galleries[this.currentGal].options.wrapAround&&0==this.currentImg?this.show(this.currentGal,this.galleries[this.currentGal].count-1):1<this.currentImg+1&&this.show(this.currentGal,this.currentImg-1)},HesSingleGallery:function t(e,i){var s=this;_classCallCheck(this,t),this.root=i,this.index=e,this.imgPaths=[],this.subTexts=[],this.altTexts=[],this.options={};e=document.getElementsByClassName("hes-gallery")[this.index];this.root.options.linkNested&&this.root.replaceImages(e),this.options.wrapAround=e.hasAttribute("data-wrap")?"true"==e.dataset.wrap:this.root.options.wrapAround,this.options.showImageCount=e.hasAttribute("data-img-count")?"true"==e.dataset.imgCount:this.root.options.showImageCount;var n=0;e.querySelectorAll("img").forEach(function(t,e){t.hasAttribute("data-disabled")?n++:(t.hasAttribute("data-fullsize")?s.imgPaths.push(t.dataset.fullsize||""):s.imgPaths.push(t.src||""),s.subTexts.push(t.dataset.subtext||""),s.altTexts.push(t.alt||""),t.onclick=function(){s.root.show(s.index,e-n)})}),this.count=this.imgPaths.length}};document.addEventListener("DOMContentLoaded",function(){HesGallery.options.autoInit&&HesGallery.init()}),"object"==("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module&&(module.exports=HesGallery),"undefined"!=typeof NodeList&&NodeList.prototype&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach);
{
"name": "hes-gallery",
"version": "1.4.11",
"version": "1.4.12",
"description": "Light, dependency free script creating a responsive gallery",

@@ -10,2 +10,5 @@ "main": "dist/hes-gallery.min.js",

},
"engines": {
"node": "11.x"
},
"repository": {

@@ -12,0 +15,0 @@ "type": "git",

# HesGallery
![licence](https://img.shields.io/npm/l/hes-gallery)
[![version](https://img.shields.io/npm/v/hes-gallery)](https://www.npmjs.com/package/hes-gallery)
[![downloads](https://img.shields.io/npm/dw/hes-gallery)](https://www.npmjs.com/package/hes-gallery)
Light, dependency free script creating a responsive gallery

@@ -38,3 +42,3 @@

## Global options
If you want, you can modify the gallery options to make it work better to you by using function `HesGallery.setOptions()`, you can also change settings passing settings object to `HesGallery.init()` function.
If you want, you can modify the gallery options to make it work better to you by using function `HesGallery.setOptions()`, you can also change settings passing settings object to `HesGallery.init()` function.
Sample:

@@ -52,3 +56,3 @@ ```javascript

```
**Important**
**Important**
If you change the settings after initializing the script, not all options can be applied. To make sure that they will, use `HesGallery.init(options)` function.

@@ -67,5 +71,6 @@

`autoInit` | *true* | If true, automaticly run `HesGallery.init()` when DOM Content is loaded
`linkNested` | *false* | If true, you can use images nested in links
## Options of single gallery
If you like, you can give one set of other options by adding attributes to the `.hes-gallery` class's container
If you like, you can give one set of other options by adding attributes to the `.hes-gallery` class's container
**Attributes accept only *true* or *false* value, in any other case the gallery will adopt values set by `HesGallery.setOptions ()` or default!**

@@ -78,3 +83,3 @@ ```html

### Available local options:
### Available local options:
Parameter | Global equivalent | Description

@@ -104,4 +109,28 @@ ---|---|---

## Images nested in Links
To support browsers without JavaScript, an option is to statically link the "large" images like so:
```html
<div class="hes-gallery">
<a href="image1-large.jpg" class="hg-image">
<img src="image1-small.jpg" alt="image1" data-subtext="Subtext" />
</a>
...
</div>
```
In that case, users can still open an expanded view but if JS is enabled, they get the HesGallery.
To enable this feature, set `linkNested` to true in the options during initialisation.
*Licence: [MIT](https://opensource.org/licenses/MIT)*
*Copyright 2019 [Artur Mędrygał](mailto:medrygal.artur@gmail.com)*
## Contribution
Feel free to contribute any changes/features for future versions of HesGallery. Please work, and create Pull Pequests on `develop` branch.
### How to run?
1. Install dependecies with `npm i` command
2. By `npm run dev` you can run development server with gulp & browsersync to faster the development of your feature
3. You can also use a `npm run build` to only build a script by babel and minimalize code
4. It would be also greate if you can provide a examples of your feature in readme and in `/demo` folder
4. When you finish, push your changes and create a Pull Request
Thanks for your help!
*Licence: [MIT](https://opensource.org/licenses/MIT)*
*Copyright 2019 [Artur Mędrygał](mailto:medrygal.artur@gmail.com)*

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc