Module: Css3buttons::Helpers::ButtonHelper
- Includes:
- ActionView::Helpers::FormTagHelper, ActionView::Helpers::UrlHelper
- Defined in:
- lib/css3buttons/helpers/button_helper.rb
Instance Method Summary collapse
- #button_group(*args, &block) ⇒ Object
- #css3buttons_stylesheets(options = {}) ⇒ Object
- #method_missing(method, *args) ⇒ Object
- #minor_button_group(*args, &block) ⇒ Object
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/css3buttons/helpers/button_helper.rb', line 6 def method_missing(method, *args) if is_link_method?(method) || is_submit_method?(method) || (method) qualifiers = ["primary", "big", "positive", "negative", "pill", "danger", "safe", "button"] color_map = {"positive" => "safe", "negative" => "danger"} method_qualifiers = strip_method_name(method).split("_") + ["button"] method_qualifiers.map! do |qualifier| if color_map.has_key?(qualifier) qualifier = color_map[qualifier] end if qualifiers.index(qualifier).nil? qualifier = [qualifier, "icon"] end qualifier end.flatten! if is_link_method?(method) && block_given? link = args.first = args. link_to(link, , &Proc.new) else label = args.first link = args[1] = args. = (method_qualifiers, ) if is_link_method?(method) link_to(label, link, ) elsif (method) content_tag :button, label, { "type" => "submit", "name" => "commit", "value" => "commit" }.merge(.stringify_keys) else submit_tag(label, ) end end else super end end |
Instance Method Details
#button_group(*args, &block) ⇒ Object
54 55 56 57 58 |
# File 'lib/css3buttons/helpers/button_helper.rb', line 54 def (*args, &block) = args. group = Css3buttons::ButtonGroup.new(self, ) group.render(&block) if block_given? end |
#css3buttons_stylesheets(options = {}) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/css3buttons/helpers/button_helper.rb', line 45 def ( = {}) [:include_reset] = true unless .has_key?(:include_reset) if [:include_reset] == true stylesheet_link_tag "css3buttons/reset", "css3buttons/css3-github-buttons" else stylesheet_link_tag "css3buttons/css3-github-buttons" end end |
#minor_button_group(*args, &block) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/css3buttons/helpers/button_helper.rb', line 60 def (*args, &block) = args. [:minor] = true group = Css3buttons::ButtonGroup.new(self, ) group.render(&block) if block_given? end |