2015-08-07 4 views
0

Я понял, как иметь 2 ползунка на странице с других сообщений. Единственный выпуск, который у меня есть, это то, что Prev & Следующие стрелки на втором слайдере, похоже, не функционируют.EasySlider1.7 - Как мне получить стрелки на втором слайдере?

Я взял эту страницу от кого-то другого, изначально создавшего первый слайдер, и я не очень разбираюсь в коде. Я использую в основном Wordpress в течение многих лет. Изучаю, как я иду.

Вот страница: GinaKetchum.com

код в файле index.html:

<script type="text/javascript" src="js/jquery.js"></script> 
 
<script type="text/javascript" src="js/easySlider1.7.js"></script> 
 
<script type="text/javascript"> 
 
\t \t $(document).ready(function(){ \t 
 
\t \t \t $("#slider").easySlider({ 
 
\t \t \t \t auto: true, 
 
\t \t \t \t continuous: true 
 
\t \t \t }); 
 
\t \t \t $("#slider2").easySlider({ 
 
\t \t \t \t auto: true, 
 
\t \t \t \t continuous: true 
 
\t \t \t }); 
 
\t \t }); \t 
 
\t </script>

Код в easySlider1.7.js:

(function($) { 
 

 
\t $.fn.easySlider = function(options){ 
 
\t 
 
\t \t // default configuration properties 
 
\t \t var defaults = { \t \t \t 
 
\t \t \t prevId: \t \t 'prevBtn', 
 
\t \t \t prevText: \t \t 'Previous', 
 
\t \t \t nextId: \t \t 'nextBtn', \t 
 
\t \t \t nextText: \t \t 'Next', 
 
\t \t \t controlsShow: \t true, 
 
\t \t \t controlsBefore: \t '', 
 
\t \t \t controlsAfter: \t '', \t 
 
\t \t \t controlsFade: \t true, 
 
\t \t \t firstId: \t \t 'firstBtn', 
 
\t \t \t firstText: \t \t 'First', 
 
\t \t \t firstShow: \t \t false, 
 
\t \t \t lastId: \t \t 'lastBtn', \t 
 
\t \t \t lastText: \t \t 'Last', 
 
\t \t \t lastShow: \t \t false, \t \t \t \t 
 
\t \t \t vertical: \t \t false, 
 
\t \t \t speed: \t \t \t 500, 
 
\t \t \t auto: \t \t \t false, 
 
\t \t \t pause: \t \t \t 5000, 
 
\t \t \t continuous: \t \t false, 
 
\t \t \t numeric: \t \t false, 
 
\t \t \t numericId: \t \t 'controls' 
 
\t \t }; 
 
\t \t 
 
\t \t var options = $.extend(defaults, options); 
 
\t \t \t \t 
 
\t \t this.each(function() { 
 
\t \t \t var obj = $(this); \t \t \t \t 
 
\t \t \t var s = $("li", obj).length; 
 
\t \t \t var w = $("li", obj).width(); 
 
\t \t \t var h = $("li", obj).height(); 
 
\t \t \t var clickable = true; 
 
\t \t \t obj.width(w); 
 
\t \t \t obj.height(h); 
 
\t \t \t obj.css("overflow","hidden"); 
 
\t \t \t var ts = s-1; 
 
\t \t \t var t = 0; 
 
\t \t \t $("ul", obj).css('width',s*w); \t \t \t 
 
\t \t \t 
 
\t \t \t if(options.continuous){ 
 
\t \t \t \t $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px")); 
 
\t \t \t \t $("ul", obj).append($("ul li:nth-child(2)", obj).clone()); 
 
\t \t \t \t $("ul", obj).css('width',(s+1)*w); 
 
\t \t \t }; \t \t \t \t 
 
\t \t \t 
 
\t \t \t if(!options.vertical) $("li", obj).css('float','left'); 
 
\t \t \t \t \t \t \t \t 
 
\t \t \t if(options.controlsShow){ 
 
\t \t \t \t var html = options.controlsBefore; \t \t \t \t 
 
\t \t \t \t if(options.numeric){ 
 
\t \t \t \t \t html += '<ol id="'+ options.numericId +'"></ol>'; 
 
\t \t \t \t } else { 
 
\t \t \t \t \t if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>'; 
 
\t \t \t \t \t html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>'; 
 
\t \t \t \t \t html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>'; 
 
\t \t \t \t \t if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>'; \t \t \t \t 
 
\t \t \t \t }; 
 
\t \t \t \t 
 
\t \t \t \t html += options.controlsAfter; \t \t \t \t \t \t 
 
\t \t \t \t $(obj).after(html); \t \t \t \t \t \t \t \t \t \t 
 
\t \t \t }; 
 
\t \t \t 
 
\t \t \t if(options.numeric){ \t \t \t \t \t \t \t \t \t 
 
\t \t \t \t for(var i=0;i<s;i++){ \t \t \t \t \t \t 
 
\t \t \t \t \t $(document.createElement("li")) 
 
\t \t \t \t \t \t .attr('id',options.numericId + (i+1)) 
 
\t \t \t \t \t \t .html('<a rel='+ i +' href=\"javascript:void(0);\">'+ (i+1) +'</a>') 
 
\t \t \t \t \t \t .appendTo($("#"+ options.numericId)) 
 
\t \t \t \t \t \t .click(function(){ \t \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t animate($("a",$(this)).attr('rel'),true); 
 
\t \t \t \t \t \t }); \t \t \t \t \t \t \t \t \t \t \t \t 
 
\t \t \t \t }; \t \t \t \t \t \t \t 
 
\t \t \t } else { 
 
\t \t \t \t $("a","#"+options.nextId).click(function(){ \t \t 
 
\t \t \t \t \t animate("next",true); 
 
\t \t \t \t }); 
 
\t \t \t \t $("a","#"+options.prevId).click(function(){ \t \t 
 
\t \t \t \t \t animate("prev",true); \t \t \t \t 
 
\t \t \t \t }); \t 
 
\t \t \t \t $("a","#"+options.firstId).click(function(){ \t \t 
 
\t \t \t \t \t animate("first",true); 
 
\t \t \t \t }); \t \t \t \t 
 
\t \t \t \t $("a","#"+options.lastId).click(function(){ \t \t 
 
\t \t \t \t \t animate("last",true); \t \t \t \t 
 
\t \t \t \t }); \t \t \t \t 
 
\t \t \t }; 
 
\t \t \t 
 
\t \t \t function setCurrent(i){ 
 
\t \t \t \t i = parseInt(i)+1; 
 
\t \t \t \t $("li", "#" + options.numericId).removeClass("current"); 
 
\t \t \t \t $("li#" + options.numericId + i).addClass("current"); 
 
\t \t \t }; 
 
\t \t \t 
 
\t \t \t function adjust(){ 
 
\t \t \t \t if(t>ts) t=0; \t \t 
 
\t \t \t \t if(t<0) t=ts; \t 
 
\t \t \t \t if(!options.vertical) { 
 
\t \t \t \t \t $("ul",obj).css("margin-left",(t*w*-1)); 
 
\t \t \t \t } else { 
 
\t \t \t \t \t $("ul",obj).css("margin-left",(t*h*-1)); 
 
\t \t \t \t } 
 
\t \t \t \t clickable = true; 
 
\t \t \t \t if(options.numeric) setCurrent(t); 
 
\t \t \t }; 
 
\t \t \t 
 
\t \t \t function animate(dir,clicked){ 
 
\t \t \t \t if (clickable){ 
 
\t \t \t \t \t clickable = false; 
 
\t \t \t \t \t var ot = t; \t \t \t \t 
 
\t \t \t \t \t switch(dir){ 
 
\t \t \t \t \t \t case "next": 
 
\t \t \t \t \t \t \t t = (ot>=ts) ? (options.continuous ? t+1 : ts) : t+1; \t \t \t \t \t \t 
 
\t \t \t \t \t \t \t break; 
 
\t \t \t \t \t \t case "prev": 
 
\t \t \t \t \t \t \t t = (t<=0) ? (options.continuous ? t-1 : 0) : t-1; 
 
\t \t \t \t \t \t \t break; 
 
\t \t \t \t \t \t case "first": 
 
\t \t \t \t \t \t \t t = 0; 
 
\t \t \t \t \t \t \t break; 
 
\t \t \t \t \t \t case "last": 
 
\t \t \t \t \t \t \t t = ts; 
 
\t \t \t \t \t \t \t break; 
 
\t \t \t \t \t \t default: 
 
\t \t \t \t \t \t \t t = dir; 
 
\t \t \t \t \t \t \t break; 
 
\t \t \t \t \t }; \t 
 
\t \t \t \t \t var diff = Math.abs(ot-t); 
 
\t \t \t \t \t var speed = diff*options.speed; \t \t \t \t \t \t 
 
\t \t \t \t \t if(!options.vertical) { 
 
\t \t \t \t \t \t p = (t*w*-1); 
 
\t \t \t \t \t \t $("ul",obj).animate(
 
\t \t \t \t \t \t \t { marginLeft: p }, 
 
\t \t \t \t \t \t \t { queue:false, duration:speed, complete:adjust } 
 
\t \t \t \t \t \t); \t \t \t \t 
 
\t \t \t \t \t } else { 
 
\t \t \t \t \t \t p = (t*h*-1); 
 
\t \t \t \t \t \t $("ul",obj).animate(
 
\t \t \t \t \t \t \t { marginTop: p }, 
 
\t \t \t \t \t \t \t { queue:false, duration:speed, complete:adjust } 
 
\t \t \t \t \t \t); \t \t \t \t \t 
 
\t \t \t \t \t }; 
 
\t \t \t \t \t 
 
\t \t \t \t \t if(!options.continuous && options.controlsFade){ \t \t \t \t \t 
 
\t \t \t \t \t \t if(t==ts){ 
 
\t \t \t \t \t \t \t $("a","#"+options.nextId).hide(); 
 
\t \t \t \t \t \t \t $("a","#"+options.lastId).hide(); 
 
\t \t \t \t \t \t } else { 
 
\t \t \t \t \t \t \t $("a","#"+options.nextId).show(); 
 
\t \t \t \t \t \t \t $("a","#"+options.lastId).show(); \t \t \t \t \t 
 
\t \t \t \t \t \t }; 
 
\t \t \t \t \t \t if(t==0){ 
 
\t \t \t \t \t \t \t $("a","#"+options.prevId).hide(); 
 
\t \t \t \t \t \t \t $("a","#"+options.firstId).hide(); 
 
\t \t \t \t \t \t } else { 
 
\t \t \t \t \t \t \t $("a","#"+options.prevId).show(); 
 
\t \t \t \t \t \t \t $("a","#"+options.firstId).show(); 
 
\t \t \t \t \t \t }; \t \t \t \t \t 
 
\t \t \t \t \t }; \t \t \t \t 
 
\t \t \t \t \t 
 
\t \t \t \t \t if(clicked) clearTimeout(timeout); 
 
\t \t \t \t \t if(options.auto && dir=="next" && !clicked){; 
 
\t \t \t \t \t \t timeout = setTimeout(function(){ 
 
\t \t \t \t \t \t \t animate("next",false); 
 
\t \t \t \t \t \t },diff*options.speed+options.pause); 
 
\t \t \t \t \t }; 
 
\t \t \t 
 
\t \t \t \t }; 
 
\t \t \t \t 
 
\t \t \t }; 
 
\t \t \t // init 
 
\t \t \t var timeout; 
 
\t \t \t if(options.auto){; 
 
\t \t \t \t timeout = setTimeout(function(){ 
 
\t \t \t \t \t animate("next",false); 
 
\t \t \t \t },options.pause); 
 
\t \t \t }; \t \t 
 
\t \t \t 
 
\t \t \t if(options.numeric) setCurrent(0); 
 
\t \t 
 
\t \t \t if(!options.continuous && options.controlsFade){ \t \t \t \t \t 
 
\t \t \t \t $("a","#"+options.prevId).hide(); 
 
\t \t \t \t $("a","#"+options.firstId).hide(); \t \t \t \t 
 
\t \t \t }; \t \t \t \t 
 
\t \t \t 
 
\t \t }); 
 
\t 
 
\t }; 
 

 
})(jQuery);

файл CSS:

/*Slider*/ \t \t \t 
 

 
.graphic, #prevBtn, #nextBtn, #slider1prev, #slider1next { 
 
margin:0; 
 
padding:0; 
 
display:block; 
 
overflow:hidden; 
 
text-indent:-8000px; 
 
} 
 
\t \t \t 
 
.container-slider{ 
 
margin:0 auto; 
 
position:relative; 
 
text-align:left; 
 
width:900px; 
 
background:#fff; 
 
} 
 

 
#slider ul, #slider li, 
 
#slider2 ul, #slider2 li{ 
 
margin:0; 
 
padding:0; 
 
list-style:none; 
 
} 
 

 
#slider2{margin-top:1em;} 
 

 
#slider li, #slider2 li{ \t 
 
width:900px; 
 
height:396px; 
 
overflow:hidden; 
 
} \t 
 

 
#prevBtn, #nextBtn, 
 
#slider1next, #slider1prev{ 
 
display:block; 
 
width:30px; 
 
height:77px; 
 
position:absolute; 
 
left:-35px; 
 
top:160px; 
 
z-index:1000; 
 
} 
 
\t 
 
#nextBtn, #slider1next{ 
 
left:905px; 
 
} 
 
\t \t \t \t \t \t \t \t \t \t \t \t \t \t 
 
#prevBtn a, #nextBtn a, 
 
#slider1next a, #slider1prev a{ 
 
display:block; 
 
position:relative; 
 
width:29px; 
 
height:51px; 
 
background-image: url(../images/btn_prev2.png); 
 
background-repeat: no-repeat; 
 
background-position: 0 0; 
 
} 
 
\t 
 
#nextBtn a, #slider1next a{ 
 
background-image: url(../images/btn_next2.png); 
 
background-repeat: no-repeat; 
 
background-position: 0 0; 
 
} \t \t 
 

 
ol#controls{ 
 
margin:1em 0; 
 
padding:0; 
 
height:28px; \t 
 
} 
 

 
ol#controls li{ 
 
margin:0 10px 0 0; 
 
padding:0; 
 
float:left; 
 
list-style:none; 
 
height:28px; 
 
line-height:28px; 
 
} 
 

 
ol#controls li a{ 
 
float:left; 
 
height:28px; 
 
line-height:28px; 
 
border:1px solid #ccc; 
 
background:#DAF3F8; 
 
color:#555; 
 
padding:0 10px; 
 
text-decoration:none; 
 
} 
 
\t \t 
 
ol#controls li.current a{ 
 
background:#5DC9E1; 
 
color:#fff; 
 
} 
 

 
ol#controls li a:focus, #prevBtn a:focus, #nextBtn a:focus{outline:none;} 
 
\t 
 
/*Slider*/ 
 

ответ

0

Изменить идентификатор prev/next для второго ползунка, а затем сделать что-то вроде:

$("#slider2").easySlider({ 
    auto: true, 
    continuous: true, 
    nextId: "slider1next", 
    prevId: "slider1prev" 
}); 
+0

Спасибо! Кажется, это сработало! Я закончил с этим: '\t $ (документ) .ready (функция() {\t \t \t \t $ ("# бегунок") easySlider ({ \t \t \t \t авто:. Правда, \t \t \t \t непрерывен : правда, \t \t \t \t prevId: 'prevBtn', NextID: 'nextBtn' \t \t \t}); \t \t \t $ ("# slider2") easySlider ({ \t \t \t \t авто:. Правда, \t \t \t \t непрерывен: правда, \t NextID: "slider1next", \t \t prevId: "slider1prev" \t \t \t }); \t \t}); \t \t ' – Katie

0

Этом изменение, похоже, сработало.

\t $(document).ready(function(){ \t 
 
\t \t \t $("#slider").easySlider({ 
 
\t \t \t \t auto: true, 
 
\t \t \t \t continuous: true, 
 
\t \t \t \t prevId: 'prevBtn', 
 
       nextId: 'nextBtn' 
 
\t \t \t }); 
 
\t \t \t $("#slider2").easySlider({ 
 
\t \t \t \t auto: true, 
 
\t \t \t \t continuous: true, 
 
      \t  nextId: "slider1next", 
 
    \t \t  prevId: "slider1prev" 
 
\t \t \t }); 
 
\t \t }); \t \t