debian-mirror-gitlab/app/assets/javascripts/namespace_select.js.coffee

26 lines
903 B
CoffeeScript
Raw Normal View History

2015-04-26 12:48:37 +05:30
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
2014-09-02 18:07:02 +05:30
2015-04-26 12:48:37 +05:30
formatSelection = (namespace) ->
namespace.kind + ": " + namespace.path
2014-09-02 18:07:02 +05:30
2015-04-26 12:48:37 +05:30
$('.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)
2014-09-02 18:07:02 +05:30
2015-04-26 12:48:37 +05:30
dropdownCssClass: "ajax-namespace-dropdown"
formatResult: namespaceFormatResult
formatSelection: formatSelection