From bb55a76379ef0d139ff24f7fdc04faa4f231bef1 Mon Sep 17 00:00:00 2001 From: kimth Date: Wed, 29 Aug 2012 22:01:16 -0400 Subject: [PATCH] Allow courseware to navigate to specific tabs of a sequence --- .../xmodule/js/src/sequence/display.coffee | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/sequence/display.coffee b/common/lib/xmodule/xmodule/js/src/sequence/display.coffee index 35a33a9ea1..ff6794ec10 100644 --- a/common/lib/xmodule/xmodule/js/src/sequence/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/sequence/display.coffee @@ -2,6 +2,7 @@ class @Sequence constructor: (element) -> @el = $(element).find('.sequence') @contents = @$('.seq_contents') + @num_contents = @contents.length @id = @el.data('id') @modx_url = @el.data('course_modx_root') @initProgress() @@ -90,18 +91,29 @@ class @Sequence @toggleArrows() @hookUpProgressEvent() + sequence_links = @$('#seq_content a.seqnav') + sequence_links.click @goto + goto: (event) => event.preventDefault() - new_position = $(event.target).data('element') - Logger.log "seq_goto", old: @position, new: new_position, id: @id - - # On Sequence chage, destroy any existing polling thread - # for queued submissions, see ../capa/display.coffee - if window.queuePollerID - window.clearTimeout(window.queuePollerID) - delete window.queuePollerID + # Links from within the coureware uses ... + if $(event.target).hasClass 'seqnav' + new_position = $(event.target).attr('href') + else + new_position = $(event.target).data('element') - @render new_position + if (1 <= new_position) and (new_position <= @num_contents) + Logger.log "seq_goto", old: @position, new: new_position, id: @id + + # On Sequence chage, destroy any existing polling thread + # for queued submissions, see ../capa/display.coffee + if window.queuePollerID + window.clearTimeout(window.queuePollerID) + delete window.queuePollerID + + @render new_position + else + alert 'Sequence error! Cannot navigate to tab ' + new_position + 'in the current SequenceModule. Please contact the course staff.' next: (event) => event.preventDefault()