Created
May 8, 2018 10:26
-
-
Save ratelChief/c56344ecd42f213ffd09e7a27fb4bd40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var onMapPinClick = function (evt) { | |
var target = evt.target; | |
var currentTarget = evt.currentTarget; | |
while (target.parentElement !== currentTarget) { | |
if (!target.parentElement.classList.contains('map__pin--main') && target.parentElement.classList.contains('map__pin')) { | |
var cardElement = template.content.querySelector('.map__card').cloneNode(true); | |
var photoElement = cardElement.querySelector('.popup__photo'); | |
var existPopup = mapElement.querySelector('.popup'); | |
if (existPopup) { | |
existPopup.remove(); | |
} | |
window.card.renderAdCard(window.data.ads[target.parentElement.dataset.indexOfPin], cardElement, photoElement); | |
mapElement.insertBefore(cardElement, document.querySelector('.map__filters-container')); | |
var popup = mapElement.querySelector('.popup'); | |
var popupCloseButton = popup.querySelector('.popup__close'); | |
popupCloseButton.addEventListener('click', function () { | |
popup.remove(); | |
}); | |
} | |
target = target.parentElement; | |
} | |
mapPins.appendChild(fragment); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment