Skip to content

Commit

Permalink
делает промежуточную проверку
Browse files Browse the repository at this point in the history
  • Loading branch information
brazilets committed Mar 11, 2024
1 parent b9c0c31 commit 687b8c0
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 6 deletions.
35 changes: 32 additions & 3 deletions js/fullSize.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ import { isEscapeKey, isEnterKey } from './util.js';

const userBigPicture = document.querySelector('.big-picture');
const userBigPictureCancel = document.querySelector('.big-picture__cancel');
const likesCounter = userBigPicture.querySelector('.likes-count');

Check failure on line 5 in js/fullSize.js

View workflow job for this annotation

GitHub Actions / Check

'likesCounter' is assigned a value but never used
const fullPicture = document.querySelector('.big-picture__img');
const pictureUrl = fullPicture.querySelector('img');

Check failure on line 7 in js/fullSize.js

View workflow job for this annotation

GitHub Actions / Check

'pictureUrl' is assigned a value but never used
const socialCommentTotalCount = document.querySelector('.social__comment-total-count');

Check failure on line 8 in js/fullSize.js

View workflow job for this annotation

GitHub Actions / Check

'socialCommentTotalCount' is assigned a value but never used
const socialCommentCount = document.querySelector('.social__comment-count');

Check failure on line 9 in js/fullSize.js

View workflow job for this annotation

GitHub Actions / Check

'socialCommentCount' is assigned a value but never used
const description = document.querySelector('.social__caption');

Check failure on line 10 in js/fullSize.js

View workflow job for this annotation

GitHub Actions / Check

'description' is assigned a value but never used
const commentsLoader = document.querySelector('.comments-loader');

Check failure on line 11 in js/fullSize.js

View workflow job for this annotation

GitHub Actions / Check

'commentsLoader' is assigned a value but never used


const onBigPictureKeydown = (evt) => {
if (isEscapeKey(evt)) {
Expand All @@ -12,13 +20,34 @@ const onBigPictureKeydown = (evt) => {

function openBigPicture() {
userBigPicture.classList.remove('hidden');

// body.classList.add('modal-open');
document.addEventListener('keydown', onBigPictureKeydown);
}

// const socialComments = document.querySelector('.social__comments');

// comments.forEach((comment) => {
// const commentElement = document.createElement('li');
// commentElement.classList.add('social__comment');

// const avatarImg = document.createElement('img');
// avatarImg.classList.add('social__picture');
// avatarImg.src = comment.avatar;
// avatarImg.alt = comment.name;

// const textElement = document.createElement('p');
// textElement.classList.add('social__text');
// textElement.textContent = comment.text;

// commentElement.appendChild(avatarImg);
// commentElement.appendChild(textElement);

// socialComments.appendChild(commentElement);
// });

function closeBigPicture() {
userBigPicture.classList.add('hidden');

// body.classList.remove('modal-open');
document.removeEventListener('keydown', onBigPictureKeydown);
}

Expand All @@ -32,4 +61,4 @@ userBigPictureCancel.addEventListener('keydown', (evt) => {
}
});

export { openBigPicture, closeBigPicture };
export { openBigPicture, closeBigPicture, userBigPicture };
10 changes: 7 additions & 3 deletions js/thumbnails.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createPosts } from './data.js';
import { openBigPicture } from './fullSize.js';
import { openBigPicture, userBigPicture } from './fullSize.js';

const templateUserPicture = document.querySelector('#picture')
.content
Expand All @@ -12,12 +12,13 @@ const containerUsersPictures = document.querySelector('.pictures');
const renderUsersPictures = () => {
const usersPicturesFragment = document.createDocumentFragment();

usersPictures.forEach(({ url, description, likes, comments }) => {
usersPictures.forEach(({ url, description, likes, comments, id }) => {
const userPicture = templateUserPicture.cloneNode(true);
userPicture.querySelector('.picture__img').src = url;
userPicture.querySelector('.picture__img').alt = description;
userPicture.querySelector('.picture__likes').textContent = likes;
userPicture.querySelector('.picture__comments').textContent = comments.length;
userPicture.dataset.id = id;
usersPicturesFragment.append(userPicture);
});

Expand All @@ -28,7 +29,10 @@ const renderUsersPictures = () => {
const pictureHandler = () => {
const pictures = document.querySelectorAll('.picture');
pictures.forEach((picture) => {
picture.addEventListener('click', () => {
picture.addEventListener('click', (event) => {
const currentPicture = usersPictures.find((photo) => event.currentTarget.dataset.id === photo.id.toString());
userBigPicture.querySelector('.big - picture__img img').src = currentPicture.url;
userBigPicture.querySelector('.social__comment-shown-count').textContent = currentPicture.comments.length;
openBigPicture();
});
});
Expand Down

0 comments on commit 687b8c0

Please sign in to comment.