h5_uploader 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,26 +5,47 @@ module Fg
5
5
 
6
6
  module H5Uploader
7
7
 
8
- class ActionView::Helpers::FormBuilder
8
+ def uploader_js_content name,options
9
+ jss = "var uploader = new qq.FileUploader({"
10
+ jss = jss << "element: document.getElementById('#{options[:id]}'),"
11
+ jss = jss << "allowedExtensions: #{options[:allowedExtensions].to_s}"
9
12
 
10
- def uploader(method,*args)
11
- options = args.extract_options!
12
- options[:id] = field_id(method)
13
- options[:action] ||= '/public/system/'
14
- options[:allowedExtensions] ||= []
13
+ options.each do |key,value| next if [:id,:allowedExtensions].include?(key)
14
+ jss = jss << ",#{key} : '#{value}'"
15
+ end
15
16
 
16
- jss = "var uploader = new qq.FileUploader({"
17
- jss = jss << "element: document.getElementById('#{options[:id]}'),"
18
- jss = jss << "allowedExtensions: #{options[:allowedExtensions].to_s}"
17
+ jss = jss << "});"
19
18
 
20
- options.each do |key,value| next if [:id,:allowedExtensions].include?(key)
21
- jss = jss << ",#{key} : '#{value}'"
22
- end
19
+ end
20
+
21
+ def uploader_field_id(label)
22
+ "field-uploader_#{label}"
23
+ end
24
+
25
+ def parse_uploader_options options,name
26
+ options[:id] = uploader_field_id(name)
27
+ options[:action] ||= '/public/system/'
28
+ options[:allowedExtensions] ||= []
29
+ end
30
+
31
+ end
32
+
33
+ end
23
34
 
24
- jss = jss << "});"
35
+ module ActionView
25
36
 
37
+ module Helpers
38
+
39
+ class FormBuilder
40
+
41
+ include Fg::H5Uploader
42
+
43
+ def uploader(method,*args)
44
+ options = args.extract_options!
45
+ parse_uploader_options options,method
46
+
26
47
  js_tag = @template.javascript_tag do
27
- jss
48
+ uploader_js_content method,options
28
49
  end
29
50
 
30
51
  @template.content_tag(:div,:id => options[:id]) do
@@ -35,8 +56,20 @@ module Fg
35
56
 
36
57
  end
37
58
 
38
- def field_id(label)
39
- "field-uploader_#{label}"
59
+ end
60
+
61
+ module FormTagHelper
62
+
63
+ include Fg::H5Uploader
64
+
65
+ def uploader_field_tag(name, *args)
66
+ options = args.extract_options!
67
+ parse_uploader_options options,name
68
+
69
+ js_tag = javascript_tag(uploader_js_content(name,options))
70
+ div_tag = content_tag(:div,content_tag(:noscript,file_field_tag(name)),:id => options[:id])
71
+ div_tag << js_tag
72
+
40
73
  end
41
74
 
42
75
  end
@@ -45,3 +78,4 @@ module Fg
45
78
 
46
79
  end
47
80
 
81
+
@@ -1,3 +1,3 @@
1
1
  module Uploader
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h5_uploader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-05 00:00:00.000000000 +02:00
12
+ date: 2011-07-06 00:00:00.000000000 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack-raw-upload
17
- requirement: &2153032480 !ruby/object:Gem::Requirement
17
+ requirement: &2153351340 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2153032480
25
+ version_requirements: *2153351340
26
26
  description: Gem add a form builder called uploader that shows a button for multiple
27
27
  file uploads usign html5 techniques
28
28
  email: