lower the length limits and put the expansion link at the postscript end

This commit is contained in:
Xibo Ning 2016-08-31 12:11:16 +08:00 committed by Mike McLean
parent 4785d2cb3d
commit b82d804d02
2 changed files with 38 additions and 16 deletions

View file

@ -394,7 +394,7 @@ $value
<th>Result</th>
<td>
#if $abbr_result_text
<a href="#" collapse" id="toggle-result" style="display: none;">Show complete results</a>
<a href="#" collapse" id="toggle-abbreviated-result" style="display: none;">Show abbreviated results</a>
<div id="abbr-result">
$abbr_result_text
</div>
@ -432,23 +432,30 @@ $value
(function() {
var abbr = document.getElementById('abbr-result');
var full = document.getElementById('full-result');
t = document.getElementById('toggle-result');
var link_to_show_abbr = document.getElementById('toggle-abbreviated-result');
var link_to_show_full = document.getElementById('toggle-full-result');
full.style.display = 'none';
t.style.display = 'block';
t.text = 'Show complete result';
t.onclick = function(e) {
if(abbr.style.display == 'none') {
abbr.style.display = 'block'
link_to_show_full.style.display = 'inline'
link_to_show_abbr.style.display = 'none'
var trigger = function(e) {
if (link_to_show_abbr.style.display == 'none') {
link_to_show_abbr.style.display = 'inline'
link_to_show_full.style.display = 'none'
abbr.style.display = 'none';
full.style.display = 'block'
}
else {
link_to_show_abbr.style.display = 'none'
link_to_show_full.style.display = 'inline'
abbr.style.display = 'block';
full.style.display = 'none'
t.text = 'show complete result';
}
else {
abbr.style.display = 'none'
full.style.display = 'block';
t.text = 'Show abbreviated result';
}
return false;
};
link_to_show_full.onclick = trigger
link_to_show_abbr.onclick = trigger
})();
</script>
#end if

View file

@ -743,16 +743,31 @@ def task_result_to_html(result=None, exc_class=None,
Returns:
Tuple of full result and abbreviated result.
"""
default_max_abbr_result_lines = 11
default_max_abbr_result_lines = 10
default_max_abbr_result_len = 512
if max_abbr_lines is None:
max_abbr_lines = default_max_abbr_result_lines
if max_abbr_len is None:
max_abbr_len = default_max_abbr_result_len
postscript_fragment = TaskResultFragment(
text='...', end_tag='</a>',
begin_tag='<a href="#" collapse" %s %s>' % (
'id="toggle-full-result"',
'style="display: none;text-decoration:none;"'))
if abbr_postscript is None:
abbr_postscript = ' ...'
elif not abbr_postscript.startswith(' '):
abbr_postscript.startswith = ' %s' % abbr_postscript.startswith
abbr_postscript = postscript_fragment.composer()
elif isinstacne(abbr_postscript, TaskResultFragment):
abbr_postscript = abbr_postscript.composer()
elif isinstance(abbr_postscript, str):
abbr_postscript = abbr_postscript
else:
abbr_postscript = '...'
if not abbr_postscript.startswith(' '):
abbr_postscript = ' %s' % abbr_postscript
full_ret_str = ''
abbr_ret_str = ''