;(function () { 'use strict'; /** * @namespace * @author Nataliia Bezvoziuk <nabe@ciklum.com> */ db.libs.factPopup = (function ($) { var factPopup = $(document).find('#fact-popup-wrapper'); var factPopupButton = $(document).find('#fact-popup-button'); var show = function(e) { factPopup.fadeIn("fast"); }; var hide = function(e) { factPopup.fadeOut("fast"); }; var isDesktop = document.documentElement.clientWidth > 768; var init = function() { $(document).ready(function() { $('#fact-popup-button').click(show); if (isDesktop) { $('#fact-popup-lukk').click(hide); $('#fact-popup-close').click(hide); } else { $('#fact-popup-wrapper').click(hide); } //hide on click outside of the modal window $(document).mouseup(function(e) { if (e.target.id !== factPopup.attr('id') && e.target.id !== factPopupButton.attr('id') && !factPopup.has(e.target).length) { factPopup.fadeOut("fast"); } }); }); }; return { init: init, reflow: init, }; })(jQuery); })();