turbolinks-form 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/app/assets/javascripts/turbolinks-form-core.js +16 -2
- data/lib/turbolinks/form/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25d8fc8571af4909c7144b3b47e2bf3ba57b19200f31955fde3694842a2e9acb
|
4
|
+
data.tar.gz: c2962e4b8b08b88a4c656d2ba33c12546dd54ecc74f4f98091a57e2e05850ce7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9915051440cdfadda16263d3bf0354fb92a956e9edbdda53907e005344890393efbec6ca0ac3f3c644b657beb42553193eafa1f7c979ea183a6068e51ffc991b
|
7
|
+
data.tar.gz: 7fef86f46fc2a937e16f82b030157cc77b566b4c62f5e53ff7d0888cfbebb4bf1b6a7fd252d5e70c07d30e3849fe015a1c45e81cbfb5d01f126a4f039f618ff2
|
data/README.md
CHANGED
@@ -97,7 +97,7 @@ Turbolinks-form will execute any `<script>` tags that the body of the response c
|
|
97
97
|
Turbolinks-form ignores Turbolinks caches. It does not populate or uses cache.
|
98
98
|
|
99
99
|
#### Events
|
100
|
-
Turbolinks-form will trigger only a subset of the
|
100
|
+
Turbolinks-form will trigger only a subset of the [Turbolink events](https://github.com/turbolinks/turbolinks#full-list-of-events). Namely:
|
101
101
|
|
102
102
|
* `turbolinks:request-start` fires before Turbolinks-form submits the form. Access the XMLHttpRequest object with `event.data.xhr`.
|
103
103
|
|
@@ -150,17 +150,31 @@ TurbolinksForm.on(document, "ajax:error", function(e, xhr) {
|
|
150
150
|
|
151
151
|
// Replaces whole body and whole head when a true error occurs (same behavior as turbolinks)
|
152
152
|
// This is done even when there is no turbolinks-form-render header (this affects all AJAX requests)
|
153
|
-
// because when an error
|
153
|
+
// because when an error occurs this header is not added by the server
|
154
154
|
var isError500 = (xhr.status == 500)
|
155
155
|
var isError404 = (xhr.status == 404)
|
156
156
|
if (isError500 || isError404) {
|
157
157
|
console.info("Error Response handled by turbolinks-form");
|
158
|
+
// dispatches turbolinks event
|
159
|
+
Turbolinks.dispatch('turbolinks:request-end', {data: {xhr: xhr}});
|
158
160
|
TurbolinksForm.handleResponse(xhr, true);
|
159
161
|
return;
|
160
162
|
}
|
161
163
|
|
164
|
+
// Detects timeout to trigger the request-end event. It is up to the developer to handle
|
165
|
+
// the timeout on the 'turbolinks:request-end' handler
|
166
|
+
// Obs: for the timeout to trigger, it is up to the developer to setup the timeout on the
|
167
|
+
// rails-ujs or jquery-ujs (instructions: https://stackoverflow.com/questions/54464003/how-to-set-timeout-using-rails-ujs).
|
168
|
+
// Otherwise, the default is no timeout.
|
169
|
+
// Ref: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState
|
170
|
+
var isTimeout = (xhr.readyState == 0 || xhr.status == 0);
|
171
|
+
if (isTimeout) {
|
172
|
+
Turbolinks.dispatch('turbolinks:request-end', {data: {xhr: xhr}});
|
173
|
+
return;
|
174
|
+
}
|
175
|
+
|
162
176
|
// does not intercept unrelated AJAX responses
|
163
|
-
if (!xhr
|
177
|
+
if (!xhr.getResponseHeader('turbolinks-form-render'))
|
164
178
|
return;
|
165
179
|
|
166
180
|
// dispatches turbolinks event
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbolinks-form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrique Gubert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|