2010-04-24 00:32:36 +00:00
|
|
|
module Admin::BaseHelper
|
2010-06-03 15:32:40 +00:00
|
|
|
|
|
|
|
def title(title = nil)
|
|
|
|
if title.nil?
|
|
|
|
@content_for_title
|
|
|
|
else
|
|
|
|
@content_for_title = title
|
|
|
|
''
|
|
|
|
end
|
2010-06-12 01:13:58 +00:00
|
|
|
end
|
2010-04-25 00:33:38 +00:00
|
|
|
|
2010-04-24 00:32:36 +00:00
|
|
|
def admin_menu_item(name, url)
|
|
|
|
label = content_tag(:em) + escape_once(' ') + t("admin.shared.menu.#{name}")
|
|
|
|
content_tag(:li, link_to(label, url), :class => name.dasherize)
|
|
|
|
end
|
|
|
|
|
2010-04-25 00:33:38 +00:00
|
|
|
def admin_button_tag(text, url, options = {})
|
2010-05-02 23:33:17 +00:00
|
|
|
text = text.is_a?(Symbol) ? t(".#{text}") : text
|
2010-04-25 00:33:38 +00:00
|
|
|
link_to(url, options) do
|
2010-07-13 20:01:40 +00:00
|
|
|
content_tag(:em, escape_once(' ')) + text
|
2010-04-25 00:33:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-05-02 23:33:17 +00:00
|
|
|
def admin_submenu_item(name, url, options = {}, &block)
|
2010-05-24 00:18:23 +00:00
|
|
|
default_options = { :i18n => true, :css => name.dasherize.downcase }
|
2010-05-02 23:33:17 +00:00
|
|
|
default_options.merge!(options)
|
|
|
|
|
2010-05-24 00:18:23 +00:00
|
|
|
css = "#{'on' if name == sections(:sub)} #{'links' if block_given?} #{options[:css]}"
|
2010-05-02 23:33:17 +00:00
|
|
|
|
|
|
|
label_link = default_options[:i18n] ? t("admin.shared.menu.#{name}") : name
|
2010-05-26 00:41:10 +00:00
|
|
|
if block_given?
|
|
|
|
popup = content_tag(:div, capture(&block), :class => 'popup', :style => 'display: none')
|
|
|
|
link = link_to(content_tag(:span, preserve(label_link + content_tag(:em))), url)
|
|
|
|
content_tag(:li, link + popup, :class => css)
|
|
|
|
else
|
|
|
|
content_tag(:li, link_to(content_tag(:span, label_link), url), :class => css)
|
|
|
|
end
|
2010-05-02 23:33:17 +00:00
|
|
|
end
|
|
|
|
|
2010-06-03 15:32:40 +00:00
|
|
|
def growl_message
|
|
|
|
if not flash.empty?
|
|
|
|
%{
|
|
|
|
$(document).ready(function() {
|
|
|
|
$.growl("#{flash.keys.first}", "#{flash.values.first}");
|
|
|
|
});
|
|
|
|
}.to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def nocoffee_tag
|
2010-07-06 15:00:02 +00:00
|
|
|
link_to 'noCoffee', 'http://www.nocoffee.fr', :id => 'nocoffee'
|
2010-06-03 15:32:40 +00:00
|
|
|
end
|
2010-07-13 00:46:17 +00:00
|
|
|
|
2010-04-24 00:32:36 +00:00
|
|
|
end
|