jquery-turbolinks 1.0.0.rc1 → 1.0.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONTRIBUTING.md +32 -0
- data/README.md +46 -15
- data/Rakefile +3 -2
- data/jquery-turbolinks.gemspec +1 -1
- data/lib/jquery-turbolinks/version.rb +1 -1
- data/package.json +1 -1
- data/spec/jquery.turbolinks_spec.coffee +0 -18
- data/src/jquery.turbolinks.coffee +2 -3
- data/vendor/assets/javascripts/jquery.turbolinks.js +3 -4
- metadata +14 -13
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# How to contribute
|
2
|
+
|
3
|
+
## Run tests
|
4
|
+
|
5
|
+
``` sh
|
6
|
+
# Bundle gems
|
7
|
+
bundle
|
8
|
+
|
9
|
+
# Install npm packages
|
10
|
+
npm install
|
11
|
+
|
12
|
+
# Run tests
|
13
|
+
rake test
|
14
|
+
|
15
|
+
# ... or run auto tests
|
16
|
+
bundle exec guard
|
17
|
+
```
|
18
|
+
|
19
|
+
## Sending pull-request
|
20
|
+
|
21
|
+
1. Fork
|
22
|
+
2. Run the tests
|
23
|
+
3. Add test for your change
|
24
|
+
4. Make tests green
|
25
|
+
5. Push
|
26
|
+
6. Send pull-request
|
27
|
+
|
28
|
+
## Please do not
|
29
|
+
|
30
|
+
* Driving drunk
|
31
|
+
* Hide the fact of finding Bigfoot
|
32
|
+
* Mess with versions, gemspec file, package.json etc
|
data/README.md
CHANGED
@@ -4,9 +4,11 @@ Do you like [Turbolinks](https://github.com/rails/turbolinks)? It's easy and fas
|
|
4
4
|
|
5
5
|
But if you have a large codebase with lots of `$(el).bind(...)` Turbolinks will surprise you. Most part of your JavaScripts will stop working in usual way. It's because the nodes on which you bind events no longer exist.
|
6
6
|
|
7
|
-
I wrote jquery.turbolinks to solve this problem in [my project](http://amplifr.com). It's easy to use: just require it *after* `jquery.js` and `
|
7
|
+
I wrote jquery.turbolinks to solve this problem in [my project](http://amplifr.com). It's easy to use: just require it *immediately after* `jquery.js`. Your other scripts should be loaded after `jquery.turbolinks.js`, and `turbolinks.js` should be after your other scripts.
|
8
8
|
|
9
|
-
|
9
|
+
Initially sponsored by [Evil Martians](http://evilmartians.com/).
|
10
|
+
|
11
|
+
This project is a member of the [OSS Manifesto](http://ossmanifesto.org/).
|
10
12
|
|
11
13
|
## Usage
|
12
14
|
|
@@ -22,9 +24,11 @@ JavaScript manifest file:
|
|
22
24
|
|
23
25
|
And it just works!
|
24
26
|
|
25
|
-
##
|
27
|
+
## Customization
|
28
|
+
|
29
|
+
### $.setReadyEvent
|
26
30
|
|
27
|
-
By default [ready](https://github.com/kossnocorp/jquery.turbolinks/blob/master/src/jquery.turbolinks.coffee#L17:L18) function is
|
31
|
+
By default [ready](https://github.com/kossnocorp/jquery.turbolinks/blob/master/src/jquery.turbolinks.coffee#L17:L18) function is bound to [page:load](https://github.com/rails/turbolinks/#events) event.
|
28
32
|
|
29
33
|
If you want to change it use `$.setReadyEvent` function:
|
30
34
|
|
@@ -32,7 +36,7 @@ If you want to change it use `$.setReadyEvent` function:
|
|
32
36
|
$.setReadyEvent('page:change');
|
33
37
|
```
|
34
38
|
|
35
|
-
|
39
|
+
### $.setFetchEvent
|
36
40
|
|
37
41
|
By default right after trigger `page:fetch` `$.isReady` is set to false. And after `page:load` is set to true.
|
38
42
|
|
@@ -42,36 +46,63 @@ If you want to change default behaviour you can use `$.setFetchEvent`:
|
|
42
46
|
$.setReadyEvent('custom_loading_event');
|
43
47
|
```
|
44
48
|
|
45
|
-
|
49
|
+
## Troubleshooting
|
50
|
+
|
51
|
+
### Events firing twice or more
|
52
|
+
|
53
|
+
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:
|
54
|
+
|
55
|
+
``` javascript
|
56
|
+
/* BAD: don't bind 'document' events while inside $()! */
|
57
|
+
$(function() {
|
58
|
+
$(document).on('click', 'button', function() { ... })
|
59
|
+
});
|
60
|
+
```
|
61
|
+
|
62
|
+
You should be binding your events outside a `$(function())` block. This will ensure that your events will only ever be bound once.
|
63
|
+
|
64
|
+
``` javascript
|
65
|
+
/* Good: events are bound outside a $() wrapper. */
|
66
|
+
$(document).on('click', 'button', function() { ... })
|
67
|
+
```
|
68
|
+
|
69
|
+
## Changelog
|
46
70
|
|
47
71
|
This project uses [Semantic Versioning](http://semver.org/) for release numbering.
|
48
72
|
|
49
|
-
|
73
|
+
### 1.0.0-rc2 (January 31, 2013)
|
74
|
+
|
75
|
+
* Fix problem with 3rd-party libraries [#12](https://github.com/kossnocorp/jquery.turbolinks/issues/12), [#15](https://github.com/kossnocorp/jquery.turbolinks/issues/15) (kudos to [@rstacruz](https://github.com/rstacruz));
|
76
|
+
* Reopen [#8](https://github.com/kossnocorp/jquery.turbolinks/issues/8).
|
77
|
+
|
78
|
+
### 1.0.0-rc1 (November 28, 2012)
|
50
79
|
|
51
80
|
* Set $.isReady to false after `page:fetch` [#6](https://github.com/kossnocorp/jquery.turbolinks/issues/6);
|
52
81
|
* add `$.setFetchEvent` function;
|
53
|
-
* remove all delegated events after trigger fetch event [#8](https://github.com/kossnocorp/jquery.turbolinks/issues/8)
|
82
|
+
* remove all delegated events after trigger fetch event [#8](https://github.com/kossnocorp/jquery.turbolinks/issues/8).
|
54
83
|
|
55
|
-
|
84
|
+
### 1.0.0-rc (November 8, 2012)
|
56
85
|
|
57
86
|
* Add turbolinks as dependency (kudos to [@gbchaosmaster](https://github.com/gbchaosmaster));
|
58
87
|
* run callback after adding to waiting list if `$.isReady` [#6](https://github.com/kossnocorp/jquery.turbolinks/issues/6).
|
59
88
|
|
60
|
-
|
89
|
+
### 0.2.1 (October 15, 2012)
|
61
90
|
|
62
91
|
* Pass jQuery object to each callback [#4](https://github.com/kossnocorp/jquery.turbolinks/issues/4)
|
63
92
|
|
64
|
-
|
93
|
+
### 0.2.0 (October 10, 2012)
|
65
94
|
|
66
95
|
* Change event: `page:change` -> `page:load` (kudos to [@davydotcom](https://github.com/davydotcom));
|
67
96
|
* added ability to change ready event via `$.setReadyEvent`
|
68
97
|
|
69
|
-
|
98
|
+
### 0.1.0 (October 3, 2012)
|
70
99
|
|
71
100
|
* First, initial release
|
72
101
|
|
73
|
-
|
102
|
+
## Contributors
|
103
|
+
|
104
|
+
Initial idea and code by [@kossnocorp](http://koss.nocorp.me/), with special thanks to [@rstacruz](https://github.com/rstacruz) and other the project's [contributors](https://github.com/kossnocorp/jquery.turbolinks/graphs/contributors).
|
74
105
|
|
75
|
-
|
106
|
+
## License
|
76
107
|
|
77
|
-
|
108
|
+
[The MIT License](https://github.com/kossnocorp/jquery.turbolinks/blob/master/LICENSE.md)
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ namespace :release do
|
|
9
9
|
task :build_gem do
|
10
10
|
system 'gem build jquery-turbolinks.gemspec'
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
task gem: :build_gem do
|
14
14
|
system "gem push jquery-turbolinks-#{JqueryTurbolinks::VERSION}.gem"
|
15
15
|
end
|
@@ -26,7 +26,8 @@ namespace :js do
|
|
26
26
|
command = [
|
27
27
|
'./node_modules/coffee-script/bin/coffee',
|
28
28
|
'--compile',
|
29
|
-
'--output ./vendor/assets/javascripts/
|
29
|
+
'--output ./vendor/assets/javascripts/',
|
30
|
+
'./src/jquery.turbolinks.coffee'
|
30
31
|
]
|
31
32
|
system command.join(' ')
|
32
33
|
end
|
data/jquery-turbolinks.gemspec
CHANGED
data/package.json
CHANGED
@@ -46,24 +46,6 @@ describe '$ Turbolinks', ->
|
|
46
46
|
|
47
47
|
callback1.should.have.been.calledWith($)
|
48
48
|
|
49
|
-
it '''
|
50
|
-
should remove all events delegated to
|
51
|
-
document after trigger fetch
|
52
|
-
''', ->
|
53
|
-
id = getUniqId()
|
54
|
-
selector = '#' + id
|
55
|
-
addEl = ->
|
56
|
-
$('body').empty()
|
57
|
-
$('<div>').attr(id: id).appendTo('body')
|
58
|
-
|
59
|
-
addEl()
|
60
|
-
$(document).on('event_name', selector, callback1)
|
61
|
-
$(selector).trigger('event_name')
|
62
|
-
$(document).trigger('page:fetch')
|
63
|
-
addEl()
|
64
|
-
$(selector).trigger('event_name')
|
65
|
-
callback1.should.have.been.calledOnce
|
66
|
-
|
67
49
|
describe '$.setReadyEvent', ->
|
68
50
|
|
69
51
|
beforeEach ->
|
@@ -1,5 +1,5 @@
|
|
1
1
|
###
|
2
|
-
jquery.turbolinks.js ~ v1.0.0-
|
2
|
+
jquery.turbolinks.js ~ v1.0.0-rc2 ~ https://github.com/kossnocorp/jquery.turbolinks
|
3
3
|
|
4
4
|
jQuery plugin for drop-in fix binded events problem caused by Turbolinks
|
5
5
|
|
@@ -8,7 +8,7 @@
|
|
8
8
|
Copyright (c) 2012 Sasha Koss
|
9
9
|
###
|
10
10
|
|
11
|
-
$ = require?('jquery')
|
11
|
+
$ = window.jQuery or require?('jquery')
|
12
12
|
|
13
13
|
# List for store callbacks passed to `$` or `$.ready`
|
14
14
|
callbacks = []
|
@@ -24,7 +24,6 @@ turbolinksReady = ->
|
|
24
24
|
|
25
25
|
# Fetch event handler
|
26
26
|
fetch = ->
|
27
|
-
$(document).off(undefined, '**')
|
28
27
|
$.isReady = false
|
29
28
|
|
30
29
|
# Bind `ready` to DOM ready event
|
@@ -1,7 +1,7 @@
|
|
1
|
-
// Generated by CoffeeScript 1.
|
1
|
+
// Generated by CoffeeScript 1.4.0
|
2
2
|
|
3
3
|
/*
|
4
|
-
jquery.turbolinks.js ~ v1.0.0-
|
4
|
+
jquery.turbolinks.js ~ v1.0.0-rc2 ~ https://github.com/kossnocorp/jquery.turbolinks
|
5
5
|
|
6
6
|
jQuery plugin for drop-in fix binded events problem caused by Turbolinks
|
7
7
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
(function() {
|
15
15
|
var $, callbacks, fetch, ready, turbolinksReady;
|
16
16
|
|
17
|
-
$ = (typeof require === "function" ? require('jquery') : void 0)
|
17
|
+
$ = window.jQuery || (typeof require === "function" ? require('jquery') : void 0);
|
18
18
|
|
19
19
|
callbacks = [];
|
20
20
|
|
@@ -34,7 +34,6 @@
|
|
34
34
|
};
|
35
35
|
|
36
36
|
fetch = function() {
|
37
|
-
$(document).off(void 0, '**');
|
38
37
|
return $.isReady = false;
|
39
38
|
};
|
40
39
|
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-turbolinks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.rc1
|
5
4
|
prerelease: 6
|
5
|
+
version: 1.0.0.rc2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sasha Koss
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
16
|
-
|
15
|
+
prerelease: false
|
16
|
+
type: :runtime
|
17
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 3.1.0
|
22
|
-
|
23
|
-
|
24
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
name: railties
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 3.1.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
|
32
|
-
|
31
|
+
prerelease: false
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
34
|
none: false
|
34
35
|
requirements:
|
35
36
|
- - ! '>='
|
36
37
|
- !ruby/object:Gem::Version
|
37
38
|
version: '0'
|
38
|
-
|
39
|
-
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
name: turbolinks
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
43
|
- - ! '>='
|
@@ -50,6 +50,7 @@ extensions: []
|
|
50
50
|
extra_rdoc_files: []
|
51
51
|
files:
|
52
52
|
- .gitignore
|
53
|
+
- CONTRIBUTING.md
|
53
54
|
- Gemfile
|
54
55
|
- Guardfile
|
55
56
|
- LICENSE.md
|
@@ -84,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
85
|
version: 1.3.1
|
85
86
|
requirements: []
|
86
87
|
rubyforge_project: jquery-turbolinks
|
87
|
-
rubygems_version: 1.8.
|
88
|
+
rubygems_version: 1.8.24
|
88
89
|
signing_key:
|
89
90
|
specification_version: 3
|
90
91
|
summary: jQuery plugin for drop-in fix binded events problem caused by Turbolinks
|