Make the accordian expand 'Week 1' by default
This fixes the regression from javascript rewrite.
This commit is contained in:
@@ -52,11 +52,12 @@
|
||||
function Navigation() {}
|
||||
|
||||
Navigation.bind = function() {
|
||||
var navigation;
|
||||
var active, navigation;
|
||||
if ($('#accordion').length) {
|
||||
navigation = new Navigation;
|
||||
active = $('#accordion ul:has(li.active)').index('#accordion ul');
|
||||
$('#accordion').bind('accordionchange', navigation.log).accordion({
|
||||
active: $('#accordion ul:has(li.active)').index('#accordion ul'),
|
||||
active: active >= 0 ? active : 1,
|
||||
header: 'h3',
|
||||
autoHeight: false
|
||||
});
|
||||
|
||||
@@ -12,14 +12,25 @@ describe 'Courseware', ->
|
||||
|
||||
describe 'bind', ->
|
||||
describe 'when the #accordion exists', ->
|
||||
it 'activate the accordion with correct active section', ->
|
||||
spyOn $.fn, 'accordion'
|
||||
$('#accordion').append('<ul><li></li></ul><ul><li class="active"></li></ul>')
|
||||
Courseware.Navigation.bind()
|
||||
expect($('#accordion').accordion).toHaveBeenCalledWith
|
||||
active: 1
|
||||
header: 'h3'
|
||||
autoHeight: false
|
||||
describe 'when there is an active section', ->
|
||||
it 'activate the accordion with correct active section', ->
|
||||
spyOn $.fn, 'accordion'
|
||||
$('#accordion').append('<ul><li></li></ul><ul><li class="active"></li></ul>')
|
||||
Courseware.Navigation.bind()
|
||||
expect($('#accordion').accordion).toHaveBeenCalledWith
|
||||
active: 1
|
||||
header: 'h3'
|
||||
autoHeight: false
|
||||
|
||||
describe 'when there is no active section', ->
|
||||
it 'activate the accordian with section 1 as active', ->
|
||||
spyOn $.fn, 'accordion'
|
||||
$('#accordion').append('<ul><li></li></ul><ul><li></li></ul>')
|
||||
Courseware.Navigation.bind()
|
||||
expect($('#accordion').accordion).toHaveBeenCalledWith
|
||||
active: 1
|
||||
header: 'h3'
|
||||
autoHeight: false
|
||||
|
||||
it 'binds the accordionchange event', ->
|
||||
Courseware.Navigation.bind()
|
||||
|
||||
@@ -16,14 +16,28 @@
|
||||
});
|
||||
describe('bind', function() {
|
||||
describe('when the #accordion exists', function() {
|
||||
it('activate the accordion with correct active section', function() {
|
||||
spyOn($.fn, 'accordion');
|
||||
$('#accordion').append('<ul><li></li></ul><ul><li class="active"></li></ul>');
|
||||
Courseware.Navigation.bind();
|
||||
return expect($('#accordion').accordion).toHaveBeenCalledWith({
|
||||
active: 1,
|
||||
header: 'h3',
|
||||
autoHeight: false
|
||||
describe('when there is an active section', function() {
|
||||
return it('activate the accordion with correct active section', function() {
|
||||
spyOn($.fn, 'accordion');
|
||||
$('#accordion').append('<ul><li></li></ul><ul><li class="active"></li></ul>');
|
||||
Courseware.Navigation.bind();
|
||||
return expect($('#accordion').accordion).toHaveBeenCalledWith({
|
||||
active: 1,
|
||||
header: 'h3',
|
||||
autoHeight: false
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('when there is no active section', function() {
|
||||
return it('activate the accordian with section 1 as active', function() {
|
||||
spyOn($.fn, 'accordion');
|
||||
$('#accordion').append('<ul><li></li></ul><ul><li></li></ul>');
|
||||
Courseware.Navigation.bind();
|
||||
return expect($('#accordion').accordion).toHaveBeenCalledWith({
|
||||
active: 1,
|
||||
header: 'h3',
|
||||
autoHeight: false
|
||||
});
|
||||
});
|
||||
});
|
||||
it('binds the accordionchange event', function() {
|
||||
|
||||
@@ -6,8 +6,9 @@ class window.Courseware
|
||||
@bind: ->
|
||||
if $('#accordion').length
|
||||
navigation = new Navigation
|
||||
active = $('#accordion ul:has(li.active)').index('#accordion ul')
|
||||
$('#accordion').bind('accordionchange', navigation.log).accordion
|
||||
active: $('#accordion ul:has(li.active)').index('#accordion ul')
|
||||
active: if active >= 0 then active else 1
|
||||
header: 'h3'
|
||||
autoHeight: false
|
||||
$('#open_close_accordion a').click navigation.toggle
|
||||
|
||||
Reference in New Issue
Block a user