//$(document).ready(function() { $.fn.newslider = function(btnNext,btnPrev) { var appliedDiv = $(this); appliedDiv.find('li').first().addClass('imgactive'); $(btnPrev).click(function(){ appliedDiv.find('.imgactive').removeClass('imgactive').addClass('oldActive'); if (appliedDiv.find('.oldActive').is(':first-child')) { appliedDiv.find('li').last().addClass('imgactive'); } else { appliedDiv.find('.oldActive').prev().addClass('imgactive'); } appliedDiv.find('.oldActive').removeClass('oldActive'); }); $(btnNext).click(function() { appliedDiv.find('.imgactive').removeClass('imgactive').addClass('oldActive'); if (appliedDiv.find('.oldActive').is(':last-child')) { appliedDiv.find('li').first().addClass('imgactive'); } else { appliedDiv.find('.oldActive').next().addClass('imgactive'); } appliedDiv.find('.oldActive').removeClass('oldActive'); }); } $('#phototab, .phototab').newslider('#phototab .btnNext','#phototab .btnprev'); $('#videotab, .videotab').newslider('#videotab .btnNext','#videotab .btnprev'); $("div[id^='phototabslide_']").each(function(index, val) { var divid = $(this).attr('id'); $('#'+divid).newslider('#'+divid+' .btnNext', '#'+divid+' .btnprev'); }); $.fn.rkslider = function(btnNext,btnPrev,auto,scrollwidth,holderwidth,percol,dots,dotsId,adaptiveHeight){ // Variable initialization var adaptiveHeight = adaptiveHeight || false; var appliedDiv = $(this); var totalLI = appliedDiv.find('ul li').size(); if(percol != ''){ var rotation = Math.ceil(totalLI/percol); }else{ var rotation = totalLI; } var totalW = totalLI * holderwidth; var lastIMG = '-'+(totalW - holderwidth*percol); var interval; var slideClick = 1; appliedDiv.find('ul').css('width',totalW); // Next Click $(btnNext).click(function(e){ //console.log(scrollwidth);console.log(left); //scrollwidth = parseInt(scrollwidth)-96; e.preventDefault(); if(adaptiveHeight) { //set parent height var lipos = slideClick == parseInt(totalLI) ? 0 : slideClick; var liheight = appliedDiv.find('ul li:eq('+(lipos)+')').height(); appliedDiv.height(liheight); } if(slideClick < rotation){ appliedDiv.find('ul').animate({ left:'-='+scrollwidth //left:'-'+parseInt(scrollwidth)-96 },500); slideClick++; }else if(slideClick == rotation){ appliedDiv.find('ul').animate({ left:'0' },1000); slideClick = 1; } if(dots == 'yes'){ $(dotsId).find('ul li.current').removeClass('current'); $(dotsId).find('ul li:eq('+(slideClick-1)+')').addClass('current'); } //console.log(totalLI+' = '+slideClick); }); // Previous Click $(btnPrev).click(function(e) { e.preventDefault(); if(adaptiveHeight) { //set parent height var lipos = slideClick == 1 ? totalLI : slideClick-1; var liheight = appliedDiv.find('ul li:eq('+(lipos-1)+')').height(); appliedDiv.height(liheight); } if(slideClick > 1){ appliedDiv.find('ul').animate({ left:'+='+scrollwidth //left: parseInt(scrollwidth)+96 },500); slideClick--; }else if(slideClick == 1){ appliedDiv.find('ul').animate({ left:lastIMG },1000); slideClick=rotation; } if(dots == 'yes'){ $(dotsId).find('ul li.current').removeClass('current'); $(dotsId).find('ul li:eq('+(slideClick-1)+')').addClass('current'); } //console.log(totalLI+' = '+slideClick); }); if(auto == 'true'){ // Interval interval = setInterval(function(){ //$(btnNext).click(); if(slideClick < rotation){ appliedDiv.find('ul').animate({ left:'-='+scrollwidth },500); slideClick++; }else if(slideClick == rotation){ appliedDiv.find('ul').animate({ left:'0' },1000); slideClick = 1; } if(dots == 'yes'){ $(dotsId).find('ul li.current').removeClass('current'); $(dotsId).find('ul li:eq('+(slideClick-1)+')').addClass('current'); } },7000); // Pause on mouse enter $(this).bind('mouseenter', function(){ clearInterval(interval); interval = null; }); // Set Interval back on mouse leave $(this).bind('mouseleave', function(){ interval = setInterval(function(){ //$(btnNext).click(); if(slideClick < rotation){ appliedDiv.find('ul').animate({ left:'-='+scrollwidth },500); slideClick++; }else if(slideClick == rotation){ appliedDiv.find('ul').animate({ left:'0' },1000); slideClick = 1; } if(dots == 'yes'){ $(dotsId).find('ul li.current').removeClass('current'); $(dotsId).find('ul li:eq('+(slideClick-1)+')').addClass('current'); } },7000); }) } if(dots == 'yes'){ $(dotsId).find('ul li:first').addClass('current'); } // Dots Click if(dots == 'yes'){ $(dotsId).find('ul li a').click(function(e){ e.preventDefault(); $(dotsId).find('ul li.current').removeClass('current'); var currentDot = $(dotsId).find('ul li').index($(this).parent()); appliedDiv.find('ul').animate({ left:'-'+(scrollwidth*currentDot) },500); $(this).parent().addClass('current'); slideClick = (currentDot+1); if(adaptiveHeight) { //set parent height var liheight = appliedDiv.find('ul li:eq('+(currentDot)+')').height(); appliedDiv.height(liheight); } }); } }; //});