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