Make event handlers fire properly
Respond to review comments LMS-1242
This commit is contained in:
@@ -230,9 +230,7 @@ class Analytics
|
||||
|
||||
# export for use
|
||||
# create parent namespaces if they do not already exist.
|
||||
# abort if underscore can not be found.
|
||||
if _?
|
||||
_.defaults window, InstructorDashboard: {}
|
||||
_.defaults window.InstructorDashboard, sections: {}
|
||||
_.defaults window.InstructorDashboard.sections,
|
||||
Analytics: Analytics
|
||||
_.defaults window, InstructorDashboard: {}
|
||||
_.defaults window.InstructorDashboard, sections: {}
|
||||
_.defaults window.InstructorDashboard.sections,
|
||||
Analytics: Analytics
|
||||
|
||||
@@ -7,8 +7,6 @@ such that the value can be defined later than this assignment (file load order).
|
||||
###
|
||||
|
||||
# Load utilities
|
||||
plantTimeout = -> window.InstructorDashboard.util.plantTimeout.apply this, arguments
|
||||
std_ajax_err = -> window.InstructorDashboard.util.std_ajax_err.apply this, arguments
|
||||
PendingInstructorTasks = -> window.InstructorDashboard.util.PendingInstructorTasks
|
||||
|
||||
# A typical section object.
|
||||
@@ -16,6 +14,12 @@ PendingInstructorTasks = -> window.InstructorDashboard.util.PendingInstructorTas
|
||||
# which holds the section body container.
|
||||
class CourseInfo
|
||||
constructor: (@$section) ->
|
||||
# attach self to html so that instructor_dashboard.coffee can find
|
||||
# this object to call event handlers like 'onClickTitle'
|
||||
@$section.data 'wrapper', @
|
||||
|
||||
# gather elements
|
||||
@instructor_tasks = new (PendingInstructorTasks()) @$section
|
||||
@$course_errors_wrapper = @$section.find '.course-errors-wrapper'
|
||||
|
||||
# if there are errors
|
||||
@@ -37,19 +41,15 @@ class CourseInfo
|
||||
else
|
||||
@$course_errors_wrapper.addClass 'open'
|
||||
|
||||
@instructor_tasks = new (PendingInstructorTasks()) @$section
|
||||
|
||||
# handler for when the section title is clicked.
|
||||
onClickTitle: -> @instructor_tasks.task_poller?.start()
|
||||
onClickTitle: -> @instructor_tasks.task_poller.start()
|
||||
|
||||
# handler for when the section is closed
|
||||
onExit: -> @instructor_tasks.task_poller?.stop()
|
||||
onExit: -> @instructor_tasks.task_poller.stop()
|
||||
|
||||
# export for use
|
||||
# create parent namespaces if they do not already exist.
|
||||
# abort if underscore can not be found.
|
||||
if _?
|
||||
_.defaults window, InstructorDashboard: {}
|
||||
_.defaults window.InstructorDashboard, sections: {}
|
||||
_.defaults window.InstructorDashboard.sections,
|
||||
CourseInfo: CourseInfo
|
||||
_.defaults window, InstructorDashboard: {}
|
||||
_.defaults window.InstructorDashboard, sections: {}
|
||||
_.defaults window.InstructorDashboard.sections,
|
||||
CourseInfo: CourseInfo
|
||||
|
||||
@@ -6,13 +6,16 @@ wrap in (-> ... apply) to defer evaluation
|
||||
such that the value can be defined later than this assignment (file load order).
|
||||
###
|
||||
|
||||
plantTimeout = -> window.InstructorDashboard.util.plantTimeout.apply this, arguments
|
||||
# Load utilities
|
||||
std_ajax_err = -> window.InstructorDashboard.util.std_ajax_err.apply this, arguments
|
||||
PendingInstructorTasks = -> window.InstructorDashboard.util.PendingInstructorTasks
|
||||
|
||||
# Data Download Section
|
||||
class DataDownload
|
||||
constructor: (@$section) ->
|
||||
# attach self to html so that instructor_dashboard.coffee can find
|
||||
# this object to call event handlers like 'onClickTitle'
|
||||
@$section.data 'wrapper', @
|
||||
# gather elements
|
||||
@$display = @$section.find '.data-display'
|
||||
@$display_text = @$display.find '.data-display-text'
|
||||
@@ -21,9 +24,9 @@ class DataDownload
|
||||
@$list_studs_btn = @$section.find("input[name='list-profiles']'")
|
||||
@$list_anon_btn = @$section.find("input[name='list-anon-ids']'")
|
||||
@$grade_config_btn = @$section.find("input[name='dump-gradeconf']'")
|
||||
@instructor_tasks = new (PendingInstructorTasks()) @$section
|
||||
|
||||
# attach click handlers
|
||||
|
||||
# The list-anon case is always CSV
|
||||
@$list_anon_btn.click (e) =>
|
||||
url = @$list_anon_btn.data 'endpoint'
|
||||
@@ -80,13 +83,11 @@ class DataDownload
|
||||
@clear_display()
|
||||
@$display_text.html data['grading_config_summary']
|
||||
|
||||
@instructor_tasks = new (PendingInstructorTasks()) @$section
|
||||
|
||||
# handler for when the section title is clicked.
|
||||
onClickTitle: -> @instructor_tasks.task_poller?.start()
|
||||
onClickTitle: -> @instructor_tasks.task_poller.start()
|
||||
|
||||
# handler for when the section is closed
|
||||
onExit: -> @instructor_tasks.task_poller?.stop()
|
||||
onExit: -> @instructor_tasks.task_poller.stop()
|
||||
|
||||
clear_display: ->
|
||||
@$display_text.empty()
|
||||
@@ -96,9 +97,7 @@ class DataDownload
|
||||
|
||||
# export for use
|
||||
# create parent namespaces if they do not already exist.
|
||||
# abort if underscore can not be found.
|
||||
if _?
|
||||
_.defaults window, InstructorDashboard: {}
|
||||
_.defaults window.InstructorDashboard, sections: {}
|
||||
_.defaults window.InstructorDashboard.sections,
|
||||
DataDownload: DataDownload
|
||||
_.defaults window, InstructorDashboard: {}
|
||||
_.defaults window.InstructorDashboard, sections: {}
|
||||
_.defaults window.InstructorDashboard.sections,
|
||||
DataDownload: DataDownload
|
||||
|
||||
@@ -118,7 +118,7 @@ setup_instructor_dashboard = (idash_content) =>
|
||||
location.hash = "#{HASH_LINK_PREFIX}#{section_name}"
|
||||
|
||||
sections_have_loaded.after ->
|
||||
$section.data('wrapper')?.onClickTitle?()
|
||||
$section.data('wrapper').onClickTitle()
|
||||
|
||||
# call onExit handler if exiting a section to a different section.
|
||||
unless $section.is $active_section
|
||||
|
||||
@@ -487,9 +487,7 @@ class Membership
|
||||
|
||||
# export for use
|
||||
# create parent namespaces if they do not already exist.
|
||||
# abort if underscore can not be found.
|
||||
if _?
|
||||
_.defaults window, InstructorDashboard: {}
|
||||
_.defaults window.InstructorDashboard, sections: {}
|
||||
_.defaults window.InstructorDashboard.sections,
|
||||
Membership: Membership
|
||||
_.defaults window, InstructorDashboard: {}
|
||||
_.defaults window.InstructorDashboard, sections: {}
|
||||
_.defaults window.InstructorDashboard.sections,
|
||||
Membership: Membership
|
||||
|
||||
@@ -81,9 +81,8 @@ class SendEmail
|
||||
class Email
|
||||
# enable subsections.
|
||||
constructor: (@$section) ->
|
||||
# attach self to html
|
||||
# so that instructor_dashboard.coffee can find this object
|
||||
# to call event handlers like 'onClickTitle'
|
||||
# attach self to html so that instructor_dashboard.coffee can find
|
||||
# this object to call event handlers like 'onClickTitle'
|
||||
@$section.data 'wrapper', @
|
||||
|
||||
# isolate # initialize SendEmail subsection
|
||||
@@ -92,17 +91,15 @@ class Email
|
||||
@instructor_tasks = new (PendingInstructorTasks()) @$section
|
||||
|
||||
# handler for when the section title is clicked.
|
||||
onClickTitle: -> @instructor_tasks.task_poller?.start()
|
||||
onClickTitle: -> @instructor_tasks.task_poller.start()
|
||||
|
||||
# handler for when the section is closed
|
||||
onExit: -> @instructor_tasks.task_poller?.stop()
|
||||
onExit: -> @instructor_tasks.task_poller.stop()
|
||||
|
||||
|
||||
# export for use
|
||||
# create parent namespaces if they do not already exist.
|
||||
# abort if underscore can not be found.
|
||||
if _?
|
||||
_.defaults window, InstructorDashboard: {}
|
||||
_.defaults window.InstructorDashboard, sections: {}
|
||||
_.defaults window.InstructorDashboard.sections,
|
||||
Email: Email
|
||||
_.defaults window, InstructorDashboard: {}
|
||||
_.defaults window.InstructorDashboard, sections: {}
|
||||
_.defaults window.InstructorDashboard.sections,
|
||||
Email: Email
|
||||
|
||||
@@ -7,10 +7,7 @@ such that the value can be defined later than this assignment (file load order).
|
||||
###
|
||||
|
||||
# Load utilities
|
||||
plantTimeout = -> window.InstructorDashboard.util.plantTimeout.apply this, arguments
|
||||
plantInterval = -> window.InstructorDashboard.util.plantInterval.apply this, arguments
|
||||
std_ajax_err = -> window.InstructorDashboard.util.std_ajax_err.apply this, arguments
|
||||
load_IntervalManager = -> window.InstructorDashboard.util.IntervalManager
|
||||
create_task_list_table = -> window.InstructorDashboard.util.create_task_list_table.apply this, arguments
|
||||
PendingInstructorTasks = -> window.InstructorDashboard.util.PendingInstructorTasks
|
||||
|
||||
@@ -27,6 +24,8 @@ find_and_assert = ($root, selector) ->
|
||||
|
||||
class StudentAdmin
|
||||
constructor: (@$section) ->
|
||||
# attach self to html so that instructor_dashboard.coffee can find
|
||||
# this object to call event handlers like 'onClickTitle'
|
||||
@$section.data 'wrapper', @
|
||||
|
||||
# gather buttons
|
||||
@@ -255,17 +254,15 @@ class StudentAdmin
|
||||
@$request_response_error_all.empty()
|
||||
|
||||
# handler for when the section title is clicked.
|
||||
onClickTitle: -> @instructor_tasks.task_poller?.start()
|
||||
onClickTitle: -> @instructor_tasks.task_poller.start()
|
||||
|
||||
# handler for when the section is closed
|
||||
onExit: -> @instructor_tasks.task_poller?.stop()
|
||||
onExit: -> @instructor_tasks.task_poller.stop()
|
||||
|
||||
|
||||
# export for use
|
||||
# create parent namespaces if they do not already exist.
|
||||
# abort if underscore can not be found.
|
||||
if _?
|
||||
_.defaults window, InstructorDashboard: {}
|
||||
_.defaults window.InstructorDashboard, sections: {}
|
||||
_.defaults window.InstructorDashboard.sections,
|
||||
StudentAdmin: StudentAdmin
|
||||
_.defaults window, InstructorDashboard: {}
|
||||
_.defaults window.InstructorDashboard, sections: {}
|
||||
_.defaults window.InstructorDashboard.sections,
|
||||
StudentAdmin: StudentAdmin
|
||||
|
||||
@@ -101,8 +101,8 @@ class IntervalManager
|
||||
@intervalID = null
|
||||
|
||||
# Start or restart firing every `ms` milliseconds.
|
||||
# Soes not fire immediately.
|
||||
start: ->
|
||||
@fn()
|
||||
if @intervalID is null
|
||||
@intervalID = setInterval @fn, @ms
|
||||
|
||||
|
||||
Reference in New Issue
Block a user