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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2705d3c1976665c606d2318617cf293bb9ab43ec
|
4
|
+
data.tar.gz: 070c14ecc0866e8651dbd6a8bb9438bef15e8342
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bcad87082cd4c62639c069c72ae60cb4dad7d9ce46da4f104935f51b582fb30dc3b9eef70c5297fc5bcc0b4db1482c67fbfab727a27848be54d74b179e687ac
|
7
|
+
data.tar.gz: ab1c8ccf568ba5db1ae9ebf00b295dff90f72e817c2524a9fb652aae965fa201aaf1614c91712d2c4455f43306b063796ebe2edc675548b61097d8713eb128b4
|
@@ -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="
|
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: '
|
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
|
-
$(
|
120
|
+
$("#<%= uploader_id %>").fileupload({
|
120
121
|
url: "<%= post_url %>",
|
121
122
|
autoUpload: true,
|
122
123
|
formData: {},
|
123
124
|
sequentialUploads: true,
|
124
|
-
fileInput: $("#
|
125
|
-
filesContainer: "
|
125
|
+
fileInput: $("#fileupload_<%= uploader_id %>"),
|
126
|
+
filesContainer: "#<%= uploader_id %>-files-container"
|
126
127
|
}).on('fileuploadcompleted', function(e, data) {
|
127
|
-
|
128
|
+
insertUploadInputsFor<%= association.capitalize %>(data.result.files);
|
128
129
|
}).bind('fileuploaddestroy', function(e, data) {
|
129
|
-
|
130
|
+
removeUploadInputsFor<%= association.capitalize %>([data]);
|
130
131
|
});
|
131
132
|
});
|
132
133
|
</script>
|
133
134
|
|
134
135
|
|
135
136
|
<script type="text/javascript">
|
136
|
-
|
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
|
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 = $("
|
154
|
+
var uploader = $("#<%= uploader_id %>").data("blueimpFileupload");
|
153
155
|
var template = uploader._renderDownload(files)['appendTo'](uploader.options.filesContainer);
|
154
156
|
uploader._transition(template);
|
155
|
-
|
157
|
+
insertUploadInputsFor<%= association.capitalize %>(files);
|
156
158
|
});
|
157
159
|
|
158
160
|
</script>
|
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.
|
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-
|
11
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|