troubleshooting Question

Jquery TabSlide - Keeping the tab open indefinitely

Avatar of LZ1
LZ1Flag for United States of America asked on
jQueryJavaScript
4 Comments1 Solution1099 ViewsLast Modified:
Hey Experts!!

I am using the Jquery tabslide (http://www.exfer.net/test/jquery/tabslide/) for my site.
I'm just playing around with it at this point, but does anyone know how I can keep the tabs open indefinitely? or via an onclick?  

The jquery is below:
var sliding = 0;
var slideTime = '';
 
// Set is sliding value
function setSliding(a_ISliding){
	sliding = a_ISliding;
}
 
// Get is sliding value
function getSliding(){
	return sliding;
}
 
// Carry out accordian styled effect
function accordion(evt) {
	el = Event.element(evt);
	var eldown = getNextSibling(el);
	
	//  If element is visible do nothing
	if ($('visible') == el) {
			return;
	}
	if ($('visible')) {
	
			if( getSliding() == 1 ){
					return false;
			}
		
			var elup = getNextSibling($('visible'));
 
			setSliding( 1 );
			
			parellelSlide( elup, eldown );
			$('visible').id = '';
			
	}
	else{
			setSliding( 1 );
			singleSlide( eldown );
	}
	
	el.id = 'visible';
}
 
 
// Setup accordian initial state
function init() {
		
		var bodyPanels = document.getElementsByClassName('panel_body');
		var panels = document.getElementsByClassName('panel');
		var noPanels = panels.length;
		var percentageWidth = 100 / noPanels;
		var position = 0;
		
		//  Loop through body panels and panels applying required styles and adding event listeners
    for (i = 0; i < bodyPanels.length; i++) {
			bodyPanels[i].hide();
			panels[i].style.width = percentageWidth + '%';
			panels[i].style.position = 'absolute';
			panels[i].style.left = position + '%';
			
			Event.observe(panels[i].getElementsByTagName('h3')[0], 'mouseover', accordion, false);
			Event.observe(panels[i].getElementsByTagName('h3')[0], 'mousemove', accordion, false);
			Event.observe(document.body, 'mousemove', resetIdle, false);
			
			position += percentageWidth;
    }
		
		if( $('visible') ){
		//  Set panel with id of visible to be initial displayed
			var vis = $('visible').parentNode.id+'-body';
			$(vis).show();
		}
		setIdle();
}
 
// Next sibling method to work around firefox issues
function getNextSibling(startBrother){
	var endBrother=startBrother.nextSibling;
  while(endBrother.nodeType!=1){
    endBrother = endBrother.nextSibling;
  }
  return endBrother;
}
 
function parellelSlide( elup, eldown ){
		new Effect.Parallel(
		[
				new Effect.SlideUp(elup),
				new Effect.SlideDown(eldown)
		], {
				duration: 0.3,
				afterFinish: function() { setSliding( 0 );}
		});
}
 
function singleSlide( eldown ){
	
		new Effect.Parallel(
		[
				new Effect.SlideDown(eldown)
		], {
				duration: 0.3,
				afterFinish: function() { setSliding( 0 );}
		});
}
 
function resetTabs(){
	
	var resetEl = getNextSibling( $('visible') );
	
	setSliding( 1 );
	
	new Effect.Parallel(
	[
			new Effect.SlideUp( resetEl )
	], {
			duration: 0.3,
			afterFinish: function() { setSliding( 0 );}
	});
	
	$('visible').id = '';
}
 
function resetIdle(){
		if($('visible')){
				window.clearTimeout( slideTime);
				slideTime = window.setTimeout( "resetTabs()", 1000 );
		}
}
 
function setIdle(){
	if( $('visible') ){
		slideTime = window.setTimeout( "resetTabs()", 10000 );
	}
}
 
Event.observe(window, 'load', init, false);

Open in new window

ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros