jquery-rails-multipart-xhr 0.0.2 → 0.0.3

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 @@
1
+ global
@@ -1,8 +1,8 @@
1
1
  module Jquery
2
2
  module Rails
3
- JQUERY_MULTIPART_XHR_VERSION = "0.0.2"
3
+ JQUERY_MULTIPART_XHR_VERSION = "0.0.3"
4
4
  module MultipartXHR
5
- VERSION = "0.0.2"
5
+ VERSION = "0.0.3"
6
6
  end
7
7
  end
8
8
  end
@@ -32,11 +32,10 @@
32
32
  **/
33
33
  (function( $, undefined ){
34
34
 
35
- var jxhr = $.ajaxSettings.xhr,
36
- rails = $.rails;
35
+ var jxhr = $.ajaxSettings.xhr;
37
36
 
38
37
 
39
- $.extend(rails, {
38
+ $.extend($.rails, {
40
39
 
41
40
  // Enable / disable ajax file uploading.
42
41
  enableXHRUpload: true,
@@ -89,20 +88,20 @@
89
88
  // Actual upload handler
90
89
  //
91
90
  handleRemoteUpload: function( form, options ){
92
- var data = rails.buildMultipartPost( form );
91
+ var data = $.rails.buildMultipartPost( form );
93
92
  options.contentType = false;
94
93
  options.processData = false;
95
94
  options.data = data[0];
96
95
  options.context = form;
97
- rails.fire( form, 'ajax:upload:start', [ data[1] ] );
96
+ $.rails.fire( form, 'ajax:upload:start', [ data[1] ] );
98
97
  return $.ajax( options );
99
98
  }
100
99
 
101
100
  });
102
101
 
103
102
  // Explicitly disable XHR uploading if the browser doesn't support it.
104
- if( !rails.XHRUploadSupport() && !rails.fileApiSupport() ){
105
- rails.enableXHRUpload = false;
103
+ if( !$.rails.XHRUploadSupport() && !$.rails.fileApiSupport() ){
104
+ $.rails.enableXHRUpload = false;
106
105
  }
107
106
 
108
107
  // Recieves a progress event and returns an object representing the progress of the upload.
@@ -125,14 +124,18 @@
125
124
 
126
125
 
127
126
  function handle_files( form ){
128
- var oajax = rails.ajax;
127
+ var oajax = $.rails.ajax;
129
128
 
130
- if( rails.enableXHRUpload ){
131
- rails.ajax = function( options ){
132
- rails.handleRemoteUpload( $(form), options );
129
+ if( $.rails.enableXHRUpload === true ){
130
+ $.rails.ajax = function( options ){
131
+ $.rails.handleRemoteUpload( $(form), options );
133
132
  };
134
- rails.handleRemote( form );
135
- rails.ajax = oajax;
133
+
134
+ form.one('ajax:complete',
135
+ function(xhr, status){
136
+ $.rails.ajax = oajax;
137
+ });
138
+
136
139
  return false;
137
140
  }
138
141
  return true;
@@ -163,7 +166,7 @@
163
166
  });
164
167
 
165
168
 
166
- $(document).delegate(rails.formSubmitSelector, 'ajax:aborted:file', function(event) {
169
+ $(document).delegate($.rails.formSubmitSelector, 'ajax:aborted:file', function(event) {
167
170
  if (this == event.target)
168
171
  return handle_files($(this));
169
172
  });
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-rails-multipart-xhr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-08 00:00:00.000000000 Z
12
+ date: 2012-06-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -86,6 +86,7 @@ extensions: []
86
86
  extra_rdoc_files: []
87
87
  files:
88
88
  - .gitignore
89
+ - .rbenv-gemsets
89
90
  - Gemfile
90
91
  - README.md
91
92
  - Rakefile