diff --git a/abigimage.jquery.js b/abigimage.jquery.js index 60eee6f..0eff1a3 100644 --- a/abigimage.jquery.js +++ b/abigimage.jquery.js @@ -1,6 +1,6 @@ /** * http://aeqdev.com/tools/js/abigimage/ - * v 1.2.3 + * v 1.2.4 * * Copyright © 2014 Maksim Krylosov * @@ -94,7 +94,7 @@ i = openI; - t.img.stop().fadeOut(opts.fadeOut) + t.img .removeAttr('src') // To re-fire load event if same image opened .attr('src', $(t[i]).attr('href')); @@ -109,8 +109,6 @@ } this.img.load(function() { - t.img.stop().fadeIn(opts.fadeIn); - // preload prev and next images after viewed images loaded t.imgNext.attr('src', $(t[nextI()]).attr('href')); t.imgPrev.attr('src', $(t[prevI()]).attr('href')); @@ -180,18 +178,19 @@ closeBtnBoxCSS: {position: 'absolute', zIndex: 104, top: 0, bottom: 0, right: 0}, prevBtnCSS: {color: '#fff', backgroundColor: '#000', opacity: .5, - padding: '0 1em', borderRadius: '0 0 1ex 0'}, + padding: '0 1em', borderRadius: '0 0 1ex 0'}, closeBtnCSS: {color: '#fff', backgroundColor: '#000', opacity: .5, - padding: '0 1em', borderRadius: '0 0 0 1ex'}, + padding: '0 1em', borderRadius: '0 0 0 1ex'}, prevBtnHoverCSS: {opacity: 1}, closeBtnHoverCSS: {opacity: 1}, - imgCSS: {position: 'absolute', zIndex: 102, margin: 'auto', top: 0, right: 0, bottom: 0, left: 0, + imgCSS: {position: 'absolute', zIndex: 102, margin: 'auto', width: 'auto', + top: 0, right: 0, bottom: 0, left: 0, display: 'block', cursor: 'pointer', maxWidth: '100%', maxHeight: '100%'}, - imgNextCSS: {position: 'absolute', top: '-10000px', width: '100px'}, - imgPrevCSS: {position: 'absolute', top: '-10000px', width: '100px'}, + imgNextCSS: {position: 'absolute', top: '-10000px', left: 0, width: '1px'}, + imgPrevCSS: {position: 'absolute', top: '-10000px', left: 0, width: '1px'}, bottomCSS: {position: 'absolute', zIndex: 103, right: 0, bottom: 0, left: 0, '-webkit-user-select': 'text', '-moz-user-select': 'text', 'user-select': 'text', diff --git a/abigimage.jquery.json b/abigimage.jquery.json index 1c4cf05..26121a4 100644 --- a/abigimage.jquery.json +++ b/abigimage.jquery.json @@ -1,6 +1,6 @@ { "name": "abigimage", - "version": "1.2.3", + "version": "1.2.4", "title": "ABigImage - view big versions of images", "author": { "name": "Maksim Krylosov", diff --git a/abigimage.jquery.min.js b/abigimage.jquery.min.js index 7b36529..a119b37 100644 --- a/abigimage.jquery.min.js +++ b/abigimage.jquery.min.js @@ -1 +1 @@ -(function(a){a.fn.abigimage=function(o){var b=a.extend(true,a.fn.abigimage.defaults,o);this.overlay=a("
").attr(b.overlayAttrs).css(b.overlayCSS).appendTo("body");this.layout=a("
").attr(b.layoutAttrs).css(b.layoutCSS).appendTo("body");this.prevBtnWrapper=a("
").attr(b.prevBtnWrapperAttrs).css(b.prevBtnWrapperCSS).appendTo(this.layout);this.prevBtnBox=a("
").attr(b.prevBtnBoxAttrs).css(b.prevBtnBoxCSS).appendTo(this.prevBtnWrapper);this.prevBtn=a("
").attr(b.prevBtnAttrs).css(b.prevBtnCSS).appendTo(this.prevBtnBox).html(b.prevBtnHtml);this.closeBtnWrapper=a("
").attr(b.closeBtnWrapperAttrs).css(b.closeBtnWrapperCSS).appendTo(this.layout);this.closeBtnBox=a("
").attr(b.closeBtnBoxAttrs).css(b.closeBtnBoxCSS).appendTo(this.closeBtnWrapper);this.closeBtn=a("
").attr(b.closeBtnAttrs).css(b.closeBtnCSS).appendTo(this.closeBtnBox).html(b.closeBtnHtml);this.img=a("").attr(b.imgAttrs).css(b.imgCSS).appendTo(this.layout);this.imgNext=a("").attr(b.imgNextAttrs).css(b.imgNextCSS).appendTo(this.layout);this.imgPrev=a("").attr(b.imgPrevAttrs).css(b.imgPrevCSS).appendTo(this.layout);this.bottom=a("
").attr(b.bottomAttrs).css(b.bottomCSS).appendTo(this.layout);var n=this,j=0,f=null;function k(){var d=f+1;if(d===n.length){d=0}return d}function c(){var d=f-1;if(d===-1){d=n.length-1}return d}function h(){if(j===n.length-1){return m()}else{++j;return g(k())}}function e(){if(j===1-n.length){return m()}else{--j;return g(c())}}function l(d){if(b.keyNext.indexOf(d.which)!==-1){d.preventDefault();h()}else{if(b.keyPrev.indexOf(d.which)!==-1){d.preventDefault();e()}else{if(b.keyClose.indexOf(d.which)!==-1){d.preventDefault();m()}}}}function m(){j=0;n.overlay.fadeOut(b.fadeOut);n.layout.fadeOut(b.fadeOut);a(document).unbind("keydown",l);return false}function g(d){if(d<0||d>n.length-1){return}f=d;n.img.stop().fadeOut(b.fadeOut).removeAttr("src").attr("src",a(n[f]).attr("href"));n.overlay.fadeIn(b.fadeIn);n.layout.fadeIn(b.fadeIn);b.onopen.call(n,n[f]);a(document).unbind("keydown",l).bind("keydown",l);return false}this.img.load(function(){n.img.stop().fadeIn(b.fadeIn);n.imgNext.attr("src",a(n[k()]).attr("href"));n.imgPrev.attr("src",a(n[c()]).attr("href"))});this.img.click(function(){return h()});this.prevBtnWrapper.click(function(){return e()});this.closeBtnWrapper.click(function(){return m()});this.prevBtnWrapper.hover(function(){n.prevBtn.stop().animate(b.prevBtnHoverCSS,b.fadeIn)},function(){n.prevBtn.stop().animate(b.prevBtnCSS,b.fadeOut)});this.closeBtnWrapper.hover(function(){n.closeBtn.stop().animate(b.closeBtnHoverCSS,b.fadeIn)},function(){n.closeBtn.stop().animate(b.closeBtnCSS,b.fadeOut)});this.bottom.hover(function(){n.bottom.stop().animate(b.bottomHoverCSS,b.fadeIn)},function(){n.bottom.stop().animate(b.bottomCSS,b.fadeOut)});return this.each(function(d){a(this).click(function(){return g(d)})})};a.fn.abigimage.defaults={fadeIn:"fast",fadeOut:"fast",prevBtnHtml:"←",closeBtnHtml:"x",keyNext:[13,32,39,40],keyPrev:[8,37,38],keyClose:[27,35,36],onopen:function(){},overlayCSS:{position:"fixed",zIndex:101,top:0,right:0,bottom:0,left:0,display:"none",backgroundColor:"#000",opacity:0.9},layoutCSS:{position:"fixed",zIndex:101,top:0,right:0,bottom:0,left:0,display:"none","-webkit-user-select":"none","-moz-user-select":"none","user-select":"none","-webkit-tap-highlight-color":"rgba(0, 0, 0, 0)",lineHeight:2.5},prevBtnWrapperCSS:{cursor:"pointer",position:"absolute",top:0,right:"50%",bottom:0,left:0},closeBtnWrapperCSS:{cursor:"pointer",position:"absolute",top:0,right:0,bottom:0,left:"50%"},prevBtnBoxCSS:{position:"absolute",zIndex:104,top:0,bottom:0,left:0},closeBtnBoxCSS:{position:"absolute",zIndex:104,top:0,bottom:0,right:0},prevBtnCSS:{color:"#fff",backgroundColor:"#000",opacity:0.5,padding:"0 1em",borderRadius:"0 0 1ex 0"},closeBtnCSS:{color:"#fff",backgroundColor:"#000",opacity:0.5,padding:"0 1em",borderRadius:"0 0 0 1ex"},prevBtnHoverCSS:{opacity:1},closeBtnHoverCSS:{opacity:1},imgCSS:{position:"absolute",zIndex:102,margin:"auto",top:0,right:0,bottom:0,left:0,display:"block",cursor:"pointer",maxWidth:"100%",maxHeight:"100%"},imgNextCSS:{position:"absolute",top:"-10000px",width:"100px"},imgPrevCSS:{position:"absolute",top:"-10000px",width:"100px"},bottomCSS:{position:"absolute",zIndex:103,right:0,bottom:0,left:0,"-webkit-user-select":"text","-moz-user-select":"text","user-select":"text",backgroundColor:"#000",color:"#fff",opacity:0.5,padding:"0 1em",textAlign:"center"},bottomHoverCSS:{opacity:1},overlayAttrs:{},layoutAttrs:{},prevBtnWrapperAttrs:{},prevBtnBoxAttrs:{},prevBtnAttrs:{},closeBtnWrapperAttrs:{},closeBtnBoxAttrs:{},closeBtnAttrs:{},imgAttrs:{},imgNextAttrs:{},imgPrevAttrs:{},bottomAttrs:{}}}(jQuery)); \ No newline at end of file +(function(a){a.fn.abigimage=function(o){var b=a.extend(true,a.fn.abigimage.defaults,o);this.overlay=a("
").attr(b.overlayAttrs).css(b.overlayCSS).appendTo("body");this.layout=a("
").attr(b.layoutAttrs).css(b.layoutCSS).appendTo("body");this.prevBtnWrapper=a("
").attr(b.prevBtnWrapperAttrs).css(b.prevBtnWrapperCSS).appendTo(this.layout);this.prevBtnBox=a("
").attr(b.prevBtnBoxAttrs).css(b.prevBtnBoxCSS).appendTo(this.prevBtnWrapper);this.prevBtn=a("
").attr(b.prevBtnAttrs).css(b.prevBtnCSS).appendTo(this.prevBtnBox).html(b.prevBtnHtml);this.closeBtnWrapper=a("
").attr(b.closeBtnWrapperAttrs).css(b.closeBtnWrapperCSS).appendTo(this.layout);this.closeBtnBox=a("
").attr(b.closeBtnBoxAttrs).css(b.closeBtnBoxCSS).appendTo(this.closeBtnWrapper);this.closeBtn=a("
").attr(b.closeBtnAttrs).css(b.closeBtnCSS).appendTo(this.closeBtnBox).html(b.closeBtnHtml);this.img=a("").attr(b.imgAttrs).css(b.imgCSS).appendTo(this.layout);this.imgNext=a("").attr(b.imgNextAttrs).css(b.imgNextCSS).appendTo(this.layout);this.imgPrev=a("").attr(b.imgPrevAttrs).css(b.imgPrevCSS).appendTo(this.layout);this.bottom=a("
").attr(b.bottomAttrs).css(b.bottomCSS).appendTo(this.layout);var n=this,j=0,f=null;function k(){var d=f+1;if(d===n.length){d=0}return d}function c(){var d=f-1;if(d===-1){d=n.length-1}return d}function h(){if(j===n.length-1){return m()}else{++j;return g(k())}}function e(){if(j===1-n.length){return m()}else{--j;return g(c())}}function l(d){if(b.keyNext.indexOf(d.which)!==-1){d.preventDefault();h()}else{if(b.keyPrev.indexOf(d.which)!==-1){d.preventDefault();e()}else{if(b.keyClose.indexOf(d.which)!==-1){d.preventDefault();m()}}}}function m(){j=0;n.overlay.fadeOut(b.fadeOut);n.layout.fadeOut(b.fadeOut);a(document).unbind("keydown",l);return false}function g(d){if(d<0||d>n.length-1){return}f=d;n.img.removeAttr("src").attr("src",a(n[f]).attr("href"));n.overlay.fadeIn(b.fadeIn);n.layout.fadeIn(b.fadeIn);b.onopen.call(n,n[f]);a(document).unbind("keydown",l).bind("keydown",l);return false}this.img.load(function(){n.imgNext.attr("src",a(n[k()]).attr("href"));n.imgPrev.attr("src",a(n[c()]).attr("href"))});this.img.click(function(){return h()});this.prevBtnWrapper.click(function(){return e()});this.closeBtnWrapper.click(function(){return m()});this.prevBtnWrapper.hover(function(){n.prevBtn.stop().animate(b.prevBtnHoverCSS,b.fadeIn)},function(){n.prevBtn.stop().animate(b.prevBtnCSS,b.fadeOut)});this.closeBtnWrapper.hover(function(){n.closeBtn.stop().animate(b.closeBtnHoverCSS,b.fadeIn)},function(){n.closeBtn.stop().animate(b.closeBtnCSS,b.fadeOut)});this.bottom.hover(function(){n.bottom.stop().animate(b.bottomHoverCSS,b.fadeIn)},function(){n.bottom.stop().animate(b.bottomCSS,b.fadeOut)});return this.each(function(d){a(this).click(function(){return g(d)})})};a.fn.abigimage.defaults={fadeIn:"fast",fadeOut:"fast",prevBtnHtml:"←",closeBtnHtml:"x",keyNext:[13,32,39,40],keyPrev:[8,37,38],keyClose:[27,35,36],onopen:function(){},overlayCSS:{position:"fixed",zIndex:101,top:0,right:0,bottom:0,left:0,display:"none",backgroundColor:"#000",opacity:0.9},layoutCSS:{position:"fixed",zIndex:101,top:0,right:0,bottom:0,left:0,display:"none","-webkit-user-select":"none","-moz-user-select":"none","user-select":"none","-webkit-tap-highlight-color":"rgba(0, 0, 0, 0)",lineHeight:2.5},prevBtnWrapperCSS:{cursor:"pointer",position:"absolute",top:0,right:"50%",bottom:0,left:0},closeBtnWrapperCSS:{cursor:"pointer",position:"absolute",top:0,right:0,bottom:0,left:"50%"},prevBtnBoxCSS:{position:"absolute",zIndex:104,top:0,bottom:0,left:0},closeBtnBoxCSS:{position:"absolute",zIndex:104,top:0,bottom:0,right:0},prevBtnCSS:{color:"#fff",backgroundColor:"#000",opacity:0.5,padding:"0 1em",borderRadius:"0 0 1ex 0"},closeBtnCSS:{color:"#fff",backgroundColor:"#000",opacity:0.5,padding:"0 1em",borderRadius:"0 0 0 1ex"},prevBtnHoverCSS:{opacity:1},closeBtnHoverCSS:{opacity:1},imgCSS:{position:"absolute",zIndex:102,margin:"auto",width:"auto",top:0,right:0,bottom:0,left:0,display:"block",cursor:"pointer",maxWidth:"100%",maxHeight:"100%"},imgNextCSS:{position:"absolute",top:"-10000px",left:0,width:"1px"},imgPrevCSS:{position:"absolute",top:"-10000px",left:0,width:"1px"},bottomCSS:{position:"absolute",zIndex:103,right:0,bottom:0,left:0,"-webkit-user-select":"text","-moz-user-select":"text","user-select":"text",backgroundColor:"#000",color:"#fff",opacity:0.5,padding:"0 1em",textAlign:"center"},bottomHoverCSS:{opacity:1},overlayAttrs:{},layoutAttrs:{},prevBtnWrapperAttrs:{},prevBtnBoxAttrs:{},prevBtnAttrs:{},closeBtnWrapperAttrs:{},closeBtnBoxAttrs:{},closeBtnAttrs:{},imgAttrs:{},imgNextAttrs:{},imgPrevAttrs:{},bottomAttrs:{}}}(jQuery)); \ No newline at end of file