Mercurial > kallithea
view MIT-Permissive-License.txt @ 7961:34c8cb3198d8
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
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Wed, 20 Nov 2019 15:12:23 +0100 |
parents | 08baa849c8a8 |
children |
line wrap: on
line source
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.