We help IT Professionals succeed at work.
Get Started

Jquery TabSlide - Keeping the tab open indefinitely

LZ1
LZ1 asked
on
1,095 Views
Last Modified: 2012-08-13
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

Comment
Watch Question
Top Expert 2011
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE