/*global $ */ $(function () { 'use strict'; var animateIn = 'animated slideInLeft', animateOut = 'animated slideOutLeft collapsing-delay', $side = $("#side"); $side.on('swipeleft', function (e) { if ($(window).width() < 768 && $side.hasClass('in')) { $side.addClass(animateOut); $side.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () { $side.removeClass(animateOut).removeClass('in'); }); } }); $(document).on('mouseup', function (e) { var closeSide = false; if ($(window).width() < 768 && e.target.parentElement && e.target.parentElement.className === 'close-side' && $side.hasClass('in')) { closeSide = true; } if ($(window).width() < 768 && !$side.is(e.target) && $side.has(e.target).length === 0 && e.target.parentElement && e.target.parentElement.id !== 'toggler' && $side.hasClass('in')) { closeSide = true; } // if the target of the click isn't the container nor a descendant of the container if (closeSide) { $side.addClass(animateOut); $side.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () { $side.removeClass(animateOut).removeClass('in'); }); } }); $side.on('show.bs.collapse', function () { $side.addClass(animateIn).on('shown.bs.collapse', function () { $side.removeClass(animateIn); }); }); $side.on('hide.bs.collapse', function () { $side.addClass(animateOut).on('hidden.bs.collapse', function () { $side.removeClass(animateOut); }); }); });