Skip to content

Instantly share code, notes, and snippets.

Created May 31, 2017 11:17
Show Gist options
  • Select an option

  • Save anonymous/7160a79486a3d6052b9efa778a1515cb to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/7160a79486a3d6052b9efa778a1515cb to your computer and use it in GitHub Desktop.
//функция закрытия попапов по клику вне его
var closeNote = function(elem) {
$(document).mouseup(function(e) {
var container = $(elem).find(".cibkpi__note");
if (!container.is(e.target) && container.has(e.target).length === 0)
{
console.log("call Event");
console.log(elem);
container.removeClass("cibkpi__note--show");
document.removeEventListener("click", closeNote());
}
});
}
//открытие заметок по клику
$("a").each(function(i, elem) {
$(elem).on("click", function(evt) {
if((evt.target === elem.querySelector('.cibkpi__title'))||
(evt.target === elem.querySelector('.cibkpi__note-btn'))) {
evt.preventDefault();
$(elem).find('.cibkpi__note').toggleClass('cibkpi__note--show');
$(elem).find(".cibkpi__note-btn").toggleClass("cibkpi__note-btn--checked");
document.addEventListener("click", closeNote(elem));
console.log("added Event")
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment