Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Initial support fo turbolinks 5 #58

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ group :development do
gem 'uglifier'
gem 'guard'
gem 'guard-rake'
gem 'talks', '0.4.0'
gem 'talks', '0.4.1'
gem 'terminal-notifier'
end
2 changes: 1 addition & 1 deletion lib/jquery-turbolinks/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module JqueryTurbolinks
VERSION = '2.1.0'
VERSION = '3.0.0'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

end
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jquery.turbolinks",
"version": "2.1.0",
"version": "3.0.0",
"authors": [
"Sasha Koss <[email protected]>",
"Rico Sta. Cruz <[email protected]>"
Expand All @@ -13,8 +13,8 @@
"chai": "~1.9.1",
"sinon": "~1.10.3",
"sinon-chai": "~2.5.0",
"jquery": "~2.1.1",
"jsdom": "~1.0.0-pre.4"
"jquery": "~2.2.2",
"jsdom": "~8.1.0"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Time flies!

},

"license": "MIT",
Expand Down
47 changes: 24 additions & 23 deletions spec/jquery.turbolinks_spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe '$ Turbolinks', ->
# Simulate a reset.
beforeEach ->
$.turbo.isReady = false
$.turbo.use 'page:load', 'page:fetch'
$.turbo.use 'turbolinks:load', 'turbolinks:request-start'
$(document).off('turbo:ready')

describe "DOM isn't ready", ->
Expand All @@ -43,10 +43,10 @@ describe '$ Turbolinks', ->

it '''
should trigger callbacks passed to
`$()` and `$.ready()` when page:load
`$()` and `$.ready()` when turbolinks:load
event fired
''', ->
$(document).trigger('page:load')
$(document).trigger('turbolinks:load')

callback1.should.have.been.calledOnce
callback2.should.have.been.calledOnce
Expand All @@ -56,23 +56,24 @@ describe '$ Turbolinks', ->
$$.fn.should.be.an.object
done()

$(document).trigger 'page:load'
$(document).trigger 'turbolinks:load'

describe '$.turbo.use', ->

beforeEach ->
$.turbo.use('page:load', 'page:fetch')
$.turbo.use('turbolinks:load', 'turbolinks:request-start')

it 'should unbind default (page:load) event', ->
it 'should unbind default (turbolinks:load) event', ->
$.turbo.use('other1', 'other2')

$(document).trigger('page:load')
$(document).trigger('turbolinks:load')

callback1.should.have.not.been.called
callback2.should.have.not.been.called

it 'should bind ready to passed function', ->
$(document)
.trigger('page:load')
.trigger('turbolinks:load')
.trigger('page:change')

callback1.should.have.been.calledOnce
Expand All @@ -81,45 +82,45 @@ describe '$ Turbolinks', ->
describe '$.setFetchEvent', ->

beforeEach ->
$.turbo.use('page:load', 'page:fetch')
$.turbo.use('turbolinks:load', 'turbolinks:request-start')
$.turbo.isReady = true

it 'should unbind default (page:fetch) event', ->
$.turbo.use('page:load', 'random_event_name')
$(document).trigger('page:fetch')
it 'should unbind default (turbolinks:request-start) event', ->
$.turbo.use('turbolinks:load', 'random_event_name')
$(document).trigger('turbolinks:request-start')
$.turbo.isReady.should.to.be.true

it 'should bind passed fetch event', ->
$.turbo.use('page:load', 'page:loading')
$(document).trigger('page:loading')
$.turbo.use('turbolinks:load', 'turbolinks:loading')
$(document).trigger('turbolinks:loading')
$.turbo.isReady.should.to.be.false

describe 'DOM is ready', ->

beforeEach ->
$.turbo.use('page:load', 'page:fetch')
$.turbo.use('turbolinks:load', 'turbolinks:request-start')
$.turbo.isReady = true

it 'should call trigger right after add to waiting list', ->
$(callback = sinon.spy())
callback.should.have.been.calledOnce

it 'should not call trigger after page:fetch and before page:load', ->
$(document).trigger('page:fetch')
it 'should not call trigger after turbolinks:request-start and before turbolinks:load', ->
$(document).trigger('turbolinks:request-start')
$(callback1 = sinon.spy())
callback1.should.have.not.been.called

$(document).trigger('page:load')
$(document).trigger('turbolinks:load')
$(callback2 = sinon.spy())
callback2.should.have.been.calledOnce

it 'should call trigger after a subsequent page:fetch and before page:load', ->
$(document).trigger('page:fetch')
$(document).trigger('page:load')
it 'should call trigger after a subsequent turbolinks:request-start and before turbolinks:load', ->
$(document).trigger('turbolinks:request-start')
$(document).trigger('turbolinks:load')
$(callback1 = sinon.spy())
callback1.should.have.been.calledOnce
$(document).trigger('page:fetch')
$(document).trigger('page:load')
$(document).trigger('turbolinks:request-start')
$(document).trigger('turbolinks:load')
callback1.should.have.been.calledTwice

it 'should pass $ as the first argument to callbacks', (done) ->
Expand Down
4 changes: 2 additions & 2 deletions src/jquery.turbolinks.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $ = window.jQuery or require?('jquery')
$document = $(document)

$.turbo =
version: '2.1.0'
version: '3.0.0'

isReady: false

Expand Down Expand Up @@ -46,4 +46,4 @@ $.turbo =

# Use with Turbolinks.
$.turbo.register()
$.turbo.use('page:load', 'page:fetch')
$.turbo.use('turbolinks:load', 'turbolinks:request-start')
4 changes: 2 additions & 2 deletions vendor/assets/javascripts/jquery.turbolinks.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/assets/javascripts/jquery.turbolinks.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.