diff --git a/README.md b/README.md index 2d91b878..7e751a16 100644 --- a/README.md +++ b/README.md @@ -60,22 +60,23 @@ $( '.swipebox' ).swipebox(); ###Options ```javascript -useCSS : true, // false will force the use of jQuery for animations +useCSS: true, // false will force the use of jQuery for animations +useSVG: true, // false will force using of PNG images, instead of scalable vector graphics as CSS initialIndexOnArray: 0, // which image index to init when a array is passed removeBarsOnMobile : true, // false will show top navigation bar on mobile devices hideCloseButtonOnMobile : false, // true will hide the close button on mobile devices removeBarsOnMobile : true, // false will show bottom bar on mobile devices hideBarsDelay : 3000, // delay before hiding bars on desktop videoMaxWidth : 1140, // videos max width -beforeOpen: function(){} , // called before opening +beforeOpen: function(){}, // called before opening afterOpen: null, // called after opening afterClose: function(){}, // called after closing afterMedia: function(){}, // called after media is loaded loopAtEnd: false, // true will return to the first image after the last image is reached -autoplayVideos: false // true will autoplay Youtube and Vimeo videos -queryStringData: {} // plain object with custom query string arguments to pass/override for video URLs, -toggleClassOnLoad: '' // CSS class that can be toggled when the slide will be loaded (like 'hidden' of Bootstrap) -useSVG: true +autoplayVideos: false, // true will autoplay Youtube and Vimeo videos +queryStringData: {}, // plain object with custom query string arguments to pass/override for video URLs, +toggleClassOnLoad: '', // CSS class that can be toggled when the slide will be loaded (like 'hidden' of Bootstrap) +closeOnBack: false // true will close the SwipeBox and remain on same URL upon clicking back button ``` ###Pull Requests diff --git a/index.html b/index.html index 2ae366f6..0d454381 100644 --- a/index.html +++ b/index.html @@ -228,6 +228,7 @@

Options

afterOpen: null, // called after opening afterClose: function() {}, // called after closing loopAtEnd: false // true will return to the first image after the last image is reached + closeOnBack: false // true will close the SwipeBox and remain on same URL upon clicking back button } ); } )( jQuery ); diff --git a/src/js/jquery.swipebox.js b/src/js/jquery.swipebox.js index f2fd0155..9a4667a5 100644 --- a/src/js/jquery.swipebox.js +++ b/src/js/jquery.swipebox.js @@ -24,7 +24,8 @@ loopAtEnd: false, autoplayVideos: false, queryStringData: {}, - toggleClassOnLoad: '' + toggleClassOnLoad: '', + closeOnBack: false }, plugin = this, @@ -587,6 +588,15 @@ $( '#swipebox-close' ).bind( action, function() { $this.closeSlide(); } ); + + if (plugin.settings.closeOnBack && window.onpopstate === null) { + var thislocation = document.location.href; + window.onpopstate = function() { + window.onpopstate = null; + window.location.replace(thislocation); + $this.closeSlide(); + }; + } }, /** @@ -909,6 +919,9 @@ * Close */ closeSlide : function () { + if (plugin.settings.closeOnBack) { + window.onpopstate = null; + } $( 'html' ).removeClass( 'swipebox-html' ); $( 'html' ).removeClass( 'swipebox-touch' ); $( window ).trigger( 'resize' ); diff --git a/src/js/jquery.swipebox.min.js b/src/js/jquery.swipebox.min.js index 3c851baa..f4b2a524 100644 --- a/src/js/jquery.swipebox.min.js +++ b/src/js/jquery.swipebox.min.js @@ -1,2 +1,2 @@ /*! Swipebox v1.4.4 | Constantin Saguin csag.co | MIT License | github.com/brutaldesign/swipebox */ -!function(a,b,c,d){c.swipebox=function(e,f){var g,h,i={useCSS:!0,useSVG:!0,initialIndexOnArray:0,removeBarsOnMobile:!0,hideCloseButtonOnMobile:!1,hideBarsDelay:3e3,videoMaxWidth:1140,vimeoColor:"cccccc",beforeOpen:null,afterOpen:null,afterClose:null,afterMedia:null,nextSlide:null,prevSlide:null,loopAtEnd:!1,autoplayVideos:!1,queryStringData:{},toggleClassOnLoad:""},j=this,k=[],l=e.selector,m=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i),n=null!==m||b.createTouch!==d||"ontouchstart"in a||"onmsgesturechange"in a||navigator.msMaxTouchPoints,o=!!b.createElementNS&&!!b.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,p=a.innerWidth?a.innerWidth:c(a).width(),q=a.innerHeight?a.innerHeight:c(a).height(),r=0,s='
';j.settings={},c.swipebox.close=function(){g.closeSlide()},c.swipebox.extend=function(){return g},j.init=function(){j.settings=c.extend({},i,f),c.isArray(e)?(k=e,g.target=c(a),g.init(j.settings.initialIndexOnArray)):c(b).on("click",l,function(a){if("slide current"===a.target.parentNode.className)return!1;c.isArray(e)||(g.destroy(),h=c(l),g.actions()),k=[];var b,d,f;f||(d="data-rel",f=c(this).attr(d)),f||(d="rel",f=c(this).attr(d)),h=f&&""!==f&&"nofollow"!==f?c(l).filter("["+d+'="'+f+'"]'):c(l),h.each(function(){var a=null,b=null;c(this).attr("title")&&(a=c(this).attr("title")),c(this).attr("href")&&(b=c(this).attr("href")),k.push({href:b,title:a})}),b=h.index(c(this)),a.preventDefault(),a.stopPropagation(),g.target=c(a.target),g.init(b)})},g={init:function(a){j.settings.beforeOpen&&j.settings.beforeOpen(),this.target.trigger("swipebox-start"),c.swipebox.isOpen=!0,this.build(),this.openSlide(a),this.openMedia(a),this.preloadMedia(a+1),this.preloadMedia(a-1),j.settings.afterOpen&&j.settings.afterOpen(a)},build:function(){var a,b=this;c("body").append(s),o&&j.settings.useSVG===!0&&(a=c("#swipebox-close").css("background-image"),a=a.replace("png","svg"),c("#swipebox-prev, #swipebox-next, #swipebox-close").css({"background-image":a})),m&&j.settings.removeBarsOnMobile&&c("#swipebox-bottom-bar, #swipebox-top-bar").remove(),c.each(k,function(){c("#swipebox-slider").append('
')}),b.setDim(),b.actions(),n&&b.gesture(),b.keyboard(),b.animBars(),b.resize()},setDim:function(){var b,d,e={};"onorientationchange"in a?a.addEventListener("orientationchange",function(){0===a.orientation?(b=p,d=q):(90===a.orientation||-90===a.orientation)&&(b=q,d=p)},!1):(b=a.innerWidth?a.innerWidth:c(a).width(),d=a.innerHeight?a.innerHeight:c(a).height()),e={width:b,height:d},c("#swipebox-overlay").css(e)},resize:function(){var b=this;c(a).resize(function(){b.setDim()}).resize()},supportTransition:function(){var a,c="transition WebkitTransition MozTransition OTransition msTransition KhtmlTransition".split(" ");for(a=0;a=m||i)){var q=.75-Math.abs(d)/s.height();s.css({top:d+"px"}),s.css({opacity:q}),i=!0}e=b,b=o.pageX-n.pageX,g=100*b/p,!j&&!i&&Math.abs(b)>=l&&(c("#swipebox-slider").css({"-webkit-transition":"",transition:""}),j=!0),j&&(b>0?0===a?c("#swipebox-overlay").addClass("leftSpringTouch"):(c("#swipebox-overlay").removeClass("leftSpringTouch").removeClass("rightSpringTouch"),c("#swipebox-slider").css({"-webkit-transform":"translate3d("+(r+g)+"%, 0, 0)",transform:"translate3d("+(r+g)+"%, 0, 0)"})):0>b&&(k.length===a+1?c("#swipebox-overlay").addClass("rightSpringTouch"):(c("#swipebox-overlay").removeClass("leftSpringTouch").removeClass("rightSpringTouch"),c("#swipebox-slider").css({"-webkit-transform":"translate3d("+(r+g)+"%, 0, 0)",transform:"translate3d("+(r+g)+"%, 0, 0)"}))))}),!1}).bind("touchend",function(a){if(a.preventDefault(),a.stopPropagation(),c("#swipebox-slider").css({"-webkit-transition":"-webkit-transform 0.4s ease",transition:"transform 0.4s ease"}),d=o.pageY-n.pageY,b=o.pageX-n.pageX,g=100*b/p,i)if(i=!1,Math.abs(d)>=2*m&&Math.abs(d)>Math.abs(f)){var k=d>0?s.height():-s.height();s.animate({top:k+"px",opacity:0},300,function(){h.closeSlide()})}else s.animate({top:0,opacity:1},300);else j?(j=!1,b>=l&&b>=e?h.getPrev():-l>=b&&e>=b&&h.getNext()):q.hasClass("visible-bars")?(h.clearTimeout(),h.hideBars()):(h.showBars(),h.setTimeout());c("#swipebox-slider").css({"-webkit-transform":"translate3d("+r+"%, 0, 0)",transform:"translate3d("+r+"%, 0, 0)"}),c("#swipebox-overlay").removeClass("leftSpringTouch").removeClass("rightSpringTouch"),c(".touching").off("touchmove").removeClass("touching")})},setTimeout:function(){if(j.settings.hideBarsDelay>0){var b=this;b.clearTimeout(),b.timeout=a.setTimeout(function(){b.hideBars()},j.settings.hideBarsDelay)}},clearTimeout:function(){a.clearTimeout(this.timeout),this.timeout=null},showBars:function(){var a=c("#swipebox-top-bar, #swipebox-bottom-bar");this.doCssTrans()?a.addClass("visible-bars"):(c("#swipebox-top-bar").animate({top:0},500),c("#swipebox-bottom-bar").animate({bottom:0},500),setTimeout(function(){a.addClass("visible-bars")},1e3))},hideBars:function(){var a=c("#swipebox-top-bar, #swipebox-bottom-bar");this.doCssTrans()?a.removeClass("visible-bars"):(c("#swipebox-top-bar").animate({top:"-50px"},500),c("#swipebox-bottom-bar").animate({bottom:"-50px"},500),setTimeout(function(){a.removeClass("visible-bars")},1e3))},animBars:function(){var a=this,b=c("#swipebox-top-bar, #swipebox-bottom-bar");b.addClass("visible-bars"),a.setTimeout(),c("#swipebox-slider").click(function(){b.hasClass("visible-bars")||(a.showBars(),a.setTimeout())}),c("#swipebox-bottom-bar").hover(function(){a.showBars(),b.addClass("visible-bars"),a.clearTimeout()},function(){j.settings.hideBarsDelay>0&&(b.removeClass("visible-bars"),a.setTimeout())})},keyboard:function(){var b=this;c(a).bind("keyup",function(a){a.preventDefault(),a.stopPropagation(),37===a.keyCode?b.getPrev():39===a.keyCode?b.getNext():27===a.keyCode&&b.closeSlide()})},actions:function(){var a=this,b="touchend click";k.length<2?(c("#swipebox-bottom-bar").hide(),d===k[1]&&c("#swipebox-top-bar").hide()):(c("#swipebox-prev").bind(b,function(b){b.preventDefault(),b.stopPropagation(),a.getPrev(),a.setTimeout()}),c("#swipebox-next").bind(b,function(b){b.preventDefault(),b.stopPropagation(),a.getNext(),a.setTimeout()})),c("#swipebox-close").bind(b,function(){a.closeSlide()})},setSlide:function(a,b){b=b||!1;var d=c("#swipebox-slider");r=100*-a,this.doCssTrans()?d.css({"-webkit-transform":"translate3d("+100*-a+"%, 0, 0)",transform:"translate3d("+100*-a+"%, 0, 0)"}):d.animate({left:100*-a+"%"}),c("#swipebox-slider .slide").removeClass("current"),c("#swipebox-slider .slide").eq(a).addClass("current"),this.setTitle(a),b&&d.fadeIn(),c("#swipebox-prev, #swipebox-next").removeClass("disabled"),0===a?c("#swipebox-prev").addClass("disabled"):a===k.length-1&&j.settings.loopAtEnd!==!0&&c("#swipebox-next").addClass("disabled")},openSlide:function(b){c("html").addClass("swipebox-html"),n?(c("html").addClass("swipebox-touch"),j.settings.hideCloseButtonOnMobile&&c("html").addClass("swipebox-no-close-button")):c("html").addClass("swipebox-no-touch"),c(a).trigger("resize"),this.setSlide(b,!0)},preloadMedia:function(a){var b=this,c=null;k[a]!==d&&(c=k[a].href),b.isVideo(c)?b.openMedia(a):setTimeout(function(){b.openMedia(a)},1e3)},openMedia:function(a){var b,e,f=this;return k[a]!==d&&(b=k[a].href),0>a||a>=k.length?!1:(e=c("#swipebox-slider .slide").eq(a),void(f.isVideo(b)?(e.html(f.getVideo(b)),j.settings.afterMedia&&j.settings.afterMedia(a)):(e.addClass("slide-loading"),f.loadMedia(b,function(){e.removeClass("slide-loading"),e.html(this),j.settings.afterMedia&&j.settings.afterMedia(a)}))))},setTitle:function(a){var b=null;c("#swipebox-title").empty(),k[a]!==d&&(b=k[a].title),b?(c("#swipebox-top-bar").show(),c("#swipebox-title").append(b)):c("#swipebox-top-bar").hide()},isVideo:function(a){if(a){if(a.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||a.match(/vimeo\.com\/([0-9]*)/)||a.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/))return!0;if(a.toLowerCase().indexOf("swipeboxvideo=1")>=0)return!0}},parseUri:function(a,d){var e=b.createElement("a"),f={};return e.href=decodeURIComponent(a),e.search&&(f=JSON.parse('{"'+e.search.toLowerCase().replace("?","").replace(/&/g,'","').replace(/=/g,'":"')+'"}')),c.isPlainObject(d)&&(f=c.extend(f,d,j.settings.queryStringData)),c.map(f,function(a,b){return a&&a>""?encodeURIComponent(b)+"="+encodeURIComponent(a):void 0}).join("&")},getVideo:function(a){var b="",c=a.match(/((?:www\.)?youtube\.com|(?:www\.)?youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/),d=a.match(/(?:www\.)?youtu\.be\/([a-zA-Z0-9\-_]+)/),e=a.match(/(?:www\.)?vimeo\.com\/([0-9]*)/),f="";return c||d?(d&&(c=d),f=g.parseUri(a,{autoplay:j.settings.autoplayVideos?"1":"0",v:""}),b=''):e?(f=g.parseUri(a,{autoplay:j.settings.autoplayVideos?"1":"0",byline:"0",portrait:"0",color:j.settings.vimeoColor}),b=''):b='','
'+b+"
"},loadMedia:function(a,b){if(0===a.trim().indexOf("#"))b.call(c("
",{"class":"swipebox-inline-container"}).append(c(a).clone().toggleClass(j.settings.toggleClassOnLoad)));else if(!this.isVideo(a)){var d=c("").on("load",function(){b.call(d)});d.attr("src",a)}},getNext:function(){var a,b=this,d=c("#swipebox-slider .slide").index(c("#swipebox-slider .slide.current"));d+10?(a=c("#swipebox-slider .slide").eq(b).contents().find("iframe").attr("src"),c("#swipebox-slider .slide").eq(b).contents().find("iframe").attr("src",a),b--,this.setSlide(b),this.preloadMedia(b-1),j.settings.prevSlide&&j.settings.prevSlide(b)):(c("#swipebox-overlay").addClass("leftSpring"),setTimeout(function(){c("#swipebox-overlay").removeClass("leftSpring")},500))},nextSlide:function(a){},prevSlide:function(a){},closeSlide:function(){c("html").removeClass("swipebox-html"),c("html").removeClass("swipebox-touch"),c(a).trigger("resize"),this.destroy()},destroy:function(){c(a).unbind("keyup"),c("body").unbind("touchstart"),c("body").unbind("touchmove"),c("body").unbind("touchend"),c("#swipebox-slider").unbind(),c("#swipebox-overlay").remove(),c.isArray(e)||e.removeData("_swipebox"),this.target&&this.target.trigger("swipebox-destroy"),c.swipebox.isOpen=!1,j.settings.afterClose&&j.settings.afterClose()}},j.init()},c.fn.swipebox=function(a){if(!c.data(this,"_swipebox")){var b=new c.swipebox(this,a);this.data("_swipebox",b)}return this.data("_swipebox")}}(window,document,jQuery); \ No newline at end of file +;(function(b,a,c,d){c.swipebox=function(i,s){var r,m={useCSS:true,useSVG:true,initialIndexOnArray:0,removeBarsOnMobile:true,hideCloseButtonOnMobile:false,hideBarsDelay:3000,videoMaxWidth:1140,vimeoColor:"cccccc",beforeOpen:null,afterOpen:null,afterClose:null,afterMedia:null,nextSlide:null,prevSlide:null,loopAtEnd:false,autoplayVideos:false,queryStringData:{},toggleClassOnLoad:"",closeOnBack:false},p=this,e=[],f,j=i.selector,q=navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)|(Android)|(PlayBook)|(BB10)|(BlackBerry)|(Opera Mini)|(IEMobile)|(webOS)|(MeeGo)/i),l=q!==null||a.createTouch!==d||("ontouchstart" in b)||("onmsgesturechange" in b)||navigator.msMaxTouchPoints,n=!!a.createElementNS&&!!a.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,h=b.innerWidth?b.innerWidth:c(b).width(),k=b.innerHeight?b.innerHeight:c(b).height(),g=0,o='
';p.settings={};c.swipebox.close=function(){r.closeSlide()};c.swipebox.extend=function(){return r};p.init=function(){p.settings=c.extend({},m,s);if(c.isArray(i)){e=i;r.target=c(b);r.init(p.settings.initialIndexOnArray)}else{c(a).on("click",j,function(v){if(v.target.parentNode.className==="slide current"){return false}if(!c.isArray(i)){r.destroy();f=c(j);r.actions()}e=[];var t,u,w;if(!w){u="data-rel";w=c(this).attr(u)}if(!w){u="rel";w=c(this).attr(u)}if(w&&w!==""&&w!=="nofollow"){f=c(j).filter("["+u+'="'+w+'"]')}else{f=c(j)}f.each(function(){var y=null,x=null;if(c(this).attr("title")){y=c(this).attr("title")}if(c(this).attr("href")){x=c(this).attr("href")}e.push({href:x,title:y})});t=f.index(c(this));v.preventDefault();v.stopPropagation();r.target=c(v.target);r.init(t)})}};r={init:function(t){if(p.settings.beforeOpen){p.settings.beforeOpen()}this.target.trigger("swipebox-start");c.swipebox.isOpen=true;this.build();this.openSlide(t);this.openMedia(t);this.preloadMedia(t+1);this.preloadMedia(t-1);if(p.settings.afterOpen){p.settings.afterOpen(t)}},build:function(){var u=this,t;c("body").append(o);if(n&&p.settings.useSVG===true){t=c("#swipebox-close").css("background-image");t=t.replace("png","svg");c("#swipebox-prev, #swipebox-next, #swipebox-close").css({"background-image":t})}if(q&&p.settings.removeBarsOnMobile){c("#swipebox-bottom-bar, #swipebox-top-bar").remove()}c.each(e,function(){c("#swipebox-slider").append('
')});u.setDim();u.actions();if(l){u.gesture()}u.keyboard();u.animBars();u.resize()},setDim:function(){var v,t,u={};if("onorientationchange" in b){b.addEventListener("orientationchange",function(){if(b.orientation===0){v=h;t=k}else{if(b.orientation===90||b.orientation===-90){v=k;t=h}}},false)}else{v=b.innerWidth?b.innerWidth:c(b).width();t=b.innerHeight?b.innerHeight:c(b).height()}u={width:v,height:t};c("#swipebox-overlay").css(u)},resize:function(){var t=this;c(b).resize(function(){t.setDim()}).resize()},supportTransition:function(){var u="transition WebkitTransition MozTransition OTransition msTransition KhtmlTransition".split(" "),t;for(t=0;t=B||x){var J=0.75-Math.abs(E)/u.height();u.css({top:E+"px"});u.css({opacity:J});x=true}}w=F;F=t.pageX-G.pageX;A=F*100/h;if(!v&&!x&&Math.abs(F)>=z){c("#swipebox-slider").css({"-webkit-transition":"",transition:""});v=true}if(v){if(0F){if(e.length===C+1){c("#swipebox-overlay").addClass("rightSpringTouch")}else{c("#swipebox-overlay").removeClass("leftSpringTouch").removeClass("rightSpringTouch");c("#swipebox-slider").css({"-webkit-transform":"translate3d("+(g+A)+"%, 0, 0)",transform:"translate3d("+(g+A)+"%, 0, 0)"})}}}}});return false}).bind("touchend",function(I){I.preventDefault();I.stopPropagation();c("#swipebox-slider").css({"-webkit-transition":"-webkit-transform 0.4s ease",transition:"transform 0.4s ease"});E=t.pageY-G.pageY;F=t.pageX-G.pageX;A=F*100/h;if(x){x=false;if(Math.abs(E)>=2*B&&Math.abs(E)>Math.abs(y)){var J=E>0?u.height():-u.height();u.animate({top:J+"px",opacity:0},300,function(){D.closeSlide()})}else{u.animate({top:0,opacity:1},300)}}else{if(v){v=false;if(F>=z&&F>=w){D.getPrev()}else{if(F<=-z&&F<=w){D.getNext()}}}else{if(!H.hasClass("visible-bars")){D.showBars();D.setTimeout()}else{D.clearTimeout();D.hideBars()}}}c("#swipebox-slider").css({"-webkit-transform":"translate3d("+g+"%, 0, 0)",transform:"translate3d("+g+"%, 0, 0)"});c("#swipebox-overlay").removeClass("leftSpringTouch").removeClass("rightSpringTouch");c(".touching").off("touchmove").removeClass("touching")})},setTimeout:function(){if(p.settings.hideBarsDelay>0){var t=this;t.clearTimeout();t.timeout=b.setTimeout(function(){t.hideBars()},p.settings.hideBarsDelay)}},clearTimeout:function(){b.clearTimeout(this.timeout);this.timeout=null},showBars:function(){var t=c("#swipebox-top-bar, #swipebox-bottom-bar");if(this.doCssTrans()){t.addClass("visible-bars")}else{c("#swipebox-top-bar").animate({top:0},500);c("#swipebox-bottom-bar").animate({bottom:0},500);setTimeout(function(){t.addClass("visible-bars")},1000)}},hideBars:function(){var t=c("#swipebox-top-bar, #swipebox-bottom-bar");if(this.doCssTrans()){t.removeClass("visible-bars")}else{c("#swipebox-top-bar").animate({top:"-50px"},500);c("#swipebox-bottom-bar").animate({bottom:"-50px"},500);setTimeout(function(){t.removeClass("visible-bars")},1000)}},animBars:function(){var u=this,t=c("#swipebox-top-bar, #swipebox-bottom-bar");t.addClass("visible-bars");u.setTimeout();c("#swipebox-slider").click(function(){if(!t.hasClass("visible-bars")){u.showBars();u.setTimeout()}});c("#swipebox-bottom-bar").hover(function(){u.showBars();t.addClass("visible-bars");u.clearTimeout()},function(){if(p.settings.hideBarsDelay>0){t.removeClass("visible-bars");u.setTimeout()}})},keyboard:function(){var t=this;c(b).bind("keyup",function(u){u.preventDefault();u.stopPropagation();if(u.keyCode===37){t.getPrev()}else{if(u.keyCode===39){t.getNext()}else{if(u.keyCode===27){t.closeSlide()}}}})},actions:function(){var v=this,t="touchend click";if(e.length<2){c("#swipebox-bottom-bar").hide();if(d===e[1]){c("#swipebox-top-bar").hide()}}else{c("#swipebox-prev").bind(t,function(w){w.preventDefault();w.stopPropagation();v.getPrev();v.setTimeout()});c("#swipebox-next").bind(t,function(w){w.preventDefault();w.stopPropagation();v.getNext();v.setTimeout()})}c("#swipebox-close").bind(t,function(){v.closeSlide()});if(p.settings.closeOnBack&&b.onpopstate===null){var u=a.location.href;b.onpopstate=function(){b.onpopstate=null;b.location.replace(u);v.closeSlide()}}},setSlide:function(u,t){t=t||false;var v=c("#swipebox-slider");g=-u*100;if(this.doCssTrans()){v.css({"-webkit-transform":"translate3d("+(-u*100)+"%, 0, 0)",transform:"translate3d("+(-u*100)+"%, 0, 0)"})}else{v.animate({left:(-u*100)+"%"})}c("#swipebox-slider .slide").removeClass("current");c("#swipebox-slider .slide").eq(u).addClass("current");this.setTitle(u);if(t){v.fadeIn()}c("#swipebox-prev, #swipebox-next").removeClass("disabled");if(u===0){c("#swipebox-prev").addClass("disabled")}else{if(u===e.length-1&&p.settings.loopAtEnd!==true){c("#swipebox-next").addClass("disabled")}}},openSlide:function(t){c("html").addClass("swipebox-html");if(l){c("html").addClass("swipebox-touch");if(p.settings.hideCloseButtonOnMobile){c("html").addClass("swipebox-no-close-button")}}else{c("html").addClass("swipebox-no-touch")}c(b).trigger("resize");this.setSlide(t,true)},preloadMedia:function(t){var u=this,v=null;if(e[t]!==d){v=e[t].href}if(!u.isVideo(v)){setTimeout(function(){u.openMedia(t)},1000)}else{u.openMedia(t)}},openMedia:function(u){var v=this,w,t;if(e[u]!==d){w=e[u].href}if(u<0||u>=e.length){return false}t=c("#swipebox-slider .slide").eq(u);if(!v.isVideo(w)){t.addClass("slide-loading");v.loadMedia(w,function(){t.removeClass("slide-loading");t.html(this);if(p.settings.afterMedia){p.settings.afterMedia(u)}})}else{t.html(v.getVideo(w));if(p.settings.afterMedia){p.settings.afterMedia(u)}}},setTitle:function(t){var u=null;c("#swipebox-title").empty();if(e[t]!==d){u=e[t].title}if(u){c("#swipebox-top-bar").show();c("#swipebox-title").append(u)}else{c("#swipebox-top-bar").hide()}},isVideo:function(t){if(t){if(t.match(/(youtube\.com|youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/)||t.match(/vimeo\.com\/([0-9]*)/)||t.match(/youtu\.be\/([a-zA-Z0-9\-_]+)/)){return true}if(t.toLowerCase().indexOf("swipeboxvideo=1")>=0){return true}}},parseUri:function(v,w){var u=a.createElement("a"),t={};u.href=decodeURIComponent(v);if(u.search){t=JSON.parse('{"'+u.search.toLowerCase().replace("?","").replace(/&/g,'","').replace(/=/g,'":"')+'"}')}if(c.isPlainObject(w)){t=c.extend(t,w,p.settings.queryStringData)}return c.map(t,function(y,x){if(y&&y>""){return encodeURIComponent(x)+"="+encodeURIComponent(y)}}).join("&")},getVideo:function(v){var x="",u=v.match(/((?:www\.)?youtube\.com|(?:www\.)?youtube-nocookie\.com)\/watch\?v=([a-zA-Z0-9\-_]+)/),w=v.match(/(?:www\.)?youtu\.be\/([a-zA-Z0-9\-_]+)/),y=v.match(/(?:www\.)?vimeo\.com\/([0-9]*)/),t="";if(u||w){if(w){u=w}t=r.parseUri(v,{autoplay:(p.settings.autoplayVideos?"1":"0"),v:""});x=''}else{if(y){t=r.parseUri(v,{autoplay:(p.settings.autoplayVideos?"1":"0"),byline:"0",portrait:"0",color:p.settings.vimeoColor});x=''}else{x=''}}return'
'+x+"
"},loadMedia:function(u,v){if(u.trim().indexOf("#")===0){v.call(c("
",{"class":"swipebox-inline-container"}).append(c(u).clone().toggleClass(p.settings.toggleClassOnLoad)))}else{if(!this.isVideo(u)){var t=c("").on("load",function(){v.call(t)});t.attr("src",u)}}},getNext:function(){var u=this,v,t=c("#swipebox-slider .slide").index(c("#swipebox-slider .slide.current"));if(t+10){u=c("#swipebox-slider .slide").eq(t).contents().find("iframe").attr("src");c("#swipebox-slider .slide").eq(t).contents().find("iframe").attr("src",u);t--;this.setSlide(t);this.preloadMedia(t-1);if(p.settings.prevSlide){p.settings.prevSlide(t)}}else{c("#swipebox-overlay").addClass("leftSpring");setTimeout(function(){c("#swipebox-overlay").removeClass("leftSpring")},500)}},nextSlide:function(t){},prevSlide:function(t){},closeSlide:function(){if(p.settings.closeOnBack){b.onpopstate=null}c("html").removeClass("swipebox-html");c("html").removeClass("swipebox-touch");c(b).trigger("resize");this.destroy()},destroy:function(){c(b).unbind("keyup");c("body").unbind("touchstart");c("body").unbind("touchmove");c("body").unbind("touchend");c("#swipebox-slider").unbind();c("#swipebox-overlay").remove();if(!c.isArray(i)){i.removeData("_swipebox")}if(this.target){this.target.trigger("swipebox-destroy")}c.swipebox.isOpen=false;if(p.settings.afterClose){p.settings.afterClose()}}};p.init()};c.fn.swipebox=function(f){if(!c.data(this,"_swipebox")){var e=new c.swipebox(this,f);this.data("_swipebox",e)}return this.data("_swipebox")}}(window,document,jQuery)); \ No newline at end of file