GitHub PullRequestReviewCommentEvent at 2014-04-22 14:46:31
Repository: tylercamp.github.io
Actor: jpetto
Payload: {"comment":{"url":"https://api.github.com/repos/tylercamp/tylercamp.github.io/pulls/comments/11856529","id":11856529,"diff_hunk":"@@ -34,32 +128,177 @@\n                     getProjectDataObject(projectName, onComplete);\n                 });\n             }\n-        }\n+        };\n     })();\n \n \n-    $('.portfolio-section').click(function (e) {\n-        var target = e.target;\n-        if (target.tagName === 'BUTTON') {\n-            //e.preventDefault();\n \n-            var $target = $(target);\n \n-            var targetProject = $target.parent().find('[name=\"name\"]').val();\n+    /* Logic for Javascript-based project display generation */\n+\n+    var $lastProjectDisplay = null;\n+    var $lastButton = null;\n+\n+    function insertProjectViewElement($projectViewElement, $projectPreviewContainer) {\n+        //  Get the project element that's at the last of this row\n+        var $projects = $('article');\n+        var $lastOfCurrentRow = null;\n+        var continuedForHeightBreak = true;\n+\n+        for (var i = 0; i < $projects.length; i++) {\n+            var $currentProject = $($projects[i]);\n+\n+            if (!$currentProject.is($projectPreviewContainer))\n+                continue;\n+\n+            while ($currentProject.offset().top === $projectPreviewContainer.offset().top) {\n+                if (i === $projects.length-1) {\n+                    continuedForHeightBreak = false;\n+                    break;\n+                }\n+\n+                $currentProject = $($projects[++i]);\n+            }\n+\n+            if (continuedForHeightBreak)\n+                $lastOfCurrentRow = $currentProject.prev();\n+            else\n+                $lastOfCurrentRow = $currentProject;\n+        }\n+\n+\n+        $projectViewElement.insertAfter($lastOfCurrentRow);\n+    }\n+\n+\n+    function scrollTo(element) {\n+        setTimeout(function () {\n+            $('body').scrollTo(element, { duration: SCROLL_SPEED, offset: -125 });\n+        }, SLIDE_SPEED * (3/4));\n+    }\n+\n+\n+    $('.portfolio-section').on('click', 'a', function (e) {\n+\n+        //  If we're mobile, just allow the browser to continue to the dedicated page\n+        if (mediaIsMobile()) {\n+            return;\n+        }\n+\n+        e.preventDefault();\n+\n \n-            getProjectDataObject(targetProject, function (projectData) {\n-                console.log(projectData);\n+        /* Slide the old project view up if we've clicked on the same button as last time */\n+        var $target = $(e.target);\n+        if ($target.is($lastButton)) {\n+            $lastProjectDisplay.slideUp(SCROLL_SPEED, function () {\n+                $lastProjectDisplay.remove();\n+                $lastProjectDisplay = null;\n+                //  There isn't a project being viewed anymore, remove event listeners\n+                unbindProjectReinsertion();\n             });\n+\n+            $lastButton = null;\n+            return;\n         }\n+\n+        $lastButton = $target;\n+\n+\n+\n+        var $containerProject = $target.closest('article');\n+        var targetProjectName = $containerProject.find('h3').text();","path":"client/script.js","position":205,"original_position":205,"commit_id":"4c037bbcd0a7650aadb2b1834a97102cab835927","original_commit_id":"4c037bbcd0a7650aadb2b1834a97102cab835927","user":{"login":"jpetto","id":317532,"avatar_url":"https://avatars.githubusercontent.com/u/317532?","gravatar_id":"58d5cdc21fe9f9dac826038e5398d963","url":"https://api.github.com/users/jpetto","html_url":"https://github.com/jpetto","followers_url":"https://api.github.com/users/jpetto/followers","following_url":"https://api.github.com/users/jpetto/following{/other_user}","gists_url":"https://api.github.com/users/jpetto/gists{/gist_id}","starred_url":"https://api.github.com/users/jpetto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jpetto/subscriptions","organizations_url":"https://api.github.com/users/jpetto/orgs","repos_url":"https://api.github.com/users/jpetto/repos","events_url":"https://api.github.com/users/jpetto/events{/privacy}","received_events_url":"https://api.github.com/users/jpetto/received_events","type":"User","site_admin":false},"body":"It's a little dangerous to rely on live text as an identifier. It would be better to use a `data-*` attribute.","created_at":"2014-04-22T14:46:31Z","updated_at":"2014-04-22T14:46:31Z","html_url":"https://github.com/tylercamp/tylercamp.github.io/pull/5#discussion_r11856529","pull_request_url":"https://api.github.com/repos/tylercamp/tylercamp.github.io/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/tylercamp/tylercamp.github.io/pulls/comments/11856529"},"html":{"href":"https://github.com/tylercamp/tylercamp.github.io/pull/5#discussion_r11856529"},"pull_request":{"href":"https://api.github.com/repos/tylercamp/tylercamp.github.io/pulls/5"}}}}