;(function($){var PLUGIN_NAME = "tabboxManager"; var ImplementationClass = function(target, config) {var settings = $.extend({}, $[PLUGIN_NAME].defaults, config);var myself = this;$(target).data(PLUGIN_NAME, myself); var $contents = null, $tabButtons = null, $tabButtonLI = null, currentTabIndex = 0, timeoutID = null; function _constructor_() {$(target).on('createChildren', initialize);$(target).on('destroyChildren', destroy);$(target).hover(function () {if (timeoutID != null) {clearTimeout(timeoutID);}}, function () {if (timeoutID != null) {timeoutID = setTimeout(slideShow, settings.pause);}});} function initialize(event) {var $box = $(".tabboxContentsBox", $(target)),contentsHeight = 0; $contents = $(".tabboxContents", $(target));$contents.each(function () {var h = $(this).height();if (h > contentsHeight) {contentsHeight = h;}$(this).css({position: "absolute", top: 0});}); $box.css({ position : "relative" }).height(contentsHeight);$tabButtons = $("#tab_btn");$tabButtonLI = $("li", $tabButtons).on('click', changeTab);currentTabIndex = -1;slideShow();} function destroy(event) {if(timeoutID != null) { clearTimeout(timeoutID); }if($tabButtonLI != null) { $tabButtonLI.off(); }timeoutID = null;} $.extend( myself, { avingnopoint : "" }); _constructor_(); function changeTab(event) {event.preventDefault();var index = $tabButtonLI.index($(this));if(currentTabIndex == index) { return; }if(timeoutID != null) { clearTimeout(timeoutID); }timeoutID = null;activateTab(index);} function activateTab(index) {if(currentTabIndex >= 0) {$("a", $tabButtonLI.eq(currentTabIndex)).removeClass("active");$contents.eq(currentTabIndex).animate( { opacity: 'hide' }, { duration: settings.duration, easing: 'swing' } );} $contents.eq(index).animate( { opacity: 'show' }, { duration: settings.duration, easing: 'swing' } );$("a", $tabButtonLI.eq(index)).addClass("active");currentTabIndex = index;} function slideShow() {var nextIndex = currentTabIndex + 1;if(nextIndex >= $tabButtonLI.length) { nextIndex = 0; }activateTab(nextIndex);timeoutID = setTimeout(slideShow, settings.pause);} }; $[PLUGIN_NAME] = {defaults : {pause: 3000, duration: 500}}; $.fn[PLUGIN_NAME] = function(config){return this.each(function(i){new ImplementationClass(this, config);});}; })(jQuery);