Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / apps / workbench / app / assets / javascripts / sizing.js
index 640893fe0ca04f36aa4388f96da60c9834920b94..569956fd3a8d463737429bc2df5953b741e3051d 100644 (file)
@@ -1,3 +1,7 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
 function graph_zoom(divId, svgId, scale) {
     var pg = document.getElementById(divId);
     vcenter = (pg.scrollTop + (pg.scrollHeight - pg.scrollTopMax)/2.0) / pg.scrollHeight;
@@ -11,20 +15,21 @@ function graph_zoom(divId, svgId, scale) {
 }
 
 function smart_scroll_fixup(s) {
-    //console.log(s);
+
     if (s != null && s.type == 'shown.bs.tab') {
         s = [s.target];
     }
     else {
         s = $(".smart-scroll");
     }
-    //console.log(s);
-    for (var i = 0; i < s.length; i++) {
-        a = s[i];
-        var h = window.innerHeight - a.getBoundingClientRect().top - 20;
+
+    s.each(function(i, a) {
+        a = $(a);
+        var h = window.innerHeight - a.offset().top - a.attr("data-smart-scroll-padding-bottom");
         height = String(h) + "px";
-        a.style['max-height'] = height;
-    }
+        a.css('max-height', height);
+    });
 }
 
-$(window).on('load resize scroll', smart_scroll_fixup);
+$(window).on('load ready resize scroll ajax:complete', smart_scroll_fixup);
+$(document).on('shown.bs.tab', 'ul.nav-tabs > li > a', smart_scroll_fixup);