Skip to content

Instantly share code, notes, and snippets.

@daltonrooney
Created May 1, 2012 19:16
Show Gist options
  • Save daltonrooney/2570640 to your computer and use it in GitHub Desktop.
Save daltonrooney/2570640 to your computer and use it in GitHub Desktop.
PSP 1.6.1 custom js
/*!
* jQuery imagesLoaded plugin v2.0.1
* http://github.com/desandro/imagesloaded
*
* MIT License. by Paul Irish et al.
*/
(function(a,b){var c="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";a.fn.imagesLoaded=function(k){var h=this,m=a.isFunction(a.Deferred)?a.Deferred():0,l=a.isFunction(m.notify),e=h.find("img").add(h.filter("img")),f=[],j=[],g=[];function i(){var n=a(j),o=a(g);if(m){if(g.length){m.reject(e,n,o)}else{m.resolve(e)}}if(a.isFunction(k)){k.call(h,e,n,o)
}}function d(n,o){if(n.src===c||a.inArray(n,f)!==-1){return}f.push(n);if(o){g.push(n)}else{j.push(n)}a.data(n,"imagesLoaded",{isBroken:o,src:n.src});if(l){m.notifyWith(a(n),[o,e,a(j),a(g)])}if(e.length===f.length){setTimeout(i);e.unbind(".imagesLoaded")}}if(!e.length){i()}else{e.bind("load.imagesLoaded error.imagesLoaded",function(n){d(n.target,n.type==="error")}).each(function(n,p){var q=p.src;var o=a.data(p,"imagesLoaded");if(o&&o.src===q){d(p,o.isBroken);return}if(p.complete&&p.naturalWidth!==b){d(p,p.naturalWidth===0||p.naturalHeight===0);
return}if(p.readyState||p.complete){p.src=c;p.src=q}})}return m?m.promise(h):h}})(jQuery);
/*!
* touchSwipe - jQuery Plugin
* http://plugins.jquery.com/project/touchSwipe
* http://labs.skinkers.com/touchSwipe/
*
* Copyright (c) 2010 Matt Bryson (www.skinkers.com)
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* $version: 1.2.3
*/
(function(a){a.fn.swipe=function(p){if(!this){return false}var e={fingers:1,threshold:75,swipe:null,swipeLeft:null,swipeRight:null,swipeUp:null,swipeDown:null,swipeStatus:null,click:null,triggerOnTouchEnd:true,allowPageScroll:"auto"};
var c="left";var i="right";var o="up";var l="down";var k="none";var d="horizontal";var g="vertical";var n="auto";var b="start";var h="move";var j="end";var f="cancel";var m="start";if(p.allowPageScroll==undefined&&(p.swipe!=undefined||p.swipeStatus!=undefined)){p.allowPageScroll=k}if(p){a.extend(e,p)}return this.each(function(){var B=a(this);var y=null;var C=0;var s={x:0,y:0};var v={x:0,y:0};var E={x:0,y:0};function u(G){m=b;C=G.touches.length;distance=0;direction=null;if(C==e.fingers){s.x=v.x=G.touches[0].pageX;
s.y=v.y=G.touches[0].pageY;if(e.swipeStatus){t(G,m)}}else{x(G)}}function D(G){if(m==j||m==f){return}v.x=G.touches[0].pageX;v.y=G.touches[0].pageY;direction=q();C=G.touches.length;m=h;A(G,direction);if(C==e.fingers){distance=w();if(e.swipeStatus){t(G,m,direction,distance)}if(!e.triggerOnTouchEnd){if(distance>=e.threshold){m=j;t(G,m);x(G)}}}else{m=f;t(G,m);x(G)}}function F(G){G.preventDefault();distance=w();direction=q();if(e.triggerOnTouchEnd){m=j;if(C==e.fingers&&v.x!=0){if(distance>=e.threshold){t(G,m);
x(G)}else{m=f;t(G,m);x(G)}}else{m=f;t(G,m);x(G)}}else{if(m==h){m=f;t(G,m);x(G)}}}function x(G){C=0;s.x=0;s.y=0;v.x=0;v.y=0;E.x=0;E.y=0}function t(H,G){if(e.swipeStatus){e.swipeStatus.call(B,H,G,direction||null,distance||0)}if(G==f){if(e.click&&C==1&&(isNaN(distance)||distance==0)){e.click.call(B,H,H.target)}}if(G==j){if(e.swipe){e.swipe.call(B,H,direction,distance)}switch(direction){case c:if(e.swipeLeft){e.swipeLeft.call(B,H,direction,distance)}break;case i:if(e.swipeRight){e.swipeRight.call(B,H,direction,distance)
}break;case o:if(e.swipeUp){e.swipeUp.call(B,H,direction,distance)}break;case l:if(e.swipeDown){e.swipeDown.call(B,H,direction,distance)}break}}}function A(G,H){if(e.allowPageScroll==k){G.preventDefault()}else{var I=e.allowPageScroll==n;switch(H){case c:if((e.swipeLeft&&I)||(!I&&e.allowPageScroll!=d)){G.preventDefault()}break;case i:if((e.swipeRight&&I)||(!I&&e.allowPageScroll!=d)){G.preventDefault()}break;case o:if((e.swipeUp&&I)||(!I&&e.allowPageScroll!=g)){G.preventDefault()}break;case l:if((e.swipeDown&&I)||(!I&&e.allowPageScroll!=g)){G.preventDefault()
}break}}}function w(){return Math.round(Math.sqrt(Math.pow(v.x-s.x,2)+Math.pow(v.y-s.y,2)))}function r(){var J=s.x-v.x;var I=v.y-s.y;var G=Math.atan2(I,J);var H=Math.round(G*180/Math.PI);if(H<0){H=360-Math.abs(H)}return H}function q(){var G=r();if((G<=45)&&(G>=0)){return c}else{if((G<=360)&&(G>=315)){return c}else{if((G>=135)&&(G<=225)){return i}else{if((G>45)&&(G<135)){return l}else{return o}}}}}try{this.addEventListener("touchstart",u,false);this.addEventListener("touchmove",D,false);this.addEventListener("touchend",F,false);
this.addEventListener("touchcancel",x,false)}catch(z){}})}})(jQuery);
/*!
* Portfolio Slideshow Pro
*/
(function(a){a(window).load(function(){var c,b,l,j,d,e,k,i,g;var m=new Array();currSlide=new Array();tabSlide=new Array();c=portfolioSlideshowOptions.psLoader;d=portfolioSlideshowOptions.psFluid;b=portfolioSlideshowOptions.psHash;l=portfolioSlideshowOptions.psFancyBox;e=portfolioSlideshowOptions.psTouchSwipe;psKeyboardNav=portfolioSlideshowOptions.psKeyboardNav;g=portfolioSlideshowOptions.psBackgroundImages;
j=portfolioSlideshowOptions.psInfoTxt;i=false;if(jQuery.browser.msie&&parseInt(jQuery.browser.version)<8){ie=true}else{ie=false}if(l===true){function f(q,p,n,o){if(p.length>1){return'<div id="image-caption">'+(q&&q.length?"<b>"+q+"</b>":"")+'<span class="fb-info"> Image '+(n+1)+" of "+p.length+"</span></div>"}else{return'<div id="image-caption">'+(q&&q.length?"<b>"+q+"</b>":"")+"</div>"}}a("a.fancybox").fancybox({titlePosition:"inside",titleFormat:f})}if(c===true){a(".slideshow-wrapper").delay(1000).queue(function(){a(".portfolio-slideshow, .slideshow-nav, .pager").css("visibility","visible");
a(this).removeClass("showloader")})}else{a(".portfolio-slideshow, .slideshow-nav, .pager").css("visibility","visible")}a("div[id^=portfolio-slideshow]").each(function(){var v=this.id.match(/portfolio-slideshow(\d+)/)[1];if(psLoop[v]==true){m[v]=0}else{m[v]=true}var t=a("#slideshow-wrapper"+v);var u=a("#slideshow-nav"+v);var C=a("#portfolio-slideshow"+v);var x=a(".psp-active");var r=a("#slideshow-wrapper"+v+".fancygrid");var n=a("#slideshow-wrapper"+v+".fancygrid.toggle-open");var y=a("#slideshow-wrapper"+v+".fancygrid.toggle-closed");
var q=C.find(".slideshow-meta");var p=t.find(".show");var A=t.find(".hide");var B=t.find(".pscarousel");var w=t.find(".psthumbs");var s=u.find(".play");var z=u.find(".pause");var o=u.find(".restart");if(ie===true){t.addClass("ie")}a("#scrollable"+v).scrollable({keyboard:false}).navigator({navi:"#carouselnav"+v,naviItem:"a"});a(".prev.browse").removeClass("hidden");t.find(".browse").click(function(){if(i!=true){i=true;setTimeout(function(){i=false},15000)}});a(".toggle-open").find(A).addClass("active");
a(".toggle-closed").find(p).addClass("active");p.click(function(){a(this).removeClass("active");A.addClass("active");w.fadeIn("fast");B.fadeIn("fast")});A.click(function(){a(this).removeClass("active");p.addClass("active");w.fadeOut("fast");B.fadeOut("fast")});n.find(".portfolio-slideshow").hide();n.find(".psthumbs").show();r.find(".pager img").click(function(){C.fadeIn("fast",function(){C.css("width","").css("height","");var D,E;D=C.find(".slideshow-content").eq(currSlide[v]).outerHeight();E=C.find(".slideshow-content").eq(currSlide[v]).width();
C.css("height",D).css("width",E);C.fadeTo("fast",1)});r.find(".slideshow-nav").show();r.find(".pager").hide();r.find("a.hide").removeClass("active");r.find("a.show").addClass("active")});r.find(".thumb-toggles a").click(function(){r.find(".portfolio-slideshow").hide();r.find(".slideshow-nav").hide();r.find(".pager").fadeIn("fast");r.find(".psthumbs").show();r.find("a.hide").removeClass("active");r.find("a.show").addClass("active")});a(function(){var H=0,F=window.location.hash;if(/\d+/.exec(F)){H=/\d+/.exec(F)[0];
H=(parseInt(H)||1)-1}if(psPagerStyle[v]==="thumbs"||psPagerStyle[v]==="carousel"){a.fn.cycle.updateActivePagerLink=function(M,N){a(M).find("img").removeClass("activeSlide").filter("#pager"+v+" img:eq("+N+")").addClass("activeSlide")}}else{a.fn.cycle.updateActivePagerLink=function(M,N){a(M).find("a").removeClass("activeSlide").filter("#pager"+v+" a:eq("+N+")").addClass("activeSlide")}}function E(){C.cycle({fx:psTrans[v],speed:psSpeed[v],timeout:psTimeout[v],delay:psDelay[v],nowrap:m[v],next:"#slideshow-wrapper"+v+" a.slideshow-next, #slideshow-wrapper"+v+" #psnext"+v,startingSlide:H,prev:"#slideshow-wrapper"+v+" a.slideshow-prev , #slideshow-wrapper"+v+" #psprev"+v,before:I,after:K,end:D,slideExpr:".slideshow-content",manualTrump:true,slideResize:false,containerResize:false,pager:"#pager"+v,cleartypeNoBg:true,pagerAnchorBuilder:L})
}E();if(g===true){x.each(function(M){a(this).delay(1000*M).queue(function(){a(this).attr("src",a(this).attr("data-img"))})})}if(psAutoplay[v]===false){C.cycle("pause")}else{if(psAudio[v]===true){C.delay(1000).queue(function(){C.cycle("resume");s.fadeOut(100,function(){z.fadeIn(10)});C.parent().nextAll(".haiku-text-player:first").jPlayer("play")})}else{s.fadeOut(100,function(){z.fadeIn(10)})}}z.click(function(){a(this).fadeOut(100,function(){s.fadeIn(10)});if(psAudio[v]===true){a(this).parent().parent().nextAll(".haiku-text-player:first").jPlayer("pause")
}C.cycle("pause")});s.click(function(){C.cycle("resume");a(this).fadeOut(100,function(){z.fadeIn(10)});if(psAudio[v]===true){a(this).parent().parent().nextAll(".haiku-text-player:first").jPlayer("play")}});o.click(function(){a("#pager"+v+" .numbers").empty();a(this).fadeOut(100,function(){z.fadeIn(10)});if(psAudio[v]===true){a(this).parent().parent().nextAll(".haiku-text-player:first").jPlayer("play")}E()});if(d===true){a(window).resize(function(){var O;O=a(window).height();a("img.psp-active").each(function(){a(this).css("max-height",(O-60))
});C.css("width","").css("height","");var M,N;M=C.find(".slideshow-content").eq(currSlide[v]).outerHeight();N=C.find(".slideshow-content").eq(currSlide[v]).width();C.css("height",M).css("width",N)})}if(psKeyboardNav===true){var J=a("body:not(.ps-active) div.slideshow-wrapper");a(document).keydown(function(M){if(a("body").is(".ps-active")){M.preventDefault()}else{if(M.which==37){J.children("#psprev"+v).click()}else{if(M.which==39){J.children("#psnext"+v).click()}}}})}if(e===true){var G=C.find(x);G.each(function(){var M=a(this);
M.swipe({swipeLeft:function(){a("#psnext"+v).click()},swipeRight:function(){a("#psprev"+v).click()},allowPageScroll:"auto"})})}a(".ps-video").hover(function(){z.click()});function L(N,M){if(psPagerStyle[v]==="thumbs"||psPagerStyle[v]==="carousel"){return"#pager"+v+" img:eq("+(N)+")"}if(psPagerStyle[v]==="bullets"||psPagerStyle[v]==="numbers"||psPagerStyle[v]==="titles"){return"#pager"+v+" a:eq("+(N)+")"}}function I(Q,O,P){var M=a(this);var N=M.find("img");var S=M.next().find("img");if(N.attr("src")=="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="){N.attr("src",N.attr("data-img"))
}if(S.attr("src")=="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=="){S.attr("src",S.attr("data-img"))}C.find(".slideshow-content").removeClass("active-slide");M.addClass("active-slide");a(".ps-video").not(a(".active-slide .ps-video")).each(function(){a(this).appendTo(a(this).parent()).hide()});M.find(".ps-video").show();dataSrc=M.find("iframe").attr("data-src");M.find("iframe").attr("src",dataSrc);tabSlide[v]=P.nextSlide+1;var R=Math.ceil(((tabSlide[v])/psCarouselSize[v])-1);
if(i!=true){a("#carouselnav"+v+" a").eq(R).click()}N.load(function(){var T,U;T=M.outerHeight();U=M.width();C.height(T).width(U)});N.imagesLoaded(function(){var T,U;T=M.outerHeight();U=M.width();C.height(T).width(U)});if(M.find(".ps-video").length>0){$h=M.find(".ps-video").attr("height");$w=M.find(".ps-video").attr("width");C.height($h).width($w)}}function K(R,P,Q){var M=a(this);var O=M.find("img");var S=M.next().find("img");currSlide[v]=Q.currSlide;if(m[v]===true){if(Q.currSlide===0){u.find(".slideshow-prev, .sep").addClass("inactive")
}else{u.find(".slideshow-prev, .sep").removeClass("inactive")}if(Q.currSlide===Q.slideCount-1){u.find(".slideshow-next, .sep").addClass("inactive")}else{u.find(".slideshow-next").removeClass("inactive")}}if(b===true){window.location.hash=Q.currSlide+1}var N=(Q.currSlide+1)+" "+j+" "+Q.slideCount;a(".slideshow-info"+v).html(N)}function D(){u.find(".slideshow-next, .sep").addClass("inactive");z.hide();s.hide();o.show()}})});a(function(){var n=a(".slideshow-popup");if(n.length>0){n.each(function(p){if(a(this).attr("href").match(/ww=[0-9]+/i)){var q=parseInt(a(this).attr("href").match(/ww=[0-9]+/i)[0].replace("ww=",""))
}else{var q="625"}if(a(this).attr("href").match(/wh=[0-9]+/i)){var o=parseInt(a(this).attr("href").match(/wh=[0-9]+/i)[0].replace("wh=",""))}else{var o="625"}a(this).fancybox({type:"iframe",autoScale:false,scrolling:"no",width:q,height:o})})}});var h=a(".photoswipe");if(h.length>0){(function(p,q,n){var o=a(".photoswipe div[id^=portfolio-slideshow]");o.each(function(){var t=a(this),s=t.find(".ps-photoswipe"),r=t.parents(".slideshow-wrapper").find(".activate-fullscreen"),u={allowUserZoom:false,captionAndToolbarShowEmptyCaptions:false};
s.on("click",function(w){var v=n.attach(s,u);w.preventDefault();v.show(0)});r.on("click",function(){var v=n.attach(s,u);v.show(0)})})}(window,window.jQuery,window.Code.PhotoSwipe))}})})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment