Commit a8acb7ff by Arjun Singh

Renamed jsloader to match up with the content more explicitly; refactored…

Renamed jsloader to match up with the content more explicitly; refactored Collapsible out into its own library
parent 68093404
......@@ -75,9 +75,12 @@ class CapaModule(XModule):
'''
icon_class = 'problem'
js = {'coffee': [resource_string(__name__, 'js/src/capa/display.coffee')],
js = {'coffee': [resource_string(__name__, 'js/src/capa/display.coffee'),
resource_string(__name__, 'js/src/javascript_loader.coffee'),
],
'js': [resource_string(__name__, 'js/src/capa/imageinput.js'),
resource_string(__name__, 'js/src/capa/schematic.js')]}
js_module_name = "Problem"
css = {'scss': [resource_string(__name__, 'css/capa/display.scss')]}
......
......@@ -17,7 +17,7 @@ log = logging.getLogger("mitx.courseware")
class HtmlModule(XModule):
js = {'coffee': [resource_string(__name__, 'js/src/jsloader.coffee'),
js = {'coffee': [resource_string(__name__, 'js/src/javascript_loader.coffee'),
resource_string(__name__, 'js/src/html/display.coffee')
]
}
......
......@@ -27,7 +27,7 @@ class @Problem
@$('section.action input.save').click @save
# Collapsibles
JavascriptLoader.setCollapsibles(@el)
Collapsible.setCollapsibles(@el)
# Dynamath
@$('input.math').keyup(@refreshMath)
......
......@@ -3,7 +3,7 @@ class @HTMLModule
constructor: (@element) ->
@el = $(@element)
JavascriptLoader.executeModuleScripts(@el)
JavascriptLoader.setCollapsibles(@el)
Collapsible.setCollapsibles(@el)
$: (selector) ->
$(selector, @el)
......@@ -58,27 +58,3 @@ class @JavascriptLoader
# properly.
$('head')[0].appendChild(s)
$(placeholder).remove()
# setCollapsibles:
# Scan module contents for generic collapsible containers
@setCollapsibles: (el) =>
###
el: jQuery object representing xmodule
###
el.find('.longform').hide();
el.find('.shortform').append('<a href="#" class="full">See full output</a>');
el.find('.collapsible section').hide();
el.find('.full').click @toggleFull
el.find('.collapsible header a').click @toggleHint
@toggleFull: (event) =>
$(event.target).parent().siblings().slideToggle()
$(event.target).parent().parent().toggleClass('open')
text = $(event.target).text() == 'See full output' ? 'Hide output' : 'See full output'
$(this).text(text)
@toggleHint: (event) =>
event.preventDefault()
$(event.target).parent().siblings().slideToggle()
$(event.target).parent().parent().toggleClass('open')
class @Collapsible
# Set of library functions that provide a simple way to add collapsible
# functionality to elements.
# setCollapsibles:
# Scan element's content for generic collapsible containers
@setCollapsibles: (el) =>
###
el: container
###
el.find('.longform').hide()
el.find('.shortform').append('<a href="#" class="full">See full output</a>')
el.find('.collapsible section').hide()
el.find('.full').click @toggleFull
el.find('.collapsible header a').click @toggleHint
@toggleFull: (event) =>
$(event.target).parent().siblings().slideToggle()
$(event.target).parent().parent().toggleClass('open')
text = $(event.target).text() == 'See full output' ? 'Hide output' : 'See full output'
$(this).text(text)
@toggleHint: (event) =>
event.preventDefault()
$(event.target).parent().siblings().slideToggle()
$(event.target).parent().parent().toggleClass('open')
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