From 7abb5906850b987cf92d8e6b80e1d68c01d86692 Mon Sep 17 00:00:00 2001 From: Sean Meyer Date: Wed, 1 Apr 2020 14:26:32 +0800 Subject: [PATCH] Fix loading more than one revision in history view --- src/wiki/static/wiki/js/diff.js | 26 +++++++++++++++----------- src/wiki/templates/wiki/history.html | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/wiki/static/wiki/js/diff.js b/src/wiki/static/wiki/js/diff.js index b20460c0..76b7622e 100644 --- a/src/wiki/static/wiki/js/diff.js +++ b/src/wiki/static/wiki/js/diff.js @@ -1,8 +1,12 @@ +$(".wiki-card-toggle").on("click", function(){ + var revision = this.dataset.revision; + var url = this.dataset.jsonUrl; + var put_in_element = "#collapse"+revision; -function get_diff_json(url, put_in_element) { - jsonWrapper(url, function (data) { - if (!$(put_in_element).find('.diff-container tbody').length > 0) { - $(put_in_element).parentsUntil('.card-group').find('.progress').show(0 , function() { + if ($(put_in_element).find('.diff-container tbody').length === 0) { + jsonWrapper(url, function (data) { + + $(put_in_element).parent().find('.progress').show(0 , function() { tbody = pydifferviewer.as_tbody({differ_output: data.diff}); $(put_in_element).find('.diff-container table').append( tbody @@ -13,11 +17,11 @@ function get_diff_json(url, put_in_element) { '
'+data.other_changes[i][1]+'
' )); } } - put_in_element.find('.diff-container').show('fast', function() {put_in_element.collapse('show');}); - $(put_in_element).parentsUntil('.card-group').find('.progress').detach(); + $(put_in_element).find('.diff-container').show('fast', function() {$(put_in_element).collapse('show');}); + $(put_in_element).parent().find('.progress').detach(); }); - } else { - put_in_element.find('.diff-container').show('fast', function() {put_in_element.collapse('toggle');}); - } - }); -} + }); + }else { + $(put_in_element).find('.diff-container').show('fast', function() {$(put_in_element).collapse('toggle');}); + } +}); diff --git a/src/wiki/templates/wiki/history.html b/src/wiki/templates/wiki/history.html index 792423c5..75ff9b66 100644 --- a/src/wiki/templates/wiki/history.html +++ b/src/wiki/templates/wiki/history.html @@ -55,7 +55,7 @@