@@ 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');});
+ }
+});
@@ 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 %}