turbolinks 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 = -> fullReplacement xhr.responseText, url
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
@@ -4,7 +4,7 @@ require 'coffee-script'
4
4
  Root = File.expand_path("../..", __FILE__)
5
5
 
6
6
  Assets = Sprockets::Environment.new do |env|
7
- env.append_path Root
7
+ env.append_path File.join(Root, "lib", "assets", "javascripts")
8
8
  end
9
9
 
10
10
  map "/js" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbolinks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: