{"action":"created","comment":{"url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls/comments/62079995","id":62079995,"diff_hunk":"@@ -29,94 +35,82 @@\n     overlayGallery.classList.add('invisible');\n   }\n \n-  function toggleToLeft(number1) {\n-    overlayGalleryControlLeft.addEventListener('click', function() {\n-      if(number1 >= 0) {\n-        if(number1 === 0) {\n-          number1 = 6;\n+  function openGallery() {\n+    photogallery.addEventListener('click', function(e) {\n+      var target = e.target;\n+\n+      while (target !== this) {\n+\n+        if(target.nodeName === 'A') {\n+          makeVisible();\n+          showImage(target.id);\n+          return false;\n         }\n-        number1--;\n-        preview.src = picturesGallery[number1];\n-        previewNumberCurrent.textContent = number1 + 1;\n-      }\n-    });\n-  }\n \n-  function toggleToRight(number2) {\n-    overlayGalleryControlRight.addEventListener('click', function() {\n-      if(number2 <= 5) {\n-        if(number2 === 5) {\n-          number2 = -1;\n+        if(target.nodeName === 'IMG') {\n+          showNumberOfImage(target.id);\n         }\n-        number2++;\n-        preview.src = picturesGallery[number2];\n-        previewNumberCurrent.textContent = number2 + 1;\n+\n+        target = target.parentNode;\n       }\n+\n     });\n-  }\n \n-  function openPreview() {\n-    for(var i = 0; i < imgGallery.length; i++) {\n-      imgGallery[i].addEventListener('click', function() {\n-        makeVisible();\n-        preview.setAttribute('height', 580);\n-        overlayGalleryPreview.appendChild(preview);\n-        previewNumberTotal.textContent = '6';\n-      });\n+    function showImage(id) {\n+      img.src = id;\n     }\n \n-    imgGallery[0].addEventListener('click', function() {\n-      preview.src = picturesGallery[0];\n-      toggleToLeft(0);\n-      toggleToRight(0);\n-      previewNumberCurrent.textContent = '1';\n-    });\n+    function showNumberOfImage(id) {\n+      previewNumberCurrent.textContent = id;\n+    }\n \n-    imgGallery[1].addEventListener('click', function() {\n-      preview.src = picturesGallery[1];\n-      preview.setAttribute('width', 500);\n-      toggleToLeft(1);\n-      toggleToRight(1);\n-      previewNumberCurrent.textContent = '2';\n-    });\n+    /* предзагрузка */\n+    for (var i = 0; i < imgGallery.length; i++) {\n+      var url = imgGallery[i].parentNode.id;\n+      overlayGalleryPreview.appendChild(img);\n+      img.setAttribute('height', 500);\n+      img.src = url;\n+      previewNumberTotal.textContent = imgGallery.length;\n+    }\n+  }\n \n-    imgGallery[2].addEventListener('click', function() {\n-      preview.src = picturesGallery[2];\n-      toggleToLeft(2);\n-      toggleToRight(2);\n-      previewNumberCurrent.textContent = '3';\n-    });\n+  openGallery();\n \n-    imgGallery[3].addEventListener('click', function() {\n-      preview.src = picturesGallery[3];\n-      toggleToLeft(3);\n-      toggleToRight(3);\n-      previewNumberCurrent.textContent = '4';\n+  function _onCloseClick() {","path":"src/gallery.js","position":null,"original_position":122,"commit_id":"193a003bedfb85c868cc57648698add83851d449","original_commit_id":"193a003bedfb85c868cc57648698add83851d449","user":{"login":"znamilya","id":5811832,"avatar_url":"https://avatars.githubusercontent.com/u/5811832?v=3","gravatar_id":"","url":"https://api.github.com/users/znamilya","html_url":"https://github.com/znamilya","followers_url":"https://api.github.com/users/znamilya/followers","following_url":"https://api.github.com/users/znamilya/following{/other_user}","gists_url":"https://api.github.com/users/znamilya/gists{/gist_id}","starred_url":"https://api.github.com/users/znamilya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/znamilya/subscriptions","organizations_url":"https://api.github.com/users/znamilya/orgs","repos_url":"https://api.github.com/users/znamilya/repos","events_url":"https://api.github.com/users/znamilya/events{/privacy}","received_events_url":"https://api.github.com/users/znamilya/received_events","type":"User","site_admin":false},"body":"как я говорил в прошлый раз, функции которые начинаются со слов on/handle являются обработчиками. Так принято в среде разработчиков. У тебя же это функции которые вешают события. Это очень путает","created_at":"2016-05-04T17:28:34Z","updated_at":"2016-05-04T17:28:34Z","html_url":"https://github.com/htmlacademy-javascript/159111-code-and-magick/pull/12#discussion_r62079995","pull_request_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls/comments/62079995"},"html":{"href":"https://github.com/htmlacademy-javascript/159111-code-and-magick/pull/12#discussion_r62079995"},"pull_request":{"href":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls/12","id":68454407,"html_url":"https://github.com/htmlacademy-javascript/159111-code-and-magick/pull/12","diff_url":"https://github.com/htmlacademy-javascript/159111-code-and-magick/pull/12.diff","patch_url":"https://github.com/htmlacademy-javascript/159111-code-and-magick/pull/12.patch","issue_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/issues/12","number":12,"state":"open","locked":false,"title":"Объект «Галерея», начало","user":{"login":"Wowaniche","id":16418549,"avatar_url":"https://avatars.githubusercontent.com/u/16418549?v=3","gravatar_id":"","url":"https://api.github.com/users/Wowaniche","html_url":"https://github.com/Wowaniche","followers_url":"https://api.github.com/users/Wowaniche/followers","following_url":"https://api.github.com/users/Wowaniche/following{/other_user}","gists_url":"https://api.github.com/users/Wowaniche/gists{/gist_id}","starred_url":"https://api.github.com/users/Wowaniche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wowaniche/subscriptions","organizations_url":"https://api.github.com/users/Wowaniche/orgs","repos_url":"https://api.github.com/users/Wowaniche/repos","events_url":"https://api.github.com/users/Wowaniche/events{/privacy}","received_events_url":"https://api.github.com/users/Wowaniche/received_events","type":"User","site_admin":false},"body":"module7-task2","created_at":"2016-04-30T02:04:31Z","updated_at":"2016-05-04T17:28:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls/12/commits","review_comments_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls/12/comments","review_comment_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls/comments{/number}","comments_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/issues/12/comments","statuses_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/statuses/193a003bedfb85c868cc57648698add83851d449","head":{"label":"Wowaniche:module7-task2","ref":"module7-task2","sha":"193a003bedfb85c868cc57648698add83851d449","user":{"login":"Wowaniche","id":16418549,"avatar_url":"https://avatars.githubusercontent.com/u/16418549?v=3","gravatar_id":"","url":"https://api.github.com/users/Wowaniche","html_url":"https://github.com/Wowaniche","followers_url":"https://api.github.com/users/Wowaniche/followers","following_url":"https://api.github.com/users/Wowaniche/following{/other_user}","gists_url":"https://api.github.com/users/Wowaniche/gists{/gist_id}","starred_url":"https://api.github.com/users/Wowaniche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wowaniche/subscriptions","organizations_url":"https://api.github.com/users/Wowaniche/orgs","repos_url":"https://api.github.com/users/Wowaniche/repos","events_url":"https://api.github.com/users/Wowaniche/events{/privacy}","received_events_url":"https://api.github.com/users/Wowaniche/received_events","type":"User","site_admin":false},"repo":{"id":54509837,"name":"code-and-magick","full_name":"Wowaniche/code-and-magick","owner":{"login":"Wowaniche","id":16418549,"avatar_url":"https://avatars.githubusercontent.com/u/16418549?v=3","gravatar_id":"","url":"https://api.github.com/users/Wowaniche","html_url":"https://github.com/Wowaniche","followers_url":"https://api.github.com/users/Wowaniche/followers","following_url":"https://api.github.com/users/Wowaniche/following{/other_user}","gists_url":"https://api.github.com/users/Wowaniche/gists{/gist_id}","starred_url":"https://api.github.com/users/Wowaniche/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wowaniche/subscriptions","organizations_url":"https://api.github.com/users/Wowaniche/orgs","repos_url":"https://api.github.com/users/Wowaniche/repos","events_url":"https://api.github.com/users/Wowaniche/events{/privacy}","received_events_url":"https://api.github.com/users/Wowaniche/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Wowaniche/code-and-magick","description":"Владимир Иванов","fork":true,"url":"https://api.github.com/repos/Wowaniche/code-and-magick","forks_url":"https://api.github.com/repos/Wowaniche/code-and-magick/forks","keys_url":"https://api.github.com/repos/Wowaniche/code-and-magick/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wowaniche/code-and-magick/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wowaniche/code-and-magick/teams","hooks_url":"https://api.github.com/repos/Wowaniche/code-and-magick/hooks","issue_events_url":"https://api.github.com/repos/Wowaniche/code-and-magick/issues/events{/number}","events_url":"https://api.github.com/repos/Wowaniche/code-and-magick/events","assignees_url":"https://api.github.com/repos/Wowaniche/code-and-magick/assignees{/user}","branches_url":"https://api.github.com/repos/Wowaniche/code-and-magick/branches{/branch}","tags_url":"https://api.github.com/repos/Wowaniche/code-and-magick/tags","blobs_url":"https://api.github.com/repos/Wowaniche/code-and-magick/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wowaniche/code-and-magick/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wowaniche/code-and-magick/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wowaniche/code-and-magick/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wowaniche/code-and-magick/statuses/{sha}","languages_url":"https://api.github.com/repos/Wowaniche/code-and-magick/languages","stargazers_url":"https://api.github.com/repos/Wowaniche/code-and-magick/stargazers","contributors_url":"https://api.github.com/repos/Wowaniche/code-and-magick/contributors","subscribers_url":"https://api.github.com/repos/Wowaniche/code-and-magick/subscribers","subscription_url":"https://api.github.com/repos/Wowaniche/code-and-magick/subscription","commits_url":"https://api.github.com/repos/Wowaniche/code-and-magick/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wowaniche/code-and-magick/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wowaniche/code-and-magick/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wowaniche/code-and-magick/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wowaniche/code-and-magick/contents/{+path}","compare_url":"https://api.github.com/repos/Wowaniche/code-and-magick/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wowaniche/code-and-magick/merges","archive_url":"https://api.github.com/repos/Wowaniche/code-and-magick/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wowaniche/code-and-magick/downloads","issues_url":"https://api.github.com/repos/Wowaniche/code-and-magick/issues{/number}","pulls_url":"https://api.github.com/repos/Wowaniche/code-and-magick/pulls{/number}","milestones_url":"https://api.github.com/repos/Wowaniche/code-and-magick/milestones{/number}","notifications_url":"https://api.github.com/repos/Wowaniche/code-and-magick/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wowaniche/code-and-magick/labels{/name}","releases_url":"https://api.github.com/repos/Wowaniche/code-and-magick/releases{/id}","deployments_url":"https://api.github.com/repos/Wowaniche/code-and-magick/deployments","created_at":"2016-03-22T21:26:33Z","updated_at":"2016-03-22T22:07:43Z","pushed_at":"2016-05-04T15:36:09Z","git_url":"git://github.com/Wowaniche/code-and-magick.git","ssh_url":"git@github.com:Wowaniche/code-and-magick.git","clone_url":"https://github.com/Wowaniche/code-and-magick.git","svn_url":"https://github.com/Wowaniche/code-and-magick","homepage":null,"size":1093,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"htmlacademy-javascript:master","ref":"master","sha":"e5aa8bc8ac5f9b4c48624de3c29adab5b8ff413d","user":{"login":"htmlacademy-javascript","id":14179712,"avatar_url":"https://avatars.githubusercontent.com/u/14179712?v=3","gravatar_id":"","url":"https://api.github.com/users/htmlacademy-javascript","html_url":"https://github.com/htmlacademy-javascript","followers_url":"https://api.github.com/users/htmlacademy-javascript/followers","following_url":"https://api.github.com/users/htmlacademy-javascript/following{/other_user}","gists_url":"https://api.github.com/users/htmlacademy-javascript/gists{/gist_id}","starred_url":"https://api.github.com/users/htmlacademy-javascript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/htmlacademy-javascript/subscriptions","organizations_url":"https://api.github.com/users/htmlacademy-javascript/orgs","repos_url":"https://api.github.com/users/htmlacademy-javascript/repos","events_url":"https://api.github.com/users/htmlacademy-javascript/events{/privacy}","received_events_url":"https://api.github.com/users/htmlacademy-javascript/received_events","type":"Organization","site_admin":false},"repo":{"id":54500677,"name":"159111-code-and-magick","full_name":"htmlacademy-javascript/159111-code-and-magick","owner":{"login":"htmlacademy-javascript","id":14179712,"avatar_url":"https://avatars.githubusercontent.com/u/14179712?v=3","gravatar_id":"","url":"https://api.github.com/users/htmlacademy-javascript","html_url":"https://github.com/htmlacademy-javascript","followers_url":"https://api.github.com/users/htmlacademy-javascript/followers","following_url":"https://api.github.com/users/htmlacademy-javascript/following{/other_user}","gists_url":"https://api.github.com/users/htmlacademy-javascript/gists{/gist_id}","starred_url":"https://api.github.com/users/htmlacademy-javascript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/htmlacademy-javascript/subscriptions","organizations_url":"https://api.github.com/users/htmlacademy-javascript/orgs","repos_url":"https://api.github.com/users/htmlacademy-javascript/repos","events_url":"https://api.github.com/users/htmlacademy-javascript/events{/privacy}","received_events_url":"https://api.github.com/users/htmlacademy-javascript/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/htmlacademy-javascript/159111-code-and-magick","description":"Владимир Иванов","fork":false,"url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick","forks_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/forks","keys_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/keys{/key_id}","collaborators_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/teams","hooks_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/hooks","issue_events_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/issues/events{/number}","events_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/events","assignees_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/assignees{/user}","branches_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/branches{/branch}","tags_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/tags","blobs_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/git/refs{/sha}","trees_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/git/trees{/sha}","statuses_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/statuses/{sha}","languages_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/languages","stargazers_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/stargazers","contributors_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/contributors","subscribers_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/subscribers","subscription_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/subscription","commits_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/commits{/sha}","git_commits_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/git/commits{/sha}","comments_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/comments{/number}","issue_comment_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/issues/comments{/number}","contents_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/contents/{+path}","compare_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/compare/{base}...{head}","merges_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/merges","archive_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/downloads","issues_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/issues{/number}","pulls_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls{/number}","milestones_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/milestones{/number}","notifications_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/labels{/name}","releases_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/releases{/id}","deployments_url":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/deployments","created_at":"2016-03-22T18:52:11Z","updated_at":"2016-03-24T12:23:38Z","pushed_at":"2016-05-04T15:36:11Z","git_url":"git://github.com/htmlacademy-javascript/159111-code-and-magick.git","ssh_url":"git@github.com:htmlacademy-javascript/159111-code-and-magick.git","clone_url":"https://github.com/htmlacademy-javascript/159111-code-and-magick.git","svn_url":"https://github.com/htmlacademy-javascript/159111-code-and-magick","homepage":"https://github.com/Wowaniche/code-and-magick","size":1066,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":1,"mirror_url":null,"open_issues_count":10,"forks":1,"open_issues":10,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls/12"},"html":{"href":"https://github.com/htmlacademy-javascript/159111-code-and-magick/pull/12"},"issue":{"href":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/issues/12"},"comments":{"href":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/htmlacademy-javascript/159111-code-and-magick/statuses/193a003bedfb85c868cc57648698add83851d449"}}}}