From 094f7d50da96060b964c0cbdcd9b282c249d6744 Mon Sep 17 00:00:00 2001 From: Louis Bailleul Date: Fri, 27 Nov 2015 11:58:56 +0000 Subject: [PATCH] Replace the reload on browser resize by a graph width resize --- html/includes/functions.inc.php | 2 +- html/js/librenms.js | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index dc23186a9..7588f237d 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -476,7 +476,7 @@ function generate_lazy_graph_tag($args) { $urlargs[] = $key."=".urlencode($arg); } - return ''; + return ''; }//end generate_lazy_graph_tag() diff --git a/html/js/librenms.js b/html/js/librenms.js index 264dab25c..ef1d6e582 100644 --- a/html/js/librenms.js +++ b/html/js/librenms.js @@ -1,3 +1,5 @@ +var oldH; +var oldW; $(document).ready(function() { // Device override ajax calls $("[name='override_config']").bootstrapSwitch('offColor','danger'); @@ -123,6 +125,8 @@ $(document).ready(function() { }); }); + oldW=$(window).width(); + oldH=$(window).height(); }); function submitCustomRange(frmdata) { @@ -144,14 +148,13 @@ function updateResolution() height:$(window).height() }, function(data) { - location.reload(); },'json' ); } var rtime; var timeout = false; -var delta = 300; +var delta = 500; $(window).on('resize', function(){ rtime = new Date(); @@ -168,9 +171,26 @@ function resizeend() { else { timeout = false; updateResolution(); + resizeGraphs(); } }; +function resizeGraphs() { + newH=$(window).height(); + newW=$(window).width(); + + ratioW=newW/oldW; + ratioH=newH/oldH; + + $('.graphs').each(function (){ + var img = jQuery(this); + img.attr('width',img.width() * ratioW); + }); + oldH=newH; + oldW=newW; +} + + $(document).on("click", '.collapse-neighbors', function(event) { var caller = $(this);