filestack-rails 4.0.5 → 4.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '0382cb6fbca8442f67208a68949845a97c895211'
4
- data.tar.gz: 67ff05ab56ad4524fad9ced697963148e7d52679
3
+ metadata.gz: df27060e0b79e5d8e1211369caf7c78e5c24e595
4
+ data.tar.gz: e898572530f16c1a0163484920da3306a9546ed2
5
5
  SHA512:
6
- metadata.gz: aec24f02d40e451d6d6bff9e515ac132e7bdd8bdbd7ebe421f89fa84aa2c24ad82938366abbe9f1767e3d288c171d2bc3af1380c056178bbddee32b4a4f4e2ca
7
- data.tar.gz: cb91b9a683922e6902fef6f6c81b2daaa1be07ecfc887f13e48d4297752e097ffc85182f81d2d4f4e32d1a2ff45dd39ae541cdd52300f77f35d6039411ff2928
6
+ metadata.gz: 9cafcf5b2e0da02126df2671746a75caf6ae73fcac9f3e8d695fb73524c80d28b5d864c57f668dafac68796c4a7510e2f44749b2af94c519b83e72dced398787
7
+ data.tar.gz: '06269c6ec68ec86739e0f4471be581eba1c666abd0cb03f92ce884e92bc807487cd2fbcc5e513925066da92244c05d1a3f34df3e919c25a08ae8c5956fb38280'
data/README.md CHANGED
@@ -136,6 +136,13 @@ Each file that is uploaded will be represented as a single object within the fil
136
136
  ```javascript
137
137
  url = data.filesUploaded[0].url
138
138
  ```
139
+
140
+ For version `v3`, you can add following callbacks: `onOpen`, `onClose`, `onFileUploadFinished`, `onFileSelected`, `onUploadStarted`, to `pickerOptions`.
141
+
142
+ ```erb
143
+ <%= filestack_picker_element 'button test', 'callbackForButton', id: 'someuniqueid', input_id: 'someuniqueinputid', pickerOptions: { onClose: 'callbackOnClose', onOpen: 'callbackOnOpen' } %>
144
+ ```
145
+
139
146
  ### Filestack Form Helper
140
147
  The form helper wraps the generic Pick element and adds the value of the returned file to an invisible text element, in order to attach to the form. It accepts the same options as the Pick element and renders the same button.
141
148
 
@@ -50,6 +50,7 @@ module FilestackRails
50
50
 
51
51
  def create_javascript_for_picker(callback, options)
52
52
  client_name, _api_key = get_client_and_api_key
53
+ other_callbacks = build_callbacks_js(options) if options
53
54
  json_string = if options.nil?
54
55
  ''
55
56
  else
@@ -68,13 +69,23 @@ module FilestackRails
68
69
 
69
70
  <<~HTML
70
71
  (function(){
71
- #{client_name}.picker({ onUploadDone: data => #{callback}(data), #{json_string} }).open()
72
+ #{client_name}.picker({ onUploadDone: data => #{callback}(data)#{other_callbacks}, #{json_string} }).open()
72
73
  })()
73
74
  HTML
74
75
  end
75
76
  get_filestack_js_result(v2: v2, v3: v3)
76
77
  end
77
78
 
79
+ def build_callbacks_js(options)
80
+ string = ""
81
+ string << ", onOpen: data => #{options.delete(:onOpen)}(data)" unless options[:onOpen].blank?
82
+ string << ", onClose: () => #{options.delete(:onClose)}()" unless options[:onClose].blank?
83
+ string << ", onFileUploadFinished: data => #{options.delete(:onFileUploadFinished)}(data)" unless options[:onFileUploadFinished].blank?
84
+ string << ", onFileSelected: data => #{options.delete(:onFileSelected)}(data)" unless options[:onFileSelected].blank?
85
+ string << ", onUploadStarted: data => #{options.delete(:onUploadStarted)}(data)" unless options[:onUploadStarted].blank?
86
+ string
87
+ end
88
+
78
89
  def get_client_and_api_key
79
90
  client_name = ::Rails.application.config.filestack_rails.client_name
80
91
  apikey = ::Rails.application.config.filestack_rails.api_key
@@ -14,7 +14,7 @@ class FilestackVersion
14
14
  end
15
15
 
16
16
  module FilestackRails
17
- VERSION = '4.0.5'
17
+ VERSION = '4.0.6'
18
18
 
19
19
  module Version
20
20
  def get_filestack_js_result(results)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filestack-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.5
4
+ version: 4.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - filestack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-20 00:00:00.000000000 Z
11
+ date: 2019-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails