Module: ApplicationHelper
Constant Summary
Localization::LOCALIZED_STRINGS
Instance Method Summary
collapse
-
#back_or_link_to(title, options = nil) ⇒ Object
-
#detour? ⇒ Boolean
-
#detour_to(title, options, html_options = nil) ⇒ Object
-
#display_notice(page) ⇒ Object
-
#h(object) ⇒ Object
-
#image_button_to(image_source, title, options, html_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
-
#image_link_to_remote(image_source, title, url_options, image_options = nil, post = false) ⇒ Object
-
#insert(page, content, selector, position = :top) ⇒ Object
-
#record(page, script) ⇒ Object
-
#resolution_image(resolution) ⇒ Object
-
#t(time_as_float) ⇒ Object
-
#update_task(page) ⇒ Object
-
#with_detour(options) ⇒ Object
#l, load_localized_strings, #valid_language?
Instance Method Details
#back_or_link_to(title, options = nil) ⇒ Object
53
54
55
56
57
58
59
|
# File 'app/helpers/application_helper.rb', line 53
def back_or_link_to(title, options = nil)
if session[:detours]
options = {:return_from_detour => true}.update(session[:detours].last)
logger.debug "linked return from detour: #{options}"
end
link_to(title, options) if options
end
|
#detour? ⇒ Boolean
49
50
51
|
# File 'app/helpers/application_helper.rb', line 49
def detour?
not session[:detours].nil?
end
|
#detour_to(title, options, html_options = nil) ⇒ Object
15
16
17
|
# File 'app/helpers/application_helper.rb', line 15
def detour_to(title, options, html_options = nil)
link_to title, with_detour(options), html_options
end
|
#display_notice(page) ⇒ Object
91
92
93
94
95
96
97
98
99
100
|
# File 'app/helpers/application_helper.rb', line 91
def display_notice(page)
if flash[:notice]
page.replace_html :notice, flash[:notice]
page.visual_effect(:appear, :notice)
page.visual_effect(:highlight, :notice)
flash.discard
else
page.visual_effect(:fade, :notice)
end
end
|
#h(object) ⇒ Object
67
68
69
70
71
72
73
|
# File 'app/helpers/application_helper.rb', line 67
def h(object)
if object.is_a? Time
object.strftime '%Y-%m-%d %H:%M:%S'
else
super object
end
end
|
9
10
11
12
13
|
# File 'app/helpers/application_helper.rb', line 9
def image_button_to(image_source, title, options, html_options = {})
image_submit_tag image_source, {:class => 'image-submit', :alt => title, :title => title,
:id => "#{title}_#{options[:id]}", :name => title,
:onclick => "form.action='#{url_for(options)}'"}.update(html_options)
end
|
#image_detour_to(image_source, title, url_options, image_options = nil, post = false) ⇒ Object
31
32
33
34
35
|
# File 'app/helpers/application_helper.rb', line 31
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
37
38
39
40
41
|
# File 'app/helpers/application_helper.rb', line 37
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
|
#image_link_to_remote(image_source, title, url_options, image_options = nil, post = false) ⇒ Object
43
44
45
46
47
|
# File 'app/helpers/application_helper.rb', line 43
def image_link_to_remote(image_source, title, url_options, image_options = nil, post = false)
image_options ||= {:class => 'image-submit'}
image_options.update :alt => title, :title => title
link_to_remote image_tag(image_source, image_options), {:url => url_options}, post ? {:method => :post} : nil
end
|
#insert(page, content, selector, position = :top) ⇒ Object
106
107
108
109
|
# File 'app/helpers/application_helper.rb', line 106
def insert(page, content, selector, position = :top)
escaped_content = content.gsub("\n", '').gsub("'", "\\\\'")
record(page, "new Insertion.#{position.to_s.capitalize}($$('#{selector}').first(), '#{escaped_content}')")
end
|
#record(page, script) ⇒ Object
102
103
104
|
# File 'app/helpers/application_helper.rb', line 102
def record(page, script)
page.call("#{script};//")
end
|
#resolution_image(resolution) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'app/helpers/application_helper.rb', line 75
def resolution_image(resolution)
image_file = case resolution
when Task::COMPLETED
'checkmark.png'
when Task::POSTPONED
'arrow_right.png'
when Task::MOVED
'arrow_right.png'
when Task::ABORTED
'ernes_stop.png'
else
raise "Unknown resolution " + resolution
end
image_tag image_file, :title => l(@task.resolution.downcase)
end
|
#t(time_as_float) ⇒ Object
61
62
63
64
65
|
# File 'app/helpers/application_helper.rb', line 61
def t(time_as_float)
return '' unless time_as_float
time_as_float = BigDecimal(time_as_float.to_s) unless time_as_float.is_a? BigDecimal
"#{time_as_float.to_i}:#{'%02d' % (time_as_float.frac * 60).round}"
end
|
#update_task(page) ⇒ Object
111
112
113
|
# File 'app/helpers/application_helper.rb', line 111
def update_task(page)
page["task_#{@task.id}"].replace render(:partial => "/tasks/task", :locals => { :task => @task, :i => 1, :active => true, :highlight_task => false, :update => :spotlight, :hidden => false })
end
|
#with_detour(options) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'app/helpers/application_helper.rb', line 19
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
|