$(document).ready(function(){ dropmenu(); tab(); tooltip(); accordion(); }); function dropmenu(){ if( !$('.rc_dm').length ){ return; } $('.rc_dm').each(function(){ $(this) .find('.dm_ctrl') .click(function(){ var target = $(this).attr('rel'); var w = $(this).outerWidth(); var h = $(this).outerHeight(); var p = $(this).position(); $('.dm_list').not('#'+target).hide(); $('#'+target) .css({ width: w, zIndex: 999, left: p.left, top: p.top + h }) .toggle(); return false; }); }); $(document).click(function(){ $('.dm_list').hide(); }); } function tab(){ if( !$('.rc_tab').length ){ return; } $('.rc_tab').each(function(){ $(this).find('.tab_ctrl:first').addClass('recent'); $(this).find('.tab_content:not(:first)').hide(); $(this).find('.tab_ctrl').click(function(){ var target = $(this).attr('href'); $(this) .parents('.rc_tab') .find('.tab_content').hide() .end() .find('.tab_ctrl').removeClass('recent'); $(this).addClass('recent'); $(target).show(); return false; }); }); } function tooltip(){ if( !$('.rc_tip').length ){ return; } $('.rc_tip').each(function(){ $(this).css({position: 'relative'}); var t = $(this).data('tip'); $(this) .mouseover(function(){ var th = $(this).find('.td').outerHeight(); var p = $(this).offset(); $(this).append(''+t+''); $(this).find('.td').show().css('display','inline-block'); $(document).mousemove(function(e){ $(this).find('.td').css({ left: e.pageX - p.left + 16, top: e.pageY - p.top - th - 20 }); }); }) .mouseout(function(){ $(this).find('.td').hide().detach(); }); }); } function accordion(){ if( !$('.rc_accor').length ){ return; } $('.rc_accor').each(function(){ $(this).find('.ac_ctrl:first').addClass('recent'); $(this).find('.ac_content:not(:first)').hide(); if($(this).hasClass('av')){ $(this).find('.ac_ctrl').click(function(){ var index = $(this).parents('.av').find('.ac_ctrl').index(this); $(this).siblings('.ac_ctrl').removeClass('recent'); $(this).addClass('recent'); $(this).parents('.rc_accor').find('.ac_content:not(:eq('+index+'))').stop().slideUp(); $(this).parents('.rc_accor').find('.ac_content:eq('+index+')').stop().slideToggle(); return false; }); } else if($(this).hasClass('ah')){ var w = $(this).find('.ac_content').css('width'); $(this).find('.ac_content:not(:eq(0))').css({width:0}); $(this).find('.ac_ctrl').click(function(){ var index = $(this).parents('.ah').find('.ac_ctrl').index(this); $(this).siblings('.ac_ctrl').removeClass('recent'); $(this).addClass('recent'); $(this).parents('.rc_accor').find('.ac_content:not(:eq('+index+'))').stop().animate({width:0}); $(this).parents('.rc_accor').find('.ac_content:eq('+index+')').stop().show().animate({width:w}); return false; }); } }); }