Module: AwsImageshack::ViewHelpersMethods

Includes:
ActionView::Helpers::FormTagHelper
Defined in:
lib/aws_imageshack.rb

Instance Method Summary collapse

Instance Method Details

#aws_image_shack_form(image = nil) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/aws_imageshack.rb', line 76

def aws_image_shack_form(image = nil)
  style_css = (@aws_options[:style_css] ? @aws_options[:style_css] : "height: 22px; border: 1px solid rgb(199, 199, 199); margin-bottom: 1px;") if !@aws_options[:class_css]
  class_css = @aws_options[:class_css] ? @aws_options[:class_css] : ""
  size = @aws_options[:size] ? @aws_options[:size] : 58
  
  image_html = ''      
  image_html = image_tag(image, :style => "float: #{@aws_options[:position]};width: #{@aws_options[:width]}px; height: #{@aws_options[:height]}px") if image

  content = ''
  content += form_tag({:controller=> params[:controller], :action => params[:action]} , :id => 'aws_upload_form', :multipart => true, :target => 'aws_hidden_iframe', :style => 'text-align:center')
  content += image_html+'</br>' if @aws_options[:position].downcase=='top'
  content += file_field('aws', 'fileupload', :size => size, :class => class_css, :style => 'style_css', :onchange => "submit();")
  content += '</br>'+image_html if @aws_options[:position].downcase!='top'
  content += "<iframe id=\"aws_hidden_iframe\" name=\"aws_hidden_iframe\" style=\"display: none\"></iframe>"
  content += "</form>"
  return content
end