-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimpleslider-1.3.min.js
7 lines (6 loc) · 2.25 KB
/
simpleslider-1.3.min.js
1
2
3
4
5
6
7
/*
SimpleSlider v1.3 by JaL Productions
http://jalproductions.co.uk/
https://github.com/jamesl1001/simpleslider
*/
function simpleslider(a,b,c,d){function e(){y=p.offsetWidth,z=p.offsetHeight}function f(a){var b=new Image;b.src=a.src;var c=setInterval(function(){0!=b.width&&0!=b.height&&(clearInterval(c),a.className+=b.width/b.height<y/z?" full-width":" full-height",g())},0)}function g(){for(var a=0,b=t.length;b>a;a++)t[a].width>=y&&(t[a].style.left=(y-t[a].width)/2+"px"),t[a].height>=z&&(t[a].style.top=(z-t[a].height)/2+"px")}function h(a){t[a].className+=" current",ssAllDots[a].className+=" current"}function i(){for(var a=0;u>a;a++)t[a].className=t[a].className.replace(/ current/,""),ssAllDots[a].className=ssAllDots[a].className.replace(/ current/,"")}function j(a){w=a>=u?0:0>a?u-1:a}function k(){i(),j(w-1),h(w)}function l(){i(),j(w+1),h(w)}function m(a){if(a.target)var b=a.target.className;else if(a.srcElement)var b=a.srcElement.className;var c=b.match(/\d+/);i(),j(parseInt(c[0])),h(c[0])}function n(){e(),g()}var o=document.getElementById("simpleslider"),p=document.getElementById("ss__wrapper"),q=(document.getElementById("ss__controls"),document.getElementById("ss__prev")),r=document.getElementById("ss__next"),s=document.getElementById("ss__dots"),t=p.getElementsByTagName("img"),u=b||t.length,v=a,w=0,x=20*u,y=0,z=0,A=v.split(":"),B=A[1]/A[0]*100;o.style.paddingBottom=p.style.paddingBottom=B+"%",s.style.width=x+"px",e();for(var C=0;u>C;C++){var D=document.createElement("div");D.className="ss__dot ss__frame"+[C],s.appendChild(D)}if(ssAllDots=s.getElementsByTagName("div"),0==t.length){for(var C=1;u>=C;C++){var E=new Image;E.src=c+"/"+d+C+".jpg",p.innerHTML+=E.outerHTML}t=p.getElementsByTagName("img")}for(var C=0,F=t.length;F>C;C++)f(t[C]);h(0),window.addEventListener?(q.addEventListener("click",k),r.addEventListener("click",l)):window.attachEvent&&(q.attachEvent("onclick",k),r.attachEvent("onclick",l));for(var C=0;u>C;C++)window.addEventListener?ssAllDots[C].addEventListener("click",m):window.attachEvent&&ssAllDots[C].attachEvent("onclick",m);document.onkeydown=function(a){switch(evt=a||window.event,evt.keyCode){case 37:k();break;case 39:l()}},window.addEventListener?window.addEventListener("resize",n):window.attachEvent&&window.attachEvent("onresize",n)}