Module: Card::Set::All::Bootstrap::Helper::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
card/tmpsets/set/mod021-card-mod-bootstrap/all/bootstrap/helper.rb,
card/tmpsets/set/mod022-card-mod-bootstrap/all/bootstrap/helper.rb

Instance Method Summary collapse

Instance Method Details

#add_list_group_classes(options) ⇒ Object



27
28
29
30
31
# File 'card/tmpsets/set/mod022-card-mod-bootstrap/all/bootstrap/helper.rb', line 27

def add_list_group_classes options
  add_class options, "list-group"
  options[:items] ||= {}
  add_class options[:items], "list-group-item"
end

#badge_tag(content, options = {}) ⇒ Object



44
45
46
47
# File 'card/tmpsets/set/mod021-card-mod-bootstrap/all/bootstrap/helper.rb', line 44

def badge_tag content, options={}
  add_class options, "badge"
  wrap_with :span, content, options
end


9
10
11
12
13
# File 'card/tmpsets/set/mod021-card-mod-bootstrap/all/bootstrap/helper.rb', line 9

def button_link link_text, opts={}
  btn_type = opts.delete(:btn_type) || "primary"
  opts[:class] = [opts[:class], "btn btn-#{btn_type}"].compact.join " "
  smart_link_to link_text, opts
end

#list_group(content_or_options = nil, options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'card/tmpsets/set/mod021-card-mod-bootstrap/all/bootstrap/helper.rb', line 19

def list_group content_or_options=nil, options={}
  options = content_or_options if block_given?
  content = block_given? ? yield : content_or_options
  content = Array(content).map(&:to_s)
  add_class options, "list-group"
  options[:items] ||= {}
  add_class options[:items], "list-group-item"
  list_tag content, options
end

#list_items(content, default_item_options) ⇒ Object



41
42
43
44
45
46
47
# File 'card/tmpsets/set/mod022-card-mod-bootstrap/all/bootstrap/helper.rb', line 41

def list_items content, default_item_options
  content.map do |item|
    i_content, i_opts = item
    i_opts ||= default_item_options
    wrap_with :li, i_content, i_opts
  end
end

#list_tag(content_or_options = nil, options = {}, &block) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'card/tmpsets/set/mod021-card-mod-bootstrap/all/bootstrap/helper.rb', line 29

def list_tag content_or_options=nil, options={}
  options = content_or_options if block_given?
  content = block_given? ? yield : content_or_options
  content = Array(content)
  default_item_options = options.delete(:items) || {}
  tag = options[:ordered] ? :ol : :ul
  wrap_with tag, options do
    content.map do |item|
      i_content, i_opts = item
      i_opts ||= default_item_options
      wrap_with :li, i_content, i_opts
    end
  end
end

#list_tag_content_and_options(content_or_options, options) ⇒ Object



49
50
51
52
53
# File 'card/tmpsets/set/mod022-card-mod-bootstrap/all/bootstrap/helper.rb', line 49

def list_tag_content_and_options content_or_options, options
  options = content_or_options if block_given?
  content = block_given? ? yield : content_or_options
  [Array(content), options]
end


49
50
51
# File 'card/tmpsets/set/mod021-card-mod-bootstrap/all/bootstrap/helper.rb', line 49

def popover_link text, title=nil, link_text=fa_icon("question-circle"), opts={}
  link_to link_text, popover_opts(text, title, opts)
end

#popover_opts(text, title, opts) ⇒ Object



53
54
55
56
57
58
59
# File 'card/tmpsets/set/mod021-card-mod-bootstrap/all/bootstrap/helper.rb', line 53

def popover_opts text, title, opts
  add_class opts, "pl-1 text-muted-link"
  opts.merge! path: "#", "data-toggle": "popover",
              "data-trigger": :focus, "data-content": text
  opts["data-title"] = title if title
  opts
end

#separatorObject



15
16
17
# File 'card/tmpsets/set/mod021-card-mod-bootstrap/all/bootstrap/helper.rb', line 15

def separator
  '<li role="separator" class="divider"></li>'
end