fileclip 0.3.0 → 0.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0676c859073d216852c397b109a24de44013b53f
4
- data.tar.gz: 6d017f9ac5d01e0b750144009c432c2583f5192a
3
+ metadata.gz: dd3ea5bcac57332d3c61a6bb49d6797fd9a951a4
4
+ data.tar.gz: 4c60a540c5a9efc0659647440c9157ae4bd5070b
5
5
  SHA512:
6
- metadata.gz: ae6c1d30f895d8071d07f693e3913ebb011c0c4dd9455d99af9fb97fd25572c7550680710ca2564132158c424cdab6d3d91d723de87df4961088a86bc8291a06
7
- data.tar.gz: 13c7805036a72919a2060226c9a5440ab65411b6dc8716825bd74531eef12b16aa05b7474392cf7905948eef2f7476cb48ee548c12241fa0810af7b0a2c47239
6
+ metadata.gz: 2dad98668a3926098921d618eb722b87a454fb288384ebc5848b1741a089b5272f78d935f689765770ef2ce2795a947e63c74fa9ac825c67d6764d34aff8625e
7
+ data.tar.gz: 00bea97058444bd69b18eca7e400c09bd56cd64eba156631a0036495c2d0b50a25b3fe73c2c9c1118c74f41a512f5f642e1506e5eafada8868f519e44494b208
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fileclip (0.2.4)
4
+ fileclip (0.3.0)
5
5
  paperclip
6
6
  paperclip (>= 3.5.1)
7
7
  railties (>= 3.0)
data/README.md CHANGED
@@ -28,12 +28,13 @@ end
28
28
  # config/initializers/fileclip.rb
29
29
  FileClip.configure do |config|
30
30
  config.filepicker_key = 'XXXXXXXXXXXXXXXXXXX'
31
- config.services = ["COMPUTER", "DROPBOX"] # Defaults to ["COMPUTER"]
32
- config.max_size = 20 # Megabytes, defaults to 20
33
- config.storage_path = "/assets/" # Defaults to "/fileclip/"
34
- config.mime_types = "images/jpeg" # Defaults to "images/*"
35
- config.file_access = "private" # Defaults to "public"
36
- config.excluded_environments = [] # Defaults to ["test"]
31
+ config.services = ["COMPUTER", "DROPBOX"] # Defaults to ["COMPUTER"]
32
+ config.max_size = 20 # Megabytes, defaults to 20
33
+ config.storage_path = "/assets/" # Defaults to "/fileclip/"
34
+ config.mime_types = "images/jpeg" # Defaults to "images/*"
35
+ config.file_access = "private" # Defaults to "public"
36
+ config.excluded_environments = [] # Defaults to ["test"]
37
+ config.default_service = "DROPBOX" # Defaults to "COMPUTER"
37
38
  end
38
39
  ````
39
40
 
@@ -62,6 +63,16 @@ end
62
63
  <%= f.submit %>
63
64
  <% end %>
64
65
 
66
+ # Specify a callback function that gets called when Filepicker completes
67
+ <%= link_to_fileclip "Choose a File", f, :callback => 'window.MyApp.filepickerCallback' %>
68
+
69
+ # For more control you can disable automatic Javascript initialization.
70
+ # You'll need to initialize the FileClip element yourself.
71
+ <%= link_to_fileclip "Choose a File", f, :class => '.my-filepicker', :js => false %>
72
+
73
+ # In your Javascript framework
74
+ (new FileClip).button('.my-filepicker');
75
+
65
76
  ````
66
77
 
67
78
  #### Current FilePicker options hardcoded
@@ -42,11 +42,11 @@ module FileClip
42
42
  end
43
43
 
44
44
  # Return empty tag if it's nil or true
45
- def activation(js, id)
45
+ def activation(js, id, callback)
46
46
  return javascript_tag unless js.nil? || js
47
47
 
48
48
  javascript_tag("(function() {
49
- (new FileClip).button('##{id}');
49
+ (new FileClip).button('##{id}', #{callback || 'null'});
50
50
  })();")
51
51
  end
52
52
 
@@ -56,7 +56,7 @@ module FileClip
56
56
  # Get attachment name
57
57
  attachment_name = form_object.object.attachment_name
58
58
 
59
- js = activation(options[:js], id)
59
+ js = activation(options[:js], id, options[:callback])
60
60
 
61
61
  js + link +
62
62
  form_object.hidden_field(:filepicker_url,
@@ -3,7 +3,7 @@ module FileClip
3
3
  attr_writer :filepicker_key, :services,
4
4
  :max_size, :storage_path,
5
5
  :mime_types, :file_access,
6
- :excluded_environments
6
+ :excluded_environments, :default_service
7
7
 
8
8
  def filepicker_key
9
9
  @filepicker_key or raise "Set Filepicker api_key"
@@ -33,6 +33,10 @@ module FileClip
33
33
  @excluded_environments or ["test"]
34
34
  end
35
35
 
36
+ def default_service
37
+ @default_service or "COMPUTER"
38
+ end
39
+
36
40
  end
37
41
 
38
42
  class << self
@@ -1,3 +1,3 @@
1
1
  module FileClip
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -4,7 +4,9 @@ class window.FileClip
4
4
  @env = ->
5
5
  "<%= Rails.env %>"
6
6
 
7
- constructor: ->
7
+ constructor: (pickerOptions) ->
8
+ @pickerOptions = pickerOptions || {}
9
+
8
10
  excludedEnvs = <%= FileClip.configuration.excluded_environments %>
9
11
  if @inArray(excludedEnvs, FileClip.env()) != -1
10
12
  return false
@@ -25,12 +27,16 @@ class window.FileClip
25
27
  @picker(callback)
26
28
 
27
29
  picker: (callback) =>
28
- filepicker.pickAndStore
30
+ pickerOptions =
29
31
  mimetypes: "<%= FileClip.configuration.mime_types %>"
30
32
  container: "modal"
31
33
  services: <%= FileClip.configuration.services %>
32
34
  maxSize: (<%= FileClip.configuration.max_size %> * 1024 * 1024)
33
- ,
35
+ openTo: "<%= FileClip.configuration.default_service %>"
36
+
37
+ $.extend(pickerOptions, @pickerOptions)
38
+
39
+ filepicker.pickAndStore pickerOptions,
34
40
  location: "S3"
35
41
  path: "<%= FileClip.configuration.storage_path %>"
36
42
  access: "<%= FileClip.configuration.file_access %>"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fileclip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Carleton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-06 00:00:00.000000000 Z
11
+ date: 2014-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paperclip