Commit eb70ef4c by Prem Sichanugrist

Directly call toggleArrow in sequence render

There might be a chance that an error got thrown after 'contentChanged'
event was fired and stop the `toggleArrow()` method to be called. This
will make sure that the navigation will still be working even some
element in the content is failed.
parent 3bfe8112
...@@ -24,7 +24,6 @@ describe 'Sequence', -> ...@@ -24,7 +24,6 @@ describe 'Sequence', ->
expect(titles).toEqual ['Video 1', 'Video 2', 'Sample Problem'] expect(titles).toEqual ['Video 1', 'Video 2', 'Sample Problem']
it 'bind the page events', -> it 'bind the page events', ->
expect(@sequence.element).toHandleWith 'contentChanged', @sequence.toggleArrows
expect($('#sequence-list a')).toHandleWith 'click', @sequence.goto expect($('#sequence-list a')).toHandleWith 'click', @sequence.goto
it 'render the active sequence content', -> it 'render the active sequence content', ->
...@@ -76,6 +75,7 @@ describe 'Sequence', -> ...@@ -76,6 +75,7 @@ describe 'Sequence', ->
spyOn $, 'postWithPrefix' spyOn $, 'postWithPrefix'
@sequence = new Sequence '1', @items, 'sequence' @sequence = new Sequence '1', @items, 'sequence'
spyOnEvent @sequence.element, 'contentChanged' spyOnEvent @sequence.element, 'contentChanged'
spyOn(@sequence, 'toggleArrows').andCallThrough()
describe 'with a different position than the current one', -> describe 'with a different position than the current one', ->
beforeEach -> beforeEach ->
...@@ -105,6 +105,9 @@ describe 'Sequence', -> ...@@ -105,6 +105,9 @@ describe 'Sequence', ->
it 'update the position', -> it 'update the position', ->
expect(@sequence.position).toEqual 1 expect(@sequence.position).toEqual 1
it 're-update the arrows', ->
expect(@sequence.toggleArrows).toHaveBeenCalled()
it 'trigger contentChanged event', -> it 'trigger contentChanged event', ->
expect('contentChanged').toHaveBeenTriggeredOn @sequence.element expect('contentChanged').toHaveBeenTriggeredOn @sequence.element
......
...@@ -9,7 +9,6 @@ class @Sequence ...@@ -9,7 +9,6 @@ class @Sequence
$(selector, @element) $(selector, @element)
bind: -> bind: ->
@element.bind 'contentChanged', @toggleArrows
@$('#sequence-list a').click @goto @$('#sequence-list a').click @goto
buildNavigation: -> buildNavigation: ->
...@@ -43,6 +42,7 @@ class @Sequence ...@@ -43,6 +42,7 @@ class @Sequence
MathJax.Hub.Queue(["Typeset", MathJax.Hub]) MathJax.Hub.Queue(["Typeset", MathJax.Hub])
@position = new_position @position = new_position
@toggleArrows()
@element.trigger 'contentChanged' @element.trigger 'contentChanged'
goto: (event) => goto: (event) =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment