# -*- encoding : utf-8 -*-
class Card; module Set; module All; module Bootstrap; module Helper; extend Card::Set # ~~~~~~~~~~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/06_bootstrap/set/all/bootstrap/helper.rb ~~~~~~~~~~~
format :html do
def glyphicon icon_type, extra_class=''
content_tag(:span, '', :class=>"glyphicon glyphicon-#{icon_type} #{extra_class}", 'aria-hidden'=>true)
end
def button_link link_text, target, html_args={}
html_args[:class] ||= ''
btn_type = html_args[:btn_type] || 'primary'
html_args[:class] += " btn btn-#{btn_type}"
smart_link link_text, target, html_args.merge(:type=>'button')
end
def dropdown_button name, opts={}
%{
#{ dropdown_list yield, opts[:class], opts[:active] }
}
end
def dropdown_list items, extra_css_class=nil, active=nil
item_list =
case items
when Array
items.map.with_index do |item,index|
if item
"#{item}"
end
end.compact.join "\n"
when Hash
items.map do |key,item|
if item
"#{item}"
end
end.compact.join "\n"
else
items
end
%{
}
end
def separator
''
end
def breadcrumb items
content_tag :ol, :class=>'breadcrumb' do
items.map do |item|
content_tag :li, item
end
end
end
# Options
# :header => { :content=>String, :brand=>( String | {:name=>, :href=>} ) }
def navbar id, opts={}
nav_opts = opts[:navbar_opts] || {}
nav_opts[:class] ||= (opts[:class] || '')
nav_opts[:class] += " navbar navbar-#{opts.delete(:navbar_type) || 'default'}"
header_opts = opts[:header] || {}
if opts[:toggle_align] == :left
opts[:collapsed_content] ||= ''
opts[:collapsed_content] += navbar_toggle(id, opts[:toggle], 'pull-left navbar-link').html_safe
opts[:toggle] = :hide
end
wrap_with :nav, nav_opts do
[
navbar_header(id, header_opts.delete(:content), header_opts.reverse_merge(:toggle=>opts[:toggle])),
(content_tag(:div, opts[:collapsed_content].html_safe, :class=>'container-fluid') if opts[:collapsed_content]),
content_tag(:div, output(yield).html_safe, :class=>"collapse navbar-collapse", :id=>"navbar-collapse-#{id}"),
]
end
end
def navbar_header id, content='', opts={}
brand = if opts[:brand]
if opts[:brand].kind_of? String
"#{opts[:brand]}"
else
link = opts[:brand][:href] || '#'
"#{opts[:brand][:name]}"
end
end
wrap_with :div, :class=>'navbar-header' do
[
(navbar_toggle(id, opts[:toggle]) unless opts[:toggle] == :hide),
brand,
(content if content)
]
end
end
def navbar_toggle id, content=nil, css_class=''
content ||= %{
}
%{
}
end
def split_button button, args={}
items = yield
args[:situation] ||= 'primary'
wrap_with :div, :class=>'btn-group' do
[
button,
button_tag(:situation=>args[:situation], :class=>'dropdown-toggle', 'data-toggle'=>'dropdown', 'aria-haspopup'=>'true', 'aria-expanded'=>'false') do
%{
Toggle Dropdown
}
end,
dropdown_list(items, nil, args[:active_item])
]
end
end
def list_tag content_or_options = nil, options = {}, &block
options = content_or_options if block_given?
content = block_given? ? yield : content_or_options
content = [content] unless content.kind_of? Array
item_options = options.delete(:items) || {}
wrap_with :ul, options do
content.map do |item|
content_tag :li, item, item_options
end.join "\n"
end
end
end
# ~~~~~~~~~~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/06_bootstrap/set/all/bootstrap/helper.rb ~~~~~~~~~~~
end;end;end;end;end;