Module: ApplicationHelper
Constant Summary
Localization::LOCALIZED_STRINGS
Instance Method Summary
collapse
-
#back_or_link_to(title, options) ⇒ Object
-
#detour_to(title, options, html_options = nil) ⇒ Object
-
#h(object) ⇒ Object
-
#image_button_to(image_source, title, options) ⇒ Object
-
#image_detour_to(image_source, title, url_options, image_options = nil, post = false) ⇒ Object
-
#image_link_to(image_source, title, url_options, image_options = nil, post = false) ⇒ Object
-
#t(time_as_float) ⇒ Object
-
#with_detour(options) ⇒ Object
#l, load_localized_strings, #valid_language?
Instance Method Details
#back_or_link_to(title, options) ⇒ Object
41
42
43
44
45
46
47
|
# File 'app/helpers/application_helper.rb', line 41
def back_or_link_to(title, options)
if session[:detours]
options = {:return_from_detour => true}.update(session[:detours].last)
logger.debug "linked return from detour: #{options}"
end
link_to title, options
end
|
#detour_to(title, options, html_options = nil) ⇒ Object
13
14
15
|
# File 'app/helpers/application_helper.rb', line 13
def detour_to(title, options, html_options = nil)
link_to title, with_detour(options), html_options
end
|
#h(object) ⇒ Object
53
54
55
56
57
58
59
|
# File 'app/helpers/application_helper.rb', line 53
def h(object)
if object.is_a? Time
object.strftime '%Y-%m-%d %H:%M:%S'
else
super object
end
end
|
6
7
8
9
10
11
|
# File 'app/helpers/application_helper.rb', line 6
def image_button_to(image_source, title, options)
html = ''
html += image_submit_tag image_source, :class => 'image-submit', :alt => title, :title => title,
:id => "#{title}_#{options[:id]}", :name => title,
:onclick => "form.action='#{url_for(options)}'"
end
|
#image_detour_to(image_source, title, url_options, image_options = nil, post = false) ⇒ Object
29
30
31
32
33
|
# File 'app/helpers/application_helper.rb', line 29
def image_detour_to(image_source, title, url_options, image_options = nil, post = false)
image_options ||= {:class => 'image-submit'}
image_options.update :alt => title, :title => title
detour_to image_tag(image_source, image_options), url_options, post ? {:method => :post} : nil
end
|
#image_link_to(image_source, title, url_options, image_options = nil, post = false) ⇒ Object
35
36
37
38
39
|
# File 'app/helpers/application_helper.rb', line 35
def image_link_to(image_source, title, url_options, image_options = nil, post = false)
image_options ||= {:class => 'image-submit'}
image_options.update :alt => title, :title => title
link_to image_tag(image_source, image_options), url_options, post ? {:method => :post} : nil
end
|
#t(time_as_float) ⇒ Object
49
50
51
|
# File 'app/helpers/application_helper.rb', line 49
def t(time_as_float)
"#{time_as_float.to_i}:#{'%02d' % (time_as_float.frac * 60).to_i}"
end
|
#with_detour(options) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
|
# File 'app/helpers/application_helper.rb', line 17
def with_detour(options)
detour_options = {:detour => params.reject {|k, v| [:detour, :return_from_detour].include? k.to_sym}}.update(options)
if options[:layout]== false
if params[:action] !~ /_no_layout$/
detour_options[:detour].update({:action => params[:action] + '_no_layout'})
end
elsif params[:action] =~ /_no_layout$/
detour_options[:detour].update({:action => params[:action][0..-11]})
end
detour_options
end
|