Module: Fg::H5Uploader

Included in:
ActionView::Helpers::FormBuilder, ActionView::Helpers::FormTagHelper
Defined in:
lib/h5_uploader.rb,
lib/h5_uploader/railtie.rb

Defined Under Namespace

Classes: Railtie

Instance Method Summary collapse

Instance Method Details

#parse_uploader_options(options, name) ⇒ Object



26
27
28
29
30
31
# File 'lib/h5_uploader.rb', line 26

def parse_uploader_options options,name
  options[:id] = uploader_field_id(name)
  options[:action] ||= '/public/system/'
  options[:allowedExtensions] ||= []
  options[:params] ||= {}
end

#uploader_field_id(label) ⇒ Object



22
23
24
# File 'lib/h5_uploader.rb', line 22

def uploader_field_id(label)
  "field_uploader_#{label}"
end

#uploader_js_content(name, options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/h5_uploader.rb', line 8

def uploader_js_content name,options
  jss = "var uploader_#{options[:id]} = new qq.FileUploader({"
  jss = jss <<  "element: document.getElementById('#{options[:id]}'),"
  jss = jss << "allowedExtensions: #{options[:allowedExtensions].to_s}"
  jss = jss << ",params: #{options[:params].to_json}" unless options[:params].nil?  

  options.each do |key,value| next if [:id,:allowedExtensions,:params].include?(key)
    jss = jss << ",#{key}: '#{value}'"
  end

  jss = jss << "});"            

end