Download:
child 91:851d44214ed2
parent 89:6498a4ad0788
90:c8e8f09464cf
Anton Shestakov <av6@dwimlabs.net>, Sun, 03 Jul 2016 23:15:56 +0800
viewer: create collapsers wholly on client-side

1 файлов изменено, 8 вставок(+), 8 удалений(-) [+]
templates/check.html file | annotate | diff | comparison | revisions
--- a/templates/check.html Sun Jul 03 23:13:48 2016 +0800
+++ b/templates/check.html Sun Jul 03 23:15:56 2016 +0800
@@ -46,19 +46,19 @@
#}<div id="l{{ number }}"{% if 'task' in line %} data-task="{{ line['task'] }}"{% end %}{% if 'cls' in line %} class="{{ line['cls'] }}"{% end %}>{#
#}<a href="#l{{ number }}" class="lineno" data-line-number="{{ number }}"></a>{#
#}{{ line['text'] }}{#
- #}{% if line.get('cls') == 'task' and line.get('task') != 'cleanup' %}{#
- #}<a class="collapser"></a>{#
- #}{% end %}{#
#}</div>{#
#}{% end %}{#
#}</pre>
<script>
(function($) {
- $('.check-log .collapser').each(function() {
- var $collapser = $(this);
- var $header = $collapser.closest('div');
- var task = $header.attr('data-task');
- var $lines = $header.nextAll('[data-task="' + task + '"]');
+ $('.check-log div.task').each(function() {
+ var $line = $(this);
+ var task = $line.attr('data-task');
+ if (task == 'cleanup') { return; }
+ var $lines = $line.nextAll('[data-task="' + task + '"]');
+ if ($lines.length === 0) { return; }
+ var $collapser = $('<a>').addClass('collapser');
+ $line.append($collapser);
var toggle = function() {
var collapsed = $collapser.hasClass('collapsed');
$lines.toggleClass('uk-hidden', collapsed);