2011-10-30 23:02:41 +00:00
|
|
|
module Locomotive::BaseHelper
|
2010-07-23 20:09:54 +00:00
|
|
|
|
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-07-23 20:09:54 +00:00
|
|
|
|
2011-11-04 15:55:51 +00:00
|
|
|
def admin_content_menu_item(name, url, options = {}, &block) # TODO: rename method name (remove admin)
|
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-07-23 20:09:54 +00:00
|
|
|
|
2011-03-03 22:51:07 +00:00
|
|
|
css = "#{'on' if name == sections(:sub)} #{options[:css]}"
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-10-30 23:02:41 +00:00
|
|
|
label_link = default_options[:i18n] ? t("locomotive.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')
|
2011-03-03 22:51:07 +00:00
|
|
|
link = link_to(content_tag(:span, preserve(label_link) + content_tag(:em)) + content_tag(:em), url, :class => css)
|
|
|
|
content_tag(:li, link + popup, :class => 'hoverable')
|
2010-05-26 00:41:10 +00:00
|
|
|
else
|
2011-03-03 22:51:07 +00:00
|
|
|
content_tag(:li, link_to(content_tag(:span, label_link), url, :class => css))
|
2010-05-26 00:41:10 +00:00
|
|
|
end
|
2010-05-02 23:33:17 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-11-08 14:34:25 +00:00
|
|
|
def local_action_button(text, url, options = {})
|
|
|
|
text = text.is_a?(Symbol) ? t(".#{text}") : text
|
|
|
|
link_to(url, options) do
|
|
|
|
content_tag(:em, escape_once(' ')) + text
|
|
|
|
end
|
|
|
|
end
|
2011-07-25 21:07:32 +00:00
|
|
|
|
2011-11-03 13:01:08 +00:00
|
|
|
# def admin_item_toggler(object)
|
|
|
|
# image_tag("admin/list/icons/node_#{(cookies["folder-#{object._id}"] != 'none') ? 'open' : 'closed'}.png", :class => 'toggler')
|
|
|
|
# end
|
2011-07-05 19:03:10 +00:00
|
|
|
|
2011-03-04 23:29:40 +00:00
|
|
|
def collection_to_js(collection, options = {})
|
|
|
|
js = collection.collect { |object| object.to_json }
|
|
|
|
|
2011-07-13 22:08:43 +00:00
|
|
|
options_to_js = ActiveSupport::JSON.encode(options).gsub(/^\{/, '').gsub(/\}$/, '')
|
2011-03-04 23:29:40 +00:00
|
|
|
|
|
|
|
"new Object({ \"collection\": [#{js.join(', ')}], #{options_to_js} })"
|
|
|
|
end
|
|
|
|
|
2010-06-03 15:32:40 +00:00
|
|
|
def growl_message
|
|
|
|
if not flash.empty?
|
2011-11-08 00:11:15 +00:00
|
|
|
first_key = flash.keys.first
|
2010-06-03 15:32:40 +00:00
|
|
|
%{
|
|
|
|
$(document).ready(function() {
|
2011-11-08 00:11:15 +00:00
|
|
|
$.growl("#{first_key}", "#{flash[first_key]}");
|
2010-06-03 15:32:40 +00:00
|
|
|
});
|
|
|
|
}.to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-11-04 15:55:51 +00:00
|
|
|
def flash_message
|
|
|
|
if not flash.empty?
|
|
|
|
first_key = flash.keys.first
|
|
|
|
content_tag :div, flash[first_key],
|
|
|
|
:id => "flash-#{first_key}",
|
|
|
|
:class => 'application-message'
|
|
|
|
else
|
|
|
|
''
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-06-03 15:32:40 +00:00
|
|
|
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-23 20:09:54 +00:00
|
|
|
|
2011-11-03 13:01:08 +00:00
|
|
|
# sites
|
|
|
|
|
|
|
|
def application_domain
|
|
|
|
domain = Locomotive.config.domain
|
|
|
|
domain += ":#{request.port}" if request.port != 80
|
|
|
|
domain
|
|
|
|
end
|
|
|
|
|
|
|
|
def manage_subdomain_or_domains?
|
|
|
|
Locomotive.config.manage_subdomain? || Locomotive.config.manage_domains?
|
|
|
|
end
|
|
|
|
|
|
|
|
def manage_subdomain?
|
|
|
|
Locomotive.config.manage_subdomain?
|
|
|
|
end
|
|
|
|
|
|
|
|
def manage_domains?
|
|
|
|
Locomotive.config.manage_domains?
|
|
|
|
end
|
|
|
|
|
|
|
|
def multi_sites?
|
|
|
|
Locomotive.config.multi_sites?
|
|
|
|
end
|
|
|
|
|
2010-07-23 20:09:54 +00:00
|
|
|
end
|