Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit f9bfb4f9d33942e47b69e9b5c5d30ee1799c16db @tors committed Mar 12, 2012
@@ -0,0 +1,4 @@
+*.gem
+.bundle
+Gemfile.lock
+pkg/*
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+# Specify your gem's dependencies in jquery-fileupload-rails.gemspec
+gemspec
@@ -0,0 +1,47 @@
+# jQuery File Upload for Rails 3.1 Asset Pipeline
+
+[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.
+
+jquery-fileupload-rails is a library that integrates jQuery File Upload for Rails 3.1 Asset Pipeline.
+
+jquery-fileupload-rails is currently using jQuery-File-Plugin version 6.5.5.
+
+## Installing Gem
+
+ gem "jquery-fileupload-rails"
+
+## Using the javascripts
+
+Require jquery-fileupload in your app/assets/application.js file.
+
+ //= require jquery-fileupload
+
+The snippet above will add the following js files to your mainfest file.
+
+ //=require jquery-fileupload/vendor/jquery.ui.widget
+ //=require jquery-fileupload/jquery.iframe-transport
+ //=require jquery-fileupload/jquery.fileupload
+ //=require jquery-fileupload/jquery.fileupload-ip
+ //=require jquery-fileupload/jquery.fileupload-ui
+ //=require jquery-fileupload/locale
+
+## Using the stylesheet
+
+Require the stylesheet file to app/assets/stylesheets/application.css
+
+ *= require jquery.fileupload-ui
+
+## Changelog
+<ul>
+ <li>Released gem v.0.1.0</li>
+</ul>
+
+## Thanks
+Thanks [Sebastian Tschan](https://github.com/blueimp) for writing an awesome file upload plugin [jQuery-File-Plugin](https://github.com/blueimp/jQuery-File-Upload)
+
+## License
+Copyright (c) 2012 Tors Dalid
+
+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:
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+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.
@@ -0,0 +1,15 @@
+#!/usr/bin/env rake
+require 'bundler'
+Bundler::GemHelper.install_tasks
+
+desc "Bundle the gem"
+task :bundle do
+ sh('bundle install')
+ sh 'gem build *.gemspec'
+ sh 'gem install *.gem'
+ sh 'rm *.gem'
+end
+
+task(:default).clear
+task :default => :bundle
+
@@ -0,0 +1,24 @@
+# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+require "jquery/fileupload/rails/version"
+
+Gem::Specification.new do |s|
+ s.name = "jquery-fileupload-rails"
+ s.version = JQuery::FileUpload::Rails::VERSION
+ s.authors = ["Tors Dalid"]
+ s.email = ["cletedalid@gmail.com"]
+ s.homepage = "https://github.com/tors/jquery-fileupload-rails"
+ s.summary = %q{jQuery File Upload for Rails 3.1 Asset Pipeline}
+ s.description = %q{jQuery File Upload by Sebastian Tschan integrated for Rails 3.1 Asset Pipeline}
+
+ s.rubyforge_project = "jquery-fileupload-rails"
+
+ s.files = Dir["lib/**/*"] + Dir["vendor/**/*"] + ["Rakefile", "README.md"]
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
+
+ s.add_dependency 'railties', '>= 3.1'
+ s.add_dependency 'actionpack', '>= 3.1'
+ s.add_development_dependency 'rails', '>= 3.1'
+end
@@ -0,0 +1,8 @@
+module JQuery
+ module FileUpload
+ module Rails
+ require 'jquery/fileupload/rails/engine' if defined?(Rails)
+ end
+ end
+end
+require 'jquery/fileupload/rails/upload' if defined?(Rails)
@@ -0,0 +1,8 @@
+module JQuery
+ module FileUpload
+ module Rails
+ class Engine < ::Rails::Engine
+ end
+ end
+ end
+end
@@ -0,0 +1,2 @@
+require "jquery/fileupload/rails/engine"
+require "jquery/fileupload/rails/version"
@@ -0,0 +1,7 @@
+module JQuery
+ module FileUpload
+ module Rails
+ VERSION = "0.0.1"
+ end
+ end
+end
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,6 @@
+//=require jquery-fileupload/vendor/jquery.ui.widget
+//=require jquery-fileupload/jquery.iframe-transport
+//=require jquery-fileupload/jquery.fileupload
+//=require jquery-fileupload/jquery.fileupload-ip
+//=require jquery-fileupload/jquery.fileupload-ui
+//=require jquery-fileupload/locale
@@ -0,0 +1,117 @@
+/*
+ * jQuery postMessage Transport Plugin 1.1
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2011, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ */
+
+/*jslint unparam: true, nomen: true */
+/*global define, window, document */
+
+(function (factory) {
+ 'use strict';
+ if (typeof define === 'function' && define.amd) {
+ // Register as an anonymous AMD module:
+ define(['jquery'], factory);
+ } else {
+ // Browser globals:
+ factory(window.jQuery);
+ }
+}(function ($) {
+ 'use strict';
+
+ var counter = 0,
+ names = [
+ 'accepts',
+ 'cache',
+ 'contents',
+ 'contentType',
+ 'crossDomain',
+ 'data',
+ 'dataType',
+ 'headers',
+ 'ifModified',
+ 'mimeType',
+ 'password',
+ 'processData',
+ 'timeout',
+ 'traditional',
+ 'type',
+ 'url',
+ 'username'
+ ],
+ convert = function (p) {
+ return p;
+ };
+
+ $.ajaxSetup({
+ converters: {
+ 'postmessage text': convert,
+ 'postmessage json': convert,
+ 'postmessage html': convert
+ }
+ });
+
+ $.ajaxTransport('postmessage', function (options) {
+ if (options.postMessage && window.postMessage) {
+ var iframe,
+ loc = $('<a>').prop('href', options.postMessage)[0],
+ target = loc.protocol + '//' + loc.host,
+ xhrUpload = options.xhr().upload;
+ return {
+ send: function (_, completeCallback) {
+ var message = {
+ id: 'postmessage-transport-' + (counter += 1)
+ },
+ eventName = 'message.' + message.id;
+ iframe = $(
+ '<iframe style="display:none;" src="' +
+ options.postMessage + '" name="' +
+ message.id + '"></iframe>'
+ ).bind('load', function () {
+ $.each(names, function (i, name) {
+ message[name] = options[name];
+ });
+ message.dataType = message.dataType.replace('postmessage ', '');
+ $(window).bind(eventName, function (e) {
+ e = e.originalEvent;
+ var data = e.data,
+ ev;
+ if (e.origin === target && data.id === message.id) {
+ if (data.type === 'progress') {
+ ev = document.createEvent('Event');
+ ev.initEvent(data.type, false, true);
+ $.extend(ev, data);
+ xhrUpload.dispatchEvent(ev);
+ } else {
+ completeCallback(
+ data.status,
+ data.statusText,
+ {postmessage: data.result},
+ data.headers
+ );
+ iframe.remove();
+ $(window).unbind(eventName);
+ }
+ }
+ });
+ iframe[0].contentWindow.postMessage(
+ message,
+ target
+ );
+ }).appendTo(document.body);
+ },
+ abort: function () {
+ if (iframe) {
+ iframe.remove();
+ }
+ }
+ };
+ }
+ });
+
+}));
@@ -0,0 +1,85 @@
+/*
+ * jQuery XDomainRequest Transport Plugin 1.1.1
+ * https://github.com/blueimp/jQuery-File-Upload
+ *
+ * Copyright 2011, Sebastian Tschan
+ * https://blueimp.net
+ *
+ * Licensed under the MIT license:
+ * http://www.opensource.org/licenses/MIT
+ *
+ * Based on Julian Aubourg's ajaxHooks xdr.js:
+ * https://github.com/jaubourg/ajaxHooks/
+ */
+
+/*jslint unparam: true */
+/*global define, window, XDomainRequest */
+
+(function (factory) {
+ 'use strict';
+ if (typeof define === 'function' && define.amd) {
+ // Register as an anonymous AMD module:
+ define(['jquery'], factory);
+ } else {
+ // Browser globals:
+ factory(window.jQuery);
+ }
+}(function ($) {
+ 'use strict';
+ if (window.XDomainRequest && $.ajaxSettings.xhr().withCredentials === undefined) {
+ $.ajaxTransport(function (s) {
+ if (s.crossDomain && s.async) {
+ if (s.timeout) {
+ s.xdrTimeout = s.timeout;
+ delete s.timeout;
+ }
+ var xdr;
+ return {
+ send: function (headers, completeCallback) {
+ function callback(status, statusText, responses, responseHeaders) {
+ xdr.onload = xdr.onerror = xdr.ontimeout = $.noop;
+ xdr = null;
+ completeCallback(status, statusText, responses, responseHeaders);
+ }
+ xdr = new XDomainRequest();
+ // XDomainRequest only supports GET and POST:
+ if (s.type === 'DELETE') {
+ s.url = s.url + (/\?/.test(s.url) ? '&' : '?') +
+ '_method=DELETE';
+ s.type = 'POST';
+ } else if (s.type === 'PUT') {
+ s.url = s.url + (/\?/.test(s.url) ? '&' : '?') +
+ '_method=PUT';
+ s.type = 'POST';
+ }
+ xdr.open(s.type, s.url);
+ xdr.onload = function () {
+ callback(
+ 200,
+ 'OK',
+ {text: xdr.responseText},
+ 'Content-Type: ' + xdr.contentType
+ );
+ };
+ xdr.onerror = function () {
+ callback(404, 'Not Found');
+ };
+ if (s.xdrTimeout) {
+ xdr.ontimeout = function () {
+ callback(0, 'timeout');
+ };
+ xdr.timeout = s.xdrTimeout;
+ }
+ xdr.send((s.hasContent && s.data) || null);
+ },
+ abort: function () {
+ if (xdr) {
+ xdr.onerror = $.noop();
+ xdr.abort();
+ }
+ }
+ };
+ }
+ });
+ }
+}));
Oops, something went wrong.

0 comments on commit f9bfb4f

Please sign in to comment.