Only run namespace select js when needed
Only needed in admin/projects.
This commit is contained in:
parent
c3b81e5f40
commit
ab1ad3bd18
2 changed files with 27 additions and 22 deletions
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue