jquery-turbolinks 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NOTES.md +1 -1
- data/README.md +19 -18
- data/lib/jquery-turbolinks/version.rb +1 -1
- data/package.json +11 -8
- data/spec/jquery.turbolinks_spec.coffee +25 -8
- data/src/jquery.turbolinks.coffee +2 -3
- data/vendor/assets/javascripts/jquery.turbolinks.js +5 -6
- data/vendor/assets/javascripts/jquery.turbolinks.min.js +1 -1
- metadata +11 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d5928028de9078ab68d9deadd5e3097645d0cb0
|
4
|
+
data.tar.gz: 3c1b76a837e43f1f2b2269dfe083aa181d42cff8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 831d2989cde58293de4de61c390cf200bb87204a271313bc4fce08a2d19b5db3356025d8cd128fad689f16b761a64d743aeab55b412487ae17680ee63c52e2d3
|
7
|
+
data.tar.gz: 5b2ec4937a7a8792189de8120ea72de9a7843c86dfbd5b55857fe7ac780c37767bf8091c0cabdb1177f7eee52e30a582e9af4529bbc01124858e874e12b658f8
|
data/NOTES.md
CHANGED
@@ -34,7 +34,7 @@ Releasing new versions
|
|
34
34
|
|
35
35
|
* Bump version (see above)
|
36
36
|
* Build .js (`rake build`)
|
37
|
-
* Release into npm and rubygems (`rake release`)
|
37
|
+
* Release into npm and rubygems (`rake release:all`)
|
38
38
|
* Draft release in https://github.com/kossnocorp/jquery.turbolinks/releases
|
39
39
|
|
40
40
|
Release it into npm/rubygems using:
|
data/README.md
CHANGED
@@ -39,6 +39,8 @@ Add it to your JavaScript manifest file, in this order:
|
|
39
39
|
|
40
40
|
And it just works!
|
41
41
|
|
42
|
+
**Checkout "[Faster page loads with Turbolinks](https://coderwall.com/p/ypzfdw)" for deeper explanation how to use jQuery Turbolink in real world**.
|
43
|
+
|
42
44
|
## API and Customization
|
43
45
|
|
44
46
|
### $.turbo.use
|
@@ -57,24 +59,6 @@ either `true` or `false` depending on whether the page is loading.
|
|
57
59
|
|
58
60
|
## Troubleshooting
|
59
61
|
|
60
|
-
### Zurb Foundation
|
61
|
-
|
62
|
-
The `$(function(){ $(document).foundation(); });` has to come before the
|
63
|
-
turbolinks gem.
|
64
|
-
|
65
|
-
``` js
|
66
|
-
//= require jquery
|
67
|
-
//= require jquery.turbolinks
|
68
|
-
//= require jquery_ujs
|
69
|
-
//
|
70
|
-
// ... your other scripts here ...
|
71
|
-
|
72
|
-
$(function(){ $(document).foundation(); });
|
73
|
-
|
74
|
-
//
|
75
|
-
//= require turbolinks
|
76
|
-
```
|
77
|
-
|
78
62
|
### Events firing twice or more
|
79
63
|
|
80
64
|
If you find that some events are being fired multiple times after using jQuery Turbolinks, you may have been binding your `document` events inside a `$(function())` block. For instance, this example below can be a common occurrence and should be avoided:
|
@@ -93,6 +77,19 @@ You should be binding your events outside a `$(function())` block. This will ens
|
|
93
77
|
$(document).on('click', 'button', function() { ... })
|
94
78
|
```
|
95
79
|
|
80
|
+
### Not working with `$(document).on('ready')`
|
81
|
+
|
82
|
+
jQuery Turbolinks doesn't support ready events bound via `$(document).on('ready', function)`. Instead, use `$(document).ready(function)` or `$(function)`.
|
83
|
+
|
84
|
+
``` javascript
|
85
|
+
// BAD: this will not work.
|
86
|
+
$(document).on('ready', function () { /* ... */ });
|
87
|
+
|
88
|
+
// OK: these two are guaranteed to work.
|
89
|
+
$(document).ready(function () { /* ... */ });
|
90
|
+
$(function () { /* ... */ });
|
91
|
+
```
|
92
|
+
|
96
93
|
## Changelog
|
97
94
|
|
98
95
|
This project uses [Semantic Versioning](http://semver.org/) for release numbering.
|
@@ -110,3 +107,7 @@ Initial idea and code by [@kossnocorp](http://koss.nocorp.me/), with special tha
|
|
110
107
|
[page:load]: https://github.com/rails/turbolinks/#events
|
111
108
|
[page:fetch]: https://github.com/rails/turbolinks/#events
|
112
109
|
[oldreadme]: https://github.com/kossnocorp/jquery.turbolinks/blob/v1.0.0.rc2/README.md
|
110
|
+
|
111
|
+
|
112
|
+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/kossnocorp/jquery.turbolinks/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
113
|
+
|
data/package.json
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
{
|
2
2
|
"name": "jquery.turbolinks",
|
3
|
-
"version": "2.0
|
4
|
-
"
|
3
|
+
"version": "2.1.0",
|
4
|
+
"authors": [
|
5
|
+
"Sasha Koss <kossnocorp@gmail.com>",
|
6
|
+
"Rico Sta. Cruz <hi@ricostacruz.com>"
|
7
|
+
],
|
5
8
|
"description": "jQuery plugin for drop-in fix binded events problem caused by Turbolinks",
|
6
9
|
|
7
10
|
"devDependencies": {
|
8
11
|
"coffee-script": "~1.7.1",
|
9
|
-
"mocha": "
|
10
|
-
"chai": "
|
11
|
-
"sinon": "
|
12
|
-
"sinon-chai": "
|
13
|
-
"jquery": "
|
14
|
-
"jsdom": "
|
12
|
+
"mocha": "~1.21.4",
|
13
|
+
"chai": "~1.9.1",
|
14
|
+
"sinon": "~1.10.3",
|
15
|
+
"sinon-chai": "~2.5.0",
|
16
|
+
"jquery": "~2.1.1",
|
17
|
+
"jsdom": "~1.0.0-pre.4"
|
15
18
|
},
|
16
19
|
|
17
20
|
"license": "MIT",
|
@@ -1,14 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
before (next) ->
|
2
|
+
require('jsdom').env
|
3
|
+
html: "<!doctype html><html><head><meta charset='utf-8'></head><body></body></html>",
|
4
|
+
done: (errors, window) ->
|
5
|
+
global.window = window
|
6
|
+
global.document = window.document
|
7
|
+
if (errors)
|
8
|
+
errors.forEach(console.error)
|
9
|
+
throw new Error(errors[0].data.error + " (" + errors[0].data.filename + ")")
|
10
|
+
next()
|
11
|
+
|
12
|
+
before ->
|
13
|
+
global.$ = require('jquery')
|
14
|
+
global.jQuery = require('jquery')
|
15
|
+
require('../src/jquery.turbolinks.coffee')
|
7
16
|
|
8
17
|
chai = require('chai')
|
9
18
|
sinon = require('sinon')
|
10
19
|
sinonChai = require('sinon-chai')
|
11
|
-
$ = require('jquery')
|
12
20
|
|
13
21
|
chai.should()
|
14
22
|
chai.use(sinonChai)
|
@@ -80,7 +88,7 @@ describe '$ Turbolinks', ->
|
|
80
88
|
$.turbo.use('page:load', 'random_event_name')
|
81
89
|
$(document).trigger('page:fetch')
|
82
90
|
$.turbo.isReady.should.to.be.true
|
83
|
-
|
91
|
+
|
84
92
|
it 'should bind passed fetch event', ->
|
85
93
|
$.turbo.use('page:load', 'page:loading')
|
86
94
|
$(document).trigger('page:loading')
|
@@ -105,6 +113,15 @@ describe '$ Turbolinks', ->
|
|
105
113
|
$(callback2 = sinon.spy())
|
106
114
|
callback2.should.have.been.calledOnce
|
107
115
|
|
116
|
+
it 'should call trigger after a subsequent page:fetch and before page:load', ->
|
117
|
+
$(document).trigger('page:fetch')
|
118
|
+
$(document).trigger('page:load')
|
119
|
+
$(callback1 = sinon.spy())
|
120
|
+
callback1.should.have.been.calledOnce
|
121
|
+
$(document).trigger('page:fetch')
|
122
|
+
$(document).trigger('page:load')
|
123
|
+
callback1.should.have.been.calledTwice
|
124
|
+
|
108
125
|
it 'should pass $ as the first argument to callbacks', (done) ->
|
109
126
|
$ ($$) ->
|
110
127
|
$$.fn.should.be.an.object
|
@@ -10,7 +10,7 @@ $ = window.jQuery or require?('jquery')
|
|
10
10
|
$document = $(document)
|
11
11
|
|
12
12
|
$.turbo =
|
13
|
-
version: '2.0
|
13
|
+
version: '2.1.0'
|
14
14
|
|
15
15
|
isReady: false
|
16
16
|
|
@@ -24,8 +24,7 @@ $.turbo =
|
|
24
24
|
addCallback: (callback) ->
|
25
25
|
if $.turbo.isReady
|
26
26
|
callback($)
|
27
|
-
|
28
|
-
$document.on 'turbo:ready', -> callback($)
|
27
|
+
$document.on 'turbo:ready', -> callback($)
|
29
28
|
|
30
29
|
onLoad: ->
|
31
30
|
$.turbo.isReady = true
|
@@ -16,19 +16,18 @@ Copyright (c) 2012-2013 Sasha Koss & Rico Sta. Cruz
|
|
16
16
|
$document = $(document);
|
17
17
|
|
18
18
|
$.turbo = {
|
19
|
-
version: '2.0
|
19
|
+
version: '2.1.0',
|
20
20
|
isReady: false,
|
21
21
|
use: function(load, fetch) {
|
22
22
|
return $document.off('.turbo').on("" + load + ".turbo", this.onLoad).on("" + fetch + ".turbo", this.onFetch);
|
23
23
|
},
|
24
24
|
addCallback: function(callback) {
|
25
25
|
if ($.turbo.isReady) {
|
26
|
-
|
27
|
-
} else {
|
28
|
-
return $document.on('turbo:ready', function() {
|
29
|
-
return callback($);
|
30
|
-
});
|
26
|
+
callback($);
|
31
27
|
}
|
28
|
+
return $document.on('turbo:ready', function() {
|
29
|
+
return callback($);
|
30
|
+
});
|
32
31
|
},
|
33
32
|
onLoad: function() {
|
34
33
|
$.turbo.isReady = true;
|
@@ -1 +1 @@
|
|
1
|
-
(function(){var r,t;r=window.jQuery||("function"==typeof require?require("jquery"):void 0),t=r(document),r.turbo={version:"2.0
|
1
|
+
(function(){var r,t;r=window.jQuery||("function"==typeof require?require("jquery"):void 0),t=r(document),r.turbo={version:"2.1.0",isReady:!1,use:function(r,o){return t.off(".turbo").on(""+r+".turbo",this.onLoad).on(""+o+".turbo",this.onFetch)},addCallback:function(o){return r.turbo.isReady&&o(r),t.on("turbo:ready",function(){return o(r)})},onLoad:function(){return r.turbo.isReady=!0,t.trigger("turbo:ready")},onFetch:function(){return r.turbo.isReady=!1},register:function(){return r(this.onLoad),r.fn.ready=this.addCallback}},r.turbo.register(),r.turbo.use("page:load","page:fetch")}).call(this);
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-turbolinks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sasha Koss
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 3.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: turbolinks
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: jQuery plugin for drop-in fix binded events problem caused by Turbolinks
|
@@ -44,8 +44,8 @@ executables: []
|
|
44
44
|
extensions: []
|
45
45
|
extra_rdoc_files: []
|
46
46
|
files:
|
47
|
-
- .gitignore
|
48
|
-
- .travis.yml
|
47
|
+
- ".gitignore"
|
48
|
+
- ".travis.yml"
|
49
49
|
- CONTRIBUTING.md
|
50
50
|
- Gemfile
|
51
51
|
- Guardfile
|
@@ -72,20 +72,19 @@ require_paths:
|
|
72
72
|
- lib
|
73
73
|
required_ruby_version: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
requirements: []
|
84
84
|
rubyforge_project: jquery-turbolinks
|
85
|
-
rubygems_version: 2.
|
85
|
+
rubygems_version: 2.2.2
|
86
86
|
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: jQuery plugin for drop-in fix binded events problem caused by Turbolinks
|
89
89
|
test_files:
|
90
90
|
- spec/jquery.turbolinks_spec.coffee
|
91
|
-
has_rdoc:
|