{"action":"created","comment":{"url":"https://api.github.com/repos/atom/tabs/pulls/comments/52415212","id":52415212,"diff_hunk":"@@ -0,0 +1,99 @@\n+{closest, indexOf, matches} = require './html-helpers'\n+\n+module.exports =\n+\n+  activate: ->\n+    @view = document.createElement 'div'\n+    @view.classList.add 'layout-overlay'\n+    document.body.appendChild @view\n+\n+  deactivate: ->\n+    @view.parentElement?.removeChild @view\n+\n+  test: {}\n+\n+  drag: (e) ->\n+    @lastCoords = e\n+    pane = @getPaneAt e\n+    itemView = @getItemViewAt e\n+    if pane? and itemView?\n+      coords = if not (@isOnlyTabInPane(pane, e.target) or pane.getItems().length is 0)\n+        [e.clientX, e.clientY]\n+      @lastSplit = @updateView itemView, coords\n+    else\n+      @disableView()\n+\n+  end: (e) ->\n+    @disableView()\n+    return unless @getItemViewAt @lastCoords\n+    target = @getPaneAt @lastCoords\n+    return unless target?\n+    toPane = switch @lastSplit\n+      when 'left'  then target.splitLeft()\n+      when 'right' then target.splitRight()\n+      when 'up'    then target.splitUp()\n+      when 'down'  then target.splitDown()\n+    tab = e.target\n+    toPane ?= target\n+    fromPane = @paneForTab tab\n+    return if toPane is fromPane\n+    item = @itemForTab tab\n+    fromPane.moveItemToPane item, toPane\n+    toPane.activateItem item\n+    toPane.activate()\n+\n+  getElement: ({clientX, clientY}, selector = '*') ->\n+    closest document.elementFromPoint(clientX, clientY), selector\n+\n+  getItemViewAt: (coords) ->\n+    @test.itemView or @getElement coords, '.item-views'\n+\n+  getPaneAt: (coords) ->\n+    @test.pane or @getElement(@lastCoords, 'atom-pane')?.getModel()\n+\n+  paneForTab: (tab) ->\n+    tab.parentElement.pane\n+\n+  itemForTab: (tab) ->\n+    @paneForTab(tab).getItems()[indexOf(tab)]\n+\n+  isOnlyTabInPane: (pane, tab) ->\n+    pane.getItems().length is 1 and pane is @paneForTab tab\n+\n+  normalizeCoords: ({left, top, width, height}, [x, y]) ->\n+    [(x-left)/width, (y-top)/height]\n+\n+  splitType: ([x, y]) ->\n+    if      x < 1/3 then 'left'\n+    else if x > 2/3 then 'right'\n+    else if y < 1/3 then 'up'\n+    else if y > 2/3 then 'down'\n+\n+  boundsForSplit: (split) ->\n+    [x, y, w, h] = switch split\n+      when 'left'   then [0,   0,   0.5, 1  ]\n+      when 'right'  then [0.5, 0,   0.5, 1  ]\n+      when 'up'     then [0,   0,   1,   0.5]\n+      when 'down'   then [0,   0.5, 1,   0.5]\n+      else               [0,   0,   1,   1  ]\n+\n+  innerBounds: ({left, top, width, height}, [x, y, w, h]) ->\n+    left += x*width; top += y*height\n+    width *= w; height *= h","path":"lib/layout.coffee","position":82,"original_position":82,"commit_id":"d425a7d9c5294bc3f6dcbcd068ebab26c6584c55","original_commit_id":"d425a7d9c5294bc3f6dcbcd068ebab26c6584c55","user":{"login":"mnquintana","id":823545,"avatar_url":"https://avatars.githubusercontent.com/u/823545?v=3","gravatar_id":"","url":"https://api.github.com/users/mnquintana","html_url":"https://github.com/mnquintana","followers_url":"https://api.github.com/users/mnquintana/followers","following_url":"https://api.github.com/users/mnquintana/following{/other_user}","gists_url":"https://api.github.com/users/mnquintana/gists{/gist_id}","starred_url":"https://api.github.com/users/mnquintana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnquintana/subscriptions","organizations_url":"https://api.github.com/users/mnquintana/orgs","repos_url":"https://api.github.com/users/mnquintana/repos","events_url":"https://api.github.com/users/mnquintana/events{/privacy}","received_events_url":"https://api.github.com/users/mnquintana/received_events","type":"User","site_admin":false},"body":"Yeah, it would be great to get this all on separate lines :smile: Thanks!","created_at":"2016-02-10T05:09:21Z","updated_at":"2016-02-10T05:09:21Z","html_url":"https://github.com/atom/tabs/pull/252#discussion_r52415212","pull_request_url":"https://api.github.com/repos/atom/tabs/pulls/252","_links":{"self":{"href":"https://api.github.com/repos/atom/tabs/pulls/comments/52415212"},"html":{"href":"https://github.com/atom/tabs/pull/252#discussion_r52415212"},"pull_request":{"href":"https://api.github.com/repos/atom/tabs/pulls/252"}}},"pull_request":{"url":"https://api.github.com/repos/atom/tabs/pulls/252","id":57354619,"html_url":"https://github.com/atom/tabs/pull/252","diff_url":"https://github.com/atom/tabs/pull/252.diff","patch_url":"https://github.com/atom/tabs/pull/252.patch","issue_url":"https://api.github.com/repos/atom/tabs/issues/252","number":252,"state":"open","locked":false,"title":"Drag and drop layout management","user":{"login":"one-more-minute","id":2234614,"avatar_url":"https://avatars.githubusercontent.com/u/2234614?v=3","gravatar_id":"","url":"https://api.github.com/users/one-more-minute","html_url":"https://github.com/one-more-minute","followers_url":"https://api.github.com/users/one-more-minute/followers","following_url":"https://api.github.com/users/one-more-minute/following{/other_user}","gists_url":"https://api.github.com/users/one-more-minute/gists{/gist_id}","starred_url":"https://api.github.com/users/one-more-minute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/one-more-minute/subscriptions","organizations_url":"https://api.github.com/users/one-more-minute/orgs","repos_url":"https://api.github.com/users/one-more-minute/repos","events_url":"https://api.github.com/users/one-more-minute/events{/privacy}","received_events_url":"https://api.github.com/users/one-more-minute/received_events","type":"User","site_admin":false},"body":"![layout](https://cloud.githubusercontent.com/assets/2234614/12613448/bb0a7bf8-c4f1-11e5-94f9-d8ff22b9f0ff.gif)\r\n\r\nThis kind of UI is really handy for those who are less keyboard-savvy, especially if you have a bunch of plots / workspace panes / consoles etc. open and don't want to remember the right sequence of commands needed to organise things :)\r\n\r\nI'm still fairly new to CoffeeScript / Atom development so feedback is definitely appreciated. The global `@lastSplit` approach is a bit weird, but seems to be necessary as the `dragend` event gives different `clientX` and `clientY` coordinates which throws things off. I've aimed for an overlay styling that works well with both light and dark syntax / ui themes, but other suggestions are appreciated there as well.","created_at":"2016-01-27T12:43:29Z","updated_at":"2016-02-10T05:09:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"675a71b863be52ace40f882100895cd20d03446d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/atom/tabs/pulls/252/commits","review_comments_url":"https://api.github.com/repos/atom/tabs/pulls/252/comments","review_comment_url":"https://api.github.com/repos/atom/tabs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/atom/tabs/issues/252/comments","statuses_url":"https://api.github.com/repos/atom/tabs/statuses/d425a7d9c5294bc3f6dcbcd068ebab26c6584c55","head":{"label":"one-more-minute:layout","ref":"layout","sha":"d425a7d9c5294bc3f6dcbcd068ebab26c6584c55","user":{"login":"one-more-minute","id":2234614,"avatar_url":"https://avatars.githubusercontent.com/u/2234614?v=3","gravatar_id":"","url":"https://api.github.com/users/one-more-minute","html_url":"https://github.com/one-more-minute","followers_url":"https://api.github.com/users/one-more-minute/followers","following_url":"https://api.github.com/users/one-more-minute/following{/other_user}","gists_url":"https://api.github.com/users/one-more-minute/gists{/gist_id}","starred_url":"https://api.github.com/users/one-more-minute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/one-more-minute/subscriptions","organizations_url":"https://api.github.com/users/one-more-minute/orgs","repos_url":"https://api.github.com/users/one-more-minute/repos","events_url":"https://api.github.com/users/one-more-minute/events{/privacy}","received_events_url":"https://api.github.com/users/one-more-minute/received_events","type":"User","site_admin":false},"repo":{"id":50505819,"name":"tabs","full_name":"one-more-minute/tabs","owner":{"login":"one-more-minute","id":2234614,"avatar_url":"https://avatars.githubusercontent.com/u/2234614?v=3","gravatar_id":"","url":"https://api.github.com/users/one-more-minute","html_url":"https://github.com/one-more-minute","followers_url":"https://api.github.com/users/one-more-minute/followers","following_url":"https://api.github.com/users/one-more-minute/following{/other_user}","gists_url":"https://api.github.com/users/one-more-minute/gists{/gist_id}","starred_url":"https://api.github.com/users/one-more-minute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/one-more-minute/subscriptions","organizations_url":"https://api.github.com/users/one-more-minute/orgs","repos_url":"https://api.github.com/users/one-more-minute/repos","events_url":"https://api.github.com/users/one-more-minute/events{/privacy}","received_events_url":"https://api.github.com/users/one-more-minute/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/one-more-minute/tabs","description":"Tabs in Atom","fork":true,"url":"https://api.github.com/repos/one-more-minute/tabs","forks_url":"https://api.github.com/repos/one-more-minute/tabs/forks","keys_url":"https://api.github.com/repos/one-more-minute/tabs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/one-more-minute/tabs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/one-more-minute/tabs/teams","hooks_url":"https://api.github.com/repos/one-more-minute/tabs/hooks","issue_events_url":"https://api.github.com/repos/one-more-minute/tabs/issues/events{/number}","events_url":"https://api.github.com/repos/one-more-minute/tabs/events","assignees_url":"https://api.github.com/repos/one-more-minute/tabs/assignees{/user}","branches_url":"https://api.github.com/repos/one-more-minute/tabs/branches{/branch}","tags_url":"https://api.github.com/repos/one-more-minute/tabs/tags","blobs_url":"https://api.github.com/repos/one-more-minute/tabs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/one-more-minute/tabs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/one-more-minute/tabs/git/refs{/sha}","trees_url":"https://api.github.com/repos/one-more-minute/tabs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/one-more-minute/tabs/statuses/{sha}","languages_url":"https://api.github.com/repos/one-more-minute/tabs/languages","stargazers_url":"https://api.github.com/repos/one-more-minute/tabs/stargazers","contributors_url":"https://api.github.com/repos/one-more-minute/tabs/contributors","subscribers_url":"https://api.github.com/repos/one-more-minute/tabs/subscribers","subscription_url":"https://api.github.com/repos/one-more-minute/tabs/subscription","commits_url":"https://api.github.com/repos/one-more-minute/tabs/commits{/sha}","git_commits_url":"https://api.github.com/repos/one-more-minute/tabs/git/commits{/sha}","comments_url":"https://api.github.com/repos/one-more-minute/tabs/comments{/number}","issue_comment_url":"https://api.github.com/repos/one-more-minute/tabs/issues/comments{/number}","contents_url":"https://api.github.com/repos/one-more-minute/tabs/contents/{+path}","compare_url":"https://api.github.com/repos/one-more-minute/tabs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/one-more-minute/tabs/merges","archive_url":"https://api.github.com/repos/one-more-minute/tabs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/one-more-minute/tabs/downloads","issues_url":"https://api.github.com/repos/one-more-minute/tabs/issues{/number}","pulls_url":"https://api.github.com/repos/one-more-minute/tabs/pulls{/number}","milestones_url":"https://api.github.com/repos/one-more-minute/tabs/milestones{/number}","notifications_url":"https://api.github.com/repos/one-more-minute/tabs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/one-more-minute/tabs/labels{/name}","releases_url":"https://api.github.com/repos/one-more-minute/tabs/releases{/id}","deployments_url":"https://api.github.com/repos/one-more-minute/tabs/deployments","created_at":"2016-01-27T12:28:56Z","updated_at":"2016-01-27T12:28:56Z","pushed_at":"2016-01-28T11:32:23Z","git_url":"git://github.com/one-more-minute/tabs.git","ssh_url":"git@github.com:one-more-minute/tabs.git","clone_url":"https://github.com/one-more-minute/tabs.git","svn_url":"https://github.com/one-more-minute/tabs","homepage":null,"size":1091,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"atom:master","ref":"master","sha":"384cb3cc4489197af4ddfbec11f018f5a456d0e7","user":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=3","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"repo":{"id":12088639,"name":"tabs","full_name":"atom/tabs","owner":{"login":"atom","id":1089146,"avatar_url":"https://avatars.githubusercontent.com/u/1089146?v=3","gravatar_id":"","url":"https://api.github.com/users/atom","html_url":"https://github.com/atom","followers_url":"https://api.github.com/users/atom/followers","following_url":"https://api.github.com/users/atom/following{/other_user}","gists_url":"https://api.github.com/users/atom/gists{/gist_id}","starred_url":"https://api.github.com/users/atom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atom/subscriptions","organizations_url":"https://api.github.com/users/atom/orgs","repos_url":"https://api.github.com/users/atom/repos","events_url":"https://api.github.com/users/atom/events{/privacy}","received_events_url":"https://api.github.com/users/atom/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/atom/tabs","description":"Tabs in Atom","fork":false,"url":"https://api.github.com/repos/atom/tabs","forks_url":"https://api.github.com/repos/atom/tabs/forks","keys_url":"https://api.github.com/repos/atom/tabs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/atom/tabs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/atom/tabs/teams","hooks_url":"https://api.github.com/repos/atom/tabs/hooks","issue_events_url":"https://api.github.com/repos/atom/tabs/issues/events{/number}","events_url":"https://api.github.com/repos/atom/tabs/events","assignees_url":"https://api.github.com/repos/atom/tabs/assignees{/user}","branches_url":"https://api.github.com/repos/atom/tabs/branches{/branch}","tags_url":"https://api.github.com/repos/atom/tabs/tags","blobs_url":"https://api.github.com/repos/atom/tabs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/atom/tabs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/atom/tabs/git/refs{/sha}","trees_url":"https://api.github.com/repos/atom/tabs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/atom/tabs/statuses/{sha}","languages_url":"https://api.github.com/repos/atom/tabs/languages","stargazers_url":"https://api.github.com/repos/atom/tabs/stargazers","contributors_url":"https://api.github.com/repos/atom/tabs/contributors","subscribers_url":"https://api.github.com/repos/atom/tabs/subscribers","subscription_url":"https://api.github.com/repos/atom/tabs/subscription","commits_url":"https://api.github.com/repos/atom/tabs/commits{/sha}","git_commits_url":"https://api.github.com/repos/atom/tabs/git/commits{/sha}","comments_url":"https://api.github.com/repos/atom/tabs/comments{/number}","issue_comment_url":"https://api.github.com/repos/atom/tabs/issues/comments{/number}","contents_url":"https://api.github.com/repos/atom/tabs/contents/{+path}","compare_url":"https://api.github.com/repos/atom/tabs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/atom/tabs/merges","archive_url":"https://api.github.com/repos/atom/tabs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/atom/tabs/downloads","issues_url":"https://api.github.com/repos/atom/tabs/issues{/number}","pulls_url":"https://api.github.com/repos/atom/tabs/pulls{/number}","milestones_url":"https://api.github.com/repos/atom/tabs/milestones{/number}","notifications_url":"https://api.github.com/repos/atom/tabs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/atom/tabs/labels{/name}","releases_url":"https://api.github.com/repos/atom/tabs/releases{/id}","deployments_url":"https://api.github.com/repos/atom/tabs/deployments","created_at":"2013-08-13T17:59:32Z","updated_at":"2016-01-26T12:25:49Z","pushed_at":"2016-01-28T11:32:23Z","git_url":"git://github.com/atom/tabs.git","ssh_url":"git@github.com:atom/tabs.git","clone_url":"https://github.com/atom/tabs.git","svn_url":"https://github.com/atom/tabs","homepage":null,"size":1234,"stargazers_count":53,"watchers_count":53,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":59,"mirror_url":null,"open_issues_count":56,"forks":59,"open_issues":56,"watchers":53,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/atom/tabs/pulls/252"},"html":{"href":"https://github.com/atom/tabs/pull/252"},"issue":{"href":"https://api.github.com/repos/atom/tabs/issues/252"},"comments":{"href":"https://api.github.com/repos/atom/tabs/issues/252/comments"},"review_comments":{"href":"https://api.github.com/repos/atom/tabs/pulls/252/comments"},"review_comment":{"href":"https://api.github.com/repos/atom/tabs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/atom/tabs/pulls/252/commits"},"statuses":{"href":"https://api.github.com/repos/atom/tabs/statuses/d425a7d9c5294bc3f6dcbcd068ebab26c6584c55"}}}}