commit:     a0bd86ca404ac92f7751c6407445cb51419c44d0
Author:     Max Magorsch <arzano <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  7 21:55:13 2020 +0000
Commit:     Max Magorsch <arzano <AT> gentoo <DOT> org>
CommitDate: Sun Jun  7 21:55:13 2020 +0000
URL:        
https://gitweb.gentoo.org/proj/gentoo-mirrorstats.git/commit/?id=a0bd86ca

Enlarge the page when using the filters

Signed-off-by: Max Magorsch <arzano <AT> gentoo.org>

 html/stats.jinja2 | 41 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 5 deletions(-)

diff --git a/html/stats.jinja2 b/html/stats.jinja2
index 482a2cf..9c04d5a 100644
--- a/html/stats.jinja2
+++ b/html/stats.jinja2
@@ -78,7 +78,7 @@
   </header>
 
 
-  <div class="container">
+  <div id="map_container" class="container">
     <div class="row">
       <div class="col-md-12">
         <h1 class="first-header">Gentoo {% if type != "all" %}{{ 
type[0]|upper}}{{type[1:]}}{%endif%} Mirrors
@@ -98,6 +98,12 @@
         <div id="mirrorLocations" style="height: 500px; margin-bottom: 
1em;"></div>
       </div>
 
+    </div>
+  </div>
+
+  <div id="table_container" class="container">
+      <div class="row">
+
       <div class="col-md-12 my-4">
         <table id="table_id" class="display table">
           <thead>
@@ -207,9 +213,13 @@
 
   <script>
 
-    $(function() {
+    var map;
+    function drawMap() {
+      if(map){
+          map.remove();
+      }
       L.Icon.Default.imagePath = 'https://www.gentoo.org/assets/img/maps/';
-      var map = L.map('mirrorLocations', { zoomAnimationThreshold: 9 } 
).setView([30, 0], 2);
+      map = L.map('mirrorLocations', { zoomAnimationThreshold: 9 } 
).setView([30, 0], 2);
       var markers = {};
 
       map.addLayer(new 
L.TileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { minZoom: 2, 
maxZoom: 8, attribution: 'Map data © <a 
href="https://openstreetmap.org";>OpenStreetMap</a> contributors' }));
@@ -307,7 +317,9 @@
           markers[index] = marker;
         }
       });
-    });
+    }
+
+    drawMap();
   </script>
 
   <script>
@@ -352,7 +364,7 @@
         ],
         "initComplete": function( settings, json ) {
             setTimeout(function(){
-                $('#table_id_length').prepend("<button onclick='addFilters();' 
class='btn btn-outline-secondary filter-button btn-sm mr-4'>Toggle 
Filters</button>");
+                $('#table_id_length').prepend("<button onclick='addFilters();' 
class='btn btn-outline-secondary filter-button btn-sm mr-4'>Filters & 
Fullscreen</button>");
                 table.buttons().container().prependTo($('#table_id_length'));
                 $('#table_id_length').prepend("<span class='mr-1'> Show 
</span>");
                 document.getElementsByClassName("buttons-colvis")[0].classList 
= "custom-select custom-select-sm form-control form-control-sm mr-4";
@@ -363,6 +375,25 @@
 
     function addFilters(){
 
+        if(document.getElementById("table_container").classList == 
"container"){
+            document.getElementById("table_container").classList = 
"container-fluid"
+        }else{
+            document.getElementById("table_container").classList = "container";
+        }
+
+        if(document.getElementById("map_container").classList == "container"){
+            document.getElementById("map_container").classList = 
"container-fluid"
+        }else{
+            document.getElementById("map_container").classList = "container";
+        }
+
+        setTimeout(function() {
+            drawMap();
+            $("#table_id").width($("#table_container").width());
+            table.columns.adjust();
+        }, 200);
+
+
         if($("#filterRow").length) {
             $("#filterRow").remove();
         }else{

Reply via email to