h5_uploader 0.3.1 → 0.3.2
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 +13 -1
- data/lib/assets/fileuploader.js +19 -11
- data/lib/h5_uploader.rb +2 -1
- data/lib/h5_uploader/version.rb +1 -1
- metadata +6 -6
data/README.md
CHANGED
@@ -20,4 +20,16 @@ Run bundle install.
|
|
20
20
|
|
21
21
|
|
22
22
|
##js library options and docs
|
23
|
-
See [file-upload](https://github.com/jgoguen/file-uploader)
|
23
|
+
See [file-upload](https://github.com/jgoguen/file-uploader)
|
24
|
+
|
25
|
+
##Custom options
|
26
|
+
Added a custom option *evalResponse* default to false. This is useful when Rails return a js to be evaluated and not to be converted into json. Note that if multiple file are uploaded the code is evaluated for any response and not on upload complete.
|
27
|
+
If option is true a valid response for the uploader is soemthing like this:
|
28
|
+
|
29
|
+
(function(){
|
30
|
+
|
31
|
+
// your callback code here
|
32
|
+
|
33
|
+
return {success:true};
|
34
|
+
})();
|
35
|
+
|
data/lib/assets/fileuploader.js
CHANGED
@@ -261,7 +261,7 @@ var qq = qq || {};
|
|
261
261
|
qq.FileUploaderBasic = function(o){
|
262
262
|
this._options = {
|
263
263
|
// set to true to see the server response
|
264
|
-
debug:
|
264
|
+
debug: true,
|
265
265
|
action: '/server/upload',
|
266
266
|
params: {},
|
267
267
|
button: null,
|
@@ -273,11 +273,12 @@ qq.FileUploaderBasic = function(o){
|
|
273
273
|
allowedExtensions: [],
|
274
274
|
sizeLimit: 0,
|
275
275
|
minSizeLimit: 0,
|
276
|
+
evalResponse : false, // used in rails UJS perform the direct callback evaluation
|
276
277
|
// events
|
277
278
|
// return false to cancel submit
|
278
279
|
onSubmit: function(id, fileName){},
|
279
280
|
onProgress: function(id, fileName, loaded, total){},
|
280
|
-
onComplete: function(id, fileName, responseJSON){},
|
281
|
+
onComplete: function(id, fileName, responseJSON,qq){},
|
281
282
|
onCancel: function(id, fileName){},
|
282
283
|
// messages
|
283
284
|
messages: {
|
@@ -338,13 +339,14 @@ qq.FileUploaderBasic.prototype = {
|
|
338
339
|
debug: this._options.debug,
|
339
340
|
action: this._options.action,
|
340
341
|
maxConnections: this._options.maxConnections,
|
342
|
+
evalResponse : this._options.evalResponse,
|
341
343
|
onProgress: function(id, fileName, loaded, total){
|
342
344
|
self._onProgress(id, fileName, loaded, total);
|
343
345
|
self._options.onProgress.call(self, id, fileName, loaded, total);
|
344
346
|
},
|
345
|
-
onComplete: function(id, fileName, result){
|
346
|
-
self._onComplete(id, fileName, result);
|
347
|
-
self._options.onComplete.call(self, id, fileName, result);
|
347
|
+
onComplete: function(id, fileName, result,qq){
|
348
|
+
self._onComplete(id, fileName, result,qq);
|
349
|
+
self._options.onComplete.call(self, id, fileName, result,qq);
|
348
350
|
},
|
349
351
|
onCancel: function(id, fileName){
|
350
352
|
self._onCancel(id, fileName);
|
@@ -372,7 +374,7 @@ qq.FileUploaderBasic.prototype = {
|
|
372
374
|
},
|
373
375
|
_onProgress: function(id, fileName, loaded, total){
|
374
376
|
},
|
375
|
-
_onComplete: function(id, fileName, result){
|
377
|
+
_onComplete: function(id, fileName, result,qq){
|
376
378
|
this._filesInProgress--;
|
377
379
|
if (result.error){
|
378
380
|
this._options.showMessage(result.error);
|
@@ -910,7 +912,7 @@ qq.UploadHandlerAbstract = function(o){
|
|
910
912
|
// maximum number of concurrent uploads
|
911
913
|
maxConnections: 999,
|
912
914
|
onProgress: function(id, fileName, loaded, total){},
|
913
|
-
onComplete: function(id, fileName, response){},
|
915
|
+
onComplete: function(id, fileName, response,qq){},
|
914
916
|
onCancel: function(id, fileName){}
|
915
917
|
};
|
916
918
|
qq.extend(this._options, o);
|
@@ -1062,7 +1064,7 @@ qq.extend(qq.UploadHandlerForm.prototype, {
|
|
1062
1064
|
|
1063
1065
|
var response = self._getIframeContentJSON(iframe);
|
1064
1066
|
|
1065
|
-
self._options.onComplete(id, fileName, response);
|
1067
|
+
self._options.onComplete(id, fileName, response,qq);
|
1066
1068
|
self._dequeue(id);
|
1067
1069
|
|
1068
1070
|
delete self._inputs[id];
|
@@ -1271,15 +1273,21 @@ qq.extend(qq.UploadHandlerXhr.prototype, {
|
|
1271
1273
|
var response;
|
1272
1274
|
|
1273
1275
|
try {
|
1274
|
-
|
1276
|
+
|
1277
|
+
if(this._options.evalResponse){
|
1278
|
+
response = eval(xhr.responseText);
|
1279
|
+
}else{
|
1280
|
+
response = eval("(" + xhr.responseText + ")");
|
1281
|
+
}
|
1282
|
+
|
1275
1283
|
} catch(err){
|
1276
1284
|
response = {};
|
1277
1285
|
}
|
1278
1286
|
|
1279
|
-
this._options.onComplete(id, name, response);
|
1287
|
+
this._options.onComplete(id, name, response,this);
|
1280
1288
|
|
1281
1289
|
} else {
|
1282
|
-
this._options.onComplete(id, name, {});
|
1290
|
+
this._options.onComplete(id, name, {},this);
|
1283
1291
|
}
|
1284
1292
|
|
1285
1293
|
this._files[id] = null;
|
data/lib/h5_uploader.rb
CHANGED
@@ -12,7 +12,8 @@ module Fg
|
|
12
12
|
jss = jss << ",params: #{options[:params].to_json}" unless options[:params].nil?
|
13
13
|
|
14
14
|
options.each do |key,value| next if [:id,:allowedExtensions,:params].include?(key)
|
15
|
-
|
15
|
+
val = (key =~ /[^(on|show|mess)]/) > 0 ? "#{value}" : "'#{value}'"
|
16
|
+
jss = jss << ",#{key}: #{val}"
|
16
17
|
end
|
17
18
|
|
18
19
|
jss = jss << "});"
|
data/lib/h5_uploader/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: h5_uploader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-07-
|
12
|
+
date: 2011-07-08 00:00:00.000000000 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack-raw-upload
|
17
|
-
requirement: &
|
17
|
+
requirement: &2154180720 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2154180720
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: actionpack
|
28
|
-
requirement: &
|
28
|
+
requirement: &2154180300 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2154180300
|
37
37
|
description: Gem add a form builder called uploader that shows a button for multiple
|
38
38
|
file uploads usign html5 techniques
|
39
39
|
email:
|