GitHub PullRequestReviewCommentEvent at 2014-02-06 10:31:04
Repository: DOM
Actor: gurugray
Payload: {"comment":{"url":"https://api.github.com/repos/front-tnu/DOM/pulls/comments/9495646","id":9495646,"diff_hunk":"@@ -1,22 +1,50 @@\n+\n+document.body.addEventListener('click',function(e){\n+    if (e.target.className === \"popup-link\") _onMouseClick(e);\n+    if (e.target.className === \"popup-overlay\" || e.target.className === \"popup-button popup-no\" || e.target.className === \"popup-close\")\n+        deletePopup();\n+});\n+\n /**\n  * Обработчик клика по ссылке с классом 'popup-link'\n  * @param {Event} e событие клика\n  * @private\n  */\n-function _onMouseClick(e) {}\n+function _onMouseClick(e) {\n+    e.returnValue = false; // для IE\n+    if(e.preventDefault) {\n+        e.preventDefault(); // для остальных браузеров\n+    }\n+    openPopupFromLink(e.target);\n+}\n \n /**\n  * Получает данные из ссылки\n- * на основе этих данных создаёт попап (через createPopup) и добавляет его в DOM\n+ * на основе этих данных показывает попап (через createPopup)\n  * @param {HTMLElement} link Ссылка с data-аттрибутами\n  */\n-function openPopupFromLink(link) {}\n+function openPopupFromLink(link) {\n+    var linkHref = link.getAttribute('href');\n+    var message = link.dataset.message.replace(\"%s\", linkHref);\n+    createPopup(link.dataset.title,message, function(){window.location.href = linkHref})\n+}\n \n /**\n  * Создаёт DOM-узел с сообщением\n  * @param {String} title Заголовок сообщение\n  * @param {String} message Текст сообщения сообщение\n  * @param {Function} onOk Обработчик клика по кнопке 'Да'\n- * @returns {HTMLElement}\n  */\n-function createPopup(title, message, onOk) {}\n+function createPopup(title, message, onOk) {\n+    document.getElementsByClassName('popup-title')[0].innerHTML = title;\n+    document.getElementsByClassName('popup-message')[0].innerHTML = message;","path":"homework.js","position":45,"original_position":45,"commit_id":"641a5e75b14cd4dc1f8450cd6f9e65db22d735cc","original_commit_id":"641a5e75b14cd4dc1f8450cd6f9e65db22d735cc","user":{"login":"gurugray","id":52771,"avatar_url":"https://gravatar.com/avatar/2ffacc76f61622698389096864acf01b?d=https%3A%2F%2Fidenticons.github.com%2Fd0196457fb5a8aa53a2e6a25582e5384.png&r=x","gravatar_id":"2ffacc76f61622698389096864acf01b","url":"https://api.github.com/users/gurugray","html_url":"https://github.com/gurugray","followers_url":"https://api.github.com/users/gurugray/followers","following_url":"https://api.github.com/users/gurugray/following{/other_user}","gists_url":"https://api.github.com/users/gurugray/gists{/gist_id}","starred_url":"https://api.github.com/users/gurugray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gurugray/subscriptions","organizations_url":"https://api.github.com/users/gurugray/orgs","repos_url":"https://api.github.com/users/gurugray/repos","events_url":"https://api.github.com/users/gurugray/events{/privacy}","received_events_url":"https://api.github.com/users/gurugray/received_events","type":"User","site_admin":false},"body":"попробуй ограничить поиск внутренностей попапа внутри попапа, а не по всему документу ;)","created_at":"2014-02-06T10:31:04Z","updated_at":"2014-02-06T10:31:04Z","html_url":"https://github.com/front-tnu/DOM/pull/4#discussion_r9495646","pull_request_url":"https://api.github.com/repos/front-tnu/DOM/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/front-tnu/DOM/pulls/comments/9495646"},"html":{"href":"https://github.com/front-tnu/DOM/pull/4#discussion_r9495646"},"pull_request":{"href":"https://api.github.com/repos/front-tnu/DOM/pulls/4"}}}}