/********************************************* * eposnet.js --------------------------------------------- @constructor @init @plugin * - eposnetTabChange *********************************************/ /* ------------------------------------------- * @constructor ------------------------------------------- */ var u = new EPOS_CARD.Util(); // u インスタンスを作成 /* ------------------------------------------- * @init ------------------------------------------- */ j$(function(){ j$.eposnetTabChange(); }); /* ------------------------------------------- * @plugin ------------------------------------------- */ (function(j$){ /* * @plugin - lotTabChange */ j$.eposnetTabChange= function(config){ if(u.isRangeSP()){ return false; } var $tabs = j$('.eposnetTab'), $content = j$('.eposnetTabBox'), TAB_ACTIVE_CLASS = 'current', CONTENT_SHOW_CLASS = 'current', id_arr = $content.map(function() { return '#' + j$(this).attr('id');}).get(), bottomTab = 'bottomTab'; if($tabs.length === 0){ return false; } var getHash = function() { var hash = window.location.hash; var index = id_arr.indexOf(hash); if (index === -1) { return false; } else { return id_arr[index]; } }; var initialize = function() { var hash = getHash(); if (hash) { var currentTab = $tabs.find('a[href="'+hash+'"]').closest("li"); currentTab.addClass(TAB_ACTIVE_CLASS); j$(hash).addClass(CONTENT_SHOW_CLASS); } else { $tabs.find('li:first').addClass(TAB_ACTIVE_CLASS); j$($content[0]).addClass(CONTENT_SHOW_CLASS); } }; var addEvent = function() { $tabs.find('a').on('click', function(e) { var href = j$(this).attr('href'); var $targetContent = j$(href); if (j$(this).closest("li").hasClass(TAB_ACTIVE_CLASS)) { return false; } $tabs.find('li').removeClass(TAB_ACTIVE_CLASS); $content.removeClass(CONTENT_SHOW_CLASS); var currentTab = $tabs.find('a[href="'+href+'"]').closest("li"); currentTab.addClass(TAB_ACTIVE_CLASS); $targetContent.addClass(CONTENT_SHOW_CLASS); EPOS_CARD.module.sizeFix(); EPOS_CARD.module.equalHeight(true, true); if(j$(this).parents('.eposnetTab').hasClass(bottomTab)){ j$(/webkit/.test(navigator.userAgent.toLowerCase()) ? "body" : "html").animate({ scrollTop: j$("#eposnetTabArea").offset().top - $tabs.height() }, 300, "swing"); } return false; }); }; return [initialize(), addEvent()]; }; })(jQuery);