fileupload-rails 0.0.1

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.
@@ -0,0 +1,171 @@
1
+ /*
2
+ * jQuery Iframe Transport Plugin 1.4
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2011, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /*jslint unparam: true, nomen: 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(['jquery'], factory);
20
+ } else {
21
+ // Browser globals:
22
+ factory(window.jQuery);
23
+ }
24
+ }(function ($) {
25
+ 'use strict';
26
+
27
+ // Helper variable to create unique names for the transport iframes:
28
+ var counter = 0;
29
+
30
+ // The iframe transport accepts three additional options:
31
+ // options.fileInput: a jQuery collection of file input fields
32
+ // options.paramName: the parameter name for the file form data,
33
+ // overrides the name property of the file input field(s),
34
+ // can be a string or an array of strings.
35
+ // options.formData: an array of objects with name and value properties,
36
+ // equivalent to the return data of .serializeArray(), e.g.:
37
+ // [{name: 'a', value: 1}, {name: 'b', value: 2}]
38
+ $.ajaxTransport('iframe', function (options) {
39
+ if (options.async && (options.type === 'POST' || options.type === 'GET')) {
40
+ var form,
41
+ iframe;
42
+ return {
43
+ send: function (_, completeCallback) {
44
+ form = $('<form style="display:none;"></form>');
45
+ // javascript:false as initial iframe src
46
+ // prevents warning popups on HTTPS in IE6.
47
+ // IE versions below IE8 cannot set the name property of
48
+ // elements that have already been added to the DOM,
49
+ // so we set the name along with the iframe HTML markup:
50
+ iframe = $(
51
+ '<iframe src="javascript:false;" name="iframe-transport-' +
52
+ (counter += 1) + '"></iframe>'
53
+ ).bind('load', function () {
54
+ var fileInputClones,
55
+ paramNames = $.isArray(options.paramName) ?
56
+ options.paramName : [options.paramName];
57
+ iframe
58
+ .unbind('load')
59
+ .bind('load', function () {
60
+ var response;
61
+ // Wrap in a try/catch block to catch exceptions thrown
62
+ // when trying to access cross-domain iframe contents:
63
+ try {
64
+ response = iframe.contents();
65
+ // Google Chrome and Firefox do not throw an
66
+ // exception when calling iframe.contents() on
67
+ // cross-domain requests, so we unify the response:
68
+ if (!response.length || !response[0].firstChild) {
69
+ throw new Error();
70
+ }
71
+ } catch (e) {
72
+ response = undefined;
73
+ }
74
+ // The complete callback returns the
75
+ // iframe content document as response object:
76
+ completeCallback(
77
+ 200,
78
+ 'success',
79
+ {'iframe': response}
80
+ );
81
+ // Fix for IE endless progress bar activity bug
82
+ // (happens on form submits to iframe targets):
83
+ $('<iframe src="javascript:false;"></iframe>')
84
+ .appendTo(form);
85
+ form.remove();
86
+ });
87
+ form
88
+ .prop('target', iframe.prop('name'))
89
+ .prop('action', options.url)
90
+ .prop('method', options.type);
91
+ if (options.formData) {
92
+ $.each(options.formData, function (index, field) {
93
+ $('<input type="hidden"/>')
94
+ .prop('name', field.name)
95
+ .val(field.value)
96
+ .appendTo(form);
97
+ });
98
+ }
99
+ if (options.fileInput && options.fileInput.length &&
100
+ options.type === 'POST') {
101
+ fileInputClones = options.fileInput.clone();
102
+ // Insert a clone for each file input field:
103
+ options.fileInput.after(function (index) {
104
+ return fileInputClones[index];
105
+ });
106
+ if (options.paramName) {
107
+ options.fileInput.each(function (index) {
108
+ $(this).prop(
109
+ 'name',
110
+ paramNames[index] || options.paramName
111
+ );
112
+ });
113
+ }
114
+ // Appending the file input fields to the hidden form
115
+ // removes them from their original location:
116
+ form
117
+ .append(options.fileInput)
118
+ .prop('enctype', 'multipart/form-data')
119
+ // enctype must be set as encoding for IE:
120
+ .prop('encoding', 'multipart/form-data');
121
+ }
122
+ form.submit();
123
+ // Insert the file input fields at their original location
124
+ // by replacing the clones with the originals:
125
+ if (fileInputClones && fileInputClones.length) {
126
+ options.fileInput.each(function (index, input) {
127
+ var clone = $(fileInputClones[index]);
128
+ $(input).prop('name', clone.prop('name'));
129
+ clone.replaceWith(input);
130
+ });
131
+ }
132
+ });
133
+ form.append(iframe).appendTo(document.body);
134
+ },
135
+ abort: function () {
136
+ if (iframe) {
137
+ // javascript:false as iframe src aborts the request
138
+ // and prevents warning popups on HTTPS in IE6.
139
+ // concat is used to avoid the "Script URL" JSLint error:
140
+ iframe
141
+ .unbind('load')
142
+ .prop('src', 'javascript'.concat(':false;'));
143
+ }
144
+ if (form) {
145
+ form.remove();
146
+ }
147
+ }
148
+ };
149
+ }
150
+ });
151
+
152
+ // The iframe transport returns the iframe content document as response.
153
+ // The following adds converters from iframe to text, json, html, and script:
154
+ $.ajaxSetup({
155
+ converters: {
156
+ 'iframe text': function (iframe) {
157
+ return $(iframe[0].body).text();
158
+ },
159
+ 'iframe json': function (iframe) {
160
+ return $.parseJSON($(iframe[0].body).text());
161
+ },
162
+ 'iframe html': function (iframe) {
163
+ return $(iframe[0].body).html();
164
+ },
165
+ 'iframe script': function (iframe) {
166
+ return $.globalEval($(iframe[0].body).text());
167
+ }
168
+ }
169
+ });
170
+
171
+ }));
@@ -0,0 +1,29 @@
1
+ /*
2
+ * jQuery File Upload Plugin Localization Example 6.5.1
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
+ /*global window */
13
+
14
+ window.locale = {
15
+ "fileupload": {
16
+ "errors": {
17
+ "maxFileSize": "File is too big",
18
+ "minFileSize": "File is too small",
19
+ "acceptFileTypes": "Filetype not allowed",
20
+ "maxNumberOfFiles": "Max number of files exceeded",
21
+ "uploadedBytes": "Uploaded bytes exceed file size",
22
+ "emptyResult": "Empty file upload result"
23
+ },
24
+ "error": "Error",
25
+ "start": "Start",
26
+ "cancel": "Cancel",
27
+ "destroy": "Delete"
28
+ }
29
+ };
@@ -0,0 +1,78 @@
1
+ /*
2
+ * jQuery File Upload Plugin JS Example 6.7
3
+ * https://github.com/blueimp/jQuery-File-Upload
4
+ *
5
+ * Copyright 2010, 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 $, window, document */
14
+
15
+ $(function () {
16
+ 'use strict';
17
+
18
+ // Initialize the jQuery File Upload widget:
19
+ $('#fileupload').fileupload();
20
+
21
+ // Enable iframe cross-domain access via redirect option:
22
+ $('#fileupload').fileupload(
23
+ 'option',
24
+ 'redirect',
25
+ window.location.href.replace(
26
+ /\/[^\/]*$/,
27
+ '/cors/result.html?%s'
28
+ )
29
+ );
30
+
31
+ if (window.location.hostname === 'blueimp.github.com') {
32
+ // Demo settings:
33
+ $('#fileupload').fileupload('option', {
34
+ url: '//jquery-file-upload.appspot.com/',
35
+ maxFileSize: 5000000,
36
+ acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
37
+ process: [
38
+ {
39
+ action: 'load',
40
+ fileTypes: /^image\/(gif|jpeg|png)$/,
41
+ maxFileSize: 20000000 // 20MB
42
+ },
43
+ {
44
+ action: 'resize',
45
+ maxWidth: 1440,
46
+ maxHeight: 900
47
+ },
48
+ {
49
+ action: 'save'
50
+ }
51
+ ]
52
+ });
53
+ // Upload server status check for browsers with CORS support:
54
+ if ($.support.cors) {
55
+ $.ajax({
56
+ url: '//jquery-file-upload.appspot.com/',
57
+ type: 'HEAD'
58
+ }).fail(function () {
59
+ $('<span class="alert alert-error"/>')
60
+ .text('Upload server currently unavailable - ' +
61
+ new Date())
62
+ .appendTo('#fileupload');
63
+ });
64
+ }
65
+ } else {
66
+ // Load existing files:
67
+ $('#fileupload').each(function () {
68
+ var that = this;
69
+ $.getJSON(this.action, function (result) {
70
+ if (result && result.length) {
71
+ $(that).fileupload('option', 'done')
72
+ .call(that, null, {result: result});
73
+ }
74
+ });
75
+ });
76
+ }
77
+
78
+ });
@@ -0,0 +1,84 @@
1
+ @charset 'UTF-8';
2
+ /*
3
+ * jQuery File Upload UI Plugin CSS 6.3
4
+ * https://github.com/blueimp/jQuery-File-Upload
5
+ *
6
+ * Copyright 2010, Sebastian Tschan
7
+ * https://blueimp.net
8
+ *
9
+ * Licensed under the MIT license:
10
+ * http://www.opensource.org/licenses/MIT
11
+ */
12
+
13
+ .fileinput-button {
14
+ position: relative;
15
+ overflow: hidden;
16
+ float: left;
17
+ margin-right: 4px;
18
+ }
19
+ .fileinput-button input {
20
+ position: absolute;
21
+ top: 0;
22
+ right: 0;
23
+ margin: 0;
24
+ border: solid transparent;
25
+ border-width: 0 0 100px 200px;
26
+ opacity: 0;
27
+ filter: alpha(opacity=0);
28
+ -moz-transform: translate(-300px, 0) scale(4);
29
+ direction: ltr;
30
+ cursor: pointer;
31
+ }
32
+ .fileupload-buttonbar .btn,
33
+ .fileupload-buttonbar .toggle {
34
+ margin-bottom: 5px;
35
+ }
36
+ .files .progress {
37
+ width: 200px;
38
+ }
39
+ .progress-animated .bar {
40
+ background: url(../img/progressbar.gif) !important;
41
+ filter: none;
42
+ }
43
+ .fileupload-loading {
44
+ position: absolute;
45
+ left: 50%;
46
+ width: 128px;
47
+ height: 128px;
48
+ background: url(../img/loading.gif) center no-repeat;
49
+ display: none;
50
+ }
51
+ .fileupload-processing .fileupload-loading {
52
+ display: block;
53
+ }
54
+
55
+ /* Fix for IE 6: */
56
+ *html .fileinput-button {
57
+ line-height: 22px;
58
+ margin: 1px -3px 0 0;
59
+ }
60
+
61
+ /* Fix for IE 7: */
62
+ *+html .fileinput-button {
63
+ margin: 1px 0 0 0;
64
+ }
65
+
66
+ @media (max-width: 480px) {
67
+ .files .btn span {
68
+ display: none;
69
+ }
70
+ .files .preview * {
71
+ width: 40px;
72
+ }
73
+ .files .name * {
74
+ width: 80px;
75
+ display: inline-block;
76
+ word-wrap: break-word;
77
+ }
78
+ .files .progress {
79
+ width: 20px;
80
+ }
81
+ .files .delete {
82
+ width: 60px;
83
+ }
84
+ }
@@ -0,0 +1,15 @@
1
+ @charset 'UTF-8';
2
+ /*
3
+ * jQuery File Upload Plugin CSS Example 1.0
4
+ * https://github.com/blueimp/jQuery-File-Upload
5
+ *
6
+ * Copyright 2012, Sebastian Tschan
7
+ * https://blueimp.net
8
+ *
9
+ * Licensed under the MIT license:
10
+ * http://www.opensource.org/licenses/MIT
11
+ */
12
+
13
+ body{
14
+ padding-top: 60px;
15
+ }
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fileupload-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Michael Schmitz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-25 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: jQuery-File-Upload for Rails
15
+ email:
16
+ - lydianblues@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - INSTALL.sh
24
+ - LICENSE
25
+ - README.md
26
+ - Rakefile
27
+ - fileupload-rails.gemspec
28
+ - lib/fileupload-rails.rb
29
+ - lib/fileupload-rails/rails.rb
30
+ - lib/fileupload-rails/version.rb
31
+ - vendor/assets/images/loading.gif
32
+ - vendor/assets/images/progressbar.gif
33
+ - vendor/assets/javascripts/cors/jquery.postmessage-transport.js
34
+ - vendor/assets/javascripts/cors/jquery.xdr-transport.js
35
+ - vendor/assets/javascripts/jquery.fileupload-fp.js
36
+ - vendor/assets/javascripts/jquery.fileupload-ui.js
37
+ - vendor/assets/javascripts/jquery.fileupload.js
38
+ - vendor/assets/javascripts/jquery.iframe-transport.js
39
+ - vendor/assets/javascripts/locale.js
40
+ - vendor/assets/javascripts/main.js
41
+ - vendor/assets/stylesheets/jquery.fileupload-ui.css
42
+ - vendor/assets/stylesheets/style.css
43
+ homepage: ''
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 1.8.23
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Package the jQuery-File-Upload javasscripts for Rails
67
+ test_files: []