|
4 | 4 |
|
5 | 5 | jquery-fileupload-rails is a library that integrates jQuery File Upload for Rails 3.1 Asset Pipeline (Rails 3.2 supported).
|
6 | 6 |
|
7 |
| -## Plugin versions |
| 7 | +## Plugin versions (7-march-2014) |
8 | 8 |
|
9 |
| -* jQuery File Upload User Interface Plugin 6.11 |
10 |
| -* jQuery File Upload Plugin 5.19.3 |
11 |
| -* jQuery UI Widget 1.9.1+amd |
| 9 | +* jQuery File Upload User Interface Plugin 8.7.1 |
| 10 | +* jQuery File Upload Plugin 5.40.1 |
| 11 | +* jQuery UI Widget 1.10.4+amd |
12 | 12 |
|
13 | 13 | ## Installing Gem
|
14 | 14 |
|
15 |
| - gem "jquery-fileupload-rails" |
| 15 | + gem "jquery-fileupload-rails", :git => 'git://github.com/Johaned/jquery-fileupload-rails' |
16 | 16 |
|
17 | 17 | ## Using the javascripts
|
18 | 18 |
|
@@ -40,21 +40,63 @@ If you only need the basic files, just add the code below to your application.js
|
40 | 40 |
|
41 | 41 | The basic setup only includes the following files:
|
42 | 42 |
|
43 |
| - //= require jquery-fileupload/vendor/jquery.ui.widget |
44 |
| - //= require jquery-fileupload/jquery.iframe-transport |
45 |
| - //= require jquery-fileupload/jquery.fileupload |
| 43 | + //=require jquery-fileupload/vendor/jquery.ui.widget |
| 44 | + //=require jquery-fileupload/jquery.iframe-transport |
| 45 | + //=require jquery-fileupload/jquery.fileupload |
| 46 | + //=require jquery-fileupload/locale |
46 | 47 |
|
47 | 48 | ## Using the stylesheet
|
48 | 49 |
|
49 | 50 | Require the stylesheet file to app/assets/stylesheets/application.css
|
50 | 51 |
|
51 | 52 | *= require jquery.fileupload-ui
|
| 53 | + |
| 54 | +## Example of Use (Rails 3.1 - RailsCast 381 Based) |
| 55 | + |
| 56 | +#### Painting Index Page |
| 57 | + <h1>Painting Gallery</h1> |
| 58 | + |
| 59 | + <div id="paintings"> |
| 60 | + <%= render @paintings %> |
| 61 | + </div> |
| 62 | + <div class="clear"></div> |
| 63 | + |
| 64 | + <%= form_for Painting.new do |f| %> |
| 65 | + <%= f.label :image, "Upload paintings:" %> |
| 66 | + <%= f.file_field :image, name: "painting[image]" %> |
| 67 | + <% end %> |
| 68 | + |
| 69 | + <div id="progress"> |
| 70 | + <div class="bar" style="width: 0%;"></div> |
| 71 | + </div> |
| 72 | + |
| 73 | +#### paintings.js.coffee |
| 74 | + |
| 75 | + $ -> |
| 76 | + if($.browser.msie && !$.support.xhrFileUpload)# works fine with jquery 1.8.3, in jquery 1.10 it does not work |
| 77 | + force_iframe = true |
| 78 | + data_type = 'iframe' |
| 79 | + else |
| 80 | + force_iframe = false |
| 81 | + data_type = 'script' |
| 82 | + $('#new_painting').fileupload |
| 83 | + dataType: data_type |
| 84 | + forceIframeTransport: force_iframe |
| 85 | + add: (e, data) -> |
| 86 | + data.context = $("<p/>").text("Uploading...").appendTo(document.body) |
| 87 | + data.submit() |
| 88 | + done: (e, data) -> |
| 89 | + data.context.text "Upload finished." |
| 90 | + progressall: (e, data) -> |
| 91 | + progress = parseInt(data.loaded / data.total * 100, 10) |
| 92 | + $("#progress .bar").css "width", progress + "%" |
| 93 | + return |
52 | 94 |
|
53 | 95 | ## Thanks
|
54 | 96 | Thanks to [Sebastian Tschan](https://github.com/blueimp) for writing an awesome file upload plugin.
|
55 | 97 |
|
56 | 98 | ## License
|
57 |
| -Copyright (c) 2012 Tors Dalid |
| 99 | +Copyright (c) 2014 Tors Dalid |
58 | 100 |
|
59 | 101 | 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:
|
60 | 102 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
0 commit comments