diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-01-11 14:58:45 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-01-11 14:58:45 +0300 |
commit | 57a4319d4277b2d7897afd91936694308e8016bf (patch) | |
tree | 2d38c2cf13b4fca5ee32cf69f2d98f5619a3a8f2 /app | |
parent | b6c2908cb2d63b5832d37d05b77e722b23d22dc6 (diff) | |
parent | 569f5701ee410b3f6da7e005e7277d1add467d44 (diff) |
Merge branch 'load-autocomplete-when-needed' into 'master'
Only load autocomplete data when actually needed
See merge request !2365
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/gfm_auto_complete.js.coffee | 19 | ||||
-rw-r--r-- | app/views/layouts/_init_auto_complete.html.haml | 8 |
2 files changed, 15 insertions, 12 deletions
diff --git a/app/assets/javascripts/gfm_auto_complete.js.coffee b/app/assets/javascripts/gfm_auto_complete.js.coffee index fa90fb65f42..4718bcf7a1e 100644 --- a/app/assets/javascripts/gfm_auto_complete.js.coffee +++ b/app/assets/javascripts/gfm_auto_complete.js.coffee @@ -68,12 +68,13 @@ GitLab.GfmAutoComplete = title: sanitize(m.title) search: "#{m.iid} #{m.title}" - $.getJSON(@dataSource).done (data) -> - # load members - input.atwho 'load', '@', data.members - # load issues - input.atwho 'load', 'issues', data.issues - # load merge requests - input.atwho 'load', 'mergerequests', data.mergerequests - # load emojis - input.atwho 'load', ':', data.emojis + if @dataSource + $.getJSON(@dataSource).done (data) -> + # load members + input.atwho 'load', '@', data.members + # load issues + input.atwho 'load', 'issues', data.issues + # load merge requests + input.atwho 'load', 'mergerequests', data.mergerequests + # load emojis + input.atwho 'load', ':', data.emojis diff --git a/app/views/layouts/_init_auto_complete.html.haml b/app/views/layouts/_init_auto_complete.html.haml index 035fe0056d3..96b38485425 100644 --- a/app/views/layouts/_init_auto_complete.html.haml +++ b/app/views/layouts/_init_auto_complete.html.haml @@ -1,4 +1,6 @@ - project = @target_project || @project -:javascript - GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_namespace_project_path(project.namespace, project, type: @noteable.class, type_id: params[:id])}" - GitLab.GfmAutoComplete.setup(); + +- if @noteable + :javascript + GitLab.GfmAutoComplete.dataSource = "#{autocomplete_sources_namespace_project_path(project.namespace, project, type: @noteable.class, type_id: params[:id])}" + GitLab.GfmAutoComplete.setup(); |