-
Notifications
You must be signed in to change notification settings - Fork 0
/
ras.min.js
1 lines (1 loc) · 3 KB
/
ras.min.js
1
(function(e,t,n,r){function i(t,n){this.element=t;var r=this,i=e(r.element),s=t.id,o=t.className.split(" "),o=o[0],u;s?u=s:u=o;i.wrap('<div class="allRas" id="AllRAS-'+u+'"/>');r.init(n,u);e.fn.ras.slide=function(e,t,n){r.slide(e,t,n)}}e.ras=e.ras||{};e.ras.slideshow={options:{duration:400,textPrev:"prev",textNext:"next"}};i.prototype={init:function(n,r){var i=this,s=e(i.element),o=s.children(),u='<div id="navRAS"><button class="btnSlideRAS prev">'+n.textPrev+'</button><button class="btnSlideRAS next">'+n.textNext+"</button></div>",a=o.length,f=s.parent();s.wrap('<div class="rasContainer" id="RASContainer-'+r+'" style="width:100%; overflow:hidden;"/>'),$RASContainer=s.parent();if(a>1){$RASContainer.before(u);var l=$RASContainer.prev("#navRAS"),c=l.next().children(),h=e(i.element),o=h.children(),p=h.parent(),d=e(t).width();var v=f.width(),m=v;o.css({"float":"left",position:"relative",width:v}).each(function(t){e(this).attr("data-slide",t)});h.css({width:m*a}).attr("data-width",m);e("img").load(function(){i.heightElement(o,h);h.css({width:v*a}).attr("data-width",v);o.css({width:v,position:"relative"})});l.find(".prev").bind("click",function(){var e=n.duration,t=n.animation;i.slide(c,"prev",e,"null")});l.find(".next").bind("click",function(){var e=n.duration,t=n.animation;i.slide(c,"next",e,"null")});e(t).resize(function(){var e=p.width();i.resizeMe(h,e,a)})}},slide:function(t,n,r){function f(){var e=t.find(".activeSlide").data("slide");a.find(".active").removeClass("active");a.find("button:eq("+e+")").addClass("active")}var i=t.data("width"),s=t.width(),o=t.children(":first"),u=t.children(":last"),a=e("#navMultiple");if(t.hasClass("navRas")){if(n=="prev"){var l=t.find(".activeSlide").prev(),c=l.data("left");if(l.length==0){t.animate({"margin-left":"-"+u.data("left")},function(){t.find(".activeSlide").removeClass("activeSlide");u.addClass("activeSlide");f()})}else{t.animate({"margin-left":"-"+c},function(){t.find(".activeSlide").removeClass("activeSlide");l.addClass("activeSlide");f()})}}else if(n=="next"){var h=t.find(".activeSlide").next(),c=h.data("left");if(h.length==0){t.animate({"margin-left":0},function(){t.find(".activeSlide").removeClass("activeSlide");o.addClass("activeSlide");f()})}else{t.animate({"margin-left":"-"+c},function(){t.find(".activeSlide").removeClass("activeSlide");h.addClass("activeSlide");f()})}}}else{if(n=="prev"){t.children().css({"margin-left":0});u.prependTo(t).css({"margin-left":"-"+i+"px"}).animate({"margin-left":0},r)}else if(n=="next"){o.animate({"margin-left":"-"+i+"px"},r,function(){e(this).css({"margin-left":0}).appendTo(t);t.children().each(function(t){e(this).attr("data-left",i*t)})})}}},heightElement:function(t,n){var r=0;t.each(function(){var t=e(this).height();if(t>r){r=t}});n.height(r);n.parent().height(r).attr("data-height",r)},resizeMe:function(e,t,n){var r=e.children();var i=t,s=i;e.css({width:t*n}).attr("data-width",t);this.heightElement(r,e)}};e.fn.ras=function(t){t=e.extend({},e.ras.slideshow.options,t);return this.each(function(){new i(this,t)})}})(jQuery,window,document)