diff options
author | Phil Hughes <me@iamphill.com> | 2016-03-07 15:37:35 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-03-10 13:54:54 +0000 |
commit | 4407532911c2fb4841cc51f9779ef51ccb6de099 (patch) | |
tree | 0e1aef05b697a05757e513fbbf5cadf84c4fc02c /app/helpers/dropdowns_helper.rb | |
parent | 198926dc7f1bf539862ead04e1e3ebb9d5b9de31 (diff) | |
download | gitlab-ce-4407532911c2fb4841cc51f9779ef51ccb6de099.tar.gz |
GitLab dropdown JS
Diffstat (limited to 'app/helpers/dropdowns_helper.rb')
-rw-r--r-- | app/helpers/dropdowns_helper.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/app/helpers/dropdowns_helper.rb b/app/helpers/dropdowns_helper.rb new file mode 100644 index 00000000000..c96b6eeebd5 --- /dev/null +++ b/app/helpers/dropdowns_helper.rb @@ -0,0 +1,47 @@ +module DropdownsHelper + def dropdown_tag(toggle_text, title: false, filter: false, placeholder: "", &block) + content_tag :div, class: "dropdown" do + dropdown_output = "" + dropdown_output += content_tag :button, class: "dropdown-menu-toggle", type: "button", data: {toggle: "dropdown"} do + output = toggle_text + output << icon('chevron-down') + output.html_safe + end + + dropdown_output += content_tag :div, class: "dropdown-menu dropdown-select dropdown-menu-selectable" do + output = "" + + if title + output += content_tag :div, class: "dropdown-title" do + title_output = content_tag(:span, title) + + title_output += content_tag :button, class: "dropdown-title-button dropdown-menu-close", aria: {label: "close"} do + icon('times') + end.html_safe + end + end + + if filter + output += content_tag :div, class: "dropdown-input" do + filter_output = search_field_tag nil, nil, class: "dropdown-input-field", placeholder: placeholder + filter_output += icon('search') + + filter_output.html_safe + end + end + + output += content_tag :div, class: "dropdown-content" do + capture(&block) if block + end + + output += content_tag :div, class: "dropdown-loading" do + icon('spinner spin') + end + + output.html_safe + end + + dropdown_output.html_safe + end + end +end |