Your IP : 216.73.216.171


Current Path : /home/ereika83/public_html/wp-content/plugins/genesis-club-pro/scripts/
Upload File :
Current File : /home/ereika83/public_html/wp-content/plugins/genesis-club-pro/scripts/jquery.tabbed-widgets.js

(function($) {

	var methods = { init :  function( options ) { 
    	var settings = $.extend({
			container_class : 'tabbed-widget-area',
			tabs_class : 'tabbed-widget-tabs',
			content_class : 'tabbed-widget-content',
			tab_title: '.widgettitle',
			active_tab : 0,
	    	}, options);
	    
    	return this.each(function() { 
    		var ele = $(this);
    		if ( $(this).find('.widget').length >= 2 ) {
    			$(this).addClass(settings.container_class);
				var wrap = $('<div />').addClass(settings.content_class);
				$(this).find('section').wrapAll( wrap);
				var tabs = $('<ul />').addClass(settings.tabs_class);
				$(this).find('.'+settings.content_class).children().each(function(i) {
					var title = $(this).find(settings.tab_title);
					title.hide();
					var anchor = $('<a/>').attr('href',"#").text(title.text());
					if (i==settings.active_tab) anchor.addClass('active');
					var tab = $('<li/>').addClass('tab').addClass('tab'+i).append(anchor);
					tabs.append(tab);
					var wrap = $('<div class="tab'+i+'" />');
					if (i==settings.active_tab) wrap.addClass('active');
					$(this).addClass('tab-content').wrapAll(wrap);	
				});
				$(this).prepend(tabs);

				tabs.find('li.tab a').each(function(i) {
					$(this).click(function(){
            	        var thisTab = $(this).parent().attr('class').replace(/tab /, '');
						var thisMetabox =  $(this).closest('.'+settings.container_class);
            	        var tabs = thisMetabox.find('.'+settings.tabs_class); 	
            	        var content = thisMetabox.find('.'+settings.content_class); 
						content.children('div.active').removeClass('active');
						tabs.find('li a.active').removeClass('active');
						tabs.find('li.'+thisTab+' a').addClass('active');
						content.children('div.'+thisTab).addClass('active');
						return false;
		 			});
	   	 			tabs.show();
				});	
    		} 

		});
      }       
	};

	$.fn.genesis_club_tabbed_widgets = function( method ) {
    	if ( methods[method] ) {
			return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
		} else if ( typeof method === 'object' || ! method ) {
      		return methods.init.apply( this, arguments );
    	} else {
      		$.error( 'Method ' +  method + ' does not exist on genesis_club_tabbed_widgets' );
    	}    
	};
	
})(jQuery);