Changeset:
        ee93ba16e3b0
        
https://sourceforge.net/p/mrbs/hg-code/ci/ee93ba16e3b001c5e8c3ea3c026003f47720e20c
Author:
        Campbell Morrison <[email protected]>
Date:
        Mon Mar 27 21:02:42 2017 +0100
Log message:

Fixed table width by having sub-tables

diffstat:

 web/css/mrbs.css.php |   9 ++++++
 web/index.php        |  71 ++++++++++++++++++++++++++++++++++++++++++++++++---
 2 files changed, 75 insertions(+), 5 deletions(-)

diffs (130 lines):

diff -r 0f940fabff9d -r ee93ba16e3b0 web/css/mrbs.css.php
--- a/web/css/mrbs.css.php      Mon Mar 27 18:12:36 2017 +0100
+++ b/web/css/mrbs.css.php      Mon Mar 27 21:02:42 2017 +0100
@@ -1424,6 +1424,15 @@
   width: 100%;
 }
 
+.main_view_data {
+  width: 100%;
+  table-layout: fixed;
+}
+
+.main_view td {
+  overflow: hidden;
+}
+
 .main_view a {
   display: block;
   width: 100%;
diff -r 0f940fabff9d -r ee93ba16e3b0 web/index.php
--- a/web/index.php     Mon Mar 27 18:12:36 2017 +0100
+++ b/web/index.php     Mon Mar 27 21:02:42 2017 +0100
@@ -119,16 +119,51 @@
 }
 
 
-function get_table($map)
+function get_row_labels_table($map)
 {
   $html = '';
   
-  $html .= "<table class=\"main_view\">\n";
+  $html .= "<table class=\"main_view_labels\">\n";
+  
+  $html .= "<thead>\n";
+  $html .= "<tr><th></th></tr>\n";
+  $html .= "</thead>\n";
+  
+  $html .= "<tbody>\n";
+  foreach ($map as $room_id => $row)
+  {
+    $html.= "<tr><td>$room_id</td></tr>\n";
+  }
+  $html .= "</tbody>\n";
+  
+  $html .= "</table>\n";
+  
+  return $html;
+}
+
+
+function get_row_data_table($map)
+{
+  $html = '';
+  
+  $html .= "<table class=\"main_view_data\">\n";
+
+  $html .= "<thead>\n";
+  $html .= "<tr>\n";
+  $n_cols = count(current($map));
+  $column_width = number_format(100/$n_cols, 6);
+  for ($i=0; $i<$n_cols; $i++)
+  {
+    $html .= "<th style=\"max-width: $column_width%\"></th>\n";
+  }
+  $html .= "</tr>\n";  
+  $html .= "</thead>\n";
+  
+  $html .= "<tbody>\n";
   
   foreach ($map as $room_id => $row)
   {
     $html .= "<tr>\n";
-    $html .= "<td>$room_id</td>\n";
     $last_id = null;
     
     while (($data = current($row)) !== false)
@@ -140,6 +175,7 @@
           // The booking has come to an end, so write it out
           $last_id = null;
           $html .= get_cell_html($content, $type, $n_slots);
+          prev($row);
         }
         else
         {
@@ -180,10 +216,19 @@
         trigger_error("To do");
       }
       $data = next($row);
-      if (($data === false) && isset($last_id))
+      if ($data === false)
       {
         // We're at the end of the row and there's a booking to write out
-        $html .= get_cell_html($content, $type, $n_slots);
+        if (isset($last_id))
+        {
+          $html .= get_cell_html($content, $type, $n_slots);
+        }
+        else
+        {
+          // This is an empty slot
+          $content = "<a href=\"\"></a>\n";  // JUST FOR NOW - TO DO
+          //$html .= get_cell_html($content, 'new');
+        }
         break;
       }
     }
@@ -191,6 +236,22 @@
     $html .= "</tr>\n";
   }
   
+  $html .= "</tbody>\n";
+  
+  $html .= "</table>\n";
+  
+  return $html;
+}
+
+function get_table($map)
+{
+  $html = '';
+  
+  $html .= "<table class=\"main_view\">\n";
+  $html .= "<tr>\n";
+  $html .= "<td>" . get_row_labels_table($map) . "</td>\n";
+  $html .= "<td>" . get_row_data_table($map) . " </td>\n";
+  $html .= "</tr>\n";
   $html .= "</table>\n";
   
   return $html;

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to