Download:
child 278:4be6e6d834b4
parent 276:019d9192cf9c
277:6777a5c2acad
Anton Shestakov <av6@dwimlabs.net>, Sun, 30 Jul 2017 14:18:11 +0800
viewer: move .check-log collapser function to candolint.js

2 файлов изменено, 24 вставок(+), 25 удалений(-) [+]
static/candolint.js file | annotate | diff | comparison | revisions
templates/check.html file | annotate | diff | comparison | revisions
--- a/static/candolint.js Sun Jul 30 13:37:55 2017 +0800
+++ b/static/candolint.js Sun Jul 30 14:18:11 2017 +0800
@@ -8,3 +8,27 @@
humanizeTimestamps();
window.setInterval(humanizeTimestamps, 15 * 1000);
})(jQuery);
+
+(function($) {
+ $('.check-log div.task').each(function() {
+ var $line = $(this);
+ var task = $line.attr('data-task');
+ 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);
+ };
+ $collapser.on('click', function() {
+ $collapser.toggleClass('collapsed');
+ toggle();
+ });
+ var important = '.error, .warning, .failure, :target';
+ if (task !== 'checks' && $lines.filter(important).length === 0) {
+ $collapser.addClass('collapsed');
+ toggle();
+ }
+ });
+})(jQuery);
--- a/templates/check.html Sun Jul 30 13:37:55 2017 +0800
+++ b/templates/check.html Sun Jul 30 14:18:11 2017 +0800
@@ -62,30 +62,5 @@
#}</div>{#
#}{% end %}{#
#}</pre>
- <script>
- (function($) {
- $('.check-log div.task').each(function() {
- var $line = $(this);
- var task = $line.attr('data-task');
- 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);
- };
- $collapser.on('click', function() {
- $collapser.toggleClass('collapsed');
- toggle();
- });
- var important = '.error, .warning, .failure, :target';
- if (task !== 'checks' && $lines.filter(important).length === 0) {
- $collapser.addClass('collapsed');
- toggle();
- }
- });
- })(jQuery);
- </script>
</div>
{% end %}