Skip to content

Instantly share code, notes, and snippets.

@daltonrooney
Created January 16, 2012 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daltonrooney/1623195 to your computer and use it in GitHub Desktop.
Save daltonrooney/1623195 to your computer and use it in GitHub Desktop.
PSP 1.5.4 custom js
/*!
* 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);
/*!
* jQuery imagesLoaded plugin v1.0.3
* http://github.com/desandro/imagesloaded
*
* MIT License. by Paul Irish et al.
*/
(function(a,b){a.fn.imagesLoaded=function(i){var g=this,e=g.find("img").add(g.filter("img")),c=e.length,h="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==";function f(){i.call(g,e)}function d(){if(--c<=0&&this.src!==h){setTimeout(f);e.unbind("load error",d)}}if(!c){f()}e.bind("load error",d).each(function(){if(this.complete||this.complete===b){var j=this.src;
this.src=h;this.src=j}});return g}})(jQuery);
/*!
* Portfolio Slideshow Pro
*/
(function(a){a(window).load(function(){var c,b,j,h,d,e,i,g;currSlide=new Array();tabSlide=new Array();c=portfolioSlideshowOptions.psLoader;d=portfolioSlideshowOptions.psFluid;b=portfolioSlideshowOptions.psHash;j=portfolioSlideshowOptions.psFancyBox;e=portfolioSlideshowOptions.psTouchSwipe;psKeyboardNav=portfolioSlideshowOptions.psKeyboardNav;h=portfolioSlideshowOptions.psInfoTxt;g=false;if(jQuery.browser.msie&&parseInt(jQuery.browser.version)<8){ie=true
}else{ie=false}if(j===true){function f(n,m,k,l){return'<div id="image-caption">'+(n&&n.length?"<b>"+n+"</b>":"")+" Image "+(k+1)+" of "+m.length+"</div>"}a("a.fancybox, .gallery-item 'a[href$='.gif'], .gallery-item 'a[href$='.jpg'], .gallery-item 'a[href$='.png'], .gallery-item 'a[href$='.jpeg']").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 q=this.id.match(/portfolio-slideshow(\d+)/)[1];var o=a("#slideshow-wrapper"+q);var p=a("#slideshow-nav"+q);var w=a("#portfolio-slideshow"+q);var s=w.find(".slideshow-content img");var m=a("#slideshow-wrapper"+q+".fancygrid");var l=o.find(".show");var u=o.find(".hide");var v=o.find(".pscarousel");var r=o.find(".psthumbs");var n=p.find(".play");var t=p.find(".pause");
var k=p.find(".restart");if(ie===true){o.addClass("ie")}a("#scrollable"+q).scrollable({keyboard:false}).navigator({navi:"#carouselnav"+q,naviItem:"a"});a(".prev.browse").removeClass("hidden");o.find(".browse").click(function(){if(g!=true){g=true;setTimeout(function(){g=false},15000)}});l.click(function(){a(this).hide();u.addClass("active");r.fadeIn("fast")});u.click(function(){a(this).removeClass("active");l.show();r.fadeOut("fast")});m.find(".portfolio-slideshow").hide();m.find(".psthumbs").show();
m.find(".pager img").click(function(){w.fadeIn("fast",function(){w.css("width","").css("height","");var x,y;x=w.find(".slideshow-content").eq(currSlide[q]).outerHeight();y=w.find(".slideshow-content").eq(currSlide[q]).width();w.css("height",x).css("width",y);w.fadeTo("fast",1)});m.find(".slideshow-nav").show();m.find(".pager").hide()});m.find(".thumb-toggles a").click(function(){m.find(".portfolio-slideshow").hide();m.find(".slideshow-nav").hide();m.find(".pager").fadeIn("fast");m.find(".psthumbs").show();
m.find("a.hide").removeClass("active");m.find("a.show").show()});a(function(){var A=0,C=window.location.hash;if(/\d+/.exec(C)){A=/\d+/.exec(C)[0];A=(parseInt(A)||1)-1}if(psPagerStyle[q]==="thumbs"||psPagerStyle[q]==="carousel"){a.fn.cycle.updateActivePagerLink=function(F,G){a(F).find("img").removeClass("activeSlide").filter("#pager"+q+" img:eq("+G+")").addClass("activeSlide")}}else{a.fn.cycle.updateActivePagerLink=function(F,G){a(F).find("a").removeClass("activeSlide").filter("#pager"+q+" a:eq("+G+")").addClass("activeSlide")
}}function D(){w.cycle({fx:psTrans[q],speed:psSpeed[q],timeout:psTimeout[q],delay:psDelay[q],random:psRandom[q],nowrap:psNoWrap[q],next:"#slideshow-wrapper"+q+" a.slideshow-next, #slideshow-wrapper"+q+" #psnext"+q,startingSlide:A,prev:"#slideshow-wrapper"+q+" a.slideshow-prev , #slideshow-wrapper"+q+" #psprev"+q,before:E,after:x,end:z,slideExpr:".slideshow-content",manualTrump:true,slideResize:false,containerResize:false,pager:"#pager"+q,cleartypeNoBg:true,pagerAnchorBuilder:y})}function B(){w.cycle({fx:psTrans[q],speed:psSpeed[q],timeout:psTimeout[q],delay:psDelay[q],random:psRandom[q],nowrap:psNoWrap[q],next:"#slideshow-wrapper"+q+" a.slideshow-next, #psnext"+q,startingSlide:A,prev:"#slideshow-wrapper"+q+" a.slideshow-prev, #psprev"+q,before:E,after:x,slideExpr:".slideshow-content",end:z,manualTrump:true,slideResize:false,containerResize:false,pager:"#pager"+q+" .numbers",cleartypeNoBg:true})
}if(psPagerStyle[q]==="numbers"){B()}else{D()}s.each(function(){a(this).attr("src",a(this).attr("data-img"))});if(psAutoplay[q]===false){w.cycle("pause")}else{if(psAudio[q]===true){w.delay(1000).queue(function(){w.cycle("resume");n.fadeOut(100,function(){t.fadeIn(10)});w.parent().nextAll(".haiku-text-player:first").jPlayer("play")})}else{n.fadeOut(100,function(){t.fadeIn(10)})}}t.click(function(){a(this).fadeOut(100,function(){n.fadeIn(10)});if(psAudio[q]===true){a(this).parent().parent().nextAll(".haiku-text-player:first").jPlayer("pause")
}w.cycle("pause")});n.click(function(){w.cycle("resume");a(this).fadeOut(100,function(){t.fadeIn(10)});if(psAudio[q]===true){a(this).parent().parent().nextAll(".haiku-text-player:first").jPlayer("play")}});k.click(function(){a("#pager"+q+" .numbers").empty();a(this).fadeOut(100,function(){t.fadeIn(10)});if(psAudio[q]===true){a(this).parent().parent().nextAll(".haiku-text-player:first").jPlayer("play")}if(psPagerStyle[q]==="numbers"){B()}else{D()}});if(d===true){a(window).resize(function(){var H;H=a(window).height();
a("img.psp-active").each(function(){a(this).css("max-height",(H-60))});w.css("width","").css("height","");var F,G;F=w.find(".slideshow-content").eq(currSlide[q]).outerHeight();G=w.find(".slideshow-content").eq(currSlide[q]).width();w.css("height",F).css("width",G)})}if(psKeyboardNav===true){a(document).keydown(function(F){if(F.which==37){a("#psprev"+q).click()}else{if(F.which==39){a("#psnext"+q).click()}}})}if(e===true){s.swipe({swipeLeft:function(){a("#psnext"+q).click()},swipeRight:function(){a("#psprev"+q).click()
},allowPageScroll:"auto"})}function y(G,F){if(psPagerStyle[q]==="thumbs"||psPagerStyle[q]==="carousel"){return"#pager"+q+" img:eq("+(G)+")"}if(psPagerStyle[q]==="bullets"){return"#pager"+q+" a:eq("+(G)+")"}}function E(I,G,H){var F=a(this);tabSlide[q]=H.nextSlide+1;var J=Math.ceil(((tabSlide[q])/psCarouselSize[q])-1);if(g!=true){a("#carouselnav"+q+" a").eq(J).click()}if(d===true){$window=a(window).height();a("img.psp-active").each(function(){a(this).css("max-height",($window-60))})}F.find("img").imagesLoaded(function(){var K,L;
K=F.height();L=F.width();w.height(K).width(L);$parenth=w.outerHeight();$imgh=a(this).height();$imgmargin=($parenth-$imgh)/2;a(this).parent().parent().css("margin-top",$imgmargin)})}function x(L,I,J){var G=a(this);currSlide[q]=J.currSlide;var F,K;F=G.height();K=G.width();if(ie===true){w.height(F).width(K)}if(psNoWrap[q]===true){if(J.currSlide===0){p.find(".slideshow-prev, .sep").addClass("inactive")}else{p.find(".slideshow-prev, .sep").removeClass("inactive")}if(J.currSlide===J.slideCount-1){p.find(".slideshow-next, .sep").addClass("inactive")
}else{p.find(".slideshow-next").removeClass("inactive")}}if(b===true){window.location.hash=J.currSlide+1}var H=(J.currSlide+1)+" "+h+" "+J.slideCount;a(".slideshow-info"+q).html(H)}function z(){p.find(".slideshow-next, .sep").addClass("inactive");t.hide();n.hide();k.show()}})});a(function(){var k=a(".video-youtube");if(k.length>0){k.each(function(m){if(a(this).attr("href").match(/ww=[0-9]+/i)){var n=parseInt(a(this).attr("href").match(/ww=[0-9]+/i)[0].replace("ww=",""))}else{var n="680"}if(a(this).attr("href").match(/wh=[0-9]+/i)){var l=parseInt(a(this).attr("href").match(/wh=[0-9]+/i)[0].replace("wh=",""))
}else{var l="495"}if(window.console&&window.console.log){console.log("fWidth #"+m+": "+n);console.log("fHeight #"+m+": "+l)}a(this).fancybox({padding:0,autoScale:false,title:this.title,scrolling:"no",href:this.href.replace(new RegExp("watch\\?v=","i"),"v/"),width:n,height:l,type:"swf",swf:{wmode:"transparent",allowfullscreen:"true"}})})}});a(function(){var k=a(".video-vimeo");if(k.length>0){k.each(function(m){if(a(this).attr("href").match(/ww=[0-9]+/i)){var n=parseInt(a(this).attr("href").match(/ww=[0-9]+/i)[0].replace("ww=",""))
}else{var n="680"}if(a(this).attr("href").match(/wh=[0-9]+/i)){var l=parseInt(a(this).attr("href").match(/wh=[0-9]+/i)[0].replace("wh=",""))}else{var l="495"}if(window.console&&window.console.log){console.log("fWidth #"+m+": "+n);console.log("fHeight #"+m+": "+l)}a(this).fancybox({padding:0,autoScale:false,title:this.title,scrolling:"no",href:this.href.replace(new RegExp("([0-9])","i"),"moogaloop.swf?autoplay=1&clip_id=$1"),width:n,height:l,type:"swf"})})}});a(function(){var k=a(".slideshow-popup");
if(k.length>0){k.each(function(m){if(a(this).attr("href").match(/ww=[0-9]+/i)){var n=parseInt(a(this).attr("href").match(/ww=[0-9]+/i)[0].replace("ww=",""))}else{var n="625"}if(a(this).attr("href").match(/wh=[0-9]+/i)){var l=parseInt(a(this).attr("href").match(/wh=[0-9]+/i)[0].replace("wh=",""))}else{var l="625"}if(window.console&&window.console.log){console.log("fWidth #"+m+": "+n);console.log("fHeight #"+m+": "+l)}a(this).fancybox({type:"iframe",autoScale:false,scrolling:"no",width:n,height:l})
})}})})})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment