Module: BootstrapNavbar::Helpers::Bootstrap3
- Defined in:
- lib/bootstrap-navbar/helpers/bootstrap3.rb
Instance Method Summary collapse
- #navbar(options = {}, &block) ⇒ Object
- #navbar_button(text, options = {}) ⇒ Object
- #navbar_collapse(options = {}, &block) ⇒ Object
- #navbar_dropdown(text, list_item_options = {}, link_options = {}, &block) ⇒ Object
- #navbar_dropdown_divider ⇒ Object
- #navbar_dropdown_header(text) ⇒ Object
- #navbar_form(url, options = {}, &block) ⇒ Object
- #navbar_group(options = {}, &block) ⇒ Object
- #navbar_header(options = {}, &block) ⇒ Object
- #navbar_item(text, url = nil, list_item_options = nil, link_options = nil, &block) ⇒ Object
- #navbar_text(text = nil, options = {}, &block) ⇒ Object
Instance Method Details
#navbar(options = {}, &block) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/bootstrap-navbar/helpers/bootstrap3.rb', line 2 def ( = {}, &block) = .dup container = .key?(:container) ? .delete(:container) : true wrapper do if container container(container, &block) else capture(&block) if block_given? end end end |
#navbar_button(text, options = {}) ⇒ Object
102 103 104 105 106 107 108 109 110 |
# File 'lib/bootstrap-navbar/helpers/bootstrap3.rb', line 102 def (text, = {}) = .dup [:class] = [[:class], 'btn', 'navbar-btn'].compact.join(' ') [:type] ||= 'button' attributes = attributes_for_tag() prepare_html <<-HTML.chomp! <button#{attributes}>#{text}</button> HTML end |
#navbar_collapse(options = {}, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bootstrap-navbar/helpers/bootstrap3.rb', line 33 def ( = {}, &block) = .dup [:class] = [[:class], 'collapse', 'navbar-collapse'].compact.join(' ') [:id] ||= 'navbar-collapsable' attributes = attributes_for_tag() prepare_html <<-HTML.chomp! <div#{attributes}> #{capture(&block) if block_given?} </div> HTML end |
#navbar_dropdown(text, list_item_options = {}, link_options = {}, &block) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/bootstrap-navbar/helpers/bootstrap3.rb', line 112 def (text, = {}, = {}, &block) , = .dup, .dup [:class] = [[:class], 'dropdown'].compact.join(' ') list_item_attributes = attributes_for_tag() [:class] = [[:class], 'dropdown-toggle'].compact.join(' ') link_attributes = attributes_for_tag() prepare_html <<-HTML.chomp! <li#{list_item_attributes}> <a href="#" data-toggle="dropdown"#{link_attributes}>#{text} <b class="caret"></b></a> <ul class="dropdown-menu"> #{capture(&block) if block_given?} </ul> </li> HTML end |
#navbar_dropdown_divider ⇒ Object
136 137 138 139 140 |
# File 'lib/bootstrap-navbar/helpers/bootstrap3.rb', line 136 def prepare_html <<-HTML.chomp! <li class="divider"></li> HTML end |
#navbar_dropdown_header(text) ⇒ Object
128 129 130 131 132 133 134 |
# File 'lib/bootstrap-navbar/helpers/bootstrap3.rb', line 128 def (text) prepare_html <<-HTML.chomp! <li class="dropdown-header"> #{text} </li> HTML end |
#navbar_form(url, options = {}, &block) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/bootstrap-navbar/helpers/bootstrap3.rb', line 77 def (url, = {}, &block) = .dup [:class] = [[:class], 'navbar-form'].compact [:class] << "navbar-#{.delete(:align)}" if .key?(:align) [:class] = [:class].join(' ') [:role] ||= 'form' attributes = attributes_for_tag() prepare_html <<-HTML.chomp! <form action="#{url}" #{attributes}> #{capture(&block) if block_given?} </form> HTML end |
#navbar_group(options = {}, &block) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bootstrap-navbar/helpers/bootstrap3.rb', line 45 def ( = {}, &block) = .dup [:class] = [[:class], 'nav', 'navbar-nav'].compact [:class] << "navbar-#{.delete(:align)}" if .key?(:align) [:class] = [:class].join(' ') attributes = attributes_for_tag() prepare_html <<-HTML.chomp! <ul#{attributes}> #{capture(&block) if block_given?} </ul> HTML end |
#navbar_header(options = {}, &block) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bootstrap-navbar/helpers/bootstrap3.rb', line 14 def ( = {}, &block) = .dup brand, brand_link = .delete(:brand), .delete(:brand_link) [:class] = [[:class], 'navbar-header'].compact.join(' ') attributes = attributes_for_tag() prepare_html <<-HTML.chomp! <div#{attributes}> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapsable"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> #{brand_link brand, brand_link unless brand.nil?} #{capture(&block) if block_given?} </div> HTML end |
#navbar_item(text, url = nil, list_item_options = nil, link_options = nil, &block) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/bootstrap-navbar/helpers/bootstrap3.rb', line 58 def (text, url = nil, = nil, = nil, &block) text, url, , = capture(&block), text, url, if block_given? url ||= '#' = ? .dup : {} = ? .dup : {} [:class] = [[:class]].compact [:class] << 'active' if current_url_or_sub_url?(url) [:class] = [:class].join(' ') list_item_attributes = attributes_for_tag() link_attributes = attributes_for_tag() prepare_html <<-HTML.chomp! <li#{list_item_attributes}> <a href="#{url}"#{link_attributes}> #{text} </a> </li> HTML end |
#navbar_text(text = nil, options = {}, &block) ⇒ Object
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/bootstrap-navbar/helpers/bootstrap3.rb', line 91 def (text = nil, = {}, &block) raise StandardError, 'Please provide either the "text" parameter or a block.' if !!text == block_given? = .dup text ||= capture(&block) [:class] = [[:class], 'navbar-text'].compact.join(' ') attributes = attributes_for_tag() prepare_html <<-HTML.chomp! <p#{attributes}>#{text}</p> HTML end |