Module: Foundationize::ViewHelpers

Defined in:
lib/foundationize/foundationize_viewhelpers.rb

Instance Method Summary collapse

Instance Method Details



62
63
64
65
66
67
68
69
70
# File 'lib/foundationize/foundationize_viewhelpers.rb', line 62

def dropdown_menu(url, text, options={}, &block)
  html = ""
   :li, class: options[:active] ? "has-dropdown active" : "has-dropdown" do
    html += link_to(url,text)
    content = capture(&block)
    html +=  :ul, content, class: "dropdown"
    raw html
  end
end

#foundationize_flashObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/foundationize/foundationize_viewhelpers.rb', line 5

def foundationize_flash
  flash_messages = []
  flash.each do |type, message|
    
    next if message.blank?

    type = :alert       if type == :error
    type = :success     if type == :success
    type = :secondary   if type == :notice

    Array(message).each do |msg|
      flash = raw("<div data-alert class=\"alert-box #{type}\">#{msg.html_safe}<a href=\"#\" class=\"close\">&times;</a></div>");
      flash_messages << flash if msg
    end
  end
  flash_messages.join("\n").html_safe
end

#left_section(&block) ⇒ Object



37
38
39
# File 'lib/foundationize/foundationize_viewhelpers.rb', line 37

def left_section(&block)
  top_bar_section("left", &block)
end


72
73
74
# File 'lib/foundationize/foundationize_viewhelpers.rb', line 72

def menu_divider (hide = false)
   :li, nil, class: hide ? "divider hide-for-small" : "divider"
end


51
52
53
54
55
56
# File 'lib/foundationize/foundationize_viewhelpers.rb', line 51

def menu_item(url, text, options={})
  html = ""
  html += menu_divider if options[:divider]
  html +=  :li, link_to(url,text), class: options[:active] ? "active" : ""
  raw html
end


58
59
60
# File 'lib/foundationize/foundationize_viewhelpers.rb', line 58

def menu_label(text)
   :li, (:label,text)
end

#right_section(&block) ⇒ Object



41
42
43
# File 'lib/foundationize/foundationize_viewhelpers.rb', line 41

def right_section(&block)
  top_bar_section("right", &block)
end

#top_bar(options = {}, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/foundationize/foundationize_viewhelpers.rb', line 23

def top_bar(options={}, &block)
   :nav, class: "top-bar" do
    content = ""
    content +=  :li, (:h1, link_to(options[:title],"#")), class: "name"
    content +=  :li, link_to(options[:text], "#"), class: options[:icon] ? "toggle-topbar menu-icon" : "toggle-topbar" 
    
    html =  :ul, raw(content), class: "title-area"

    content = capture(&block)
    html += :section, content, class: "top-bar-section"
    raw html
  end
end

#top_bar_section(direction, &block) ⇒ Object



45
46
47
48
49
# File 'lib/foundationize/foundationize_viewhelpers.rb', line 45

def top_bar_section(direction, &block)
   :ul, class: direction do
    yield
  end
end