turbograft 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/assets/javascripts/turbograft/turbolinks.coffee +16 -2
- data/lib/turbograft/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f51cd95b7cebb4dc5951437b2a1026f6c3b810c8
|
4
|
+
data.tar.gz: 27867ee91c017ea05233ada000f44b15fdbd1cba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebad3b4003a5d3a2c34597c382f84b0b66e4966d24e827ef098ad5beb769d8a17dcf1913711627f8999ed3ba389d089aead2cc299a66541074551e60aac83d34
|
7
|
+
data.tar.gz: 1b6c92c9f37b6ccaa8519267276de41b8144faeb9250a7d690d84dccd82b084761d1f4cd51e10b0ba0bc6197b321380bb42e6e3ce136fc548066609645cb391a
|
@@ -104,7 +104,6 @@ class window.Turbolinks
|
|
104
104
|
@loadPage: (url, xhr, partialReplace = false, onLoadFunction = (->), replaceContents = [], replaceAllExcept = []) ->
|
105
105
|
triggerEvent 'page:receive'
|
106
106
|
|
107
|
-
|
108
107
|
if doc = processResponse(xhr, partialReplace)
|
109
108
|
reflectNewUrl url
|
110
109
|
nodes = changePage(extractTitleAndBody(doc)..., partialReplace, replaceContents, replaceAllExcept)
|
@@ -121,7 +120,9 @@ class window.Turbolinks
|
|
121
120
|
|
122
121
|
if onlyKeys.length
|
123
122
|
nodesToRefresh = [].concat(getNodesWithRefreshAlways(), getNodesMatchingRefreshKeys(onlyKeys))
|
124
|
-
|
123
|
+
nodes = refreshNodes(nodesToRefresh, body)
|
124
|
+
setAutofocusElement() if anyAutofocusElement(nodes)
|
125
|
+
return nodes
|
125
126
|
else
|
126
127
|
refreshNodes(getNodesWithRefreshAlways(), body)
|
127
128
|
persistStaticElements(body)
|
@@ -133,6 +134,7 @@ class window.Turbolinks
|
|
133
134
|
triggerEvent 'page:before-replace'
|
134
135
|
document.documentElement.replaceChild body, document.body
|
135
136
|
CSRFToken.update csrfToken if csrfToken?
|
137
|
+
setAutofocusElement()
|
136
138
|
executeScriptTags() if runScripts
|
137
139
|
currentState = window.history.state
|
138
140
|
triggerEvent 'page:change'
|
@@ -155,6 +157,18 @@ class window.Turbolinks
|
|
155
157
|
|
156
158
|
return matchingNodes
|
157
159
|
|
160
|
+
anyAutofocusElement = (nodes) ->
|
161
|
+
for node in nodes
|
162
|
+
if node.querySelectorAll('input[autofocus], textarea[autofocus]').length > 0
|
163
|
+
return true
|
164
|
+
|
165
|
+
false
|
166
|
+
|
167
|
+
setAutofocusElement = ->
|
168
|
+
autofocusElement = (list = document.querySelectorAll 'input[autofocus], textarea[autofocus]')[list.length - 1]
|
169
|
+
if autofocusElement and document.activeElement isnt autofocusElement
|
170
|
+
autofocusElement.focus()
|
171
|
+
|
158
172
|
deleteRefreshNeverNodes = (body) ->
|
159
173
|
for node in body.querySelectorAll('[refresh-never]')
|
160
174
|
node.parentNode.removeChild(node)
|
data/lib/turbograft/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbograft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kristian Plettenberg-Dussault
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2015-01-
|
16
|
+
date: 2015-01-22 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: coffee-rails
|