New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

simplelightbox

Package Overview
Dependencies
Maintainers
1
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simplelightbox - npm Package Compare versions

Comparing version 1.9.0 to 1.10.0

4

bower.json
{
"name": "simplelightbox",
"version": "1.9.0",
"version": "1.10.0",
"homepage": "http://andreknieriem.de/simple-lightbox",

@@ -37,2 +37,2 @@ "authors": [

]
}
}

@@ -15,65 +15,60 @@

var options = $.extend({
overlay: true,
spinner: true,
nav: true,
navText: ['‹','›'],
captions: true,
captionDelay: 0,
captionSelector: 'img',
captionType: 'attr',
captionsData: 'title',
captionPosition: 'bottom',
close: true,
closeText: '×',
swipeClose: true,
showCounter: true,
fileExt: 'png|jpg|jpeg|gif',
animationSlide: true,
animationSpeed: 250,
preloading: true,
enableKeyboard: true,
loop: true,
rel: false,
docClose: true,
swipeTolerance: 50,
className: 'simple-lightbox',
widthRatio: 0.8,
heightRatio: 0.9,
disableRightClick: false,
disableScroll: true,
alertError: true,
alertErrorMessage: 'Image not found, next image will be loaded',
additionalHtml: false
}, options );
overlay: true,
spinner: true,
nav: true,
navText: ['‹', '›'],
captions: true,
captionDelay: 0,
captionSelector: 'img',
captionType: 'attr',
captionsData: 'title',
captionPosition: 'bottom',
close: true,
closeText: '×',
swipeClose: true,
showCounter: true,
fileExt: 'png|jpg|jpeg|gif',
animationSlide: true,
animationSpeed: 250,
preloading: true,
enableKeyboard: true,
loop: true,
rel: false,
docClose: true,
swipeTolerance: 50,
className: 'simple-lightbox',
widthRatio: 0.8,
heightRatio: 0.9,
disableRightClick: false,
disableScroll: true,
alertError: true,
alertErrorMessage: 'Image not found, next image will be loaded',
additionalHtml: false,
history: true
}, options);
// global variables
var touchDevice = ( 'ontouchstart' in window ),
pointerEnabled = window.navigator.pointerEnabled || window.navigator.msPointerEnabled,
touched = function( event ){
if( touchDevice ) return true;
if( !pointerEnabled || typeof event === 'undefined' || typeof event.pointerType === 'undefined' )
return false;
if( typeof event.MSPOINTER_TYPE_MOUSE !== 'undefined' )
{
if( event.MSPOINTER_TYPE_MOUSE != event.pointerType )
return true;
}
else
if( event.pointerType != 'mouse' )
return true;
return false;
},
swipeDiff = 0,
swipeYDiff = 0,
pointerEnabled = window.navigator.pointerEnabled || window.navigator.msPointerEnabled,
touched = function( event ){
if( touchDevice ) return true;
if( !pointerEnabled || typeof event === 'undefined' || typeof event.pointerType === 'undefined' ) return false;
if( typeof event.MSPOINTER_TYPE_MOUSE !== 'undefined' ) {
if( event.MSPOINTER_TYPE_MOUSE != event.pointerType ) return true;
}
else {
if( event.pointerType != 'mouse' ) return true;
}
return false;
},
swipeDiff = 0,
swipeYDiff = 0,
curImg = $(),
transPrefix = function(){
var s = document.body || document.documentElement, s = s.style;
if( s.WebkitTransition == '' ) return '-webkit-';
if( s.MozTransition == '' ) return '-moz-';
if( s.OTransition == '' ) return '-o-';
if( s.transition == '' ) return '';
return false;
transPrefix = function(){
var s = document.body || document.documentElement, s = s.style;
if( s.WebkitTransition == '' ) return '-webkit-';
if( s.MozTransition == '' ) return '-moz-';
if( s.OTransition == '' ) return '-o-';
if( s.transition == '' ) return '';
return false;
},

@@ -86,3 +81,2 @@ opened = false,

});
return $related;

@@ -93,2 +87,42 @@ },

canTransisions = (transPrefix !== false) ? true : false,
supportsPushState = ('pushState' in history),
historyhasChanged = false,
historyUpdateTimeout,
winLoc = window.location,
getHash = function(){
return winLoc.hash.substring(1);
},
initialHash = getHash(),
updateHash = function(){
var hash = getHash(),
newHash = 'pid='+(index+1);
var newURL = winLoc.href.split('#')[0] + '#' + newHash;
if(supportsPushState){
history[historyhasChanged ? 'replaceState' : 'pushState']('', document.title, newURL);
}else {
if(historyhasChanged) {
winLoc.replace( newURL );
} else {
winLoc.hash = newHash;
}
}
historyhasChanged = true;
},
resetHash = function() {
if (supportsPushState) {
history.pushState('', document.title, winLoc.pathname + winLoc.search );
} else {
winLoc.hash = '';
}
clearTimeout(historyUpdateTimeout);
},
updateURL = function(){
if(!historyhasChanged) {
updateHash(); // first time
} else {
historyUpdateTimeout = setTimeout(updateHash, 800);
}
},
prefix = 'simplelb',

@@ -110,12 +144,11 @@ overlay = $('<div>').addClass('sl-overlay'),

setup = function(){
if(options.close) closeBtn.appendTo(wrapper);
if(options.showCounter){
if(objects.length > 1){
counter.appendTo(wrapper);
counter.find('.sl-total').text(objects.length);
}
}
if(options.nav) nav.appendTo(wrapper);
if(options.spinner) spinner.appendTo(wrapper);
if(options.close) closeBtn.appendTo(wrapper);
if(options.showCounter){
if(objects.length > 1){
counter.appendTo(wrapper);
counter.find('.sl-total').text(objects.length);
}
}
if(options.nav) nav.appendTo(wrapper);
if(options.spinner) spinner.appendTo(wrapper);
},

@@ -130,55 +163,61 @@ openImage = function(elem){

index = objects.index(elem);
curImg = $( '<img/>' )
.hide()
.attr('src', elem.attr('href'));
if(loaded.indexOf(elem.attr('href')) == -1){
loaded.push(elem.attr('href'));
}
image.html('').attr('style','');
curImg.appendTo(image);
addEvents();
overlay.fadeIn('fast');
$('.sl-close').fadeIn('fast');
spinner.show();
nav.fadeIn('fast');
$('.sl-wrapper .sl-counter .sl-current').text(index +1);
counter.fadeIn('fast');
adjustImage();
if(options.preloading) preload();
setTimeout( function(){ elem.trigger($.Event('shown.simplelightbox')); } ,options.animationSpeed);
curImg = $( '<img/>' )
.hide()
.attr('src', elem.attr('href'));
if(loaded.indexOf(elem.attr('href')) == -1){
loaded.push(elem.attr('href'));
}
image.html('').attr('style','');
curImg.appendTo(image);
addEvents();
overlay.fadeIn('fast');
$('.sl-close').fadeIn('fast');
spinner.show();
nav.fadeIn('fast');
$('.sl-wrapper .sl-counter .sl-current').text(index +1);
counter.fadeIn('fast');
adjustImage();
if(options.preloading) preload();
setTimeout( function(){ elem.trigger($.Event('shown.simplelightbox')); } ,options.animationSpeed);
},
adjustImage = function(dir){
if(!curImg.length) return;
var tmpImage = new Image(),
var tmpImage = new Image(),
windowWidth = $( window ).width() * options.widthRatio,
windowHeight = $( window ).height() * options.heightRatio;
tmpImage.src = curImg.attr( 'src' );
tmpImage.src = curImg.attr( 'src' );
$(tmpImage).bind('error',function(ev){
//no image was found
objects.eq(index).trigger($.Event('error.simplelightbox'))
animating = false;
opened = true;
spinner.hide();
if(options.alertError){
alert(options.alertErrorMessage);
if(dir == 1 || dir == -1){
loadImage(dir);
} else {
loadImage(1);
}
return;
}
})
tmpImage.onload = function() {
if (typeof dir !== 'undefined') {
//no image was found
objects.eq(index).trigger($.Event('error.simplelightbox'))
animating = false;
opened = true;
spinner.hide();
if(options.alertError){
alert(options.alertErrorMessage);
if(dir == 1 || dir == -1){
loadImage(dir);
} else {
loadImage(1);
}
return;
}
});
tmpImage.onload = function() {
if (typeof dir !== 'undefined') {
objects.eq(index)
.trigger($.Event('changed.simplelightbox'))
.trigger($.Event( (dir===1?'nextDone':'prevDone')+'.simplelightbox'));
.trigger($.Event('changed.simplelightbox'))
.trigger($.Event( (dir===1?'nextDone':'prevDone')+'.simplelightbox'));
}
if(loaded.indexOf(curImg.attr( 'src' )) == -1){
loaded.push(curImg.attr( 'src' ));
}
// history
if(options.history){
updateURL();
}
if(loaded.indexOf(curImg.attr( 'src' )) == -1){
loaded.push(curImg.attr( 'src' ));
}
var imageWidth = tmpImage.width,

@@ -269,2 +308,15 @@ imageHeight = tmpImage.height;

if(options.history){
setTimeout(function() {
$(window).on('hashchange.'+prefix,function(){
if(opened){
if(getHash() === initialHash) {
close();
return;
}
}
});
}, 40);
}
// nav-buttons

@@ -284,7 +336,7 @@ nav.on('click.'+prefix, 'button', function(e){

imageLeft = 0;
image
.on( 'touchstart.'+prefix+' mousedown.'+prefix, function(e)
{
if(mousedown) return true;
if(mousedown) return true;
if( canTransisions ) imageLeft = parseInt( image.css( 'left' ) );

@@ -326,3 +378,3 @@ mousedown = true;

}
if( options.swipeClose && Math.abs(swipeYDiff) > 50 && Math.abs( swipeDiff ) < options.swipeTolerance) {

@@ -338,2 +390,3 @@ close();

$( window ).off( 'resize.'+prefix);
$( window ).off( 'hashchange.'+prefix);
},

@@ -361,3 +414,3 @@ preload = function(){

.trigger($.Event( (dir===1?'next':'prev')+'.simplelightbox'));
var newIndex = index + dir;

@@ -372,3 +425,3 @@ if(animating || (newIndex < 0 || newIndex >= objects.length) && options.loop == false ) return;

}
$('.sl-image').animate( css, options.animationSpeed, function(){

@@ -392,14 +445,16 @@ setTimeout( function(){

var elem = objects.eq(index),
triggered = false;
triggered = false;
elem.trigger($.Event('close.simplelightbox'));
$('.sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter').fadeOut('fast', function(){
if(options.disableScroll) handleScrollbar('show');
$('.sl-wrapper, .sl-overlay').remove();
removeEvents();
if(!triggered) elem.trigger($.Event('closed.simplelightbox'));
triggered = true;
});
curImg = $();
opened = false;
animating = false;
resetHash();
$('.sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter').fadeOut('fast', function(){
if(options.disableScroll) handleScrollbar('show');
$('.sl-wrapper, .sl-overlay').remove();
removeEvents();
if(!triggered) elem.trigger($.Event('closed.simplelightbox'));
triggered = true;
});
curImg = $();
opened = false;
animating = false;
},

@@ -410,16 +465,16 @@ handleScrollbar = function(type){

if (!fullWindowWidth) {
var documentElementRect = document.documentElement.getBoundingClientRect()
fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
}
var documentElementRect = document.documentElement.getBoundingClientRect()
fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left)
}
if(document.body.clientWidth < fullWindowWidth){
var scrollDiv = document.createElement('div'),
padding = parseInt($('body').css('padding-right'),10);
scrollDiv.className = 'sl-scrollbar-measure';
$('body').append(scrollDiv);
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
$(document.body)[0].removeChild(scrollDiv);
$('body').data('padding',padding);
if(scrollbarWidth > 0){
$('body').addClass('hidden-scroll').css({'padding-right':padding+scrollbarWidth});
}
padding = parseInt($('body').css('padding-right'),10);
scrollDiv.className = 'sl-scrollbar-measure';
$('body').append(scrollDiv);
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
$(document.body)[0].removeChild(scrollDiv);
$('body').data('padding',padding);
if(scrollbarWidth > 0){
$('body').addClass('hidden-scroll').css({'padding-right':padding+scrollbarWidth});
}
}

@@ -434,11 +489,9 @@ } else {

// open lightbox
objects.on( 'click.'+prefix, function( e ){
if(isValidLink(this)){
e.preventDefault();
if(animating) return false;
openImage($(this));
}
if(isValidLink(this)){
e.preventDefault();
if(animating) return false;
openImage($(this));
}
});

@@ -498,3 +551,3 @@

}
this.destroy = function(){

@@ -506,3 +559,3 @@ $( document ).unbind('click.'+prefix).unbind('keyup.'+prefix);

}
this.refresh = function(){

@@ -516,2 +569,2 @@ this.destroy();

};
})( jQuery, window, document );
})( jQuery, window, document );

@@ -5,2 +5,2 @@ /*

*/
!function(e,t,n,i){"use strict";e.fn.simpleLightbox=function(i){var i=e.extend({overlay:!0,spinner:!0,nav:!0,navText:["&lsaquo;","&rsaquo;"],captions:!0,captionDelay:0,captionSelector:"img",captionType:"attr",captionsData:"title",captionPosition:"bottom",close:!0,closeText:"×",swipeClose:!0,showCounter:!0,fileExt:"png|jpg|jpeg|gif",animationSlide:!0,animationSpeed:250,preloading:!0,enableKeyboard:!0,loop:!0,rel:!1,docClose:!0,swipeTolerance:50,className:"simple-lightbox",widthRatio:.8,heightRatio:.9,disableRightClick:!1,disableScroll:!0,alertError:!0,alertErrorMessage:"Image not found, next image will be loaded",additionalHtml:!1},i),a=(t.navigator.pointerEnabled||t.navigator.msPointerEnabled,0),o=0,s=e(),l=function(){var e=n.body||n.documentElement,e=e.style;return""==e.WebkitTransition?"-webkit-":""==e.MozTransition?"-moz-":""==e.OTransition?"-o-":""==e.transition?"":!1},r=!1,d=[],c=function(t,n){var i=e(n.selector).filter(function(){return e(this).attr("rel")===t});return i},p=i.rel&&i.rel!==!1?c(i.rel,this):this,l=l(),h=l!==!1?!0:!1,g="simplelb",f=e("<div>").addClass("sl-overlay"),u=e("<button>").addClass("sl-close").html(i.closeText),m=e("<div>").addClass("sl-spinner").html("<div></div>"),v=e("<div>").addClass("sl-navigation").html('<button class="sl-prev">'+i.navText[0]+'</button><button class="sl-next">'+i.navText[1]+"</button>"),x=e("<div>").addClass("sl-counter").html('<span class="sl-current"></span>/<span class="sl-total"></span>'),b=!1,y=0,w=e("<div>").addClass("sl-caption pos-"+i.captionPosition),E=e("<div>").addClass("sl-image"),C=e("<div>").addClass("sl-wrapper").addClass(i.className),T=function(t){return i.fileExt?"a"==e(t).prop("tagName").toLowerCase()&&new RegExp(".("+i.fileExt+")$","i").test(e(t).attr("href")):!0},S=function(){i.close&&u.appendTo(C),i.showCounter&&p.length>1&&(x.appendTo(C),x.find(".sl-total").text(p.length)),i.nav&&v.appendTo(C),i.spinner&&m.appendTo(C)},k=function(t){t.trigger(e.Event("show.simplelightbox")),i.disableScroll&&W("hide"),C.appendTo("body"),E.appendTo(C),i.overlay&&f.appendTo(e("body")),b=!0,y=p.index(t),s=e("<img/>").hide().attr("src",t.attr("href")),-1==d.indexOf(t.attr("href"))&&d.push(t.attr("href")),E.html("").attr("style",""),s.appendTo(E),M(),f.fadeIn("fast"),e(".sl-close").fadeIn("fast"),m.show(),v.fadeIn("fast"),e(".sl-wrapper .sl-counter .sl-current").text(y+1),x.fadeIn("fast"),I(),i.preloading&&O(),setTimeout(function(){t.trigger(e.Event("shown.simplelightbox"))},i.animationSpeed)},I=function(n){if(s.length){var a=new Image,o=e(t).width()*i.widthRatio,l=e(t).height()*i.heightRatio;a.src=s.attr("src"),e(a).bind("error",function(t){return p.eq(y).trigger(e.Event("error.simplelightbox")),b=!1,r=!0,m.hide(),i.alertError?(alert(i.alertErrorMessage),void P(1==n||-1==n?n:1)):void 0}),a.onload=function(){"undefined"!=typeof n&&p.eq(y).trigger(e.Event("changed.simplelightbox")).trigger(e.Event((1===n?"nextDone":"prevDone")+".simplelightbox")),-1==d.indexOf(s.attr("src"))&&d.push(s.attr("src"));var c=a.width,g=a.height;if(c>o||g>l){var f=c/g>o/l?c/o:g/l;c/=f,g/=f}e(".sl-image").css({top:(e(t).height()-g)/2+"px",left:(e(t).width()-c)/2+"px"}),m.hide(),s.css({width:c+"px",height:g+"px"}).fadeIn("fast"),r=!0;var u="self"==i.captionSelector?p.eq(y):p.eq(y).find(i.captionSelector);if("data"==i.captionType)var v=u.data(i.captionsData);else if("text"==i.captionType)var v=u.html();else var v=u.prop(i.captionsData);if(i.loop||(0==y&&e(".sl-prev").hide(),y>=p.length-1&&e(".sl-next").hide(),y>0&&e(".sl-prev").show(),y<p.length-1&&e(".sl-next").show()),1==p.length&&e(".sl-prev, .sl-next").hide(),1==n||-1==n){var x={opacity:1};i.animationSlide&&(h?(D(0,100*n+"px"),setTimeout(function(){D(i.animationSpeed/1e3,"0px"),50})):x.left=parseInt(e(".sl-image").css("left"))+100*n+"px"),e(".sl-image").animate(x,i.animationSpeed,function(){b=!1,q(v)})}else b=!1,q(v);i.additionalHtml&&0==e(".sl-additional-html").length&&e("<div>").html(i.additionalHtml).addClass("sl-additional-html").appendTo(e(".sl-image"))}}},q=function(t){""!=t&&"undefined"!=typeof t&&i.captions&&w.html(t).hide().appendTo(e(".sl-image")).delay(i.captionDelay).fadeIn("fast")},D=function(t,n){var i={};i[l+"transform"]="translateX("+n+")",i[l+"transition"]=l+"transform "+t+"s linear",e(".sl-image").css(i)},M=function(){e(t).on("resize."+g,I),e(n).on("click."+g+" touchstart."+g,".sl-close",function(e){e.preventDefault(),r&&L()}),v.on("click."+g,"button",function(t){t.preventDefault(),a=0,P(e(this).hasClass("sl-next")?1:-1)});var s=0,l=0,d=0,c=0,f=!1,u=0;E.on("touchstart."+g+" mousedown."+g,function(e){return f?!0:(h&&(u=parseInt(E.css("left"))),f=!0,s=e.originalEvent.pageX||e.originalEvent.touches[0].pageX,d=e.originalEvent.pageY||e.originalEvent.touches[0].pageY,!1)}).on("touchmove."+g+" mousemove."+g+" pointermove MSPointerMove",function(e){return f?(e.preventDefault(),l=e.originalEvent.pageX||e.originalEvent.touches[0].pageX,c=e.originalEvent.pageY||e.originalEvent.touches[0].pageY,a=s-l,o=d-c,void(i.animationSlide&&(h?D(0,-a+"px"):E.css("left",u-a+"px")))):!0}).on("touchend."+g+" mouseup."+g+" touchcancel."+g+" mouseleave."+g+" pointerup pointercancel MSPointerUp MSPointerCancel",function(e){if(f){f=!1;var t=!0;i.loop||(0==y&&0>a&&(t=!1),y>=p.length-1&&a>0&&(t=!1)),Math.abs(a)>i.swipeTolerance&&t?P(a>0?1:-1):i.animationSlide&&(h?D(i.animationSpeed/1e3,"0px"):E.animate({left:u+"px"},i.animationSpeed/2)),i.swipeClose&&Math.abs(o)>50&&Math.abs(a)<i.swipeTolerance&&L()}})},R=function(){v.off("click","button"),e(n).off("click."+g,".sl-close"),e(t).off("resize."+g)},O=function(){var t=0>y+1?p.length-1:y+1>=p.length-1?0:y+1,n=0>y-1?p.length-1:y-1>=p.length-1?0:y-1;e("<img />").attr("src",p.eq(t).attr("href")).load(function(){-1==d.indexOf(e(this).attr("src"))&&d.push(e(this).attr("src")),p.eq(y).trigger(e.Event("nextImageLoaded.simplelightbox"))}),e("<img />").attr("src",p.eq(n).attr("href")).load(function(){-1==d.indexOf(e(this).attr("src"))&&d.push(e(this).attr("src")),p.eq(y).trigger(e.Event("prevImageLoaded.simplelightbox"))})},P=function(t){p.eq(y).trigger(e.Event("change.simplelightbox")).trigger(e.Event((1===t?"next":"prev")+".simplelightbox"));var n=y+t;if(!(b||(0>n||n>=p.length)&&0==i.loop)){y=0>n?p.length-1:n>p.length-1?0:n,e(".sl-wrapper .sl-counter .sl-current").text(y+1);var o={opacity:0};i.animationSlide&&(h?D(i.animationSpeed/1e3,-100*t-a+"px"):o.left=parseInt(e(".sl-image").css("left"))+-100*t+"px"),e(".sl-image").animate(o,i.animationSpeed,function(){setTimeout(function(){var n=p.eq(y);s.attr("src",n.attr("href")),-1==d.indexOf(n.attr("href"))&&m.show(),e(".sl-caption").remove(),I(t),i.preloading&&O()},100)})}},L=function(){if(!b){var t=p.eq(y),n=!1;t.trigger(e.Event("close.simplelightbox")),e(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter").fadeOut("fast",function(){i.disableScroll&&W("show"),e(".sl-wrapper, .sl-overlay").remove(),R(),n||t.trigger(e.Event("closed.simplelightbox")),n=!0}),s=e(),r=!1,b=!1}},W=function(i){if("hide"==i){var a=t.innerWidth;if(!a){var o=n.documentElement.getBoundingClientRect();a=o.right-Math.abs(o.left)}if(n.body.clientWidth<a){var s=n.createElement("div"),l=parseInt(e("body").css("padding-right"),10);s.className="sl-scrollbar-measure",e("body").append(s);var r=s.offsetWidth-s.clientWidth;e(n.body)[0].removeChild(s),e("body").data("padding",l),r>0&&e("body").addClass("hidden-scroll").css({"padding-right":l+r})}}else e("body").removeClass("hidden-scroll").css({"padding-right":e("body").data("padding")})};return S(),p.on("click."+g,function(t){if(T(this)){if(t.preventDefault(),b)return!1;k(e(this))}}),e(n).on("click."+g+" touchstart."+g,function(t){r&&i.docClose&&0==e(t.target).closest(".sl-image").length&&0==e(t.target).closest(".sl-navigation").length&&L()}),i.disableRightClick&&e(n).on("contextmenu",".sl-image img",function(e){return!1}),i.enableKeyboard&&e(n).on("keyup."+g,function(e){if(e.preventDefault(),a=0,r){var t=e.keyCode;27==t&&L(),(37==t||39==e.keyCode)&&P(39==e.keyCode?1:-1)}}),this.open=function(t){t=t||e(this[0]),k(t)},this.next=function(){P(1)},this.prev=function(){P(-1)},this.close=function(){L()},this.destroy=function(){e(n).unbind("click."+g).unbind("keyup."+g),L(),e(".sl-overlay, .sl-wrapper").remove(),this.off("click")},this.refresh=function(){this.destroy(),e(this.selector).simpleLightbox(i)},this}}(jQuery,window,document);
!function(a,b,c,d){"use strict";a.fn.simpleLightbox=function(d){var s,d=a.extend({overlay:!0,spinner:!0,nav:!0,navText:["&lsaquo;","&rsaquo;"],captions:!0,captionDelay:0,captionSelector:"img",captionType:"attr",captionsData:"title",captionPosition:"bottom",close:!0,closeText:"×",swipeClose:!0,showCounter:!0,fileExt:"png|jpg|jpeg|gif",animationSlide:!0,animationSpeed:250,preloading:!0,enableKeyboard:!0,loop:!0,rel:!1,docClose:!0,swipeTolerance:50,className:"simple-lightbox",widthRatio:.8,heightRatio:.9,disableRightClick:!1,disableScroll:!0,alertError:!0,alertErrorMessage:"Image not found, next image will be loaded",additionalHtml:!1,history:!0},d),h=(b.navigator.pointerEnabled||b.navigator.msPointerEnabled,0),i=0,j=a(),k=function(){var a=c.body||c.documentElement,a=a.style;return""==a.WebkitTransition?"-webkit-":""==a.MozTransition?"-moz-":""==a.OTransition?"-o-":""==a.transition&&""},l=!1,m=[],n=function(b,c){var d=a(c.selector).filter(function(){return a(this).attr("rel")===b});return d},o=d.rel&&d.rel!==!1?n(d.rel,this):this,k=k(),p=k!==!1,q="pushState"in history,r=!1,t=b.location,u=function(){return t.hash.substring(1)},v=u(),w=function(){var b=(u(),"pid="+(G+1)),d=t.href.split("#")[0]+"#"+b;q?history[r?"replaceState":"pushState"]("",c.title,d):r?t.replace(d):t.hash=b,r=!0},x=function(){q?history.pushState("",c.title,t.pathname+t.search):t.hash="",clearTimeout(s)},y=function(){r?s=setTimeout(w,800):w()},z="simplelb",A=a("<div>").addClass("sl-overlay"),B=a("<button>").addClass("sl-close").html(d.closeText),C=a("<div>").addClass("sl-spinner").html("<div></div>"),D=a("<div>").addClass("sl-navigation").html('<button class="sl-prev">'+d.navText[0]+'</button><button class="sl-next">'+d.navText[1]+"</button>"),E=a("<div>").addClass("sl-counter").html('<span class="sl-current"></span>/<span class="sl-total"></span>'),F=!1,G=0,H=a("<div>").addClass("sl-caption pos-"+d.captionPosition),I=a("<div>").addClass("sl-image"),J=a("<div>").addClass("sl-wrapper").addClass(d.className),K=function(b){return!d.fileExt||"a"==a(b).prop("tagName").toLowerCase()&&new RegExp(".("+d.fileExt+")$","i").test(a(b).attr("href"))},L=function(){d.close&&B.appendTo(J),d.showCounter&&o.length>1&&(E.appendTo(J),E.find(".sl-total").text(o.length)),d.nav&&D.appendTo(J),d.spinner&&C.appendTo(J)},M=function(b){b.trigger(a.Event("show.simplelightbox")),d.disableScroll&&V("hide"),J.appendTo("body"),I.appendTo(J),d.overlay&&A.appendTo(a("body")),F=!0,G=o.index(b),j=a("<img/>").hide().attr("src",b.attr("href")),m.indexOf(b.attr("href"))==-1&&m.push(b.attr("href")),I.html("").attr("style",""),j.appendTo(I),Q(),A.fadeIn("fast"),a(".sl-close").fadeIn("fast"),C.show(),D.fadeIn("fast"),a(".sl-wrapper .sl-counter .sl-current").text(G+1),E.fadeIn("fast"),N(),d.preloading&&S(),setTimeout(function(){b.trigger(a.Event("shown.simplelightbox"))},d.animationSpeed)},N=function(c){if(j.length){var e=new Image,f=a(b).width()*d.widthRatio,g=a(b).height()*d.heightRatio;e.src=j.attr("src"),a(e).bind("error",function(b){if(o.eq(G).trigger(a.Event("error.simplelightbox")),F=!1,l=!0,C.hide(),d.alertError)return alert(d.alertErrorMessage),void T(1==c||c==-1?c:1)}),e.onload=function(){"undefined"!=typeof c&&o.eq(G).trigger(a.Event("changed.simplelightbox")).trigger(a.Event((1===c?"nextDone":"prevDone")+".simplelightbox")),d.history&&y(),m.indexOf(j.attr("src"))==-1&&m.push(j.attr("src"));var h=e.width,i=e.height;if(h>f||i>g){var k=h/i>f/g?h/f:i/g;h/=k,i/=k}a(".sl-image").css({top:(a(b).height()-i)/2+"px",left:(a(b).width()-h)/2+"px"}),C.hide(),j.css({width:h+"px",height:i+"px"}).fadeIn("fast"),l=!0;var n="self"==d.captionSelector?o.eq(G):o.eq(G).find(d.captionSelector);if("data"==d.captionType)var q=n.data(d.captionsData);else if("text"==d.captionType)var q=n.html();else var q=n.prop(d.captionsData);if(d.loop||(0==G&&a(".sl-prev").hide(),G>=o.length-1&&a(".sl-next").hide(),G>0&&a(".sl-prev").show(),G<o.length-1&&a(".sl-next").show()),1==o.length&&a(".sl-prev, .sl-next").hide(),1==c||c==-1){var r={opacity:1};d.animationSlide&&(p?(P(0,100*c+"px"),setTimeout(function(){P(d.animationSpeed/1e3,"0px"),50})):r.left=parseInt(a(".sl-image").css("left"))+100*c+"px"),a(".sl-image").animate(r,d.animationSpeed,function(){F=!1,O(q)})}else F=!1,O(q);d.additionalHtml&&0==a(".sl-additional-html").length&&a("<div>").html(d.additionalHtml).addClass("sl-additional-html").appendTo(a(".sl-image"))}}},O=function(b){""!=b&&"undefined"!=typeof b&&d.captions&&H.html(b).hide().appendTo(a(".sl-image")).delay(d.captionDelay).fadeIn("fast")},P=function(b,c){var d={};d[k+"transform"]="translateX("+c+")",d[k+"transition"]=k+"transform "+b+"s linear",a(".sl-image").css(d)},Q=function(){a(b).on("resize."+z,N),a(c).on("click."+z+" touchstart."+z,".sl-close",function(a){a.preventDefault(),l&&U()}),d.history&&setTimeout(function(){a(b).on("hashchange."+z,function(){if(l&&u()===v)return void U()})},40),D.on("click."+z,"button",function(b){b.preventDefault(),h=0,T(a(this).hasClass("sl-next")?1:-1)});var e=0,f=0,g=0,j=0,k=!1,m=0;I.on("touchstart."+z+" mousedown."+z,function(a){return!!k||(p&&(m=parseInt(I.css("left"))),k=!0,e=a.originalEvent.pageX||a.originalEvent.touches[0].pageX,g=a.originalEvent.pageY||a.originalEvent.touches[0].pageY,!1)}).on("touchmove."+z+" mousemove."+z+" pointermove MSPointerMove",function(a){return!k||(a.preventDefault(),f=a.originalEvent.pageX||a.originalEvent.touches[0].pageX,j=a.originalEvent.pageY||a.originalEvent.touches[0].pageY,h=e-f,i=g-j,void(d.animationSlide&&(p?P(0,-h+"px"):I.css("left",m-h+"px"))))}).on("touchend."+z+" mouseup."+z+" touchcancel."+z+" mouseleave."+z+" pointerup pointercancel MSPointerUp MSPointerCancel",function(a){if(k){k=!1;var b=!0;d.loop||(0==G&&h<0&&(b=!1),G>=o.length-1&&h>0&&(b=!1)),Math.abs(h)>d.swipeTolerance&&b?T(h>0?1:-1):d.animationSlide&&(p?P(d.animationSpeed/1e3,"0px"):I.animate({left:m+"px"},d.animationSpeed/2)),d.swipeClose&&Math.abs(i)>50&&Math.abs(h)<d.swipeTolerance&&U()}})},R=function(){D.off("click","button"),a(c).off("click."+z,".sl-close"),a(b).off("resize."+z),a(b).off("hashchange."+z)},S=function(){var b=G+1<0?o.length-1:G+1>=o.length-1?0:G+1,c=G-1<0?o.length-1:G-1>=o.length-1?0:G-1;a("<img />").attr("src",o.eq(b).attr("href")).load(function(){m.indexOf(a(this).attr("src"))==-1&&m.push(a(this).attr("src")),o.eq(G).trigger(a.Event("nextImageLoaded.simplelightbox"))}),a("<img />").attr("src",o.eq(c).attr("href")).load(function(){m.indexOf(a(this).attr("src"))==-1&&m.push(a(this).attr("src")),o.eq(G).trigger(a.Event("prevImageLoaded.simplelightbox"))})},T=function(b){o.eq(G).trigger(a.Event("change.simplelightbox")).trigger(a.Event((1===b?"next":"prev")+".simplelightbox"));var c=G+b;if(!(F||(c<0||c>=o.length)&&0==d.loop)){G=c<0?o.length-1:c>o.length-1?0:c,a(".sl-wrapper .sl-counter .sl-current").text(G+1);var e={opacity:0};d.animationSlide&&(p?P(d.animationSpeed/1e3,-100*b-h+"px"):e.left=parseInt(a(".sl-image").css("left"))+-100*b+"px"),a(".sl-image").animate(e,d.animationSpeed,function(){setTimeout(function(){var c=o.eq(G);j.attr("src",c.attr("href")),m.indexOf(c.attr("href"))==-1&&C.show(),a(".sl-caption").remove(),N(b),d.preloading&&S()},100)})}},U=function(){if(!F){var b=o.eq(G),c=!1;b.trigger(a.Event("close.simplelightbox")),x(),a(".sl-image img, .sl-overlay, .sl-close, .sl-navigation, .sl-image .sl-caption, .sl-counter").fadeOut("fast",function(){d.disableScroll&&V("show"),a(".sl-wrapper, .sl-overlay").remove(),R(),c||b.trigger(a.Event("closed.simplelightbox")),c=!0}),j=a(),l=!1,F=!1}},V=function(d){if("hide"==d){var e=b.innerWidth;if(!e){var f=c.documentElement.getBoundingClientRect();e=f.right-Math.abs(f.left)}if(c.body.clientWidth<e){var g=c.createElement("div"),h=parseInt(a("body").css("padding-right"),10);g.className="sl-scrollbar-measure",a("body").append(g);var i=g.offsetWidth-g.clientWidth;a(c.body)[0].removeChild(g),a("body").data("padding",h),i>0&&a("body").addClass("hidden-scroll").css({"padding-right":h+i})}}else a("body").removeClass("hidden-scroll").css({"padding-right":a("body").data("padding")})};return L(),o.on("click."+z,function(b){if(K(this)){if(b.preventDefault(),F)return!1;M(a(this))}}),a(c).on("click."+z+" touchstart."+z,function(b){l&&d.docClose&&0==a(b.target).closest(".sl-image").length&&0==a(b.target).closest(".sl-navigation").length&&U()}),d.disableRightClick&&a(c).on("contextmenu",".sl-image img",function(a){return!1}),d.enableKeyboard&&a(c).on("keyup."+z,function(a){if(a.preventDefault(),h=0,l){var b=a.keyCode;27==b&&U(),37!=b&&39!=a.keyCode||T(39==a.keyCode?1:-1)}}),this.open=function(b){b=b||a(this[0]),M(b)},this.next=function(){T(1)},this.prev=function(){T(-1)},this.close=function(){U()},this.destroy=function(){a(c).unbind("click."+z).unbind("keyup."+z),U(),a(".sl-overlay, .sl-wrapper").remove(),this.off("click")},this.refresh=function(){this.destroy(),a(this.selector).simpleLightbox(d)},this}}(jQuery,window,document);
{
"name": "simplelightbox",
"version": "1.9.0",
"version": "1.10.0",
"description": "Touch-friendly image lightbox for mobile and desktop with jQuery",

@@ -5,0 +5,0 @@ "main": "dist/simple-lightbox.js",

@@ -36,3 +36,3 @@ # simplelightbox

| showCounter | true | bool | show current image index or not |
| fileExt | 'png&#124;jpg&#124;jpeg&#124;gif' | regexp or false | list of fileextensions the plugin works with or false for disable the check |
| fileExt | 'png&#124;jpg&#124;jpeg&#124;gif' | regexp or false | list of fileextensions the plugin works with or false for disable the check |
| animationSpeed | 250 | int | how long takes the slide animation |

@@ -43,3 +43,3 @@ | animationSlide | true | bool | weather to slide in new photos or not, disable to fade |

| loop | true | bool | enables looping through images |
| rel | false | mixed | group images by rel attribute of link with same selector.
| rel | false | mixed | group images by rel attribute of link with same selector.
| docClose | true | bool | closes the lightbox when clicking outside |

@@ -55,2 +55,3 @@ | swipeTolerance | 50 | int | how much pixel you have to swipe, until next or previous image |

| additionalHtml | false | string | Additional HTML showing inside every image. Usefull for watermark etc. If false nothing is added |
| history | true | bool | enable history back closes lightbox instead of reloading the page |

@@ -110,2 +111,3 @@ ### Events

### Changelog
**1.10.0 - Implemented feature-request #48, history back, some bugfixing and code styling**
**1.9.0 - Implemented feature-request #16, added rel option for grouping images**

@@ -147,2 +149,2 @@ **1.8.6 - Implemented feature-request #46, added refresh method**

[bitstarr](https://github.com/bitstarr)
[Geoffrey Crofte](http://geoffrey.crofte.fr/) - [Github](https://github.com/creativejuiz/)
[Geoffrey Crofte](http://geoffrey.crofte.fr/) - [Github](https://github.com/creativejuiz/)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc