11import { toggleClass , isEscapeKey } from './util.js' ;
22
3+ const COMMENT_STEP = 5 ;
4+
35const fullSizePhotoContainer = document . querySelector ( '.big-picture' ) ;
46const fullSizePhoto = fullSizePhotoContainer . querySelector ( '.big-picture__img img' ) ;
57const likesCount = document . querySelector ( '.likes-count' ) ;
68const commentCount = document . querySelector ( '.social__comment-count' ) ;
79const userCommentsContainer = document . querySelector ( '.social__comments' ) ;
810const userComment = userCommentsContainer . querySelector ( '.social__comment' ) ;
9- const commentsLoaderBtn = document . querySelector ( '.comments-loader' ) ;
11+ const commentsLoaderButton = document . querySelector ( '.comments-loader' ) ;
1012const caption = document . querySelector ( '.social__caption' ) ;
11- const closeBtn = document . querySelector ( '#picture-cancel' ) ;
12-
13- const COMMENT_STEP = 5 ;
13+ const closeButton = document . querySelector ( '.big-picture__cancel' ) ;
1414
1515const commentFragment = document . createDocumentFragment ( ) ;
1616
@@ -53,15 +53,15 @@ const renderComments = () => {
5353 }
5454
5555 if ( currentComments . length <= COMMENT_STEP || commentsCount >= currentComments . length ) {
56- commentsLoaderBtn . classList . add ( 'hidden' ) ;
56+ commentsLoaderButton . classList . add ( 'hidden' ) ;
5757 } else {
58- commentsLoaderBtn . classList . remove ( 'hidden' ) ;
58+ commentsLoaderButton . classList . remove ( 'hidden' ) ;
5959 }
6060
6161 userCommentsContainer . appendChild ( commentFragment ) ;
6262} ;
6363
64- const onCloseFullSizePhoto = ( ) => {
64+ const onCloseFullSizePhotoClick = ( ) => {
6565 closeFullSizePhoto ( ) ;
6666} ;
6767
@@ -74,11 +74,11 @@ const onFullSizePhotoEscKey = (evt) => {
7474
7575function closeFullSizePhoto ( ) {
7676 commentsCount = COMMENT_STEP ;
77- document . removeEventListener ( 'keydown' , onFullSizePhotoEscKey ) ;
7877 toggleModal ( ) ;
78+ document . removeEventListener ( 'keydown' , onFullSizePhotoEscKey ) ;
7979}
8080
81- const onCommentsLoaderBtn = ( ) => {
81+ const onCommentsLoaderButtonClick = ( ) => {
8282 commentsCount += COMMENT_STEP ;
8383 renderComments ( ) ;
8484} ;
@@ -87,12 +87,12 @@ const renderFullSizePhoto = (photo) => {
8787 currentComments = photo . comments . slice ( ) ;
8888 show ( photo ) ;
8989 renderComments ( ) ;
90- document . addEventListener ( 'keydown' , onFullSizePhotoEscKey ) ;
9190 toggleModal ( ) ;
91+ document . addEventListener ( 'keydown' , onFullSizePhotoEscKey ) ;
9292} ;
9393
94- commentsLoaderBtn . addEventListener ( 'click' , onCommentsLoaderBtn ) ;
95- closeBtn . addEventListener ( 'click' , onCloseFullSizePhoto ) ;
94+ commentsLoaderButton . addEventListener ( 'click' , onCommentsLoaderButtonClick ) ;
95+ closeButton . addEventListener ( 'click' , onCloseFullSizePhotoClick ) ;
9696
9797
9898export { renderFullSizePhoto } ;
0 commit comments