module BootstrapHelpers
- Author
-
Maurizio Casimirri (maurizio.cas@gmail.com)
- Copyright
-
Copyright © 2012 Maurizio Casimirri
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Public Instance Methods
# File lib/bootstrap-helpers.rb, line 308 def accordion(opts = {}) opts[:accordion_id] ||= 'accordion' builder = AccordionBuilder.new opts, self content_tag :div, :class => 'accordion', :id => opts[:accordion_id] do yield builder end end
# File lib/bootstrap-helpers.rb, line 120 def alert(message) "<div class='alert'>#{h(message)}</div>".html_safe end
# File lib/bootstrap-helpers.rb, line 37 def bootstrap_fluid! @bootstrap_float_style = true end
# File lib/bootstrap-helpers.rb, line 41 def bootstrap_fluid? !!@bootstrap_float_style end
# File lib/bootstrap-helpers.rb, line 33 def bootstrap_row_class bootstrap_fluid? ? "row-fluid" : "row" end
# File lib/bootstrap-helpers.rb, line 213 def brand(*args, &block) if !args.last.is_a?(Hash) args << {} end args.last[:class] = "brand" link_to(*args, &block) end
# File lib/bootstrap-helpers.rb, line 45 def container(opts = {}, &block) if opts.delete(:fluid) bootstrap_fluid! end opts[:class] = ("#{opts[:class]}".split(" ") + [bootstrap_container_class]).join(" ") content_tag("div", opts, &block) end
# File lib/bootstrap-helpers.rb, line 116 def form_actions(&block) content_tag :div, :class => "form-actions", &block end
# File lib/bootstrap-helpers.rb, line 72 def icon(icon_id, opts={}) opts[:class] ||= "" opts[:class] << " icon icon-#{icon_id}" opts[:class].strip! content_tag :i, "", opts end
# File lib/bootstrap-helpers.rb, line 150 def pills(options = {}, &block) "<ul class=\"nav nav-pills #{options[:class]}\">#{capture(&block)}</ul>".html_safe end
# File lib/bootstrap-helpers.rb, line 54 def row(opts = {}, &block) opts[:class] = ("#{opts[:class]}".split(" ") + [bootstrap_row_class]).join(" ") content_tag("div", opts, &block) end
# File lib/bootstrap-helpers.rb, line 60 def span(size, opts = {}, &block) offset = opts.delete(:offset) class_arr = ("#{opts[:class]}".split(" ") + ["span#{size}"]) if offset class_arr << "offset#{offset}" end opts[:class] = class_arr.join(" ") content_tag("div", opts, &block) end
# File lib/bootstrap-helpers.rb, line 254 def tabs(opts = {}) opts[:direction] ||= 'above' opts[:style] ||= 'tabs' builder = TabsBuilder.new self yield builder tabs = content_tag(:ul, builder.pane_handles.join("\n").html_safe, :class => "nav nav-#{opts[:style]}") contents = content_tag(:div, builder.pane_contents.join("\n").html_safe, :class => 'tab-content') css_direction = "tabs-#{opts[:direction]}" unless opts[:direction] == 'above' content_tag :div, :class => "tabbable #{css_direction}" do if opts[:direction] == 'below' contents + tabs else tabs + contents end end end