Sha256: 05cbb66f794f99791dbbccfbedc9db6b784ff2988a0a2ec0775d4d0eb2af63f1

Contents?: true

Size: 1.64 KB

Versions: 6

Compression:

Stored size: 1.64 KB

Contents

# Methods added to this helper will be available to all templates in the application.
require 'localization'

module ApplicationHelper
  include Localization
  
  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

  def detour_to(title, options, html_options = nil)
    link_to title, options_for_detour(options), html_options
  end
  
  def options_for_detour(options)
    detour_options = {:detour => params.reject {|k, v| [:detour, :return_from_detour].include? k.to_sym}}.update(options)
    detour_options[:detour].update({:action => params[:action] + '_no_layout'}) if (not options[:layout].nil?) && params[:action] !~ /_no_layout$/
    detour_options
  end
  
  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, :method => post ? :post : :get
  end
  
  def back_or_link_to(title, options)
    if session[:detours]
      options = {:return_from_detour => true}.update(session[:detours].last)
puts "linked return from detour: #{options}"
    end
    link_to title, options
  end

  def t(time_as_float)
    "#{time_as_float.to_i}:#{'%02d' % (time_as_float.frac * 60).to_i}" 
  end
  
  def h(object)
    if object.is_a? Time
      object.strftime '%Y-%m-%d %H:%M:%S'
    else
      super object
    end
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
backlog-0.4.0 app/helpers/application_helper.rb
backlog-0.5.0 app/helpers/application_helper.rb
backlog-0.5.1 app/helpers/application_helper.rb
backlog-0.5.2 app/helpers/application_helper.rb
backlog-0.5.3 app/helpers/application_helper.rb
backlog-0.5.4 app/helpers/application_helper.rb