Module: ButtonHelper
- Includes:
- ActionView::Helpers, FormatHelper
- Included in:
- ActionView::Helpers::FormBuilder
- Defined in:
- app/helpers/button_helper.rb
Instance Method Summary collapse
- #button(content_or_options = nil, options = {}, &block) ⇒ Object
- #button_group(options = {}, &block) ⇒ Object
- #button_toolbar(options = {}, &block) ⇒ Object
- #navbar_button(content_or_options = nil, options = {}, &block) ⇒ Object
Methods included from FormatHelper
Instance Method Details
#button(content_or_options = nil, options = {}, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/button_helper.rb', line 5 def (=nil, ={}, &block) .is_a?(Hash) ? = : content = layout = 'btn-block' if .delete(:layout).try(:to_sym) == :block size = get_btn_size(.delete(:size)) type = get_btn_type(.delete(:type)) prepend_class(, 'btn', type, size, layout) content_tag :button, do content.presence || capture(&block) end end |
#button_group(options = {}, &block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/button_helper.rb', line 18 def (={}, &block) size = get_btn_group_size(.delete(:size)) layout = if .delete(:layout).try(:to_sym) == :vertical 'btn-group-vertical' else 'btn-group' end prepend_class(, layout, size) [:role] = squeeze_n_strip("group #{options[:role]}") [:data] = ([:data] || {}).merge({bui: 'btn_group', size: size}) content_tag :div, , &block end |
#button_toolbar(options = {}, &block) ⇒ Object
33 34 35 36 37 38 |
# File 'app/helpers/button_helper.rb', line 33 def (={}, &block) prepend_class(, 'btn-toolbar') prepend_role(, 'toolbar') content_tag :div, , &block end |
#navbar_button(content_or_options = nil, options = {}, &block) ⇒ Object
40 41 42 43 44 45 |
# File 'app/helpers/button_helper.rb', line 40 def (=nil, ={}, &block) .is_a?(Hash) ? = : content = prepend_class(, 'navbar-btn') content, , &block end |