turbolinks 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/assets/javascripts/turbolinks.js.coffee +8 -2
- data/test/config.ru +1 -1
- metadata +1 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
visit = (url) ->
|
2
|
-
if browserSupportsPushState
|
2
|
+
if browserSupportsPushState?
|
3
3
|
reflectNewUrl url
|
4
4
|
fetchReplacement url
|
5
5
|
else
|
@@ -10,7 +10,8 @@ fetchReplacement = (url) ->
|
|
10
10
|
xhr = new XMLHttpRequest
|
11
11
|
xhr.open 'GET', url, true
|
12
12
|
xhr.setRequestHeader 'Accept', 'text/html, application/xhtml+xml, application/xml'
|
13
|
-
xhr.onload
|
13
|
+
xhr.onload = -> fullReplacement xhr.responseText, url
|
14
|
+
xhr.onabort = -> console.log "Aborted turbolink fetch!"
|
14
15
|
xhr.send()
|
15
16
|
|
16
17
|
fullReplacement = (html, url) ->
|
@@ -86,8 +87,13 @@ handleClick = (event) ->
|
|
86
87
|
|
87
88
|
browserSupportsPushState = window.history and window.history.pushState and window.history.replaceState
|
88
89
|
|
90
|
+
rememberInitialPage = ->
|
91
|
+
window.history.replaceState { turbolinks: true }, "", document.location.href
|
92
|
+
|
89
93
|
|
90
94
|
if browserSupportsPushState
|
95
|
+
rememberInitialPage()
|
96
|
+
|
91
97
|
window.addEventListener 'popstate', (event) ->
|
92
98
|
if event.state?.turbolinks
|
93
99
|
fetchReplacement document.location.href
|
data/test/config.ru
CHANGED