actionverb_s3_direct_upload 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module S3DirectUpload
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionverb_s3_direct_upload
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-26 00:00:00.000000000 Z
12
+ date: 2012-12-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -88,9 +88,7 @@ files:
88
88
  - lib/s3_direct_upload/form_helper.rb
89
89
  - lib/s3_direct_upload/version.rb
90
90
  - lib/s3_direct_upload.rb
91
- - app/assets/javascripts/s3_direct_upload.js
92
91
  - app/assets/javascripts/s3_direct_upload.js.coffee
93
- - app/assets/javascripts/s3_direct_upload.js.js
94
92
  - app/assets/stylesheets/s3_direct_upload_progress_bars.css.scss
95
93
  - LICENSE
96
94
  - README.md
@@ -1,117 +0,0 @@
1
- // Generated by CoffeeScript 1.3.3
2
- var $;
3
-
4
- $ = jQuery;
5
-
6
- $.fn.S3Uploader = function(options) {
7
- var $uploadForm, build_content_object, current_files, setUploadForm, settings;
8
- if (this.length > 1) {
9
- this.each(function() {
10
- return $(this).S3Uploader(options);
11
- });
12
- return this;
13
- }
14
- $uploadForm = this;
15
- settings = {
16
- path: '',
17
- additional_data: null,
18
- before_add: null,
19
- remove_completed_progress_bar: true,
20
- progress_container: $uploadForm
21
- };
22
- $.extend(settings, options);
23
- current_files = [];
24
- setUploadForm = function() {
25
- return $uploadForm.fileupload({
26
- start: function(e) {
27
- return $uploadForm.trigger("s3_upload_start", [e]);
28
- },
29
- add: function(e, data) {
30
- var file;
31
- current_files.push(data);
32
- file = data.files[0];
33
- if (!(settings.before_add && !settings.before_add(file))) {
34
- if ($('#template-upload').length > 0) {
35
- data.context = $(tmpl("template-upload", file));
36
- }
37
- settings['progress_container'].append(data.context);
38
- return data.submit();
39
- }
40
- },
41
- progress: function(e, data) {
42
- var progress;
43
- if (data.context) {
44
- progress = parseInt(data.loaded / data.total * 100, 10);
45
- return data.context.find('.bar').css('width', progress + '%');
46
- }
47
- },
48
- done: function(e, data) {
49
- var content, to;
50
- content = build_content_object($uploadForm, data.files[0]);
51
- to = $uploadForm.data('post');
52
- if (to) {
53
- content[$uploadForm.data('as')] = content.url;
54
- $.post(to, content);
55
- }
56
- if (data.context && settings.remove_completed_progress_bar) {
57
- data.context.remove();
58
- }
59
- $uploadForm.trigger("s3_upload_complete", [content]);
60
- current_files.splice($.inArray(data, current_files), 1);
61
- if (current_files.length === 0) {
62
- return $(document).trigger("s3_uploads_complete");
63
- }
64
- },
65
- fail: function(e, data) {
66
- var content;
67
- content = build_content_object($uploadForm, data.files[0]);
68
- content.error_thrown = data.errorThrown;
69
- return $uploadForm.trigger("s3_upload_failed", [content]);
70
- },
71
- formData: function(form) {
72
- var data, fileType;
73
- data = form.serializeArray();
74
- fileType = "";
75
- if ("type" in this.files[0]) {
76
- fileType = this.files[0].type;
77
- }
78
- data.push({
79
- name: "Content-Type",
80
- value: fileType
81
- });
82
- data[1].value = settings.path + data[1].value;
83
- return data;
84
- }
85
- });
86
- };
87
- build_content_object = function($uploadForm, file) {
88
- var content, domain, path;
89
- domain = $uploadForm.attr('action');
90
- path = settings.path + $uploadForm.find('input[name=key]').val().replace('/${filename}', '');
91
- content = {};
92
- content.url = domain + path + '/' + file.name;
93
- content.filename = file.name;
94
- content.filepath = path;
95
- if ('size' in file) {
96
- content.filesize = file.size;
97
- }
98
- if ('type' in file) {
99
- content.filetype = file.type;
100
- }
101
- if (settings.additional_data) {
102
- content = $.extend(content, settings.additional_data);
103
- }
104
- return content;
105
- };
106
- this.initialize = function() {
107
- setUploadForm();
108
- return this;
109
- };
110
- this.path = function(new_path) {
111
- return settings.path = new_path;
112
- };
113
- this.additional_data = function(new_data) {
114
- return settings.additional_data = new_data;
115
- };
116
- return this.initialize();
117
- };
@@ -1,117 +0,0 @@
1
- // Generated by CoffeeScript 1.3.3
2
- var $;
3
-
4
- $ = jQuery;
5
-
6
- $.fn.S3Uploader = function(options) {
7
- var $uploadForm, build_content_object, current_files, setUploadForm, settings;
8
- if (this.length > 1) {
9
- this.each(function() {
10
- return $(this).S3Uploader(options);
11
- });
12
- return this;
13
- }
14
- $uploadForm = this;
15
- settings = {
16
- path: '',
17
- additional_data: null,
18
- before_add: null,
19
- remove_completed_progress_bar: true,
20
- progress_container: $uploadForm
21
- };
22
- $.extend(settings, options);
23
- current_files = [];
24
- setUploadForm = function() {
25
- return $uploadForm.fileupload({
26
- start: function(e) {
27
- return $uploadForm.trigger("s3_uploads_start", [e]);
28
- },
29
- add: function(e, data) {
30
- var file;
31
- current_files.push(data);
32
- file = data.files[0];
33
- if (!(settings.before_add && !settings.before_add(file))) {
34
- if ($('#template-upload').length > 0) {
35
- data.context = $(tmpl("template-upload", file));
36
- }
37
- settings['progress_container'].append(data.context);
38
- return data.submit();
39
- }
40
- },
41
- progress: function(e, data) {
42
- var progress;
43
- if (data.context) {
44
- progress = parseInt(data.loaded / data.total * 100, 10);
45
- return data.context.find('.bar').css('width', progress + '%');
46
- }
47
- },
48
- done: function(e, data) {
49
- var content, to;
50
- content = build_content_object($uploadForm, data.files[0]);
51
- to = $uploadForm.data('post');
52
- if (to) {
53
- content[$uploadForm.data('as')] = content.url;
54
- $.post(to, content);
55
- }
56
- if (data.context && settings.remove_completed_progress_bar) {
57
- data.context.remove();
58
- }
59
- $uploadForm.trigger("s3_upload_complete", [content]);
60
- current_files.splice($.inArray(data, current_files), 1);
61
- if (current_files.length === 0) {
62
- return $(document).trigger("s3_uploads_complete");
63
- }
64
- },
65
- fail: function(e, data) {
66
- var content;
67
- content = build_content_object($uploadForm, data.files[0]);
68
- content.error_thrown = data.errorThrown;
69
- return $uploadForm.trigger("s3_upload_failed", [content]);
70
- },
71
- formData: function(form) {
72
- var data, fileType;
73
- data = form.serializeArray();
74
- fileType = "";
75
- if ("type" in this.files[0]) {
76
- fileType = this.files[0].type;
77
- }
78
- data.push({
79
- name: "Content-Type",
80
- value: fileType
81
- });
82
- data[1].value = settings.path + data[1].value;
83
- return data;
84
- }
85
- });
86
- };
87
- build_content_object = function($uploadForm, file) {
88
- var content, domain, path;
89
- domain = $uploadForm.attr('action');
90
- path = settings.path + $uploadForm.find('input[name=key]').val().replace('/${filename}', '');
91
- content = {};
92
- content.url = domain + path + '/' + file.name;
93
- content.filename = file.name;
94
- content.filepath = path;
95
- if ('size' in file) {
96
- content.filesize = file.size;
97
- }
98
- if ('type' in file) {
99
- content.filetype = file.type;
100
- }
101
- if (settings.additional_data) {
102
- content = $.extend(content, settings.additional_data);
103
- }
104
- return content;
105
- };
106
- this.initialize = function() {
107
- setUploadForm();
108
- return this;
109
- };
110
- this.path = function(new_path) {
111
- return settings.path = new_path;
112
- };
113
- this.additional_data = function(new_data) {
114
- return settings.additional_data = new_data;
115
- };
116
- return this.initialize();
117
- };