Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / apps / workbench / app / assets / javascripts / sizing.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 function graph_zoom(divId, svgId, scale) {
6     var pg = document.getElementById(divId);
7     vcenter = (pg.scrollTop + (pg.scrollHeight - pg.scrollTopMax)/2.0) / pg.scrollHeight;
8     hcenter = (pg.scrollLeft + (pg.scrollWidth - pg.scrollLeftMax)/2.0) / pg.scrollWidth;
9     var g = document.getElementById(svgId);
10     g.setAttribute("height", parseFloat(g.getAttribute("height")) * scale);
11     g.setAttribute("width", parseFloat(g.getAttribute("width")) * scale);
12     pg.scrollTop = (vcenter * pg.scrollHeight) - (pg.scrollHeight - pg.scrollTopMax)/2.0;
13     pg.scrollLeft = (hcenter * pg.scrollWidth) - (pg.scrollWidth - pg.scrollLeftMax)/2.0;
14     smart_scroll_fixup();
15 }
16
17 function smart_scroll_fixup(s) {
18
19     if (s != null && s.type == 'shown.bs.tab') {
20         s = [s.target];
21     }
22     else {
23         s = $(".smart-scroll");
24     }
25
26     s.each(function(i, a) {
27         a = $(a);
28         var h = window.innerHeight - a.offset().top - a.attr("data-smart-scroll-padding-bottom");
29         height = String(h) + "px";
30         a.css('max-height', height);
31     });
32 }
33
34 $(window).on('load ready resize scroll ajax:complete', smart_scroll_fixup);
35 $(document).on('shown.bs.tab', 'ul.nav-tabs > li > a', smart_scroll_fixup);