Skip to content

Commit f9bfb4f

Browse files
committed
first commit
0 parents  commit f9bfb4f

21 files changed

+2524
-0
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.gem
2+
.bundle
3+
Gemfile.lock
4+
pkg/*

Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source "http://rubygems.org"
2+
3+
# Specify your gem's dependencies in jquery-fileupload-rails.gemspec
4+
gemspec

README.md

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# jQuery File Upload for Rails 3.1 Asset Pipeline
2+
3+
[jQuery-File-Plugin](https://github.com/blueimp/jQuery-File-Upload) is a file upload plugin written by [Sebastian Tschan](https://github.com/blueimp). jQuery File Upload features multiple file selection, drag&drop support, progress bars and preview images for jQuery. Supports cross-domain, chunked and resumable file uploads and client-side image resizing.
4+
5+
jquery-fileupload-rails is a library that integrates jQuery File Upload for Rails 3.1 Asset Pipeline.
6+
7+
jquery-fileupload-rails is currently using jQuery-File-Plugin version 6.5.5.
8+
9+
## Installing Gem
10+
11+
gem "jquery-fileupload-rails"
12+
13+
## Using the javascripts
14+
15+
Require jquery-fileupload in your app/assets/application.js file.
16+
17+
//= require jquery-fileupload
18+
19+
The snippet above will add the following js files to your mainfest file.
20+
21+
//=require jquery-fileupload/vendor/jquery.ui.widget
22+
//=require jquery-fileupload/jquery.iframe-transport
23+
//=require jquery-fileupload/jquery.fileupload
24+
//=require jquery-fileupload/jquery.fileupload-ip
25+
//=require jquery-fileupload/jquery.fileupload-ui
26+
//=require jquery-fileupload/locale
27+
28+
## Using the stylesheet
29+
30+
Require the stylesheet file to app/assets/stylesheets/application.css
31+
32+
*= require jquery.fileupload-ui
33+
34+
## Changelog
35+
<ul>
36+
<li>Released gem v.0.1.0</li>
37+
</ul>
38+
39+
## Thanks
40+
Thanks [Sebastian Tschan](https://github.com/blueimp) for writing an awesome file upload plugin [jQuery-File-Plugin](https://github.com/blueimp/jQuery-File-Upload)
41+
42+
## License
43+
Copyright (c) 2012 Tors Dalid
44+
45+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
46+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
47+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Rakefile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env rake
2+
require 'bundler'
3+
Bundler::GemHelper.install_tasks
4+
5+
desc "Bundle the gem"
6+
task :bundle do
7+
sh('bundle install')
8+
sh 'gem build *.gemspec'
9+
sh 'gem install *.gem'
10+
sh 'rm *.gem'
11+
end
12+
13+
task(:default).clear
14+
task :default => :bundle
15+

jquery-fileupload-rails.gemspec

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- encoding: utf-8 -*-
2+
$:.push File.expand_path("../lib", __FILE__)
3+
require "jquery/fileupload/rails/version"
4+
5+
Gem::Specification.new do |s|
6+
s.name = "jquery-fileupload-rails"
7+
s.version = JQuery::FileUpload::Rails::VERSION
8+
s.authors = ["Tors Dalid"]
9+
s.email = ["cletedalid@gmail.com"]
10+
s.homepage = "https://github.com/tors/jquery-fileupload-rails"
11+
s.summary = %q{jQuery File Upload for Rails 3.1 Asset Pipeline}
12+
s.description = %q{jQuery File Upload by Sebastian Tschan integrated for Rails 3.1 Asset Pipeline}
13+
14+
s.rubyforge_project = "jquery-fileupload-rails"
15+
16+
s.files = Dir["lib/**/*"] + Dir["vendor/**/*"] + ["Rakefile", "README.md"]
17+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19+
s.require_paths = ["lib"]
20+
21+
s.add_dependency 'railties', '>= 3.1'
22+
s.add_dependency 'actionpack', '>= 3.1'
23+
s.add_development_dependency 'rails', '>= 3.1'
24+
end

lib/jquery-fileupload-rails.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module JQuery
2+
module FileUpload
3+
module Rails
4+
require 'jquery/fileupload/rails/engine' if defined?(Rails)
5+
end
6+
end
7+
end
8+
require 'jquery/fileupload/rails/upload' if defined?(Rails)

lib/jquery/fileupload/rails/engine.rb

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module JQuery
2+
module FileUpload
3+
module Rails
4+
class Engine < ::Rails::Engine
5+
end
6+
end
7+
end
8+
end

lib/jquery/fileupload/rails/upload.rb

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require "jquery/fileupload/rails/engine"
2+
require "jquery/fileupload/rails/version"
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module JQuery
2+
module FileUpload
3+
module Rails
4+
VERSION = "0.0.1"
5+
end
6+
end
7+
end

vendor/assets/images/loading.gif

3.81 KB
Loading

vendor/assets/images/progressbar.gif

3.25 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//=require jquery-fileupload/vendor/jquery.ui.widget
2+
//=require jquery-fileupload/jquery.iframe-transport
3+
//=require jquery-fileupload/jquery.fileupload
4+
//=require jquery-fileupload/jquery.fileupload-ip
5+
//=require jquery-fileupload/jquery.fileupload-ui
6+
//=require jquery-fileupload/locale
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* jQuery postMessage Transport Plugin 1.1
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+
var counter = 0,
28+
names = [
29+
'accepts',
30+
'cache',
31+
'contents',
32+
'contentType',
33+
'crossDomain',
34+
'data',
35+
'dataType',
36+
'headers',
37+
'ifModified',
38+
'mimeType',
39+
'password',
40+
'processData',
41+
'timeout',
42+
'traditional',
43+
'type',
44+
'url',
45+
'username'
46+
],
47+
convert = function (p) {
48+
return p;
49+
};
50+
51+
$.ajaxSetup({
52+
converters: {
53+
'postmessage text': convert,
54+
'postmessage json': convert,
55+
'postmessage html': convert
56+
}
57+
});
58+
59+
$.ajaxTransport('postmessage', function (options) {
60+
if (options.postMessage && window.postMessage) {
61+
var iframe,
62+
loc = $('<a>').prop('href', options.postMessage)[0],
63+
target = loc.protocol + '//' + loc.host,
64+
xhrUpload = options.xhr().upload;
65+
return {
66+
send: function (_, completeCallback) {
67+
var message = {
68+
id: 'postmessage-transport-' + (counter += 1)
69+
},
70+
eventName = 'message.' + message.id;
71+
iframe = $(
72+
'<iframe style="display:none;" src="' +
73+
options.postMessage + '" name="' +
74+
message.id + '"></iframe>'
75+
).bind('load', function () {
76+
$.each(names, function (i, name) {
77+
message[name] = options[name];
78+
});
79+
message.dataType = message.dataType.replace('postmessage ', '');
80+
$(window).bind(eventName, function (e) {
81+
e = e.originalEvent;
82+
var data = e.data,
83+
ev;
84+
if (e.origin === target && data.id === message.id) {
85+
if (data.type === 'progress') {
86+
ev = document.createEvent('Event');
87+
ev.initEvent(data.type, false, true);
88+
$.extend(ev, data);
89+
xhrUpload.dispatchEvent(ev);
90+
} else {
91+
completeCallback(
92+
data.status,
93+
data.statusText,
94+
{postmessage: data.result},
95+
data.headers
96+
);
97+
iframe.remove();
98+
$(window).unbind(eventName);
99+
}
100+
}
101+
});
102+
iframe[0].contentWindow.postMessage(
103+
message,
104+
target
105+
);
106+
}).appendTo(document.body);
107+
},
108+
abort: function () {
109+
if (iframe) {
110+
iframe.remove();
111+
}
112+
}
113+
};
114+
}
115+
});
116+
117+
}));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* jQuery XDomainRequest Transport Plugin 1.1.1
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+
* Based on Julian Aubourg's ajaxHooks xdr.js:
12+
* https://github.com/jaubourg/ajaxHooks/
13+
*/
14+
15+
/*jslint unparam: true */
16+
/*global define, window, XDomainRequest */
17+
18+
(function (factory) {
19+
'use strict';
20+
if (typeof define === 'function' && define.amd) {
21+
// Register as an anonymous AMD module:
22+
define(['jquery'], factory);
23+
} else {
24+
// Browser globals:
25+
factory(window.jQuery);
26+
}
27+
}(function ($) {
28+
'use strict';
29+
if (window.XDomainRequest && $.ajaxSettings.xhr().withCredentials === undefined) {
30+
$.ajaxTransport(function (s) {
31+
if (s.crossDomain && s.async) {
32+
if (s.timeout) {
33+
s.xdrTimeout = s.timeout;
34+
delete s.timeout;
35+
}
36+
var xdr;
37+
return {
38+
send: function (headers, completeCallback) {
39+
function callback(status, statusText, responses, responseHeaders) {
40+
xdr.onload = xdr.onerror = xdr.ontimeout = $.noop;
41+
xdr = null;
42+
completeCallback(status, statusText, responses, responseHeaders);
43+
}
44+
xdr = new XDomainRequest();
45+
// XDomainRequest only supports GET and POST:
46+
if (s.type === 'DELETE') {
47+
s.url = s.url + (/\?/.test(s.url) ? '&' : '?') +
48+
'_method=DELETE';
49+
s.type = 'POST';
50+
} else if (s.type === 'PUT') {
51+
s.url = s.url + (/\?/.test(s.url) ? '&' : '?') +
52+
'_method=PUT';
53+
s.type = 'POST';
54+
}
55+
xdr.open(s.type, s.url);
56+
xdr.onload = function () {
57+
callback(
58+
200,
59+
'OK',
60+
{text: xdr.responseText},
61+
'Content-Type: ' + xdr.contentType
62+
);
63+
};
64+
xdr.onerror = function () {
65+
callback(404, 'Not Found');
66+
};
67+
if (s.xdrTimeout) {
68+
xdr.ontimeout = function () {
69+
callback(0, 'timeout');
70+
};
71+
xdr.timeout = s.xdrTimeout;
72+
}
73+
xdr.send((s.hasContent && s.data) || null);
74+
},
75+
abort: function () {
76+
if (xdr) {
77+
xdr.onerror = $.noop();
78+
xdr.abort();
79+
}
80+
}
81+
};
82+
}
83+
});
84+
}
85+
}));

0 commit comments

Comments
 (0)