{"action":"created","comment":{"url":"https://api.github.com/repos/angular/material/pulls/comments/37579717","id":37579717,"diff_hunk":"@@ -177,61 +203,143 @@ function MenuDirective() {\n   }\n }\n \n-function MenuController($mdMenu, $attrs, $element, $scope) {\n+function MenuController($mdMenu, $attrs, $element, $scope, $mdUtil, $timeout) {\n+\n   var menuContainer;\n-  var ctrl = this;\n+  var self = this;\n   var triggerElement;\n \n-  this.init = angular.bind(this, init);\n-  this.open = angular.bind(this, openMenu);\n-  this.close = angular.bind(this, closeMenu);\n-\n-  this.positionMode = angular.bind(this, positionMode);\n-  this.offsets = angular.bind(this, offsets);\n-\n-  // Expose a open function to the child scope for html to use\n-  $scope.$mdOpenMenu = this.open;\n+  this.nestLevel = parseInt($attrs.mdNestLevel, 10) || 0;\n \n   /**\n    * Called by our linking fn to provide access to the menu-content\n    * element removed during link\n    */\n-  function init(setMenuContainer) {\n+  this.init = function init(setMenuContainer, opts) {\n+    opts = opts || {};\n     menuContainer = setMenuContainer;\n     // Default element for ARIA attributes has the ngClick or ngMouseenter expression\n     triggerElement = $element[0].querySelector('[ng-click],[ng-mouseenter]');\n-  }\n+\n+    this.isInMenuBar = opts.isInMenuBar;\n+    this.nestedMenus = $mdUtil.nodesToArray(menuContainer[0].querySelectorAll('.md-nested-menu'));\n+    this.enableHoverListener();\n+\n+    menuContainer.on('$mdInterimElementRemove', function() {\n+      self.isOpen = false;\n+    });\n+  };\n+\n+  this.enableHoverListener = function() {\n+    $scope.$on('$mdMenuOpen', function(event, el) {\n+      if (menuContainer[0].contains(el[0])) {\n+        self.currentlyOpenMenu = el.controller('mdMenu');\n+        self.isAlreadyOpening = false;\n+        self.currentlyOpenMenu.registerContainerProxy(self.triggerContainerProxy.bind(self));\n+      }\n+    });\n+    $scope.$on('$mdMenuClose', function(event, el) {\n+      if (menuContainer[0].contains(el[0])) {\n+        self.currentlyOpenMenu = undefined;\n+      }\n+    });\n+\n+    var menuItems = angular.element($mdUtil.nodesToArray(menuContainer[0].querySelectorAll('md-menu-item')));\n+\n+    var openMenuTimeout;\n+    menuItems.on('mouseenter', function(event) {\n+      if (self.isAlreadyOpening) return;\n+      var nestedMenu = (\n+        event.target.querySelector('md-menu')\n+          || $mdUtil.getClosest(event.target, 'MD-MENU')\n+      );\n+      openMenuTimeout = $timeout(function() {\n+        if (nestedMenu) {\n+          nestedMenu = angular.element(nestedMenu).controller('mdMenu');\n+        }\n+\n+        if (self.currentlyOpenMenu && self.currentlyOpenMenu != nestedMenu) {\n+          var closeTo = self.nestLevel + 1;\n+          self.currentlyOpenMenu.close(true, { closeTo: closeTo });\n+        } else if (nestedMenu && !nestedMenu.isOpen && nestedMenu.open) {\n+          self.isAlreadyOpening = true;\n+          nestedMenu.open();\n+        }\n+      }, nestedMenu ? 100 : 250);","path":"src/components/menu/_menu.js","position":148,"original_position":148,"commit_id":"59753bcb16c6a4983c841c99f52dfea0ab581940","original_commit_id":"59753bcb16c6a4983c841c99f52dfea0ab581940","user":{"login":"jelbourn","id":838736,"avatar_url":"https://avatars.githubusercontent.com/u/838736?v=3","gravatar_id":"","url":"https://api.github.com/users/jelbourn","html_url":"https://github.com/jelbourn","followers_url":"https://api.github.com/users/jelbourn/followers","following_url":"https://api.github.com/users/jelbourn/following{/other_user}","gists_url":"https://api.github.com/users/jelbourn/gists{/gist_id}","starred_url":"https://api.github.com/users/jelbourn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jelbourn/subscriptions","organizations_url":"https://api.github.com/users/jelbourn/orgs","repos_url":"https://api.github.com/users/jelbourn/repos","events_url":"https://api.github.com/users/jelbourn/events{/privacy}","received_events_url":"https://api.github.com/users/jelbourn/received_events","type":"User","site_admin":false},"body":"Very magic numbers","created_at":"2015-08-20T20:51:41Z","updated_at":"2015-08-20T20:51:41Z","html_url":"https://github.com/angular/material/pull/4269#discussion_r37579717","pull_request_url":"https://api.github.com/repos/angular/material/pulls/4269","_links":{"self":{"href":"https://api.github.com/repos/angular/material/pulls/comments/37579717"},"html":{"href":"https://github.com/angular/material/pull/4269#discussion_r37579717"},"pull_request":{"href":"https://api.github.com/repos/angular/material/pulls/4269"}}},"pull_request":{"url":"https://api.github.com/repos/angular/material/pulls/4269","id":42961699,"html_url":"https://github.com/angular/material/pull/4269","diff_url":"https://github.com/angular/material/pull/4269.diff","patch_url":"https://github.com/angular/material/pull/4269.patch","issue_url":"https://api.github.com/repos/angular/material/issues/4269","number":4269,"state":"open","locked":false,"title":"feat(menuBar): add menu bar component","user":{"login":"rschmukler","id":651740,"avatar_url":"https://avatars.githubusercontent.com/u/651740?v=3","gravatar_id":"","url":"https://api.github.com/users/rschmukler","html_url":"https://github.com/rschmukler","followers_url":"https://api.github.com/users/rschmukler/followers","following_url":"https://api.github.com/users/rschmukler/following{/other_user}","gists_url":"https://api.github.com/users/rschmukler/gists{/gist_id}","starred_url":"https://api.github.com/users/rschmukler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rschmukler/subscriptions","organizations_url":"https://api.github.com/users/rschmukler/orgs","repos_url":"https://api.github.com/users/rschmukler/repos","events_url":"https://api.github.com/users/rschmukler/events{/privacy}","received_events_url":"https://api.github.com/users/rschmukler/received_events","type":"User","site_admin":false},"body":"closes #78","created_at":"2015-08-20T18:26:53Z","updated_at":"2015-08-20T20:51:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"84afae7ae0a7027d067c72ddaa0161328fc9f12f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/angular/material/pulls/4269/commits","review_comments_url":"https://api.github.com/repos/angular/material/pulls/4269/comments","review_comment_url":"https://api.github.com/repos/angular/material/pulls/comments{/number}","comments_url":"https://api.github.com/repos/angular/material/issues/4269/comments","statuses_url":"https://api.github.com/repos/angular/material/statuses/59753bcb16c6a4983c841c99f52dfea0ab581940","head":{"label":"angular:wip-menu-bar","ref":"wip-menu-bar","sha":"59753bcb16c6a4983c841c99f52dfea0ab581940","user":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"repo":{"id":21399598,"name":"material","full_name":"angular/material","owner":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/angular/material","description":"Material design for Angular","fork":false,"url":"https://api.github.com/repos/angular/material","forks_url":"https://api.github.com/repos/angular/material/forks","keys_url":"https://api.github.com/repos/angular/material/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angular/material/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angular/material/teams","hooks_url":"https://api.github.com/repos/angular/material/hooks","issue_events_url":"https://api.github.com/repos/angular/material/issues/events{/number}","events_url":"https://api.github.com/repos/angular/material/events","assignees_url":"https://api.github.com/repos/angular/material/assignees{/user}","branches_url":"https://api.github.com/repos/angular/material/branches{/branch}","tags_url":"https://api.github.com/repos/angular/material/tags","blobs_url":"https://api.github.com/repos/angular/material/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angular/material/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angular/material/git/refs{/sha}","trees_url":"https://api.github.com/repos/angular/material/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angular/material/statuses/{sha}","languages_url":"https://api.github.com/repos/angular/material/languages","stargazers_url":"https://api.github.com/repos/angular/material/stargazers","contributors_url":"https://api.github.com/repos/angular/material/contributors","subscribers_url":"https://api.github.com/repos/angular/material/subscribers","subscription_url":"https://api.github.com/repos/angular/material/subscription","commits_url":"https://api.github.com/repos/angular/material/commits{/sha}","git_commits_url":"https://api.github.com/repos/angular/material/git/commits{/sha}","comments_url":"https://api.github.com/repos/angular/material/comments{/number}","issue_comment_url":"https://api.github.com/repos/angular/material/issues/comments{/number}","contents_url":"https://api.github.com/repos/angular/material/contents/{+path}","compare_url":"https://api.github.com/repos/angular/material/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angular/material/merges","archive_url":"https://api.github.com/repos/angular/material/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angular/material/downloads","issues_url":"https://api.github.com/repos/angular/material/issues{/number}","pulls_url":"https://api.github.com/repos/angular/material/pulls{/number}","milestones_url":"https://api.github.com/repos/angular/material/milestones{/number}","notifications_url":"https://api.github.com/repos/angular/material/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angular/material/labels{/name}","releases_url":"https://api.github.com/repos/angular/material/releases{/id}","created_at":"2014-07-01T19:20:06Z","updated_at":"2015-08-20T19:48:04Z","pushed_at":"2015-08-20T20:03:47Z","git_url":"git://github.com/angular/material.git","ssh_url":"git@github.com:angular/material.git","clone_url":"https://github.com/angular/material.git","svn_url":"https://github.com/angular/material","homepage":"https://material.angularjs.org/","size":92643,"stargazers_count":9980,"watchers_count":9980,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1681,"mirror_url":null,"open_issues_count":1102,"forks":1681,"open_issues":1102,"watchers":9980,"default_branch":"master"}},"base":{"label":"angular:master","ref":"master","sha":"a6c14b3b169ece236332abc35e45920b7c588eae","user":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"repo":{"id":21399598,"name":"material","full_name":"angular/material","owner":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/angular/material","description":"Material design for Angular","fork":false,"url":"https://api.github.com/repos/angular/material","forks_url":"https://api.github.com/repos/angular/material/forks","keys_url":"https://api.github.com/repos/angular/material/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angular/material/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angular/material/teams","hooks_url":"https://api.github.com/repos/angular/material/hooks","issue_events_url":"https://api.github.com/repos/angular/material/issues/events{/number}","events_url":"https://api.github.com/repos/angular/material/events","assignees_url":"https://api.github.com/repos/angular/material/assignees{/user}","branches_url":"https://api.github.com/repos/angular/material/branches{/branch}","tags_url":"https://api.github.com/repos/angular/material/tags","blobs_url":"https://api.github.com/repos/angular/material/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angular/material/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angular/material/git/refs{/sha}","trees_url":"https://api.github.com/repos/angular/material/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angular/material/statuses/{sha}","languages_url":"https://api.github.com/repos/angular/material/languages","stargazers_url":"https://api.github.com/repos/angular/material/stargazers","contributors_url":"https://api.github.com/repos/angular/material/contributors","subscribers_url":"https://api.github.com/repos/angular/material/subscribers","subscription_url":"https://api.github.com/repos/angular/material/subscription","commits_url":"https://api.github.com/repos/angular/material/commits{/sha}","git_commits_url":"https://api.github.com/repos/angular/material/git/commits{/sha}","comments_url":"https://api.github.com/repos/angular/material/comments{/number}","issue_comment_url":"https://api.github.com/repos/angular/material/issues/comments{/number}","contents_url":"https://api.github.com/repos/angular/material/contents/{+path}","compare_url":"https://api.github.com/repos/angular/material/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angular/material/merges","archive_url":"https://api.github.com/repos/angular/material/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angular/material/downloads","issues_url":"https://api.github.com/repos/angular/material/issues{/number}","pulls_url":"https://api.github.com/repos/angular/material/pulls{/number}","milestones_url":"https://api.github.com/repos/angular/material/milestones{/number}","notifications_url":"https://api.github.com/repos/angular/material/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angular/material/labels{/name}","releases_url":"https://api.github.com/repos/angular/material/releases{/id}","created_at":"2014-07-01T19:20:06Z","updated_at":"2015-08-20T19:48:04Z","pushed_at":"2015-08-20T20:03:47Z","git_url":"git://github.com/angular/material.git","ssh_url":"git@github.com:angular/material.git","clone_url":"https://github.com/angular/material.git","svn_url":"https://github.com/angular/material","homepage":"https://material.angularjs.org/","size":92643,"stargazers_count":9980,"watchers_count":9980,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1681,"mirror_url":null,"open_issues_count":1102,"forks":1681,"open_issues":1102,"watchers":9980,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angular/material/pulls/4269"},"html":{"href":"https://github.com/angular/material/pull/4269"},"issue":{"href":"https://api.github.com/repos/angular/material/issues/4269"},"comments":{"href":"https://api.github.com/repos/angular/material/issues/4269/comments"},"review_comments":{"href":"https://api.github.com/repos/angular/material/pulls/4269/comments"},"review_comment":{"href":"https://api.github.com/repos/angular/material/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/angular/material/pulls/4269/commits"},"statuses":{"href":"https://api.github.com/repos/angular/material/statuses/59753bcb16c6a4983c841c99f52dfea0ab581940"}}}}