module Sunrise::Views::Helper

Public Instance Methods

encode_email(email_address, _options = {}) click to toggle source
# File lib/sunrise/views/helper.rb, line 97
def encode_email(email_address, _options = {})
  email_address = email_address.to_s
  string = ''

  "document.write('#{email_address}');".each_byte do |c|
    string << format('%%%x', c)
  end

  "<script type=\"#{Mime::JS}\">eval(decodeURIComponent('#{string}'))</script>"
end
javascript(*args) click to toggle source
# File lib/sunrise/views/helper.rb, line 6
def javascript(*args)
  content_for(:head) { javascript_include_tag(*args) }
end
stylesheet(*args) click to toggle source
# File lib/sunrise/views/helper.rb, line 10
def stylesheet(*args)
  content_for(:head) { stylesheet_link_tag(*args) }
end
swf_object(swf, id, width, height, flash_version, options = {}) click to toggle source

swf_object

# File lib/sunrise/views/helper.rb, line 65
def swf_object(swf, id, width, height, flash_version, options = {})
  options.symbolize_keys!

  params = options.delete(:params) || {}
  attributes = options.delete(:attributes) || {}
  flashvars = options.delete(:flashvars) || {}

  attributes[:classid] ||= 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
  attributes[:id] ||= id
  attributes[:name] ||= id

  output_buffer = ActiveSupport::SafeBuffer.new

  if options[:create_div]
    output_buffer << content_tag(:div,
                                 "This website requires <a href='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&promoid=BIOW' target='_blank'>Flash player</a> #{flash_version} or higher.",
                                 id: id)
  end

  js = []

  js << "var params = {#{params.to_a.map { |item| "#{item[0]}:'#{item[1]}'" }.join(',')}};"
  js << "var attributes = {#{attributes.to_a.map { |item| "#{item[0]}:'#{item[1]}'" }.join(',')}};"
  js << "var flashvars = {#{flashvars.to_a.map { |item| "#{item[0]}:'#{item[1]}'" }.join(',')}};"

  js << "swfobject.embedSWF('#{swf}', '#{id}', '#{width}', '#{height}', '#{flash_version}', '/swf/expressInstall.swf', flashvars, params, attributes);"

  output_buffer << javascript_tag(js.join)

  output_buffer
end