Javascript.RU

Создать новую тему Ответ
 
Опции темы Искать в теме
  #1 (permalink)  
Старый 08.05.2014, 00:53
Интересующийся
Отправить личное сообщение для Blackmore1991 Посмотреть профиль Найти все сообщения от Blackmore1991
 
Регистрация: 13.03.2013
Сообщений: 18

Как сделать кнопки next и prev слайдера
Помогите пожалуйста сделать кнопки предыдущий слайд и следующий!

<div id="bannerRotator">
    <ul>
      <li rel="1" style="display: none;"><a href="http://witerra.pixarweb.ru/redirect.php?action=banner&amp;goto=5" target="_self"><img src="images/slide_1.jpg" border="0" alt="" width="700" height="321"></a></li>      <li rel="2" style="display: none;"><a href="http://witerra.pixarweb.ru/redirect.php?action=banner&amp;goto=6" target="_self"><img src="images/slide_1.jpg" border="0" alt="" width="700" height="321"></a></li>      <li rel="3" style="display: none;"><a href="http://witerra.pixarweb.ru/redirect.php?action=banner&amp;goto=7" target="_self"><img src="images/slide_1.jpg" border="0" alt="" width="700" height="321"></a></li>      <li rel="4" style="display: none;"><a href="http://witerra.pixarweb.ru/redirect.php?action=banner&amp;goto=8" target="_self"><img src="images/slide_1.jpg" border="0" alt="" width="700" height="321"></a></li>      <li rel="5" style="display: none;"><a href="http://witerra.pixarweb.ru/redirect.php?action=banner&amp;goto=9" target="_self"><img src="images/slide_1.jpg" border="0" alt="" width="700" height="321"></a></li>      <li rel="6" style="display: list-item;"><a href="http://witerra.pixarweb.ru/redirect.php?action=banner&amp;goto=17" target="_self"><img src="images/slide_1.jpg" border="0" alt="" width="700" height="321"></a></li>    </ul>


    <div id="bannerNav" timeoutid="2990"></div>


       Вот эти
	<div name="prev" class="navy prev-slide"></div>
       <div name="next" class="navy next-slide"></div>

  </div>


function bannerRotator(selector, scrollTime, pauseTime){
  //default values of scroll time and pause time if nothing is set
  if (scrollTime == null){
    scrollTime=400;
  }
  if(pauseTime== null){
    pauseTime=5000;
  }
  
  $(selector+" li:first").css("display", "block"); //show the first list item
  $(selector+" li").each(function( intIndex ){
     $(this).attr('rel', (intIndex+1));   //add the list position to the rel of each of our nav items
  });

 //create navigation buttons for each banner in the list
  var count = $(selector+" li").size(); //get total number of list items
  var i = 1;
  while(i <= count){
	if(i == $(selector+" li:visible").attr('rel')){  //if its the nav item that belongs to the visible image, mark it as the active nav item
      $('#bannerNav').append("<a class='active' rel='"+i+"' href='#'></a> ");
	}
	else{
	  $('#bannerNav').append("<a rel='"+i+"' href='#'></a> ");
	}
	i++;
  }
  
  scrollImages(count, selector, scrollTime, pauseTime); //start the images scrolling
  
  //handle navigation by clicking
  $("#bannerNav a").click(function () {
    $("#bannerNav a.active").removeClass('active');									
	$(this).addClass('active'); //move the active nav item to this item

	var currentClassName = $(selector+" li:visible").attr('rel');
	var nextClassName = $(this).attr('rel');
	var storedTimeoutID = $("#bannerNav").attr('timeoutID');

	clearTimeout(storedTimeoutID);//stop the images from looping when a nav button is pressed
	$("span.pause").hide();
	$("span.play").show();
	
	if( nextClassName != currentClassName ){ //if they click on the button for the image they are already viewing... do nothing.	
	  $(selector+" li:visible").fadeOut(scrollTime);
	  $(selector+" li[rel="+nextClassName+"]").fadeIn(scrollTime);
	}
	return false; //stop the link from going to where the href attribute tells it
  });
  
  //print a pause/play button
  $('#bannerNav').append("<span class='pause'></span> ");
  $('#bannerNav').append("<span href='#' class='play' style='display:none;'></span> ");
  
  //stop the images looping on pause click
  $("span.pause").click(function () { 
    var storedTimeoutID = $("#bannerNav").attr('timeoutID');
	clearTimeout(storedTimeoutID);
	$("span.pause").hide();
	$("span.play").show();
  });
  
  //start the images looping on play click
  $("span.play").click(function () { 
    scrollImages(count, selector, scrollTime, pauseTime);
	$("span.play").hide();
	$("span.pause").show();
  });
  
}

function scrollImages(count, selector, scrollTime, pauseTime){
  currentClass = $(selector+" li:visible").attr('rel'); //get the list position of the image that we save to the rel attribute on page load
  nextClass = $(selector+" li:visible").attr('rel'); //open a new variable for the next class
  if (currentClass == count ){ nextClass=1; } //if you've reached the end of the images... start from number 1 again
  else{ nextClass++; } //if not just add one to the last number
  var timeout = setTimeout(function(){
    $(selector+" li[rel="+currentClass+"]").fadeOut(scrollTime) //fade out old image
	$("#bannerNav a.active").removeClass('active'); //remove active class from our nav
	$("#bannerNav a[rel="+nextClass+"]").addClass('active'); //add new active class to the next nav item
	$(selector+" li[rel="+nextClass+"]").fadeIn(scrollTime, scrollImages(count, selector, scrollTime, pauseTime)) //fade in the new image and start the loop again
  }, pauseTime);
  $("#bannerNav").attr('timeoutID', timeout); //save the timeout id as an attribute of that LI so we can cancel the loop later if a nav button is pressed
  $(selector+" li[rel="+currentClass+"]").animate({opacity : 1.0}, scrollTime, function(){ timeout }); //hold the image for as long as our scroll time is set for
}

Последний раз редактировалось Blackmore1991, 08.05.2014 в 00:56.
Ответить с цитированием
  #2 (permalink)  
Старый 08.05.2014, 08:00
Интересующийся
Отправить личное сообщение для Blackmore1991 Посмотреть профиль Найти все сообщения от Blackmore1991
 
Регистрация: 13.03.2013
Сообщений: 18

Помогите плиз , хотя бы в каком направлении мне двигаться?
Ответить с цитированием
  #3 (permalink)  
Старый 08.05.2014, 08:17
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,070

Blackmore1991
а взять готовый слайдер ?
Ответить с цитированием
  #4 (permalink)  
Старый 08.05.2014, 17:55
Интересующийся
Отправить личное сообщение для Blackmore1991 Посмотреть профиль Найти все сообщения от Blackmore1991
 
Регистрация: 13.03.2013
Сообщений: 18

Он просто для cms и выводится в админке!
Ответить с цитированием
Ответ



Опции темы Искать в теме
Искать в теме:

Расширенный поиск


Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Сделать кнопки next и prev bullet2018 Общие вопросы Javascript 10 27.10.2012 13:49
Как сделать что бы при регистрации человека на моем сайте у него не появлялось... drunkwolfs Общие вопросы Javascript 2 07.08.2012 10:58
Как сделать, чтобы при наведении на кнопку справа от нее появлялись текстовые ссылки? Tass Общие вопросы Javascript 7 17.02.2011 09:06
Как сделать? При выходе мышкой за пределы окна браузера, начинает грузится другая стр alb Events/DOM/Window 13 01.09.2010 12:19
Многостраничная галерея на lightbox.js Как сделать? MASTER Общие вопросы Javascript 9 24.07.2009 14:38