Free javascript Hosting


sidetabs.js

Uploaded on Dec 31 2009 00:13 by freebdinfo

var jqsideTabs;
var tabs, h = 50, r = 0,ra = 0;
$(document)
.ready(function(){
jqsideTabs = $('#sideTabs').addClass('closed');

tabs = jqsideTabs
.find('.tab h3')
.clone()
.appendTo(jqsideTabs)
.each(function(i){
var that = $(this), cls = '',ow,newThis, newEl;

if( i == 0 ) cls = ' active';
newEl = $('<a href="#" class="tabLinks'+cls+'">' + that.text() + '</a>');
that.replaceWith(newEl);

ow = newEl.outerWidth();

if( i == 0 ) ra = ow;
else r = ow;

h = newEl.css({'top':h , 'right': -ow }).height() + h;

newThis = newEl.get(0);
newThis.jq = newEl;
newThis.i = i;

newEl.click(function(){
var el = this.jq;

if( jqsideTabs.hasClass( 'closed' ) ){
jqsideTabs.removeClass('closed');
}
else if( !jqsideTabs.hasClass( 'closed' ) && el.hasClass('active') ){
jqsideTabs.addClass('closed');
}

el
.siblings()
.removeClass('active')
.css({'right': -r })
.end()
.addClass('active')
.css({'right': -ra });

tabs.eq( this.i ).show().siblings('.tab').hide();

return false;
});
})
.end()
.parent()
.eq(0)
.addClass('active')
.end()
.filter(':not(:eq(0))')
.hide()
.end();

jqsideTabs.bind("mouseleave",function(){
jqsideTabs
.animate({left:-310}, 'fast', function(){
jqsideTabs.addClass('closed').removeAttr('style');
});
});
});

Back to list