{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/64324844","id":64324844,"diff_hunk":"@@ -3266,5 +3306,219 @@ var Awesomescreen = {\n         .querySelector('.tab-content[data-content=\"' + dataContent +'\"]')\n         .classList.add('show');\n     }\n+  },\n+\n+  initSpatialNavigation: function awesomescreen_initSpatialNavigation() {\n+    SpatialNavigation.init();\n+\n+    this.enableSpatialNavigation();\n+\n+    SpatialNavigation.makeFocusable();\n+\n+    SpatialNavigation.focus('tool-bar');\n+\n+    document.querySelector('.tab-navigation').addEventListener('sn:willmove',\n+      function(e){\n+        let target = e.target;\n+        if (!target.classList.contains('tab-option')) {\n+          return;\n+        }\n+\n+        let detail = e.detail;\n+        if (detail.direction === 'left' && !target.previousElementSibling) {\n+          e.preventDefault();\n+        }\n+        if (detail.direction === 'right' && !target.nextElementSibling) {\n+          e.preventDefault();\n+        }\n+      });\n+\n+    document.querySelector('#sync-tab-content .tab-list-view')\n+      .addEventListener('keydown', function(e){\n+        let firsListItem =\n+          document\n+            .querySelector(`#sync-tab-content\n+              .tab-list-item:first-child .list-item`);\n+\n+        if (firsListItem !== e.target || e.keyCode !== KeyEvent.DOM_VK_UP) {\n+          e.stopPropagation();\n+        }\n+      });\n+  },\n+\n+  enableSpatialNavigation: function awesomescreen_disableSpatialNavigation() {\n+    if (this.isSpatialNavigationEnable) {\n+      return;\n+    }\n+\n+    function getSearchBarStyle() {\n+      if (Toolbar.toolbarPanel) {\n+       return (Toolbar.getSearchBarStyle() == 'true');\n+      } else {\n+       let toolbarPanel = document.getElementById('toolbar-panel');\n+       return (toolbarPanel.dataset.search == 'true');\n+      }\n+    }\n+\n+    let toolbarSelector = [\n+      '#sidebar-button-block',\n+      '#back-button-block',\n+      '#address-form',\n+      '#url-input',\n+      '#search-form',\n+      '#search-input',\n+      '#search-button',\n+      '#search-clear-button',\n+      '#search-close-button',\n+      '#show-bookmarks-button-block',\n+      '#home-button-block',\n+      '#tabs-button-block',\n+      '#menu-button-block'\n+    ];\n+\n+    SpatialNavigation.add({\n+      id: 'tool-bar',\n+      selector: toolbarSelector.join(','),\n+      defaultElement: '#search-form',\n+      enterTo: 'last-focused',\n+      navigableFilter: function(el) {\n+        let id = el.id;\n+\n+        if (id === 'address-form') {\n+          // If current focus element is #url-input, next focus element should\n+          // be out of #address-form\n+          if (document.activeElement.id === 'url-input') {\n+            return false;\n+          }\n+\n+          // If the input is not empty, the address-form shouldn't\n+          // be navigable.\n+          let inputEl = document.getElementById('url-input');\n+          if (inputEl.value) {\n+            return false;\n+          }\n+        } else if (id === 'url-input') {\n+          // If current focus element is #address-form, only click enter\n+          // button can focus on #url-input\n+          if(document.activeElement.id === 'address-form') {\n+            return false;\n+          }\n+\n+          // If the input is empty, the url-input shouldn't be navigable.\n+          let inputEl = document.getElementById('url-input');\n+          if (!inputEl.value) {\n+            return false;\n+          }\n+        } else if (id === 'search-form') {\n+          let isSearch = getSearchBarStyle();\n+          if (isSearch) {\n+            return false;\n+          }\n+\n+          // If the input is not empty, the search-form shouldn't\n+          // be navigable.\n+          let inputEl = document.getElementById('search-input');\n+          if (inputEl.value) {\n+            return false;\n+          }\n+        } else if (id === 'search-input' || id === 'search-button') {\n+          // If current focus element is #search-form, we shouldn't be","path":"tv_apps/browser/js/awesomescreen.js","position":305,"original_position":305,"commit_id":"e1f983396e74bb0e696fcd24a81ff733e8588c61","original_commit_id":"e1f983396e74bb0e696fcd24a81ff733e8588c61","user":{"login":"danhuang1202","id":4784004,"avatar_url":"https://avatars.githubusercontent.com/u/4784004?v=3","gravatar_id":"","url":"https://api.github.com/users/danhuang1202","html_url":"https://github.com/danhuang1202","followers_url":"https://api.github.com/users/danhuang1202/followers","following_url":"https://api.github.com/users/danhuang1202/following{/other_user}","gists_url":"https://api.github.com/users/danhuang1202/gists{/gist_id}","starred_url":"https://api.github.com/users/danhuang1202/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danhuang1202/subscriptions","organizations_url":"https://api.github.com/users/danhuang1202/orgs","repos_url":"https://api.github.com/users/danhuang1202/repos","events_url":"https://api.github.com/users/danhuang1202/events{/privacy}","received_events_url":"https://api.github.com/users/danhuang1202/received_events","type":"User","site_admin":false},"body":"Updated","created_at":"2016-05-24T03:48:21Z","updated_at":"2016-05-24T03:48:21Z","html_url":"https://github.com/mozilla-b2g/gaia/pull/34337#discussion_r64324844","pull_request_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/34337","_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments/64324844"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/34337#discussion_r64324844"},"pull_request":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/34337"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/34337","id":70633713,"html_url":"https://github.com/mozilla-b2g/gaia/pull/34337","diff_url":"https://github.com/mozilla-b2g/gaia/pull/34337.diff","patch_url":"https://github.com/mozilla-b2g/gaia/pull/34337.patch","issue_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/34337","number":34337,"state":"open","locked":false,"title":"Bug 1267159 - Add spatial navagation support in browser . r=lchang","user":{"login":"danhuang1202","id":4784004,"avatar_url":"https://avatars.githubusercontent.com/u/4784004?v=3","gravatar_id":"","url":"https://api.github.com/users/danhuang1202","html_url":"https://github.com/danhuang1202","followers_url":"https://api.github.com/users/danhuang1202/followers","following_url":"https://api.github.com/users/danhuang1202/following{/other_user}","gists_url":"https://api.github.com/users/danhuang1202/gists{/gist_id}","starred_url":"https://api.github.com/users/danhuang1202/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danhuang1202/subscriptions","organizations_url":"https://api.github.com/users/danhuang1202/orgs","repos_url":"https://api.github.com/users/danhuang1202/repos","events_url":"https://api.github.com/users/danhuang1202/events{/privacy}","received_events_url":"https://api.github.com/users/danhuang1202/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-05-19T03:59:02Z","updated_at":"2016-05-24T03:48:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d4093d44177375e24ac44f73d26f88dd0ab6c028","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/34337/commits","review_comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/34337/comments","review_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/34337/comments","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/e1f983396e74bb0e696fcd24a81ff733e8588c61","head":{"label":"danhuang1202:bug1267159_spatial_navigation_in_browser","ref":"bug1267159_spatial_navigation_in_browser","sha":"e1f983396e74bb0e696fcd24a81ff733e8588c61","user":{"login":"danhuang1202","id":4784004,"avatar_url":"https://avatars.githubusercontent.com/u/4784004?v=3","gravatar_id":"","url":"https://api.github.com/users/danhuang1202","html_url":"https://github.com/danhuang1202","followers_url":"https://api.github.com/users/danhuang1202/followers","following_url":"https://api.github.com/users/danhuang1202/following{/other_user}","gists_url":"https://api.github.com/users/danhuang1202/gists{/gist_id}","starred_url":"https://api.github.com/users/danhuang1202/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danhuang1202/subscriptions","organizations_url":"https://api.github.com/users/danhuang1202/orgs","repos_url":"https://api.github.com/users/danhuang1202/repos","events_url":"https://api.github.com/users/danhuang1202/events{/privacy}","received_events_url":"https://api.github.com/users/danhuang1202/received_events","type":"User","site_admin":false},"repo":{"id":40878236,"name":"gaia","full_name":"danhuang1202/gaia","owner":{"login":"danhuang1202","id":4784004,"avatar_url":"https://avatars.githubusercontent.com/u/4784004?v=3","gravatar_id":"","url":"https://api.github.com/users/danhuang1202","html_url":"https://github.com/danhuang1202","followers_url":"https://api.github.com/users/danhuang1202/followers","following_url":"https://api.github.com/users/danhuang1202/following{/other_user}","gists_url":"https://api.github.com/users/danhuang1202/gists{/gist_id}","starred_url":"https://api.github.com/users/danhuang1202/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danhuang1202/subscriptions","organizations_url":"https://api.github.com/users/danhuang1202/orgs","repos_url":"https://api.github.com/users/danhuang1202/repos","events_url":"https://api.github.com/users/danhuang1202/events{/privacy}","received_events_url":"https://api.github.com/users/danhuang1202/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danhuang1202/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see","fork":true,"url":"https://api.github.com/repos/danhuang1202/gaia","forks_url":"https://api.github.com/repos/danhuang1202/gaia/forks","keys_url":"https://api.github.com/repos/danhuang1202/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danhuang1202/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danhuang1202/gaia/teams","hooks_url":"https://api.github.com/repos/danhuang1202/gaia/hooks","issue_events_url":"https://api.github.com/repos/danhuang1202/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/danhuang1202/gaia/events","assignees_url":"https://api.github.com/repos/danhuang1202/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/danhuang1202/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/danhuang1202/gaia/tags","blobs_url":"https://api.github.com/repos/danhuang1202/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danhuang1202/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danhuang1202/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/danhuang1202/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danhuang1202/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/danhuang1202/gaia/languages","stargazers_url":"https://api.github.com/repos/danhuang1202/gaia/stargazers","contributors_url":"https://api.github.com/repos/danhuang1202/gaia/contributors","subscribers_url":"https://api.github.com/repos/danhuang1202/gaia/subscribers","subscription_url":"https://api.github.com/repos/danhuang1202/gaia/subscription","commits_url":"https://api.github.com/repos/danhuang1202/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/danhuang1202/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/danhuang1202/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/danhuang1202/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/danhuang1202/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/danhuang1202/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danhuang1202/gaia/merges","archive_url":"https://api.github.com/repos/danhuang1202/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danhuang1202/gaia/downloads","issues_url":"https://api.github.com/repos/danhuang1202/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/danhuang1202/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/danhuang1202/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/danhuang1202/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danhuang1202/gaia/labels{/name}","releases_url":"https://api.github.com/repos/danhuang1202/gaia/releases{/id}","deployments_url":"https://api.github.com/repos/danhuang1202/gaia/deployments","created_at":"2015-08-17T08:38:52Z","updated_at":"2016-01-13T08:50:36Z","pushed_at":"2016-05-23T06:06:27Z","git_url":"git://github.com/danhuang1202/gaia.git","ssh_url":"git@github.com:danhuang1202/gaia.git","clone_url":"https://github.com/danhuang1202/gaia.git","svn_url":"https://github.com/danhuang1202/gaia","homepage":"https://wiki.mozilla.org/B2G","size":988073,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"mozilla-b2g:master","ref":"master","sha":"d9cc10c90fe3f8fa8701b6adb823c563729eb9e2","user":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"repo":{"id":2317369,"name":"gaia","full_name":"mozilla-b2g/gaia","owner":{"login":"mozilla-b2g","id":1261292,"avatar_url":"https://avatars.githubusercontent.com/u/1261292?v=3","gravatar_id":"","url":"https://api.github.com/users/mozilla-b2g","html_url":"https://github.com/mozilla-b2g","followers_url":"https://api.github.com/users/mozilla-b2g/followers","following_url":"https://api.github.com/users/mozilla-b2g/following{/other_user}","gists_url":"https://api.github.com/users/mozilla-b2g/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla-b2g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla-b2g/subscriptions","organizations_url":"https://api.github.com/users/mozilla-b2g/orgs","repos_url":"https://api.github.com/users/mozilla-b2g/repos","events_url":"https://api.github.com/users/mozilla-b2g/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla-b2g/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla-b2g/gaia","description":"Gaia is a HTML5-based Phone UI for the Boot 2 Gecko Project. NOTE: For details of what branches are used for what releases, see","fork":false,"url":"https://api.github.com/repos/mozilla-b2g/gaia","forks_url":"https://api.github.com/repos/mozilla-b2g/gaia/forks","keys_url":"https://api.github.com/repos/mozilla-b2g/gaia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla-b2g/gaia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla-b2g/gaia/teams","hooks_url":"https://api.github.com/repos/mozilla-b2g/gaia/hooks","issue_events_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla-b2g/gaia/events","assignees_url":"https://api.github.com/repos/mozilla-b2g/gaia/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla-b2g/gaia/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/tags","blobs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla-b2g/gaia/languages","stargazers_url":"https://api.github.com/repos/mozilla-b2g/gaia/stargazers","contributors_url":"https://api.github.com/repos/mozilla-b2g/gaia/contributors","subscribers_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscribers","subscription_url":"https://api.github.com/repos/mozilla-b2g/gaia/subscription","commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla-b2g/gaia/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla-b2g/gaia/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla-b2g/gaia/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla-b2g/gaia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla-b2g/gaia/merges","archive_url":"https://api.github.com/repos/mozilla-b2g/gaia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla-b2g/gaia/downloads","issues_url":"https://api.github.com/repos/mozilla-b2g/gaia/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla-b2g/gaia/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla-b2g/gaia/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla-b2g/gaia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla-b2g/gaia/labels{/name}","releases_url":"https://api.github.com/repos/mozilla-b2g/gaia/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla-b2g/gaia/deployments","created_at":"2011-09-03T01:38:46Z","updated_at":"2016-05-23T13:37:52Z","pushed_at":"2016-05-24T03:03:44Z","git_url":"git://github.com/mozilla-b2g/gaia.git","ssh_url":"git@github.com:mozilla-b2g/gaia.git","clone_url":"https://github.com/mozilla-b2g/gaia.git","svn_url":"https://github.com/mozilla-b2g/gaia","homepage":"https://wiki.mozilla.org/B2G","size":1242090,"stargazers_count":2043,"watchers_count":2043,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":2559,"mirror_url":null,"open_issues_count":1307,"forks":2559,"open_issues":1307,"watchers":2043,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/34337"},"html":{"href":"https://github.com/mozilla-b2g/gaia/pull/34337"},"issue":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/34337"},"comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/issues/34337/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/34337/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/pulls/34337/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla-b2g/gaia/statuses/e1f983396e74bb0e696fcd24a81ff733e8588c61"}}}}
{"actor":{"display_login":"danhuang1202"}}