(function ($) { $(document).ready(function() { // // ************** // Back to Top // ************** /* $(window).scroll(function () { if ($(this).scrollTop() > 200) { $('#back-top').removeClass('bounce-out').addClass('bounce-in'); } else { $('#back-top').removeClass('bounce-in').addClass('bounce-out'); } });*/ $('#back-top').click(function () { $('body,html').stop(false, false).animate({ scrollTop: 0 }, 400); return false; }); }); })(window.jQuery);;/* * Check if the current view is Desktop * * @returns {Boolean} */ function viewDesktop() { var width = jQuery('#wrap').innerWidth(); //console.log('w = ' + width); if (width > 730) { return true; } else { return false; } } /* * Закрывает все текущие раскрытые пункты .dropdown * */ function closingDropdowns() { jQuery('.drop-hover .dropdown-menu').each( function() { jQuery(this).closest('.dropdown').removeClass('open'); jQuery(this).closest('.dropdown').removeClass('dontClose'); }); } function dropHoverMenu() { jQuery('.drop-hover .dropdown').on('show.bs.dropdown', function () { if (jQuery('.dropdown-toggle', this).hasClass('isdisabled')) { jQuery('.dropdown-toggle', this).removeClass('isdisabled'); } }); jQuery('.drop-hover .dropdown').on('hide.bs.dropdown', function (e) { if (jQuery(this).hasClass('dontClose')) { /* Если .dropdown-toggle - активная ссылка (для этого элементу * необходимо добавить класс .disabled): * * Пример разметки: * * * То по-разному отслеживаем клики по табам внутри .dropdown-menu * * см. выше: * $(.dropdown-menu').on('click', '.nav-tabs a', function(){ ... }); */ if (jQuery('.dropdown-toggle', this).hasClass('dhelp')) { if (jQuery('.dropdown-toggle', this).hasClass('isdisabled')) { jQuery(this).removeClass('dontClose'); } } else { jQuery(this).removeClass('dontClose'); } e.preventDefault(); } else { } }); jQuery('.drop-hover .dropdown').on('hidden.bs.dropdown', function (e) { jQuery(this).removeClass('open'); if (jQuery('.dropdown-toggle', this).hasClass('isdisabled')) { jQuery('.dropdown-toggle', this).removeClass('isdisabled'); jQuery('.dropdown-toggle', this).addClass('disabled'); } }); // Showing dropdown content on hover //$('.drop-hover .navbar-nav > li').on({ jQuery('.drop-hover .dropdown').on({ mouseenter: function () { if (viewDesktop()) { jQuery('.dropdown-toggle', this).trigger('click'); } }, mouseleave: function () { if (viewDesktop()) { if (jQuery(this).hasClass('open')) { //Класс isdisabled введён, чтобы работали переходы по ссылкам //с классом dropdown-toggle if (jQuery('.dropdown-toggle', this).hasClass('disabled')) { jQuery('.dropdown-toggle', this).removeClass('disabled'); jQuery('.dropdown-toggle', this).addClass('isdisabled'); jQuery('.dropdown-toggle', this).trigger('click'); } else { jQuery('.dropdown-toggle', this).trigger('click'); } //У пункта .dropdown должна быть хотя бы одна ссылка //без класса .disabled, чтобы выпадание блока .dropdown-menu работало jQuery('.dhelp', this).removeClass('disabled'); } } }, }); jQuery('.drop-hover .dropdown .dropdown-toggle').on({ click: function() { if (jQuery(this).parent().hasClass('dontClose')) { jQuery(this).parent().removeClass('dontClose'); jQuery(this).parent().removeClass('open'); jQuery(this).trigger('click'); } } }); // При открытии одного из пунктов закрываем другие jQuery('.drop-hover > .dropdown').on('show.bs.dropdown', function (e) { closingDropdowns(); jQuery(this).parent().addClass('open'); }); jQuery(window).scroll(function () { // Don't close dropdown-menu on scrolling on mobile if (!viewDesktop()) { jQuery('.drop-hover .dropdown.open').addClass('dontClose'); } }); } (function ($) { $(document).ready(function() { dropHoverMenu(); }); })(window.jQuery);;(function ($) { $(document).ready(function() { jQuery('.colorbox').colorbox(); }); })(window.jQuery);