module TheAdmin::LayoutHelpers

Layout helpers @author Tim Mushen

Public Instance Methods

x_accordian_bottom() click to toggle source

Accordian (bottom) view helper @return [String] accordian card bottom html

# File lib/the-admin/layout.rb, line 69
def x_accordian_bottom
panel =<<EOS
          <!-- End Accordian -->
        </div>
    </div>
</div>
</div>
EOS
        return panel
end
x_accordian_top(tag: "p", id: "accordian", title: "") click to toggle source

Accordian (top) view helper

# File lib/the-admin/layout.rb, line 48
def x_accordian_top(tag: "p", id: "accordian", title: "")

panel =<<EOS
<div class="panel-group" id="accordion">
<div class="panel panel-default">
    <div class="panel-heading">
        <#{tag} class="">
            <a data-target="#accordian_#{id}" href="#" data-toggle="collapse">
               #{title} <b class="caret"></b>
            </a>
        </#{tag}>
    </div>
    <div id="accordian_#{id}" class="panel-collapse collapse">
        <div class="panel-body">
            <!-- Start Accordian -->
EOS
        return panel
end
x_card_bottom() click to toggle source

Card (bottom) view helper @return [String] rendered card bottom html

# File lib/the-admin/layout.rb, line 39
def x_card_bottom
panel =<<EOS
        </div>
</div>
EOS
        return panel
end
x_card_top(title: "",subtitle: "", card_class: "", header_css: "", buttons: "", modal_cog_url: "") click to toggle source

Card (top) view helper @param title [String] title of the card @param subtitle [String] subtitle of the card @param card_class [String] card html classes @param header_css [String] header css of the card @param buttons [String] card buttons @return [String] rendered card top html

# File lib/the-admin/layout.rb, line 13
def x_card_top(title: "",subtitle: "", card_class: "", header_css: "", buttons: "", modal_cog_url: "")

modal_cog_html = ""
unless modal_cog_url == ""
        modal_cog_html = "<a href='#{modal_cog_url}' class='btn btn-button btn-sm' data-toggle='modal'><i class='fa fa-cog'></i></a>"
end
if title != ""
title =<<EOS
<div class="header #{header_css}">
        <h4 class="title pull-left">#{title}</h4>
        <div class="pull-right title_right">#{buttons} #{modal_cog_html}</div>
        <div class="clearfix"></div>
        <p class="category">#{subtitle}</p>
</div>
EOS
end
panel =<<EOS
<div class="card #{card_class}">
  #{title}
        <div class="content">
EOS
        return panel
end
x_gravitar(email: "") click to toggle source

Gravitar view helper @param email [String] email of the user to show the garvitar @return [String] gravitar image uri

# File lib/the-admin/layout.rb, line 83
def x_gravitar(email: "")
        hash = ""
        
                if !email.nil?
                # get the email from URL-parameters or what have you and make lowercase
                email_address = email.downcase

                # create the md5 hash
                hash = Digest::MD5.hexdigest(email_address)
                end
        # compile URL which can be used in <img src="RIGHT_HERE"...
        image_src = "https://www.gravatar.com/avatar/#{hash}?d=mm"

        return image_src
end
x_number_widget(label: "", value: "", icon: "", info_modal: "", inversed: false) click to toggle source

Dashboard Number Widget @param label [String] number widget label @param value [String] number widget value @param icon [String] number widget icon @return [String] rendered number widget

# File lib/the-admin/layout.rb, line 146
def x_number_widget(label: "", value: "", icon: "", info_modal: "", inversed: false)

icon_html = ""
unless icon == ""
        icon_html = "<i class='fa #{icon}'></i> "
end

info_modal_html = ""
unless info_modal == ""
        info_modal_html = "<a href='#{info_modal}' class='' data-toggle='modal'><i class='fa fa-info-circle'></i></a>"
end 

if inversed == false
widget =<<EOS
<div class="x_number_widget_wrapper">
        <div class="x_number_widget_value">#{value}</div>
        <div class="x_number_widget_label">#{icon_html}#{label} #{info_modal_html}</div>
</div>
EOS
else
widget =<<EOS
<div class="x_number_widget_wrapper_inversed">
        <div class="x_number_widget_label">#{icon_html}#{label} #{info_modal_html}</div>
        <div class="x_number_widget_value">#{value}</div>
</div>
EOS

end

return widget

end
x_tabs(active: "", tabs: array) click to toggle source

Student Tabs Nav @param active [String] tab active @param tabs [Array] array of tabs @return [String] rendered tabs navigation

# File lib/the-admin/layout.rb, line 103
def x_tabs(active: "", tabs: array)

tab_builder = ""

tabs.each do |t|
s = ""
if t[:name] == active
        active_s = "active"
else
        active_s = ""
end

if t[:icon].present?
        icon = "<i class='fa #{t[:icon]}'></i> "
else
        icon = ""
end

s =<<EOS
<li class="#{active_s}">
        <a href="#{t[:url]}">#{icon}#{t[:name]}</a>
</li>
EOS
tab_builder  << s
end

tab_wrapper =<<EOS
<div class="tabs_wrapper">
<ul class="nav nav-tabs flex-wrap" role="tablist">
#{tab_builder}
</ul>
</div>
EOS

return tab_wrapper
end