Module: BootstrapHelper

Defined in:
lib/trap/helpers/bootstrap_helper.rb

Instance Method Summary collapse

Instance Method Details



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/trap/helpers/bootstrap_helper.rb', line 11

def dropdown(text, icon = nil, &block)
   :li, class: :drowdown do
    concat(link_to('#', class: 'dropdown-toggle', data: { toggle: :dropdown }) do
  if icon
 concat icon_element icon
 concat ' '
  end
  concat text
  unless icon
 concat ' '
 concat  :span, '', class: :caret
  end
    end)
    concat((:ul, class: 'dropdown-menu') do
  yield block
    end)
  end
end

#icon_element(name) ⇒ Object



30
31
32
# File 'lib/trap/helpers/bootstrap_helper.rb', line 30

def icon_element(name)
   :i, '', class: "fa fa-#{name}"
end


2
3
4
5
6
7
8
9
# File 'lib/trap/helpers/bootstrap_helper.rb', line 2

def menu_item(name = nil, path = '#', *args, &block)
  path = name || path if block_given?
  options = args.extract_options!
   :li, class: is_active?(path, options) do
    name, path = path, options if block_given?
    link_to name, path, options, &block
  end
end

#model_menu_item(model:, route:, icon: nil, number: nil) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/trap/helpers/bootstrap_helper.rb', line 34

def model_menu_item(model:, route:, icon: nil, number: nil)
  title = model.is_a?(Class) ? model.model_name.human.pluralize(:ru) : model
  if icon
    menu_item route do
      concat icon_element icon
      concat ' '
      concat title
      if number && number != 0
        concat ' '
        concat((:span, number.to_s, class: 'badge danger'))
      end
    end
  else
    menu_item title, route
  end
end