]> git.mjollnir.org Git - moodle.git/commitdiff
Fixed up styles for simple boxes see MDL-8101
authormoodler <moodler>
Tue, 23 Jan 2007 05:37:26 +0000 (05:37 +0000)
committermoodler <moodler>
Tue, 23 Jan 2007 05:37:26 +0000 (05:37 +0000)
lib/deprecatedlib.php
lib/weblib.php

index d4135882016c04e7a2ca870ae133f84abbf07fe2..fa932916e1bdced8cd42da2c4c115e4d33685d21 100644 (file)
@@ -836,14 +836,25 @@ function print_simple_box_start($align='', $width='', $color='', $padding=5, $cl
 
     $output = '';
 
-    $divclasses = $class.' '.$class.'content';
+    $divclasses = 'box '.$class.' '.$class.'content';
     $divstyles  = '';
 
     if ($align) {
         $divclasses .= ' boxalign'.$align;    // Implement alignment using a class
     }
     if ($width) {    // Hopefully we can eliminate these in calls to this function (inline styles are bad)
-        $divstyles  .= ' width:'.$width.';';
+        if (substr($width, -1, 1) == '%') {    // Width is a % value
+            $width = (int) substr($width, 0, -1);    // Extract just the number
+            if ($width < 40) {
+                $divclasses .= ' boxwidthnarrow';    // Approx 30% depending on theme
+            } else if ($width > 60) {
+                $divclasses .= ' boxwidthwide';      // Approx 80% depending on theme
+            } else {
+                $divclasses .= ' boxwidthnormal';    // Approx 50% depending on theme
+            }
+        } else {
+            $divstyles  .= ' width:'.$width.';';     // Last resort
+        }
     }
     if ($color) {    // Hopefully we can eliminate these in calls to this function (inline styles are bad)
         $divstyles  .= ' background:'.$color.';';
index 3452b3cc9bbe547155db61eba8bff04ac996e318..6368975dd7d0bd4da2ebcc950a8b657e03a97dd5 100644 (file)
@@ -2864,7 +2864,7 @@ function print_box_start($classes='generalbox', $ids='', $return=false) {
         $ids = ' id="'.$ids.'"';
     }
 
-    $output .= '<div'.$ids.' class="'.$classes.'">';
+    $output .= '<div'.$ids.' class="box '.$classes.'">';
 
     if ($return) {
         return $output;