jquery_file_download-rails 0.0.1 → 0.0.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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/README.md +5 -0
- data/app/assets/javascripts/jquery.fileDownload.js +44 -18
- data/lib/jquery_file_download/rails/version.rb +2 -2
- metadata +10 -14
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 001ac5f6d85fd0d3a155528273e156f9388413e9
|
4
|
+
data.tar.gz: cc820635a9a22ce29577e1fb3d850617e2cae303
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1be1e0c7248ede3cc0b26f1d2b93e81ecee75ae316c0784d917afc4454b8312a6286bc929ece7bbd4f4f7ffe89b99b12c2e2ea6dfcbcdf1e3e84e8be75be4ae2
|
7
|
+
data.tar.gz: 0834547f4b0c83c903793b26aef1451cd2ab1454d9fdaeef966710c568ffaefca938a393a372e76ede6446e6f14d4c334ef0596f6c9b9151d18ceff7904e2272
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -43,6 +43,11 @@ class DownloadController < ApplicationController
|
|
43
43
|
end
|
44
44
|
```
|
45
45
|
|
46
|
+
# Samples
|
47
|
+
|
48
|
+
* See [jquery_file_download-rails-samples](https://github.com/rcook/jquery_file_download-rails-samples)
|
49
|
+
for detailed step-by-step instructions and sample application.
|
50
|
+
|
46
51
|
# Usage
|
47
52
|
|
48
53
|
With the gem installed, the `$.fileDownload` jQuery plugin is available in the browser.
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* jQuery File Download Plugin v1.4.
|
2
|
+
* jQuery File Download Plugin v1.4.3
|
3
3
|
*
|
4
4
|
* http://www.johnculviner.com
|
5
5
|
*
|
@@ -24,7 +24,7 @@
|
|
24
24
|
'\r': "#13;",
|
25
25
|
'\n': "#10;",
|
26
26
|
'"': 'quot;',
|
27
|
-
"'": '
|
27
|
+
"'": '#39;' /*single quotes just to be safe, IE8 doesn't support ', so use ' instead */
|
28
28
|
};
|
29
29
|
|
30
30
|
$.extend({
|
@@ -50,6 +50,7 @@ $.extend({
|
|
50
50
|
//the stock android browser straight up doesn't support file downloads initiated by a non GET: http://code.google.com/p/android/issues/detail?id=1780
|
51
51
|
//specify a message here to display if a user tries with an android browser
|
52
52
|
//if jQuery UI is installed this will be a dialog, otherwise it will be an alert
|
53
|
+
//Set to null to disable the message and attempt to download anyway
|
53
54
|
//
|
54
55
|
androidPostUnsupportedMessageHtml: "Unfortunately your Android browser doesn't support this type of file download. Please try again with a different browser.",
|
55
56
|
|
@@ -113,6 +114,12 @@ $.extend({
|
|
113
114
|
//
|
114
115
|
cookiePath: "/",
|
115
116
|
|
117
|
+
//
|
118
|
+
//if specified it will be used when attempting to clear the above name value pair
|
119
|
+
//useful for when downloads are being served on a subdomain (e.g. downloads.example.com)
|
120
|
+
//
|
121
|
+
cookieDomain: null,
|
122
|
+
|
116
123
|
//
|
117
124
|
//the title for the popup second window as a download is processing in the case of a mobile browser
|
118
125
|
//
|
@@ -153,7 +160,7 @@ $.extend({
|
|
153
160
|
|
154
161
|
var httpMethodUpper = settings.httpMethod.toUpperCase();
|
155
162
|
|
156
|
-
if (isAndroid && httpMethodUpper !== "GET") {
|
163
|
+
if (isAndroid && httpMethodUpper !== "GET" && settings.androidPostUnsupportedMessageHtml) {
|
157
164
|
//the stock android browser straight up doesn't support file downloads initiated by non GET requests: http://code.google.com/p/android/issues/detail?id=1780
|
158
165
|
|
159
166
|
if ($().dialog) {
|
@@ -321,16 +328,18 @@ $.extend({
|
|
321
328
|
|
322
329
|
|
323
330
|
function checkFileDownloadComplete() {
|
324
|
-
|
325
331
|
//has the cookie been written due to a file download occuring?
|
326
332
|
if (document.cookie.indexOf(settings.cookieName + "=" + settings.cookieValue) != -1) {
|
327
333
|
|
328
334
|
//execute specified callback
|
329
335
|
internalCallbacks.onSuccess(fileUrl);
|
330
336
|
|
331
|
-
//remove
|
332
|
-
|
337
|
+
//remove cookie
|
338
|
+
var cookieData = settings.cookieName + "=; path=" + settings.cookiePath + "; expires=" + new Date(0).toUTCString() + ";";
|
339
|
+
if (settings.cookieDomain) cookieData += " domain=" + settings.cookieDomain + ";";
|
340
|
+
document.cookie = cookieData;
|
333
341
|
|
342
|
+
//remove iframe
|
334
343
|
cleanUp(false);
|
335
344
|
|
336
345
|
return;
|
@@ -352,16 +361,27 @@ $.extend({
|
|
352
361
|
if ($form && $form.length) {
|
353
362
|
var $contents = $(formDoc.body).contents().first();
|
354
363
|
|
355
|
-
|
356
|
-
|
357
|
-
|
364
|
+
try {
|
365
|
+
if ($contents.length && $contents[0] === $form[0]) {
|
366
|
+
isFailure = false;
|
367
|
+
}
|
368
|
+
} catch (e) {
|
369
|
+
if (e && e.number == -2146828218) {
|
370
|
+
// IE 8-10 throw a permission denied after the form reloads on the "$contents[0] === $form[0]" comparison
|
371
|
+
isFailure = true;
|
372
|
+
} else {
|
373
|
+
throw e;
|
374
|
+
}
|
375
|
+
}
|
358
376
|
}
|
359
377
|
|
360
378
|
if (isFailure) {
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
379
|
+
// IE 8-10 don't always have the full content available right away, they need a litle bit to finish
|
380
|
+
setTimeout(function () {
|
381
|
+
internalCallbacks.onFail(formDoc.body.innerHTML, fileUrl);
|
382
|
+
cleanUp(true);
|
383
|
+
}, 100);
|
384
|
+
|
365
385
|
return;
|
366
386
|
}
|
367
387
|
}
|
@@ -402,9 +422,11 @@ $.extend({
|
|
402
422
|
}
|
403
423
|
|
404
424
|
if (isIos) {
|
405
|
-
downloadWindow.focus
|
406
|
-
|
407
|
-
|
425
|
+
if (downloadWindow.focus) {
|
426
|
+
downloadWindow.focus(); //ios safari bug doesn't allow a window to be closed unless it is focused
|
427
|
+
if (isFailure) {
|
428
|
+
downloadWindow.close();
|
429
|
+
}
|
408
430
|
}
|
409
431
|
}
|
410
432
|
}
|
@@ -424,8 +446,12 @@ $.extend({
|
|
424
446
|
return '&' + htmlSpecialCharsPlaceHolders[match];
|
425
447
|
});
|
426
448
|
}
|
427
|
-
|
428
|
-
|
449
|
+
var promise = deferred.promise();
|
450
|
+
promise.abort = function() {
|
451
|
+
cleanUp();
|
452
|
+
$iframe.remove();
|
453
|
+
};
|
454
|
+
return promise;
|
429
455
|
}
|
430
456
|
});
|
431
457
|
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery_file_download-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Richard Cook
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-
|
11
|
+
date: 2014-12-07 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: railties
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 3.1.0
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 3.1.0
|
30
27
|
description: jquery.fileDownload.js package for Rails 3.1+ asset pipeline
|
@@ -36,8 +33,8 @@ files:
|
|
36
33
|
- app/assets/javascripts/jquery.fileDownload.js
|
37
34
|
- lib/jquery_file_download.rb
|
38
35
|
- lib/jquery_file_download/rails.rb
|
39
|
-
- lib/jquery_file_download/rails/engine.rb
|
40
36
|
- lib/jquery_file_download/rails/version.rb
|
37
|
+
- lib/jquery_file_download/rails/engine.rb
|
41
38
|
- LICENSE
|
42
39
|
- Rakefile
|
43
40
|
- README.md
|
@@ -45,26 +42,25 @@ files:
|
|
45
42
|
homepage: https://github.com/rcook/jquery_file_download-rails/
|
46
43
|
licenses:
|
47
44
|
- MIT
|
45
|
+
metadata: {}
|
48
46
|
post_install_message:
|
49
47
|
rdoc_options: []
|
50
48
|
require_paths:
|
51
49
|
- lib
|
52
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
-
none: false
|
54
51
|
requirements:
|
55
|
-
- -
|
52
|
+
- - '>='
|
56
53
|
- !ruby/object:Gem::Version
|
57
54
|
version: '0'
|
58
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
-
none: false
|
60
56
|
requirements:
|
61
|
-
- -
|
57
|
+
- - '>='
|
62
58
|
- !ruby/object:Gem::Version
|
63
59
|
version: '0'
|
64
60
|
requirements: []
|
65
61
|
rubyforge_project:
|
66
|
-
rubygems_version:
|
62
|
+
rubygems_version: 2.0.14
|
67
63
|
signing_key:
|
68
|
-
specification_version:
|
64
|
+
specification_version: 4
|
69
65
|
summary: jquery_file_download-rails
|
70
66
|
test_files: []
|