Module: ApplicationHelper
- Includes:
- UrlForFix, UserSystem
- Included in:
- ApplicationController
- Defined in:
- app/helpers/application_helper.rb
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, link_options, image_options = nil, post = false) ⇒ Object
- #insert(page, content, selector, position = :top) ⇒ Object
- #l(value, *args) ⇒ Object
- #record(page, script) ⇒ Object
- #resolution_image(resolution) ⇒ Object
- #t(time_as_float, *args) ⇒ Object
- #update_task(page) ⇒ Object
- #with_detour(options) ⇒ Object
Instance Method Details
#back_or_link_to(title, options = nil) ⇒ Object
51 52 53 54 55 56 57 |
# File 'app/helpers/application_helper.rb', line 51 def back_or_link_to(title, = nil) if session[:detours] = {:return_from_detour => true}.update(session[:detours].last) logger.debug "linked return from detour: #{}" end link_to(title, ) if end |
#detour? ⇒ Boolean
47 48 49 |
# File 'app/helpers/application_helper.rb', line 47 def detour? not session[:detours].nil? end |
#detour_to(title, options, html_options = nil) ⇒ Object
13 14 15 |
# File 'app/helpers/application_helper.rb', line 13 def detour_to(title, , = nil) link_to title, with_detour(), end |
#display_notice(page) ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'app/helpers/application_helper.rb', line 94 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
70 71 72 73 74 75 76 |
# File 'app/helpers/application_helper.rb', line 70 def h(object) if object.is_a? Time object.strftime '%Y-%m-%d %H:%M:%S' else super object end end |
#image_button_to(image_source, title, options, html_options = {}) ⇒ Object
7 8 9 10 11 |
# File 'app/helpers/application_helper.rb', line 7 def (image_source, title, , = {}) image_submit_tag image_source, {:class => 'image-submit', :alt => title, :title => title, :id => "#{title}_#{[:id]}", :name => title, :onclick => "form.action='#{url_for()}'"}.update() 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, , = nil, post = false) ||= {:class => 'image-submit'} .update :alt => title, :title => title detour_to image_tag(image_source, ), , 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, , = nil, post = false) ||= {:class => 'image-submit'} .update :alt => title, :title => title link_to image_tag(image_source, ), , post ? {:method => :post} : nil end |
#image_link_to_remote(image_source, title, link_options, image_options = nil, post = false) ⇒ Object
41 42 43 44 45 |
# File 'app/helpers/application_helper.rb', line 41 def image_link_to_remote(image_source, title, , = nil, post = false) ||= {:class => 'image-submit'} .update :alt => title, :title => title link_to_remote image_tag(image_source, ), , post ? {:method => :post} : nil end |
#insert(page, content, selector, position = :top) ⇒ Object
109 110 111 112 |
# File 'app/helpers/application_helper.rb', line 109 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 |
#l(value, *args) ⇒ Object
59 60 61 |
# File 'app/helpers/application_helper.rb', line 59 def l(value, *args) return t(value, *args) if value.is_a?(Symbol) end |
#record(page, script) ⇒ Object
105 106 107 |
# File 'app/helpers/application_helper.rb', line 105 def record(page, script) page.call("#{script};//") end |
#resolution_image(resolution) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/helpers/application_helper.rb', line 78 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(resolution.downcase) end |
#t(time_as_float, *args) ⇒ Object
63 64 65 66 67 68 |
# File 'app/helpers/application_helper.rb', line 63 def t(time_as_float, *args) return super if time_as_float.is_a?(Symbol) 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
114 115 116 |
# File 'app/helpers/application_helper.rb', line 114 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
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/application_helper.rb', line 17 def with_detour() = {:detour => params.reject {|k, v| [:detour, :return_from_detour].include? k.to_sym}}.update() if [:layout]== false if params[:action] !~ /_no_layout$/ [:detour].update({:action => params[:action] + '_no_layout'}) end elsif params[:action] =~ /_no_layout$/ [:detour].update({:action => params[:action][0..-11]}) end end |