{"action":"created","comment":{"url":"https://api.github.com/repos/c2corg/v6_ui/pulls/comments/47224222","id":47224222,"diff_hunk":"@@ -0,0 +1,184 @@\n+goog.provide('app.SearchController');\n+goog.provide('app.searchDirective');\n+\n+goog.require('app');\n+goog.require('app.utils');\n+goog.require('ngeo.searchDirective');\n+\n+\n+/**\n+ * The directive for the auto-complete search field shown in the header\n+ * of every page.\n+ *\n+ * @return {angular.Directive} Directive Definition Object.\n+ */\n+app.searchDirective = function() {\n+  return {\n+    restrict: 'E',\n+    controller: 'AppSearchController',\n+    bindToController: true,\n+    controllerAs: 'ctrl',\n+    template:\n+        '<input type=\"text\" placeholder=\"search…\" ' +\n+        'ngeo-search=\"ctrl.options\" ' +\n+        'ngeo-search-datasets=\"ctrl.datasets\" ' +\n+        'ngeo-search-listeners=\"ctrl.listeners\">',\n+    link:\n+        /**\n+         * @param {angular.Scope} scope Scope.\n+         * @param {angular.JQLite} element Element.\n+         * @param {angular.Attributes} attrs Atttributes.\n+         */\n+        function(scope, element, attrs) {\n+          // Empty the search field on focus and blur.\n+          element.find('input').on('focus blur', function() {\n+            $(this).typeahead('val', '');\n+          });\n+        }\n+  };\n+};\n+app.module.directive('appSearch', app.searchDirective);\n+\n+\n+\n+/**\n+ * @constructor\n+ * @param {angular.Scope} $rootScope Angular root scope.\n+ * @param {angular.$compile} $compile Angular compile service.\n+ * @param {string} apiUrl Base URL of the API.\n+ * @param {angularGettext.Catalog} gettextCatalog Gettext catalog.\n+ * @param {Array.<string>} cultures All cultures.\n+ * @ngInject\n+ */\n+app.SearchController = function(\n+    $rootScope, $compile, apiUrl, gettextCatalog, cultures) {\n+\n+  /**\n+   * @type {string}\n+   * @private\n+   */\n+  this.apiUrl_ = apiUrl;\n+\n+  /**\n+   * @type {Array.<string>}\n+   * @private\n+   */\n+  this.cultures_ = cultures;\n+\n+  /**\n+   * @type {angularGettext.Catalog}\n+   * @private\n+   */\n+  this.gettextCatalog_ = gettextCatalog;\n+\n+  /**\n+   * @type {TypeaheadOptions}\n+   * @export\n+   */\n+  this.options = /** @type {TypeaheadOptions} */ ({\n+    highlight: true,\n+    hint: true,\n+    minLength: 2\n+  });\n+\n+  /**\n+   * @type {Array.<TypeaheadDataset>}\n+   * @export\n+   */\n+  this.datasets = [\n+    this.createDataset_('waypoints', 'Waypoints'),\n+    this.createDataset_('routes', 'Routes')\n+  ];\n+\n+  /**\n+   * @type {ngeox.SearchDirectiveListeners}\n+   * @export\n+   */\n+  this.listeners = /** @type {ngeox.SearchDirectiveListeners} */ ({\n+    select: angular.bind(this, app.SearchController.select_)\n+  });\n+};\n+\n+\n+/**\n+ * @param {string} type The document type.\n+ * @param {string} title The category title.\n+ * @return {TypeaheadDataset} A data set.\n+ * @private\n+ */\n+app.SearchController.prototype.createDataset_ = function(type, title) {\n+  var bloodhoundEngine = this.createAndInitBloodhound_(type);\n+  return /** @type {TypeaheadDataset} */({\n+    source: bloodhoundEngine.ttAdapter(),\n+    display: function(suggestion) {\n+      return suggestion['label'];\n+    },\n+    limit: 20,\n+    templates: {\n+      header: angular.bind(this, function() {","path":"c2corg_ui/static/js/searchdirective.js","position":118,"original_position":118,"commit_id":"39fc8555fc45530c18ca8e3680aa7af0aad6fc53","original_commit_id":"39fc8555fc45530c18ca8e3680aa7af0aad6fc53","user":{"login":"gberaudo","id":7294662,"avatar_url":"https://avatars.githubusercontent.com/u/7294662?v=3","gravatar_id":"","url":"https://api.github.com/users/gberaudo","html_url":"https://github.com/gberaudo","followers_url":"https://api.github.com/users/gberaudo/followers","following_url":"https://api.github.com/users/gberaudo/following{/other_user}","gists_url":"https://api.github.com/users/gberaudo/gists{/gist_id}","starred_url":"https://api.github.com/users/gberaudo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gberaudo/subscriptions","organizations_url":"https://api.github.com/users/gberaudo/orgs","repos_url":"https://api.github.com/users/gberaudo/repos","events_url":"https://api.github.com/users/gberaudo/events{/privacy}","received_events_url":"https://api.github.com/users/gberaudo/received_events","type":"User","site_admin":false},"body":":wink:","created_at":"2015-12-10T13:18:07Z","updated_at":"2015-12-10T13:18:07Z","html_url":"https://github.com/c2corg/v6_ui/pull/52#discussion_r47224222","pull_request_url":"https://api.github.com/repos/c2corg/v6_ui/pulls/52","_links":{"self":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/comments/47224222"},"html":{"href":"https://github.com/c2corg/v6_ui/pull/52#discussion_r47224222"},"pull_request":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/52"}}},"pull_request":{"url":"https://api.github.com/repos/c2corg/v6_ui/pulls/52","id":53112431,"html_url":"https://github.com/c2corg/v6_ui/pull/52","diff_url":"https://github.com/c2corg/v6_ui/pull/52.diff","patch_url":"https://github.com/c2corg/v6_ui/pull/52.patch","issue_url":"https://api.github.com/repos/c2corg/v6_ui/issues/52","number":52,"state":"open","locked":false,"title":"Add search control","user":{"login":"tsauerwein","id":266474,"avatar_url":"https://avatars.githubusercontent.com/u/266474?v=3","gravatar_id":"","url":"https://api.github.com/users/tsauerwein","html_url":"https://github.com/tsauerwein","followers_url":"https://api.github.com/users/tsauerwein/followers","following_url":"https://api.github.com/users/tsauerwein/following{/other_user}","gists_url":"https://api.github.com/users/tsauerwein/gists{/gist_id}","starred_url":"https://api.github.com/users/tsauerwein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsauerwein/subscriptions","organizations_url":"https://api.github.com/users/tsauerwein/orgs","repos_url":"https://api.github.com/users/tsauerwein/repos","events_url":"https://api.github.com/users/tsauerwein/events{/privacy}","received_events_url":"https://api.github.com/users/tsauerwein/received_events","type":"User","site_admin":false},"body":"Not ready, but reviews already welcome.","created_at":"2015-12-09T12:28:36Z","updated_at":"2015-12-10T13:18:07Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3541498257c59e6ff3c74a407f3b1895ddbb0a6d","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/c2corg/v6_ui/pulls/52/commits","review_comments_url":"https://api.github.com/repos/c2corg/v6_ui/pulls/52/comments","review_comment_url":"https://api.github.com/repos/c2corg/v6_ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/c2corg/v6_ui/issues/52/comments","statuses_url":"https://api.github.com/repos/c2corg/v6_ui/statuses/39fc8555fc45530c18ca8e3680aa7af0aad6fc53","head":{"label":"c2corg:search-control","ref":"search-control","sha":"39fc8555fc45530c18ca8e3680aa7af0aad6fc53","user":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"repo":{"id":43445823,"name":"v6_ui","full_name":"c2corg/v6_ui","owner":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/c2corg/v6_ui","description":"UI for c2c.org v6","fork":false,"url":"https://api.github.com/repos/c2corg/v6_ui","forks_url":"https://api.github.com/repos/c2corg/v6_ui/forks","keys_url":"https://api.github.com/repos/c2corg/v6_ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/c2corg/v6_ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/c2corg/v6_ui/teams","hooks_url":"https://api.github.com/repos/c2corg/v6_ui/hooks","issue_events_url":"https://api.github.com/repos/c2corg/v6_ui/issues/events{/number}","events_url":"https://api.github.com/repos/c2corg/v6_ui/events","assignees_url":"https://api.github.com/repos/c2corg/v6_ui/assignees{/user}","branches_url":"https://api.github.com/repos/c2corg/v6_ui/branches{/branch}","tags_url":"https://api.github.com/repos/c2corg/v6_ui/tags","blobs_url":"https://api.github.com/repos/c2corg/v6_ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/c2corg/v6_ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/c2corg/v6_ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/c2corg/v6_ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/c2corg/v6_ui/statuses/{sha}","languages_url":"https://api.github.com/repos/c2corg/v6_ui/languages","stargazers_url":"https://api.github.com/repos/c2corg/v6_ui/stargazers","contributors_url":"https://api.github.com/repos/c2corg/v6_ui/contributors","subscribers_url":"https://api.github.com/repos/c2corg/v6_ui/subscribers","subscription_url":"https://api.github.com/repos/c2corg/v6_ui/subscription","commits_url":"https://api.github.com/repos/c2corg/v6_ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/c2corg/v6_ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/c2corg/v6_ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/c2corg/v6_ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/c2corg/v6_ui/contents/{+path}","compare_url":"https://api.github.com/repos/c2corg/v6_ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/c2corg/v6_ui/merges","archive_url":"https://api.github.com/repos/c2corg/v6_ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/c2corg/v6_ui/downloads","issues_url":"https://api.github.com/repos/c2corg/v6_ui/issues{/number}","pulls_url":"https://api.github.com/repos/c2corg/v6_ui/pulls{/number}","milestones_url":"https://api.github.com/repos/c2corg/v6_ui/milestones{/number}","notifications_url":"https://api.github.com/repos/c2corg/v6_ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/c2corg/v6_ui/labels{/name}","releases_url":"https://api.github.com/repos/c2corg/v6_ui/releases{/id}","created_at":"2015-09-30T16:52:44Z","updated_at":"2015-12-04T09:43:07Z","pushed_at":"2015-12-10T11:52:39Z","git_url":"git://github.com/c2corg/v6_ui.git","ssh_url":"git@github.com:c2corg/v6_ui.git","clone_url":"https://github.com/c2corg/v6_ui.git","svn_url":"https://github.com/c2corg/v6_ui","homepage":null,"size":267,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":28,"forks":0,"open_issues":28,"watchers":2,"default_branch":"master"}},"base":{"label":"c2corg:master","ref":"master","sha":"b7b33f4e98b17803cf3f0c668efabea6f141f668","user":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"repo":{"id":43445823,"name":"v6_ui","full_name":"c2corg/v6_ui","owner":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/c2corg/v6_ui","description":"UI for c2c.org v6","fork":false,"url":"https://api.github.com/repos/c2corg/v6_ui","forks_url":"https://api.github.com/repos/c2corg/v6_ui/forks","keys_url":"https://api.github.com/repos/c2corg/v6_ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/c2corg/v6_ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/c2corg/v6_ui/teams","hooks_url":"https://api.github.com/repos/c2corg/v6_ui/hooks","issue_events_url":"https://api.github.com/repos/c2corg/v6_ui/issues/events{/number}","events_url":"https://api.github.com/repos/c2corg/v6_ui/events","assignees_url":"https://api.github.com/repos/c2corg/v6_ui/assignees{/user}","branches_url":"https://api.github.com/repos/c2corg/v6_ui/branches{/branch}","tags_url":"https://api.github.com/repos/c2corg/v6_ui/tags","blobs_url":"https://api.github.com/repos/c2corg/v6_ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/c2corg/v6_ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/c2corg/v6_ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/c2corg/v6_ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/c2corg/v6_ui/statuses/{sha}","languages_url":"https://api.github.com/repos/c2corg/v6_ui/languages","stargazers_url":"https://api.github.com/repos/c2corg/v6_ui/stargazers","contributors_url":"https://api.github.com/repos/c2corg/v6_ui/contributors","subscribers_url":"https://api.github.com/repos/c2corg/v6_ui/subscribers","subscription_url":"https://api.github.com/repos/c2corg/v6_ui/subscription","commits_url":"https://api.github.com/repos/c2corg/v6_ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/c2corg/v6_ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/c2corg/v6_ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/c2corg/v6_ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/c2corg/v6_ui/contents/{+path}","compare_url":"https://api.github.com/repos/c2corg/v6_ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/c2corg/v6_ui/merges","archive_url":"https://api.github.com/repos/c2corg/v6_ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/c2corg/v6_ui/downloads","issues_url":"https://api.github.com/repos/c2corg/v6_ui/issues{/number}","pulls_url":"https://api.github.com/repos/c2corg/v6_ui/pulls{/number}","milestones_url":"https://api.github.com/repos/c2corg/v6_ui/milestones{/number}","notifications_url":"https://api.github.com/repos/c2corg/v6_ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/c2corg/v6_ui/labels{/name}","releases_url":"https://api.github.com/repos/c2corg/v6_ui/releases{/id}","created_at":"2015-09-30T16:52:44Z","updated_at":"2015-12-04T09:43:07Z","pushed_at":"2015-12-10T11:52:39Z","git_url":"git://github.com/c2corg/v6_ui.git","ssh_url":"git@github.com:c2corg/v6_ui.git","clone_url":"https://github.com/c2corg/v6_ui.git","svn_url":"https://github.com/c2corg/v6_ui","homepage":null,"size":267,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":28,"forks":0,"open_issues":28,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/52"},"html":{"href":"https://github.com/c2corg/v6_ui/pull/52"},"issue":{"href":"https://api.github.com/repos/c2corg/v6_ui/issues/52"},"comments":{"href":"https://api.github.com/repos/c2corg/v6_ui/issues/52/comments"},"review_comments":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/52/comments"},"review_comment":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/52/commits"},"statuses":{"href":"https://api.github.com/repos/c2corg/v6_ui/statuses/39fc8555fc45530c18ca8e3680aa7af0aad6fc53"}}}}