summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorCiro Santilli <ciro.santilli@gmail.com>2014-10-21 22:52:38 +0200
committerCiro Santilli <ciro.santilli@gmail.com>2014-10-21 22:54:22 +0200
commitab1ad3bd18d9b9359fc361d7dab3b317fdd38984 (patch)
tree27eb07adff653a195eb21b917d927a805cb0f9e8 /app/assets
parentc3b81e5f400ebc935683fc2cf0e561b2b17a1052 (diff)
downloadgitlab-ce-ab1ad3bd18d9b9359fc361d7dab3b317fdd38984.tar.gz
Only run namespace select js when needed
Only needed in admin/projects.
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/dispatcher.js.coffee6
-rw-r--r--app/assets/javascripts/namespace_select.js.coffee43
2 files changed, 27 insertions, 22 deletions
diff --git a/app/assets/javascripts/dispatcher.js.coffee b/app/assets/javascripts/dispatcher.js.coffee
index 00b52758fa8..72bff2d8ab4 100644
--- a/app/assets/javascripts/dispatcher.js.coffee
+++ b/app/assets/javascripts/dispatcher.js.coffee
@@ -81,7 +81,11 @@ class Dispatcher
shortcut_handler = true
switch path.first()
- when 'admin' then new Admin()
+ when 'admin'
+ new Admin()
+ switch path[1]
+ when 'projects'
+ new NamespaceSelect()
when 'dashboard'
shortcut_handler = new ShortcutsDashboardNavigation()
when 'projects'
diff --git a/app/assets/javascripts/namespace_select.js.coffee b/app/assets/javascripts/namespace_select.js.coffee
index 00d135d1449..a02c4515ccc 100644
--- a/app/assets/javascripts/namespace_select.js.coffee
+++ b/app/assets/javascripts/namespace_select.js.coffee
@@ -1,24 +1,25 @@
-$ ->
- namespaceFormatResult = (namespace) ->
- markup = "<div class='namespace-result'>"
- markup += "<span class='namespace-kind'>" + namespace.kind + "</span>"
- markup += "<span class='namespace-path'>" + namespace.path + "</span>"
- markup += "</div>"
- markup
+class @NamespaceSelect
+ constructor: ->
+ namespaceFormatResult = (namespace) ->
+ markup = "<div class='namespace-result'>"
+ markup += "<span class='namespace-kind'>" + namespace.kind + "</span>"
+ markup += "<span class='namespace-path'>" + namespace.path + "</span>"
+ markup += "</div>"
+ markup
- formatSelection = (namespace) ->
- namespace.kind + ": " + namespace.path
+ formatSelection = (namespace) ->
+ namespace.kind + ": " + namespace.path
- $('.ajax-namespace-select').each (i, select) ->
- $(select).select2
- placeholder: "Search for namespace"
- multiple: $(select).hasClass('multiselect')
- minimumInputLength: 0
- query: (query) ->
- Api.namespaces query.term, (namespaces) ->
- data = { results: namespaces }
- query.callback(data)
+ $('.ajax-namespace-select').each (i, select) ->
+ $(select).select2
+ placeholder: "Search for namespace"
+ multiple: $(select).hasClass('multiselect')
+ minimumInputLength: 0
+ query: (query) ->
+ Api.namespaces query.term, (namespaces) ->
+ data = { results: namespaces }
+ query.callback(data)
- dropdownCssClass: "ajax-namespace-dropdown"
- formatResult: namespaceFormatResult
- formatSelection: formatSelection
+ dropdownCssClass: "ajax-namespace-dropdown"
+ formatResult: namespaceFormatResult
+ formatSelection: formatSelection