active_admin_multi_upload 0.0.2 → 0.0.3

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: 6c270bdc9e6a211d4726f836ee13213c70edd984
4
- data.tar.gz: 94d9e3f22817f207d754c12ec81e84423030d7a1
3
+ metadata.gz: 2705d3c1976665c606d2318617cf293bb9ab43ec
4
+ data.tar.gz: 070c14ecc0866e8651dbd6a8bb9438bef15e8342
5
5
  SHA512:
6
- metadata.gz: dcbdb10871c9b7551e5d6a2ad4e0a9d90c809ccabc389dff0c28f33669b3f316a80205e4e03743a4709f1113c3b88ff2ec64142506ebc16f2d6bb9d5a6fcf904
7
- data.tar.gz: 85ccb5f853cf2690be903fcfcdebf38921969ea5f12c5d9e570ac45a24cdab3e6bfb9a338b0932612da405f439297f2de809ef11eaeb0efe8800491d4d999975
6
+ metadata.gz: 5bcad87082cd4c62639c069c72ae60cb4dad7d9ce46da4f104935f51b582fb30dc3b9eef70c5297fc5bcc0b4db1482c67fbfab727a27848be54d74b179e687ac
7
+ data.tar.gz: ab1c8ccf568ba5db1ae9ebf00b295dff90f72e817c2524a9fb652aae965fa201aaf1614c91712d2c4455f43306b063796ebe2edc675548b61097d8713eb128b4
@@ -1096,7 +1096,7 @@ table th[class*="col-"] {
1096
1096
  opacity: 1;
1097
1097
  }
1098
1098
 
1099
- #uploader {
1099
+ .uploader {
1100
1100
  margin: 10px 30px 10px 30px;
1101
1101
  }
1102
1102
 
@@ -7,10 +7,11 @@
7
7
  input_id_prefix = options[:input_id_prefix] ||= "#{resource.class.name.downcase}_#{association.singularize}_ids_"
8
8
  post_url = options[:post_url] ||= "/admin/#{association}/create_upload"
9
9
  input_name = options[:input_name] ||= "#{association.singularize}[#{attribute}]"
10
+ uploader_id = options[:uploader_name] ||= "#{association}_uploader"
10
11
 
11
12
  %>
12
13
 
13
- <div id="uploader">
14
+ <div id="<%= uploader_id %>" class="uploader">
14
15
  <!-- The fileupload-buttonbar contains buttons to add/delete files and start/cancel the upload -->
15
16
  <div class="row fileupload-buttonbar">
16
17
  <div class="span7">
@@ -18,7 +19,7 @@
18
19
  <span class="btn btn-success fileinput-button">
19
20
  <i class="icon-plus icon-white"></i>
20
21
  <span>Add files...</span>
21
- <input id="fileupload" type="file" name="<%= input_name %>" multiple>
22
+ <input id="fileupload_<%= uploader_id %>" type="file" name="<%= input_name %>" multiple>
22
23
  </span>
23
24
  <button type="reset" class="btn btn-warning cancel">
24
25
  <i class="icon-ban-circle icon-white"></i>
@@ -35,7 +36,7 @@
35
36
  <div class="fileupload-process"></div>
36
37
  <br>
37
38
  <!-- The table listing the files available for upload/download -->
38
- <table class="table table-striped"><tbody class="files" id="files-container" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
39
+ <table class="table table-striped"><tbody class="files" id="<%= uploader_id %>-files-container" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>
39
40
  </div>
40
41
 
41
42
 
@@ -46,7 +47,7 @@
46
47
  acceptFileTypes: 'Filetype not allowed',
47
48
  maxNumberOfFiles: 'Max number of files exceeded',
48
49
  uploadedBytes: 'Uploaded bytes exceed file size',
49
- emptyResult: 'Empty file upload result'
50
+ emptyResult: 'Something went wrong. Please try again'
50
51
  };
51
52
  </script>
52
53
 
@@ -116,31 +117,32 @@
116
117
  <script type="text/javascript" charset="utf-8">
117
118
  $(function () {
118
119
  // Initialize the jQuery File Upload widget:
119
- $('#uploader').fileupload({
120
+ $("#<%= uploader_id %>").fileupload({
120
121
  url: "<%= post_url %>",
121
122
  autoUpload: true,
122
123
  formData: {},
123
124
  sequentialUploads: true,
124
- fileInput: $("#fileupload"),
125
- filesContainer: "#files-container"
125
+ fileInput: $("#fileupload_<%= uploader_id %>"),
126
+ filesContainer: "#<%= uploader_id %>-files-container"
126
127
  }).on('fileuploadcompleted', function(e, data) {
127
- insertUploadInputs(data.result.files);
128
+ insertUploadInputsFor<%= association.capitalize %>(data.result.files);
128
129
  }).bind('fileuploaddestroy', function(e, data) {
129
- removeUploadInputs([data]);
130
+ removeUploadInputsFor<%= association.capitalize %>([data]);
130
131
  });
131
132
  });
132
133
  </script>
133
134
 
134
135
 
135
136
  <script type="text/javascript">
136
- var insertUploadInputs = function(files) {
137
+
138
+ var insertUploadInputsFor<%= association.capitalize %> = function(files) {
137
139
  $.each(files, function(index, file) {
138
140
  var input = $("<input type='hidden' class='file-upload' name='<%= uploaded_ids_form_input_name %>' id='<%= input_id_prefix %>" + file.id + "' value='" + file.id + "' />");
139
141
  input.insertAfter($("#upload_" + file.id));
140
142
  });
141
143
  };
142
144
 
143
- var removeUploadInputs = function(files) {
145
+ var removeUploadInputsFor<%= association.capitalize %> = function(files) {
144
146
  $.each(files, function(index, file) {
145
147
  var id = file.url.split("/").pop();
146
148
  $("#<%= input_id_prefix %>" + id).remove();
@@ -149,10 +151,10 @@ var removeUploadInputs = function(files) {
149
151
 
150
152
  $(function () {
151
153
  var files = <%= existing_uploads.map(&:to_jq_upload).to_json.html_safe %>;
152
- var uploader = $("#uploader").data("blueimpFileupload");
154
+ var uploader = $("#<%= uploader_id %>").data("blueimpFileupload");
153
155
  var template = uploader._renderDownload(files)['appendTo'](uploader.options.filesContainer);
154
156
  uploader._transition(template);
155
- insertUploadInputs(files);
157
+ insertUploadInputsFor<%= association.capitalize %>(files);
156
158
  });
157
159
 
158
160
  </script>
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminMultiUpload
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_multi_upload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isaac Norman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-13 00:00:00.000000000 Z
11
+ date: 2014-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails