/** * pgwslideshow - version 2.0 * * copyright 2014, jonathan m. piat * http://pgwjs.com - http://pagawa.com * * released under the gnu gplv3 license - http://opensource.org/licenses/gpl-3.0 */ (function(a){a.fn.pgwslideshow=function(q){var i={mainclassname:"pgwslideshow",transitioneffect:"sliding",displaylist:true,displaycontrols:true,touchcontrols:true,autoslide:false,beforeslide:false,afterslide:false,maxheight:null,adaptiveduration:200,transitionduration:500,intervalduration:3000};if(this.length==0){return this}else{if(this.length>1){this.each(function(){a(this).pgwslideshow(q)});return this}}var j=this;j.plugin=this;j.config={};j.data=[];j.currentslide=0;j.slidecount=0;j.resizeevent=null;j.intervalevent=null;j.touchfirstposition=null;j.touchlistlastposition=false;j.window=a(window);var p=function(){j.config=a.extend({},i,q);g();if(j.config.displaylist){b()}j.window.resize(function(){cleartimeout(j.resizeevent);j.resizeevent=settimeout(function(){e();var r=j.plugin.find(".ps-current > ul > li.elt_"+j.currentslide+" img").height();h(r);if(j.config.displaylist){b();n()}},100)});if(j.config.autoslide){k()}return true};var h=function(r,s){if(j.config.maxheight){if(r+j.plugin.find(".ps-list").height()>j.config.maxheight){r=j.config.maxheight-j.plugin.find(".ps-list").height()}}if(typeof j.plugin.find(".ps-current").animate=="function"){j.plugin.find(".ps-current").stop().animate({height:r},j.config.adaptiveduration,function(){if(j.config.maxheight){j.plugin.find(".ps-current > ul > li img").css("max-height",r+"px")}})}else{j.plugin.find(".ps-current").css("height",r);if(j.config.maxheight){j.plugin.find(".ps-current > ul > li img").css("max-height",r+"px")}}return true};var c=function(){var r=0;j.plugin.show();j.plugin.find(".ps-list > ul > li").show().each(function(){r+=a(this).width()});j.plugin.find(".ps-list > ul").width(r);return true};var e=function(){if(j.plugin.width()<=640){j.plugin.addclass("pgw-narrow").removeclass("pgw-wide")}else{j.plugin.addclass("pgw-wide").removeclass("pgw-narrow")}return true};var g=function(){j.plugin.removeclass("pgwslideshow").removeclass(j.config.mainclassname);j.plugin.wrap('
');j.plugin=j.plugin.parent();j.plugin.wrap('');j.plugin=j.plugin.parent();j.plugin.prepend('"+r.description+"
"}if(t!=""){if(r.link){t='"+t+""}if(typeof j.plugin.find(".ps-caption").fadein=="function"){j.plugin.find(".ps-caption").html(t);j.plugin.find(".ps-caption").fadein(j.config.transitionduration/2)}else{j.plugin.find(".ps-caption").html(t);j.plugin.find(".ps-caption").show()}}j.plugin.find(".ps-list > ul > li .ps-item").removeclass("ps-selected");j.plugin.find(".ps-list > ul > li.elt_"+r.id+" .ps-item").addclass("ps-selected");if(j.config.displaylist){b();n()}if(j.config.displaycontrols){if(typeof j.plugin.find(".ps-current > .ps-prev").fadein=="function"){j.plugin.find(".ps-current > .ps-prev, .ps-current > .ps-next").fadein(j.config.transitionduration/2)}else{j.plugin.find(".ps-current > .ps-prev, .ps-current > .ps-next").show()}}if(typeof j.config.afterslide=="function"){j.config.afterslide(r.id)}var s=j.plugin.find(".ps-current .elt_"+r.id+" img").height();h(s,true);return true};var f=function(u){var t=j.plugin.find(".ps-current > ul");t.find("li").not(".elt_"+j.currentslide).not(".elt_"+u.id).each(function(){if(typeof a(this).stop=="function"){a(this).stop()}a(this).css("position","").css("z-index",1).hide()});if(j.currentslide>0){var r=t.find(".elt_"+j.currentslide);if(typeof r.animate!="function"){r.animate=function(v,w,x){r.css(v);if(x){x()}}}if(typeof r.stop=="function"){r.stop()}r.css("position","absolute").animate({opacity:0},j.config.transitionduration,function(){r.css("position","").css("z-index",1).hide()})}j.currentslide=u.id;var s=t.find(".elt_"+u.id);if(typeof s.animate!="function"){s.animate=function(v,w,x){s.css(v);if(x){x()}}}if(typeof s.stop=="function"){s.stop()}s.css("position","absolute").show().animate({opacity:1},j.config.transitionduration,function(){s.css("position","").css("z-index",2).css("display","block");m(u)});return true};var o=function(v,y){var u=j.plugin.find(".ps-current > ul");if(typeof y=="undefined"){y="left"}if(j.currentslide==0){u.find(".elt_1").css({position:"",left:"",opacity:1,"z-index":2}).show();j.plugin.find(".ps-list > li.elt_1").css("opacity","1");m(v)}else{if(j.transitioninprogress){return false}j.transitioninprogress=true;var x=u.width();if(y=="left"){var r=-x;var w=x}else{var r=x;var w=-x}var s=u.find(".elt_"+j.currentslide);if(typeof s.animate!="function"){s.animate=function(z,a,b){s.css(z);if(b){b()}}}s.css("position","absolute").animate({left:r},j.config.transitionduration,function(){s.css("position","").css("z-index",1).css("left","").css("opacity",0).hide()});var t=u.find(".elt_"+v.id);if(typeof t.animate!="function"){t.animate=function(z,a,b){t.css(z);if(b){b()}}}t.css("position","absolute").css("left",w).css("opacity",1).show().animate({left:0},j.config.transitionduration,function(){t.css("position","").css("left","").css("z-index",2).show();j.transitioninprogress=false;m(v)})}j.currentslide=v.id;return true};var l=function(r,t,u){if(r==j.currentslide){return false}var s=j.data[r-1];if(typeof s=="undefined"){throw new error("pgwslideshow - the element "+r+" is undefined");return false}if(typeof u=="undefined"){u="left"}if(typeof j.config.beforeslide=="function"){j.config.beforeslide(r)}if(typeof j.plugin.find(".ps-caption").fadeout=="function"){j.plugin.find(".ps-caption, .ps-prev, .ps-next").fadeout(j.config.transitionduration/2)}else{j.plugin.find(".ps-caption, .ps-prev, .ps-next").hide()}if(j.config.transitioneffect=="sliding"){o(s,u)}else{f(s)}if(typeof t!="undefined"&&j.config.autoslide){k()}return true};var k=function(){clearinterval(j.intervalevent);if(j.slidecount>1&&j.config.autoslide){j.intervalevent=setinterval(function(){if(j.currentslide+1<=j.slidecount){var r=j.currentslide+1}else{var r=1}l(r)},j.config.intervalduration)}return true};var b=function(){if(!j.config.displaylist){return false}c();var w=j.plugin.find(".ps-list");var u=w.width();var r=j.plugin.find(".ps-list > ul");var v=r.width();if(v>u){/*r.css("margin","0 45px");*/var t=parseint(r.css("margin-left"));var s=parseint(r.css("margin-right"));u-=(t+s);w.find(".ps-prev").show().unbind("click").click(function(){var y=parseint(r.css("left"));var x=y+u;if(y==0){x=-(v-u)}else{if(x>0){x=0}}if(typeof r.animate=="function"){r.animate({left:x},j.config.transitionduration)}else{r.css("left",x)}});w.find(".ps-next").show().unbind("click").click(function(){var y=parseint(r.css("left"));var x=y-u;var z=-(v-u);if(y==z){x=0}else{if(x