Module: Faalis::Dashboard::Helpers::BoxHelpers

Included in:
Faalis::DashboardHelper
Defined in:
lib/faalis/dashboard/helpers/box_helpers.rb

Defined Under Namespace

Classes: Box, Tabs

Instance Method Summary collapse

Instance Method Details

#box(title = nil, **options) {|content| ... } ⇒ Object

Yields:

  • (content)


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/faalis/dashboard/helpers/box_helpers.rb', line 63

def box(title = nil, **options)
  content = Box.new

  yield content

  result = "<div class='box #{options[:box_class] || 'box-default'}'>" +
    "<div class='box-header with-border'>" +
    "<h3 class='box-title'>" +
    title +
    '</h3>'

  unless options[:show_tools].nil?
    result += "<div class='box-tools pull-right'>" +
      "<button class='btn btn-box-tool' data-widget='collapse'>" +
      "<i class='fa fa-minus'></i></button>" +
      "</div><!-- /.box-tools -->"
  end

  result += "</div><!-- /.box-header -->" +
    "<div class='box-body'>" +
    capture(&content.body_content) +
    "</div><!-- /.box-body -->"

  unless content.footer_content.nil?
    result += '<div class="box-footer">' +
      content.footer_content +
      "</div><!-- /.box-footer-->"
  end

  result += "</div><!-- /.box -->"

  result.html_safe
end

#tabbed_box(title = nil, **options) {|content| ... } ⇒ Object

Yields:

  • (content)


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/faalis/dashboard/helpers/box_helpers.rb', line 98

def tabbed_box(title = nil, **options)
  content = Tabs.new

  yield content

  result = "<div class='nav-tabs-custom'>" +
    "<ul class='nav nav-tabs pull-right'>"

  content.tabs.each do |tab|
    active = nil
    active = "class='active'" if tab.active?

    result += "<li #{active}><a href='#tab_#{tab.id}-#{tab.id}' data-toggle='tab'>" +
      "<i class='fa #{tab.title_icon}'></i> #{tab.title}</a></li>"
  end

  result += "<li class='pull-left header'><i class='fa #{options[:title_icon]}'></i>#{title}</li>" +
    "</ul>" +
    "<div class='tab-content'>"

  content.tabs.each do |tab|
    result += "<div class='tab-pane #{'active' if tab.active?}' id='tab_#{tab.id}-#{tab.id}'>" +
      capture(&tab.content) +
      "</div><!-- /.tab-pane -->"
  end

  result += "</div><!-- /.tab-content --></div>"
  result.html_safe
end