Commit 81f2521c by Tom Giannattasio

moved collapsible functionality out of problem.html template and into display.coffee

parent e08124c3
...@@ -26,6 +26,13 @@ class @Problem ...@@ -26,6 +26,13 @@ class @Problem
@$('section.action input.show').click @show @$('section.action input.show').click @show
@$('section.action input.save').click @save @$('section.action input.save').click @save
# Collapsibles
@$('.longform').hide();
@$('.shortform').append('<a href="#" class="full">See full output</a>');
@$('.collapsible section').hide();
@$('.full').click @toggleFull
@$('.collapsible header a').click @toggleHint
# Dynamath # Dynamath
@$('input.math').keyup(@refreshMath) @$('input.math').keyup(@refreshMath)
@$('input.math').each (index, element) => @$('input.math').each (index, element) =>
...@@ -333,6 +340,17 @@ class @Problem ...@@ -333,6 +340,17 @@ class @Problem
element.CodeMirror.save() if element.CodeMirror.save element.CodeMirror.save() if element.CodeMirror.save
@answers = @inputs.serialize() @answers = @inputs.serialize()
toggleFull: =>
$(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')
inputtypeSetupMethods: inputtypeSetupMethods:
'text-input-dynamath': (element) => 'text-input-dynamath': (element) =>
......
...@@ -30,38 +30,4 @@ ...@@ -30,38 +30,4 @@
</section> </section>
% endif % endif
</section> </section>
</section> </section>
\ No newline at end of file
<%block name="js_extra">
<script type="text/javascript" charset="utf-8">
var collapsibleSet;
$(function(){
// this should be brought back into problems
$('.longform').hide();
$('.shortform').append('<a href="#" class="full">See full output</a>');
$('.collapsible section').hide();
$('.full').click(function() {
$(this).parent().siblings().slideToggle();
$(this).parent().parent().toggleClass('open');
var text = $(this).text() == 'See full output' ? 'Hide output' : 'See full output';
$(this).text(text);
return false;
});
function toggleHint(e) {
e.preventDefault();
$(this).parent().siblings().slideToggle();
$(this).parent().parent().toggleClass('open');
return false;
}
if(!collapsibleSet) {
collapsibleSet = true;
$('body').delegate('.collapsible header a', 'click', toggleHint);
}
});
</script>
</%block>
\ No newline at end of file
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