(function () { $(document).ready(function () { KsTopbar.init(); }); })(window.jQuery); var KsTopbar = { /** * Constructeur * * @return {void} */ init: function () { var m_topbar = $(document).find('#kstopbar'); var m_body = $(document).find('body'); m_body.addClass('has-kstopbar'); checkScroll(); $(window).scroll(function (event) { checkScroll(); }); function checkScroll() { var scroll = $(window).scrollTop(); if(scroll <= 25) { $(document).find('body').removeClass('kstopbar-invisible'); } else { $(document).find('body').addClass('kstopbar-invisible'); } } // LEFT if($(document).find('.kstopbar-left').hasClass('is-animating')) { var timer1_click = false; if(parseInt($(document).find('.kstopbar-left').data('click')) == 1) { timer1_click = true; } var timer1_speed = 6000; if($(document).find('.kstopbar-left').data('speed') !== undefined) { timer1_speed = parseInt($(document).find('.kstopbar-left').data('speed')); } if(!timer1_click) { var timer1 = setInterval(timer_left, 6000); function timer_left() { nextTimerLeft(); } } } $(document).on('click', '.kstopbar-left[data-click="1"] .kstopbar-item', function(){ nextTimerLeft(); }); function nextTimerLeft() { var tc = $(document).find('.kstopbar-left .kstopbar-item.active'); var tc_next_item = parseInt(tc.data('item'))+1; var tc_next = $(document).find('.kstopbar-left .kstopbar-item[data-item="'+tc_next_item+'"]'); if(tc_next.length == 0) { tc_next = $(document).find('.kstopbar-left .kstopbar-item:first-child'); } tc.removeClass('active'); tc_next.addClass('active'); } // RIGHT` if($(document).find('.kstopbar-right').hasClass('is-animating')) { var timer2_click = false; if(parseInt($(document).find('.kstopbar-right').data('click')) == 1) { timer2_click = true; } var timer2_speed = 6000; if($(document).find('.kstopbar-right').data('speed') !== undefined) { timer2_speed = parseInt($(document).find('.kstopbar-right').data('speed')); } if(!timer2_click) { var timer2 = setInterval(timer_right, timer2_speed); function timer_right() { nextTimerRight(); } } } $(document).on('click', '.kstopbar-right[data-click="1"] .kstopbar-item', function(){ nextTimerRight(); }); function nextTimerRight() { var tc = $(document).find('.kstopbar-right .kstopbar-item.active'); var tc_next_item = parseInt(tc.data('item'))+1; var tc_next = $(document).find('.kstopbar-right .kstopbar-item[data-item="'+tc_next_item+'"]'); if(tc_next.length == 0) { tc_next = $(document).find('.kstopbar-right .kstopbar-item:first-child'); } tc.removeClass('active'); tc_next.addClass('active'); } // MOBILE if($(document).find('.kstopbar-mobile').hasClass('is-animating')) { var timer3_click = false; if(parseInt($(document).find('.kstopbar-mobile').data('click')) == 1) { timer3_click = true; } var timer3_speed = 6000; if($(document).find('.kstopbar-mobile').data('speed') !== undefined) { timer3_speed = parseInt($(document).find('.kstopbar-mobile').data('speed')); } if(!timer3_click) { var timer3 = setInterval(timer_mobile, 6000); function timer_mobile() { nextTimerMobile(); } } } $(document).on('click', '.kstopbar-mobile[data-click="1"] .kstopbar-item', function(){ nextTimerMobile(); }); function nextTimerMobile() { var tc = $(document).find('.kstopbar-mobile .kstopbar-item.active'); var tc_next_item = parseInt(tc.data('item'))+1; var tc_next = $(document).find('.kstopbar-mobile .kstopbar-item[data-item="'+tc_next_item+'"]'); if(tc_next.length == 0) { tc_next = $(document).find('.kstopbar-mobile .kstopbar-item:first-child'); } tc.removeClass('active'); tc_next.addClass('active'); } }, };