Module: ToolbarHelper

Defined in:
app/helpers/toolbar_helper.rb

Instance Method Summary collapse

Instance Method Details

#f7_toolbar_item(title_or_options, options = nil, &block) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/toolbar_helper.rb', line 3

def f7_toolbar_item(title_or_options, options=nil, &block)
  output = []
  if title_or_options.class == Hash
    options = title_or_options if options.nil?
    title = options[:title]
  else
    title = title_or_options
  end
  title ||= capture(&block) if block_given?

  href = options[:href] || '#'

  css_classes = []
  css_classes << (@is_tabbar ? 'tab-link' : 'link')
  css_classes += [options[:class]] if options[:class]

  if @is_tabbar
    if options.has_key? :icon
       :a, :href => href, :class => css_classes do
        if options[:badge]
          if options[:badge].kind_of? Hash
            badge_data = options[:badge]
            badge_classes = [:badge]
            badge_classes << badge_data[:class]
            badge =  :span, badge_data[:text], :class => badge_classes
          else
            badge =  :span, options[:badge], :class => [:badge, 'badge-red']
          end
          link = link_icon_i(options[:icon], badge)
        else
          link = link_icon_i(options[:icon])              
        end
        output << link
        output << (:span, title, :class => 'tabbar-label') if @has_labels && !title.blank?
        output.join("\n").html_safe
      end
    else
       :a, title, :href => href, :class => css_classes
    end
  else
     :a, title, :href => href, :class => css_classes
  end
end