rails-uploader 0.0.8 → 0.1.0
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.
- data/README.md +3 -3
- data/app/controllers/uploader/attachments_controller.rb +15 -5
- data/app/views/uploader/default/_container.html.erb +5 -2
- data/app/views/uploader/default/_download.html.erb +6 -3
- data/app/views/uploader/default/_sortable.html.erb +24 -0
- data/config/routes.rb +1 -1
- data/lib/uploader.rb +6 -1
- data/lib/uploader/helpers/field_tag.rb +4 -0
- data/lib/uploader/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +52 -0
- data/spec/dummy/public/uploads/picture/data/1/thumb_rails.png +0 -0
- data/vendor/assets/javascripts/uploader/jquery.fileupload-fp.js +223 -0
- data/vendor/assets/javascripts/uploader/jquery.fileupload-ui.js +295 -133
- data/vendor/assets/javascripts/uploader/jquery.fileupload.js +464 -204
- data/vendor/assets/javascripts/uploader/jquery.iframe-transport.js +21 -7
- data/vendor/assets/javascripts/uploader/jquery.ui.widget.js +365 -117
- data/vendor/assets/stylesheets/uploader/default.css +1 -0
- metadata +5 -3
- data/vendor/assets/javascripts/uploader/jquery.fileupload-ip.js +0 -160
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-02-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sqlite3
|
@@ -52,6 +52,7 @@ extra_rdoc_files:
|
|
52
52
|
- README.md
|
53
53
|
files:
|
54
54
|
- app/views/uploader/default/_upload.html.erb
|
55
|
+
- app/views/uploader/default/_sortable.html.erb
|
55
56
|
- app/views/uploader/default/_container.html.erb
|
56
57
|
- app/views/uploader/default/_init.html.erb
|
57
58
|
- app/views/uploader/default/_download.html.erb
|
@@ -81,6 +82,7 @@ files:
|
|
81
82
|
- vendor/assets/images/uploader/ico_attach.png
|
82
83
|
- vendor/assets/images/uploader/progressBarFillBg.png
|
83
84
|
- vendor/assets/images/uploader/but_del_tag2.png
|
85
|
+
- vendor/assets/javascripts/uploader/jquery.fileupload-fp.js
|
84
86
|
- vendor/assets/javascripts/uploader/locales/uk.js
|
85
87
|
- vendor/assets/javascripts/uploader/locales/ru.js
|
86
88
|
- vendor/assets/javascripts/uploader/locales/en.js
|
@@ -89,7 +91,6 @@ files:
|
|
89
91
|
- vendor/assets/javascripts/uploader/jquery.fileupload-ui.js
|
90
92
|
- vendor/assets/javascripts/uploader/jquery.fileupload.js
|
91
93
|
- vendor/assets/javascripts/uploader/tmpl.min.js
|
92
|
-
- vendor/assets/javascripts/uploader/jquery.fileupload-ip.js
|
93
94
|
- vendor/assets/javascripts/uploader/jquery.iframe-transport.js
|
94
95
|
- MIT-LICENSE
|
95
96
|
- Rakefile
|
@@ -209,3 +210,4 @@ test_files:
|
|
209
210
|
- spec/factories/assets.rb
|
210
211
|
- spec/factories/files/rails.png
|
211
212
|
- spec/fileuploads_spec.rb
|
213
|
+
has_rdoc:
|
@@ -1,160 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* jQuery File Upload Image Processing Plugin 1.0.6
|
3
|
-
* https://github.com/blueimp/jQuery-File-Upload
|
4
|
-
*
|
5
|
-
* Copyright 2012, Sebastian Tschan
|
6
|
-
* https://blueimp.net
|
7
|
-
*
|
8
|
-
* Licensed under the MIT license:
|
9
|
-
* http://www.opensource.org/licenses/MIT
|
10
|
-
*/
|
11
|
-
|
12
|
-
/*jslint nomen: true, unparam: true, regexp: true */
|
13
|
-
/*global define, window, document */
|
14
|
-
|
15
|
-
(function (factory) {
|
16
|
-
'use strict';
|
17
|
-
if (typeof define === 'function' && define.amd) {
|
18
|
-
// Register as an anonymous AMD module:
|
19
|
-
define([
|
20
|
-
'jquery',
|
21
|
-
'load-image',
|
22
|
-
'canvas-to-blob',
|
23
|
-
'./jquery.fileupload'
|
24
|
-
], factory);
|
25
|
-
} else {
|
26
|
-
// Browser globals:
|
27
|
-
factory(
|
28
|
-
window.jQuery,
|
29
|
-
window.loadImage,
|
30
|
-
window.canvasToBlob
|
31
|
-
);
|
32
|
-
}
|
33
|
-
}(function ($, loadImage, canvasToBlob) {
|
34
|
-
'use strict';
|
35
|
-
|
36
|
-
// The File Upload IP version extends the basic fileupload widget
|
37
|
-
// with image processing functionality:
|
38
|
-
$.widget('blueimpIP.fileupload', $.blueimp.fileupload, {
|
39
|
-
|
40
|
-
options: {
|
41
|
-
// The regular expression to define which image files are to be
|
42
|
-
// resized, given that the browser supports the operation:
|
43
|
-
resizeSourceFileTypes: /^image\/(gif|jpeg|png)$/,
|
44
|
-
// The maximum file size of images that are to be resized:
|
45
|
-
resizeSourceMaxFileSize: 20000000, // 20MB
|
46
|
-
// The maximum width of the resized images:
|
47
|
-
resizeMaxWidth: undefined,
|
48
|
-
// The maximum height of the resized images:
|
49
|
-
resizeMaxHeight: undefined,
|
50
|
-
// The minimum width of the resized images:
|
51
|
-
resizeMinWidth: undefined,
|
52
|
-
// The minimum height of the resized images:
|
53
|
-
resizeMinHeight: undefined,
|
54
|
-
|
55
|
-
// The add callback is invoked as soon as files are added to the fileupload
|
56
|
-
// widget (via file input selection, drag & drop or add API call).
|
57
|
-
// See the basic file upload widget for more information:
|
58
|
-
add: function (e, data) {
|
59
|
-
$(this).fileupload('resize', data).done(function () {
|
60
|
-
data.submit();
|
61
|
-
});
|
62
|
-
}
|
63
|
-
},
|
64
|
-
|
65
|
-
// Resizes the image file at the given index and stores the created blob
|
66
|
-
// at the original position of the files list, returns a Promise object:
|
67
|
-
_resizeImage: function (files, index, options) {
|
68
|
-
var that = this,
|
69
|
-
file = files[index],
|
70
|
-
deferred = $.Deferred(),
|
71
|
-
canvas,
|
72
|
-
blob;
|
73
|
-
options = options || this.options;
|
74
|
-
loadImage(
|
75
|
-
file,
|
76
|
-
function (img) {
|
77
|
-
var width = img.width,
|
78
|
-
height = img.height;
|
79
|
-
canvas = loadImage.scale(img, {
|
80
|
-
maxWidth: options.resizeMaxWidth,
|
81
|
-
maxHeight: options.resizeMaxHeight,
|
82
|
-
minWidth: options.resizeMinWidth,
|
83
|
-
minHeight: options.resizeMinHeight,
|
84
|
-
canvas: true
|
85
|
-
});
|
86
|
-
if (width !== canvas.width || height !== canvas.height) {
|
87
|
-
canvasToBlob(canvas, function (blob) {
|
88
|
-
if (!blob.name) {
|
89
|
-
if (file.type === blob.type) {
|
90
|
-
blob.name = file.name;
|
91
|
-
} else if (file.name) {
|
92
|
-
blob.name = file.name.replace(
|
93
|
-
/\..+$/,
|
94
|
-
'.' + blob.type.substr(6)
|
95
|
-
);
|
96
|
-
}
|
97
|
-
}
|
98
|
-
files[index] = blob;
|
99
|
-
deferred.resolveWith(that);
|
100
|
-
}, file);
|
101
|
-
} else {
|
102
|
-
deferred.resolveWith(that);
|
103
|
-
}
|
104
|
-
}
|
105
|
-
);
|
106
|
-
return deferred.promise();
|
107
|
-
},
|
108
|
-
|
109
|
-
// Resizes the images given as files property of the data parameter,
|
110
|
-
// returns a Promise object that allows to bind a done handler, which
|
111
|
-
// will be invoked after processing all images is done:
|
112
|
-
resize: function (data) {
|
113
|
-
var that = this,
|
114
|
-
options = $.extend({}, this.options, data),
|
115
|
-
resizeAll = $.type(options.resizeSourceMaxFileSize) !== 'number',
|
116
|
-
isXHRUpload = this._isXHRUpload(options);
|
117
|
-
$.each(data.files, function (index, file) {
|
118
|
-
if (isXHRUpload && that._resizeSupport &&
|
119
|
-
(options.resizeMaxWidth || options.resizeMaxHeight ||
|
120
|
-
options.resizeMinWidth || options.resizeMinHeight) &&
|
121
|
-
(resizeAll || file.size < options.resizeSourceMaxFileSize) &&
|
122
|
-
options.resizeSourceFileTypes.test(file.type)) {
|
123
|
-
that._processing += 1;
|
124
|
-
if (that._processing === 1) {
|
125
|
-
that.element.addClass('fileupload-processing');
|
126
|
-
}
|
127
|
-
that._processingQueue = that._processingQueue.pipe(function () {
|
128
|
-
var deferred = $.Deferred();
|
129
|
-
that._resizeImage(
|
130
|
-
data.files,
|
131
|
-
index,
|
132
|
-
options
|
133
|
-
).done(function () {
|
134
|
-
that._processing -= 1;
|
135
|
-
if (that._processing === 0) {
|
136
|
-
that.element
|
137
|
-
.removeClass('fileupload-processing');
|
138
|
-
}
|
139
|
-
deferred.resolveWith(that);
|
140
|
-
});
|
141
|
-
return deferred.promise();
|
142
|
-
});
|
143
|
-
}
|
144
|
-
});
|
145
|
-
return this._processingQueue;
|
146
|
-
},
|
147
|
-
|
148
|
-
_create: function () {
|
149
|
-
$.blueimp.fileupload.prototype._create.call(this);
|
150
|
-
this._processing = 0;
|
151
|
-
this._processingQueue = $.Deferred().resolveWith(this).promise();
|
152
|
-
this._resizeSupport = canvasToBlob && canvasToBlob(
|
153
|
-
document.createElement('canvas'),
|
154
|
-
$.noop
|
155
|
-
);
|
156
|
-
}
|
157
|
-
|
158
|
-
});
|
159
|
-
|
160
|
-
}));
|