Sha256: 0b7024106e35cc88845d88874e029417f743cd709248a045670ceece79e6a902

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 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.update({:detour => {:controller => @controller.controller_name, :action => @controller.action_name, :id => params[:id]}}), html_options
    link_to title, options.update({:detour => params.reject {|k, v| [:detour, :return_from_detour].include? k.to_sym}}), html_options
  end
  
  def image_detour_to(image_source, title, image_options, options )
    image_options ||= {:class => 'image-submit'}
    image_options.update :alt => title, :title => title
    detour_to image_tag(image_source, image_options), options
  end
  
  def back_or_link_to(title, options)
    if session[:detours]
      options = session[:detours].last.update({:return_from_detour => true})
puts "linked 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

2 entries across 2 versions & 1 rubygems

Version Path
backlog-0.2.0 app/helpers/application_helper.rb
backlog-0.2.1 app/helpers/application_helper.rb