~netlandish/django-wiki

7abb5906850b987cf92d8e6b80e1d68c01d86692 — Sean Meyer 4 years ago b8c6d81
Fix loading more than one revision in history view

2 files changed, 16 insertions(+), 12 deletions(-)

M src/wiki/static/wiki/js/diff.js
M src/wiki/templates/wiki/history.html
M src/wiki/static/wiki/js/diff.js => src/wiki/static/wiki/js/diff.js +15 -11
@@ 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) {
                                                  '<dd>'+data.other_changes[i][1]+'</dd>'  ));
          }
        }
        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');});
  }
});

M src/wiki/templates/wiki/history.html => src/wiki/templates/wiki/history.html +1 -1
@@ 55,7 55,7 @@
      <div class="" id="accordion{{ revision.revision_number }}">
        <div class="card bg-light">
          <div class="card-body">
            <a class="wiki-card-toggle" style="float: left;" href="#collapse{{ revision.revision_number }}" onclick="get_diff_json('{% url 'wiki:diff' revision.id %}', $('#collapse{{ revision.revision_number }}'))">
            <a class="wiki-card-toggle" data-revision="{{ revision.revision_number }}" data-json-url="{% url 'wiki:diff' revision.id %}"  style="float: left;" href="#collapse{{ revision.revision_number }}">
              {% if revision == article.current_revision %}
                <i class="fa fa-flag"></i>
              {% else %}