remotipart 0.3.1 → 0.3.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.
- data/README.rdoc +23 -5
- data/lib/generators/templates/jquery.remotipart.js +24 -14
- data/remotipart.gemspec +2 -2
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -9,20 +9,36 @@ This gem augments the native Rails jQuery remote form function enabling asynchro
|
|
9
9
|
* {jQuery}[http://jquery.com]
|
10
10
|
* {The jquery-rails gem}[http://rubygems.org/gems/jquery-rails], which really just installs {the Rails jQuery driver (jquery-ujs)}[https://github.com/rails/jquery-ujs]
|
11
11
|
|
12
|
-
<b>
|
12
|
+
<b>SEE VERSION COMPATIBILITY BELOW TO MATCH THE CORRECT VERSION OF REMOTIPART.JS TO YOUR VERSION OF RAILS.JS</b>
|
13
13
|
* {The jQuery Form plugin}[http://jquery.malsup.com/form/]
|
14
14
|
|
15
|
+
== Version Compatibility
|
16
|
+
|
17
|
+
<table><tr><th>Remotipart version</th><th>Compatible with rails.js version</th></tr>
|
18
|
+
<tr><td></td><td></td></tr>
|
19
|
+
<tr><td></td><td></td></tr>
|
20
|
+
<tr><td></td><td></td></tr>
|
21
|
+
<tr><td></td><td></td></tr>
|
22
|
+
</table>
|
23
|
+
|
15
24
|
== Installation
|
16
25
|
|
17
|
-
<b>Prerequisite: Make sure you have a supported jquery-ujs (rails.js) version
|
26
|
+
<b>Prerequisite: Make sure you have a supported jquery-ujs (rails.js) version.</b>
|
27
|
+
|
28
|
+
<b>To be certain, replace public/javascripts/rails.js with {this version}[https://github.com/rails/jquery-ujs/raw/51272c68714748420d8c35984b3e2532ab14f748/src/rails.js] of rails.js. Alternatively, follow {these instructions}[https://github.com/formasfunction/remotipart/wiki/Getting-Remotipart-to-work-with-latest-jquery-ujs] to get Remotipart working with the latest jquery-ujs.</b>
|
18
29
|
|
19
30
|
1. Install the Remotipart gem
|
31
|
+
* Add this line to your GEMFILE
|
32
|
+
|
33
|
+
gem 'remotipart'
|
20
34
|
|
21
|
-
|
35
|
+
* And run
|
36
|
+
|
37
|
+
bundle install
|
22
38
|
|
23
39
|
2. Run the Remotipart generator to add jquery.remotipart.js to public/javascripts/
|
24
40
|
|
25
|
-
|
41
|
+
rails g remotipart
|
26
42
|
|
27
43
|
3. Add the Javascript files for jQuery, the Rails jQuery driver, jQuery Form plugin, and Remotipart to your template, making sure to include jquery.remotipart.js *after* jQuery and the Rails jQuery driver
|
28
44
|
|
@@ -85,7 +101,9 @@ create.js.erb
|
|
85
101
|
<% end %>
|
86
102
|
|
87
103
|
== Note on Patches/Pull Requests
|
88
|
-
|
104
|
+
|
105
|
+
<b>If you have a general improvement, optimization, or refactoring, please {read this first}[https://github.com/formasfunction/remotipart/wiki/Refactoring-and-Improving-Remotipart].</b>
|
106
|
+
|
89
107
|
* Fork the project.
|
90
108
|
* Make your feature addition or bug fix.
|
91
109
|
* Add tests for it. This is important so I don't break it in a
|
@@ -1,4 +1,9 @@
|
|
1
1
|
(function ($) {
|
2
|
+
function fire(obj, name, data) {
|
3
|
+
var event = new $.Event(name);
|
4
|
+
obj.trigger(event, data);
|
5
|
+
return event.result !== false;
|
6
|
+
}
|
2
7
|
$.fn.extend({
|
3
8
|
/**
|
4
9
|
* Handles execution of remote calls involving file uploads, firing overridable events along the way
|
@@ -22,7 +27,6 @@
|
|
22
27
|
}))
|
23
28
|
.data('remotipartSubmitted', dataType);
|
24
29
|
|
25
|
-
if (el.triggerAndReturn('ajax:before')) {
|
26
30
|
if (dataType == 'script') {
|
27
31
|
url = url.split('?'); // split on GET params
|
28
32
|
if(url[0].substr(-3) != '.js') url[0] += '.js'; // force rails to respond to respond to the request with :format = js
|
@@ -32,9 +36,14 @@
|
|
32
36
|
el.ajaxSubmit({
|
33
37
|
url: url,
|
34
38
|
dataType: dataType,
|
35
|
-
beforeSend: function (xhr) {
|
36
|
-
|
37
|
-
|
39
|
+
beforeSend: function (xhr, settings) {
|
40
|
+
if (settings.dataType === undefined) {
|
41
|
+
xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
|
42
|
+
}
|
43
|
+
var proceed = fire(el, 'ajax:beforeSend', [xhr, settings, true]);
|
44
|
+
if (proceed) { el.trigger('ajax:loading', [xhr]); }
|
45
|
+
return proceed;
|
46
|
+
},
|
38
47
|
success: function (data, status, xhr) {
|
39
48
|
el.trigger('ajax:success', [data, status, xhr]);
|
40
49
|
},
|
@@ -42,21 +51,22 @@
|
|
42
51
|
el.trigger('ajax:complete', xhr);
|
43
52
|
},
|
44
53
|
error: function (xhr, status, error) {
|
45
|
-
el.trigger('ajax:failure', [xhr, status, error]);
|
54
|
+
el.trigger('ajax:failure ajax:error', [xhr, status, error]);
|
46
55
|
}
|
47
56
|
});
|
48
57
|
}
|
49
58
|
|
50
59
|
el.trigger('ajax:after');
|
51
|
-
}
|
52
|
-
},
|
53
|
-
_callRemote: $.fn.callRemote, //store the original rails callRemote
|
54
|
-
callRemote: function(){ //override the rails callRemote and check for a file input
|
55
|
-
if(this.find('input:file').length){
|
56
|
-
this.callRemotipart();
|
57
|
-
} else {
|
58
|
-
this._callRemote();
|
59
|
-
}
|
60
60
|
}
|
61
61
|
});
|
62
|
+
|
63
|
+
$('form[data-remote]').live('ajax:beforeSend', function (evt, xhr, settings, remotipart) {
|
64
|
+
|
65
|
+
if (!remotipart && $(this).find('input:file').length) {
|
66
|
+
$(this).callRemotipart();
|
67
|
+
return false;
|
68
|
+
}
|
69
|
+
|
70
|
+
return true;
|
71
|
+
});
|
62
72
|
})(jQuery);
|
data/remotipart.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{remotipart}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Greg Leppert", "Steve Schwartz"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-05-01}
|
13
13
|
s.description = %q{Remotipart is a Ruby on Rails gem enabling remote multipart forms (AJAX style file uploads) with jQuery.
|
14
14
|
This gem augments the native Rails jQuery remote form function enabling asynchronous file uploads with little to no modification to your application.
|
15
15
|
It requires jQuery (http://jquery.com), the Rails jQuery driver (http://github.com/rails/jquery-ujs), and the jQuery Form plugin (http://jquery.malsup.com/form/).
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: remotipart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Greg Leppert
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-05-01 00:00:00 -04:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|