|
Page 1 of 1
|
[ 3 posts ] |
|
Active tab not working with non-dynamic tabs
| Author |
Message |
|
zenicanin
Joined: Wed Dec 16, 2009 1:05 pm Posts: 1
|
 Active tab not working with non-dynamic tabs
It works if I click on each tab individually, but as it progresses through the slides, the active tab stays on tab 1. I'm using latest version. Can you help please? Here's the code. Code: <div class="coda-nav" id="coda-nav-1">
<ul> <li class="tab1"><a href="#1" class="xtrig" rel="coda-slider-1">Recent News One</a> <span class="researchSeparator">|</span></li> <li class="tab2"><a href="#2" class="xtrig" rel="coda-slider-1">Recent News Two</a> <span class="researchSeparator">|</span></li> <li class="tab3"><a href="#3" class="xtrig" rel="coda-slider-1">Recent News Three</a></li> </ul>
<div class="clear"></div> </div>
<div class="wideBlueBoxContent"> <div class="coda-slider-wrapper"> <div class="coda-slider" id="coda-slider-1"> <div class="panel"> <div class="panel-wrapper"> <img src="recentNews1.jpg" /> <h2 class="title">Recent News One</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas metus nulla. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas metus nulla.</p> </div> </div> <div class="panel"> <div class="panel-wrapper"> <img src="recentNews2.jpg" /> <h2 class="title">Recent News Two</h2> <p>Proin nec turpis eget dolor dictum lacinia. Nullam nunc magna, tincidunt eu porta in. Proin nec turpis eget dolor dictum lacinia. Nullam nunc magna.</p>
</div> </div> <div class="panel"> <div class="panel-wrapper"> <img src="recentNews3.jpg" /> <h2 class="title">Recent News Three</h2> <p>Cras luctus fringilla odio vel hendrerit. Cras pulvinar auctor sollicitudin. Cras luctus fringilla odio vel hendrerit. Cras pulvinar auctor sollicitudin.</p> </div>
</div> </div><!-- .coda-slider --> </div><!-- .coda-slider-wrapper --> </div>
slider JS file Code: /* jQuery Coda-Slider v2.0 - http://www.ndoherty.biz/coda-slider Copyright (c) 2009 Niall Doherty This plugin available for use in all personal or commercial projects under both MIT and GPL licenses. */
$(function(){ // Remove the coda-slider-no-js class from the body $("body").removeClass("coda-slider-no-js"); // Preloader $(".coda-slider").children('.panel').hide().end().prepend('<p class="loading">Loading...<br /><img src="images/ajax-loader.gif" alt="loading..." /></p>'); });
var sliderCount = 1;
$.fn.codaSlider = function(settings) {
settings = $.extend({ autoHeight: true, autoHeightEaseDuration: 1000, autoHeightEaseFunction: "easeInOutExpo", autoSlide: false, autoSlideInterval: 7000, autoSlideStopWhenClicked: true, crossLinking: true, dynamicArrows: true, dynamicArrowLeftText: "« left", dynamicArrowRightText: "right »", dynamicTabs: true, dynamicTabsAlign: "center", dynamicTabsPosition: "top", externalTriggerSelector: "a.xtrig", firstPanelToLoad: 1, panelTitleSelector: "h2.title", slideEaseDuration: 1000, slideEaseFunction: "easeInOutExpo" }, settings); return this.each(function(){ // Uncomment the line below to test your preloader // alert("Testing preloader"); var slider = $(this); // If we need arrows if (settings.dynamicArrows) { slider.parent().addClass("arrows"); slider.before('<div class="coda-nav-left" id="coda-nav-left-' + sliderCount + '"><a href="#">' + settings.dynamicArrowLeftText + '</a></div>'); slider.after('<div class="coda-nav-right" id="coda-nav-right-' + sliderCount + '"><a href="#">' + settings.dynamicArrowRightText + '</a></div>'); }; var panelWidth = slider.find(".panel").width(); var panelCount = slider.find(".panel").size(); var panelContainerWidth = panelWidth*panelCount; var navClicks = 0; // Used if autoSlideStopWhenClicked = true // Surround the collection of panel divs with a container div (wide enough for all panels to be lined up end-to-end) $('.panel', slider).wrapAll('<div class="panel-container"></div>'); // Specify the width of the container div (wide enough for all panels to be lined up end-to-end) $(".panel-container", slider).css({ width: panelContainerWidth }); // Specify the current panel. // If the loaded URL has a hash (cross-linking), we're going to use that hash to give the slider a specific starting position... if (settings.crossLinking && location.hash && parseInt(location.hash.slice(1)) <= panelCount) { var currentPanel = parseInt(location.hash.slice(1)); var offset = - (panelWidth*(currentPanel - 1)); $('.panel-container', slider).css({ marginLeft: offset }); // If that's not the case, check to see if we're supposed to load a panel other than Panel 1 initially... } else if (settings.firstPanelToLoad != 1 && settings.firstPanelToLoad <= panelCount) { var currentPanel = settings.firstPanelToLoad; var offset = - (panelWidth*(currentPanel - 1)); $('.panel-container', slider).css({ marginLeft: offset }); // Otherwise, we'll just set the current panel to 1... } else { var currentPanel = 1; }; // Left arrow click $("#coda-nav-left-" + sliderCount + " a").click(function(){ navClicks++; if (currentPanel == 1) { offset = - (panelWidth*(panelCount - 1)); alterPanelHeight(panelCount - 1); currentPanel = panelCount; slider.siblings('.coda-nav').find('a.current').removeClass('current').parents('ul').find('li:last a').addClass('current'); } else { currentPanel -= 1; alterPanelHeight(currentPanel - 1); offset = - (panelWidth*(currentPanel - 1)); slider.siblings('.coda-nav').find('a.current').removeClass('current').parent().prev().find('a').addClass('current'); }; $('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction); if (settings.crossLinking) { location.hash = currentPanel }; // Change the URL hash (cross-linking) return false; }); // Right arrow click $('#coda-nav-right-' + sliderCount + ' a').click(function(){ navClicks++; if (currentPanel == panelCount) { offset = 0; currentPanel = 1; alterPanelHeight(0); slider.siblings('.coda-nav').find('a.current').removeClass('current').parents('ul').find('a:eq(0)').addClass('current'); } else { offset = - (panelWidth*currentPanel); alterPanelHeight(currentPanel); currentPanel += 1; slider.siblings('.coda-nav').find('a.current').removeClass('current').parent().next().find('a').addClass('current'); }; $('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction); if (settings.crossLinking) { location.hash = currentPanel }; // Change the URL hash (cross-linking) return false; }); // If we need a dynamic menu if (settings.dynamicTabs) { var dynamicTabs = '<div class="coda-nav" id="coda-nav-' + sliderCount + '"><ul></ul></div>'; switch (settings.dynamicTabsPosition) { case "bottom": slider.parent().append(dynamicTabs); break; default: slider.parent().prepend(dynamicTabs); break; }; ul = $('#coda-nav-' + sliderCount + ' ul'); // Create the nav items $('.panel', slider).each(function(n) { ul.append('<li class="tab' + (n+1) + '"><a href="#' + (n+1) + '">' + $(this).find(settings.panelTitleSelector).text() + '</a></li>'); }); navContainerWidth = slider.width() + slider.siblings('.coda-nav-left').width() + slider.siblings('.coda-nav-right').width(); ul.parent().css({ width: navContainerWidth }); switch (settings.dynamicTabsAlign) { case "center": ul.css({ width: ($("li", ul).width() + 2) * panelCount }); break; case "right": ul.css({ float: 'right' }); break; }; }; // If we need a tabbed nav $('#coda-nav-' + sliderCount + ' a').each(function(z) { // What happens when a nav link is clicked $(this).bind("click", function() { navClicks++; $(this).addClass('current').parents('ul').find('a').not($(this)).removeClass('current'); offset = - (panelWidth*z); alterPanelHeight(z); currentPanel = z + 1; $('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction); if (!settings.crossLinking) { return false }; // Don't change the URL hash unless cross-linking is specified }); }); // External triggers (anywhere on the page) $(settings.externalTriggerSelector).each(function() { // Make sure this only affects the targeted slider if (sliderCount == parseInt($(this).attr("rel").slice(12))) { $(this).bind("click", function() { navClicks++; targetPanel = parseInt($(this).attr("href").slice(1)); offset = - (panelWidth*(targetPanel - 1)); alterPanelHeight(targetPanel - 1); currentPanel = targetPanel; // Switch the current tab: slider.siblings('.coda-nav').find('a').removeClass('current').parents('ul').find('li:eq(' + (targetPanel - 1) + ') a').addClass('current'); // Slide $('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction); if (!settings.crossLinking) { return false }; // Don't change the URL hash unless cross-linking is specified }); }; }); // Specify which tab is initially set to "current". Depends on if the loaded URL had a hash or not (cross-linking). if (settings.crossLinking && location.hash && parseInt(location.hash.slice(1)) <= panelCount) { $("#coda-nav-" + sliderCount + " a:eq(" + (location.hash.slice(1) - 1) + ")").addClass("current"); // If there's no cross-linking, check to see if we're supposed to load a panel other than Panel 1 initially... } else if (settings.firstPanelToLoad != 1 && settings.firstPanelToLoad <= panelCount) { $("#coda-nav-" + sliderCount + " a:eq(" + (settings.firstPanelToLoad - 1) + ")").addClass("current"); // Otherwise we must be loading Panel 1, so make the first tab the current one. } else { $("#coda-nav-" + sliderCount + " a:eq(0)").addClass("current"); }; // Set the height of the first panel if (settings.autoHeight) { panelHeight = $('.panel:eq(' + (currentPanel - 1) + ')', slider).height(); slider.css({ height: panelHeight }); }; // Trigger autoSlide if (settings.autoSlide) { slider.ready(function() { setTimeout(autoSlide,settings.autoSlideInterval); }); }; function alterPanelHeight(x) { if (settings.autoHeight) { panelHeight = $('.panel:eq(' + x + ')', slider).height() slider.animate({ height: panelHeight }, settings.autoHeightEaseDuration, settings.autoHeightEaseFunction); }; }; function autoSlide() { if (navClicks == 0 || !settings.autoSlideStopWhenClicked) { if (currentPanel == panelCount) { var offset = 0; currentPanel = 1; } else { var offset = - (panelWidth*currentPanel); currentPanel += 1; }; alterPanelHeight(currentPanel - 1); // Switch the current tab: slider.siblings('.coda-nav').find('a').removeClass('current').parents('ul').find('li:eq(' + (currentPanel - 1) + ') a').addClass('current'); // Slide: $('.panel-container', slider).animate({ marginLeft: offset }, settings.slideEaseDuration, settings.slideEaseFunction); setTimeout(autoSlide,settings.autoSlideInterval); }; }; // Kill the preloader $('.panel', slider).show().end().find("p.loading").remove(); slider.removeClass("preload"); sliderCount++; }); };
|
| Wed Dec 16, 2009 1:09 pm |
|
 |
|
pagepusher
Joined: Wed Mar 10, 2010 4:00 am Posts: 1
|
 Re: Active tab not working with non-dynamic tabs
Hi. I'm having the exact same problem and is about to give up. Did you find any solution? Thanks for a great JS-tool 
|
| Wed Mar 10, 2010 4:03 am |
|
 |
|
leanda
Joined: Sat Mar 13, 2010 4:43 pm Posts: 2
|
 Re: Active tab not working with non-dynamic tabs
Same problem but only in Firefox, works fine in Safari. dynamicTabs and dynamicArrows both set to false in the head and the jquery.coda-slider-2.0.js Using #coda-slider-5 doesn't work as in the example having to use #coda-slider-1. html: Code: <div class="coda-slider-wrapper"> <div id="coda-nav-left-1" class="coda-nav-left"><a href="#" title="Slide left"></a></div> <div class="coda-slider preload" id="coda-slider-1"> <div class="panel"> <div class="panel-wrapper"> <img src="images/sparks_remove.png" alt="" width="930px" height="310px"/> </div> </div> <div class="panel"> <div class="panel-wrapper"> <img src="images/slide1_remove.png" alt="" width="" height=""/> </div> </div> <div class="panel"> <div class="panel-wrapper"> <img src="images/slide2_remove.png" alt="" width="" height=""/> </div> </div> </div><!-- .coda-slider --> <div id="coda-nav-right-1" class="coda-nav-right"><a href="#" title="Slide right"></a></div> <div id="coda-nav-1" class="coda-nav"> <ul> <li class="tab1"><a href="#1">Panel 1</a></li> <li class="tab2"><a href="#2">Panel 2</a></li> <li class="tab3"><a href="#3">Panel 3</a></li> </ul> </div> </div><!-- .coda-slider-wrapper --> CSS: Code: /* jQuery Coda-Slider v2.0 - http://www.ndoherty.biz/coda-slider Copyright (c) 2009 Niall Doherty This plugin available for use in all personal or commercial projects under both MIT and GPL licenses. */
/* Most common stuff you'll need to change */
.coda-slider-wrapper { padding: 0 0 } .coda-slider { background: #DDDFE0; border: 1px solid #fff; } /* Use this to keep the slider content contained in a box even when JavaScript is disabled */ .coda-slider-no-js .coda-slider { height: 318px; overflow: hidden !important; } /* Change the width of the entire slider (without dynamic arrows) */
.coda-slider, .coda-slider .panel { width: 938px; height: 318px; } /* Change margin and width of the slider (with dynamic arrows) */ .coda-slider-wrapper.arrows .coda-slider, .coda-slider-wrapper.arrows .coda-slider .panel { width: 938px } .coda-slider-wrapper.arrows .coda-slider { margin: 0 10px } /* Arrow styling */ .coda-nav-left a { background: url(../images/arrow_left.png) no-repeat; color: #fff; margin: 174px 6px 0 0; width: 24px; height: 36px; } .coda-nav-right a { background: url(../images/arrow_right.png) no-repeat; color: #fff; margin: 174px 0 0 6px; width: 24px; height: 36px; } /* Tab nav */ .coda-nav ul li a.current { background: url(../images/red_dot.png) no-repeat} /* Panel padding */ .coda-slider .panel-wrapper { padding: 4px } /* Preloader */ .coda-slider p.loading { padding: 20px; text-align: center }
/* Don't change anything below here unless you know what you're doing */
/* Tabbed nav */ .coda-nav ul { clear: both; display: block; margin: auto; overflow: hidden; } .coda-nav ul li { display: inline } .coda-nav ul li a { background: url(../images/grey_dot.png) no-repeat; display: block; float: left; margin: 0 6px 0 6px; padding: 7px 6px 7px 6px; text-decoration: none } /* Miscellaneous */ .coda-slider-wrapper { clear: both; overflow: auto; } .coda-slider { float: left; overflow: hidden; position: relative; margin: 30px 0 17px 0; } .coda-slider .panel { display: block; float: left; } .coda-slider .panel-container { position: relative; } .coda-nav-left, .coda-nav-right { float: left; } .coda-nav-left a, .coda-nav-right a { display: block; text-align: center; text-decoration: none; } .coda-nav ul span { display: none; }
|
| Sun Mar 14, 2010 1:38 pm |
|
|
|
Page 1 of 1
|
[ 3 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 3 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|