# HG changeset patch # User Thomas De Schampheleire # Date 2019-11-20 15:12:23 # Node ID 34c8cb3198d8bd15204c827399acbac63b0917d8 # Parent fb0417c65c64a48d8f40cd57d8ffd8e4983ea561 diff: fix 2-way diff panel height Since a jQuery upgrade in commit c225c37c069d, 2-way diff was broken: the height was not correct, and sometimes the source code was shown in gray boxes. Analysis showed that in the invocation of mergely (templates/files/diff_2way.html), '$("#footer").height()' is undefined, in turn caused by the absence of an HTML element with id 'footer'. In jQuery 3.0, the height function returns 'undefined' on empty sets, while it was 'null' in older versions. This is important because in a mathematical expression, 'null' behaves as the number 0, but 'undefined' causes a NaN (not-a-number) result. See: https://jquery.com/upgrade-guide/3.0/#breaking-change-return-values-on-empty-sets-are-undefined The 'id' property on the footer was removed in commit 61c99cdbbfff, retaining only the 'class="footer"'. Fix the problem by using the class-based selector to get the footer height. As the footer height will now be an actual value instead of '0' originally, we can update the calculation without 'magic' values like '36' which was actually a reference to the footer size. When we initialize mergely, the page only contains the header and footer. All window space below the footer can be assigned to the compare panes. The height specified to mergely is thus the total window height minus the header height (the top position of the footer) and the footer height. Note: another change in this context is that jQuery 3.0 can now return non-integer values for .height(), e.g. 138.0345. In the case of 2-way diff, this is not an actual problem. See: https://jquery.com/upgrade-guide/3.0/#breaking-change-width-height-css-quot-width-quot-and-css-quot-height-quot-can-return-non-integer-values diff --git a/kallithea/templates/files/diff_2way.html b/kallithea/templates/files/diff_2way.html --- a/kallithea/templates/files/diff_2way.html +++ b/kallithea/templates/files/diff_2way.html @@ -67,7 +67,11 @@ var orig2_url = ${h.jshtml(h.url('files_ $(document).ready(function () { $('#compare').mergely({ width: 'auto', - height: $(window).height() - $('#compare').offset().top - $('#footer').height() - 35, + /* let the 2 compare panes use all the window space currently available + below footer (i.e. on an empty page with just header and footer): */ + height: $(window).height() + - $('.footer').offset().top + - $('.footer').height(), fgcolor: {a:'#ddffdd',c:'#cccccc',d:'#ffdddd'}, bgcolor: '#fff', viewport: true,