# HG changeset patch # User Thomas De Schampheleire # Date 2019-04-14 20:32:10 # Node ID b293ec74ef989195daaeb33fd5259bfd01dbe5b8 # Parent 6df08d78f8e73534c537813b3f73c18e6164ecd5 files: restore 'Show Authors' functionality Commit d66201a7ce6e ("files: change "callbacks" function to the more descriptive name "post_load_state" and let it take an actual state data object") broke the 'Show Authors' button when visiting a file in the files browser. The button normally shows a count of authors and their avatars, but after the aforementioned commit it did nothing. Following patch would have fixed the problems in commit d66201a7ce6e: diff --git a/kallithea/templates/files/files_source.html b/kallithea/templates/files/files_source.html --- a/kallithea/templates/files/files_source.html +++ b/kallithea/templates/files/files_source.html @@ -81,11 +81,13 @@ But, later the code got refactored more, and commit 006d68c4d7b9 ("files: use the web browsers built-in js history instead of native.history.js") broke the feature further: the click handler for the button no longer got installed on the 'document-ready' event, but only when a new 'state' is loaded. And it seems there is never a situation where a new state preserves the button, so it makes no sense installing the click handler at that moment. Instead, move the click handler back to the 'document-ready' event. diff --git a/kallithea/templates/files/files.html b/kallithea/templates/files/files.html --- a/kallithea/templates/files/files.html +++ b/kallithea/templates/files/files.html @@ -205,16 +205,6 @@ var post_load_state = function(state) { } } }); - $('#show_authors').on('click', function(){ - $.ajax({ - url: pyroutes.url('files_authors_home', {'revision': _rev, 'f_path': _f_path}), - success: function(data) { - $('#file_authors').html(data); - $('#file_authors').show(); - tooltip_activate(); - } - }); - }); } $(document).ready(function(){ @@ -247,6 +237,16 @@ $(document).ready(function(){ $("#branch_selector").val(${h.js(c.changeset.raw_id)}); } }); + $('#show_authors').on('click', function(){ + $.ajax({ + url: pyroutes.url('files_authors_home', {'revision': ${h.js(c.changeset.raw_id)}, 'f_path': ${h.js(h.safe_unicode(c.file.path))}}), + success: function(data) { + $('#file_authors').html(data); + $('#file_authors').show(); + tooltip_activate(); + } + }); + }); });