turbolinks-js 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +0 -8
- data/lib/assets/javascripts/turbolinks.js +12 -12
- data/test/index.html +2 -2
- data/test/reload.html +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -5,14 +5,6 @@ Same as Turbolinks but without the CoffeeScript requirement.
|
|
5
5
|
Check [Turbolinks](https://github.com/rails/turbolinks) for
|
6
6
|
more information.
|
7
7
|
|
8
|
-
Compatibility
|
9
|
-
-------------
|
10
|
-
|
11
|
-
Turbolinks is designed to work with any browser that fully supports pushState and all the related APIs. This includes Safari 6.0+ (but not Safari 5.1.x!), IE10, and latest Chromes and Firefoxes.
|
12
|
-
|
13
|
-
Do note that existing JavaScript libraries may not all be compatible with Turbolinks out of the box due to the change in instantiation cycle. You might very well have to modify them to work with Turbolinks' new set of events.
|
14
|
-
|
15
|
-
|
16
8
|
Installation
|
17
9
|
------------
|
18
10
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// Generated by CoffeeScript 1.3.3
|
2
2
|
(function() {
|
3
|
-
var anchoredLink,
|
3
|
+
var anchoredLink, assetsChanged, browserCompatibleDocumentParser, browserSupportsPushState, cacheCurrentPage, changePage, constrainPageCacheTo, createDocument, crossOriginLink, currentState, executeScriptTags, extractLink, extractTitleAndBody, extractTrackAssets, fetchHistory, fetchReplacement, handleClick, ignoreClick, initialized, installClickHandlerLast, intersection, noTurbolink, nonHtmlLink, nonStandardClick, pageCache, recallScrollPosition, referer, reflectNewUrl, reflectRedirectedUrl, rememberCurrentState, rememberCurrentTrackingAssets, rememberCurrentUrl, rememberInitialPage, resetScrollPosition, targetLink, trackingAssets, triggerEvent, visit,
|
4
4
|
__hasProp = {}.hasOwnProperty,
|
5
5
|
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
6
6
|
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
referer = document.location.href;
|
12
12
|
|
13
|
-
|
13
|
+
trackingAssets = [];
|
14
14
|
|
15
15
|
pageCache = {};
|
16
16
|
|
@@ -139,8 +139,8 @@
|
|
139
139
|
|
140
140
|
reflectRedirectedUrl = function(xhr) {
|
141
141
|
var location;
|
142
|
-
if ((location = xhr.getResponseHeader('X-XHR-Current-Location'))) {
|
143
|
-
return window.history.replaceState(currentState, '', location);
|
142
|
+
if ((location = xhr.getResponseHeader('X-XHR-Current-Location')) !== document.location.pathname + document.location.search) {
|
143
|
+
return window.history.replaceState(currentState, '', location + document.location.hash);
|
144
144
|
}
|
145
145
|
};
|
146
146
|
|
@@ -155,8 +155,8 @@
|
|
155
155
|
return currentState = window.history.state;
|
156
156
|
};
|
157
157
|
|
158
|
-
|
159
|
-
return
|
158
|
+
rememberCurrentTrackingAssets = function() {
|
159
|
+
return trackingAssets = extractTrackAssets(document);
|
160
160
|
};
|
161
161
|
|
162
162
|
rememberInitialPage = function() {
|
@@ -183,13 +183,13 @@
|
|
183
183
|
return document.dispatchEvent(event);
|
184
184
|
};
|
185
185
|
|
186
|
-
|
186
|
+
extractTrackAssets = function(doc) {
|
187
187
|
var node, _i, _len, _ref, _results;
|
188
188
|
_ref = doc.head.childNodes;
|
189
189
|
_results = [];
|
190
190
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
191
191
|
node = _ref[_i];
|
192
|
-
if (node.
|
192
|
+
if ((typeof node.getAttribute === "function" ? node.getAttribute('data-turbolinks-track') : void 0) != null) {
|
193
193
|
_results.push(node.src || node.href);
|
194
194
|
}
|
195
195
|
}
|
@@ -197,9 +197,9 @@
|
|
197
197
|
};
|
198
198
|
|
199
199
|
assetsChanged = function(doc) {
|
200
|
-
var
|
201
|
-
|
202
|
-
return
|
200
|
+
var extractedTrackAssets;
|
201
|
+
extractedTrackAssets = extractTrackAssets(doc);
|
202
|
+
return extractedTrackAssets.length !== trackingAssets.length || intersection(extractedTrackAssets, trackingAssets).length !== trackingAssets.length;
|
203
203
|
};
|
204
204
|
|
205
205
|
intersection = function(a, b) {
|
@@ -309,7 +309,7 @@
|
|
309
309
|
browserSupportsPushState = window.history && window.history.pushState && window.history.replaceState && window.history.state !== void 0;
|
310
310
|
|
311
311
|
if (browserSupportsPushState) {
|
312
|
-
|
312
|
+
rememberCurrentTrackingAssets();
|
313
313
|
document.addEventListener('click', installClickHandlerLast, true);
|
314
314
|
window.addEventListener('popstate', function(event) {
|
315
315
|
var _ref;
|
data/test/index.html
CHANGED
@@ -16,10 +16,10 @@
|
|
16
16
|
<li><a href="/other.html"><span>Wrapped link</span></a></li>
|
17
17
|
<li><a href="http://www.google.com/">Cross origin</a></li>
|
18
18
|
<li><a href="/other.html" onclick="if(!confirm('follow link?')) { return false}">Confirm Fire Order</a></li>
|
19
|
-
<li><a href="/reload.html"><span>
|
19
|
+
<li><a href="/reload.html"><span>New assets track </span></a></li>
|
20
20
|
<li><a href="/dummy.gif?12345">Query Param Image Link</a></li>
|
21
21
|
<li><a href="#">Hash link</a></li>
|
22
|
-
<li><a href="/reload.html#foo">
|
22
|
+
<li><a href="/reload.html#foo">New assets track with hash link</a></li>
|
23
23
|
</ul>
|
24
24
|
|
25
25
|
<div style="background:#ccc;height:5000px;width:200px;">
|
data/test/reload.html
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8">
|
5
5
|
<title>Home</title>
|
6
|
-
<script type="text/javascript" src="/js/turbolinks.js?1"></script>
|
6
|
+
<script type="text/javascript" src="/js/turbolinks.js?1" data-turbolinks-track='true'></script>
|
7
7
|
<script type="text/javascript">
|
8
8
|
document.addEventListener("page:change", function() {
|
9
9
|
console.log("page changed");
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turbolinks-js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-12-04 00:00:00.000000000 Z
|
14
14
|
dependencies: []
|
15
15
|
description:
|
16
16
|
email:
|