From 14e945650d3ff4fb934802c849612a67ed2a9245 Mon Sep 17 00:00:00 2001 From: cajus Date: Sun, 14 Mar 2010 12:01:25 +0000 Subject: [PATCH] Updated progress bar git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@16502 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/html/themes/modern/style.css | 1 + gosa-core/include/functions.inc | 106 +++++++++++++------------ 2 files changed, 55 insertions(+), 52 deletions(-) diff --git a/gosa-core/html/themes/modern/style.css b/gosa-core/html/themes/modern/style.css index 5db9f79a7..23ef115d7 100644 --- a/gosa-core/html/themes/modern/style.css +++ b/gosa-core/html/themes/modern/style.css @@ -1348,6 +1348,7 @@ background-image:none; div.progress { text-align:center; + display: block; color: rgba(255,255,255,0.9); padding:1px; border: 1px solid rgba(0,0,0,0.6); diff --git a/gosa-core/include/functions.inc b/gosa-core/include/functions.inc index cbcc4a46e..e0d4f8a35 100644 --- a/gosa-core/include/functions.inc +++ b/gosa-core/include/functions.inc @@ -2442,11 +2442,62 @@ function compare_revision($revision_file, $revision) * \param int 'percentage' Value to display * \param int 'width' width of the resulting output * \param int 'height' height of the resulting output - * \param boolean 'showvalue' weither to show the percentage in the progressbar or not + * \param boolean 'showtext' weither to show the percentage in the progressbar or not * */ -function progressbar($percentage,$width=100,$height=15,$showvalue=false) +function progressbar($percentage, $width= 200, $height= 14, $showText= false, $colorize= true, $id= "") { - return(""); + $text= ""; + $class= ""; + $style= "width:${width}px;height:${height}px;"; + + // Fix percentage range + $percentage= floor($percentage); + if ($percentage > 100) { + $percentage= 100; + } + if ($percentage < 0) { + $percentage= 0; + } + + // Only show text if we're above 10px height + if ($showText && $height>10){ + $text= $percentage."%"; + } + + // Set font size + $style.= "font-size:".($height-3)."px;"; + + // Set color + if ($colorize){ + if ($percentage < 70) { + $class= " progress-low"; + } elseif ($percentage < 80) { + $class= " progress-mid"; + } elseif ($percentage < 90) { + $class= " progress-high"; + } else { + $class= " progress-full"; + } + } + + // Apply gradients + $hoffset= floor($height / 2) + 4; + $woffset= floor(($width+5) * (100-$percentage) / 100); + $style.="-moz-box-shadow: + 0 0 2px rgba(255, 255, 255, 0.4) inset, + 0 4px 6px rgba(255, 255, 255, 0.4) inset, + 0 ".$hoffset."px 0 -2px rgba(255, 255, 255, 0.2) inset, + -".$woffset."px 0 0 -2px rgba(255, 255, 255, 0.2) inset, + -".($woffset+1)."px 0 0 -2px rgba(0, 0, 0, 0.6) inset, + 0pt ".($hoffset+1)."px 8px rgba(0, 0, 0, 0.3) inset, + 0pt 1px 0px rgba(0, 0, 0, 0.2);"; + + // Set ID + if ($id != ""){ + $id= "id='$id'"; + } + + return "
$text
"; } @@ -3582,54 +3633,5 @@ function image($path, $action= "", $title= "", $align= "middle") } -function progress($progress, $width= 200, $height= 14) -{ - $text= ""; - $class= ""; - $style= "width:${width};height:${height}px;"; - - // Fix progress range - $progress= floor($progress); - if ($progress > 100) { - $progress= 100; - } - if ($progress < 0) { - $progress= 0; - } - - // Only show text if we're above 10px height - if ($height>10){ - $text= $progress."%"; - } - - // Set font size - $style.= "font-size:".($height-3)."px;"; - - // Set color - if ($progress < 70) { - $class= " progress-low"; - } elseif ($progress < 80) { - $class= " progress-mid"; - } elseif ($progress < 90) { - $class= " progress-high"; - } else { - $class= " progress-full"; - } - - // Apply gradients - $hoffset= floor($height / 2) + 4; - $woffset= floor($width * (100-$progress) / 100); - $style.="-moz-box-shadow: - 0 0 2px rgba(255, 255, 255, 0.4) inset, - 0 4px 6px rgba(255, 255, 255, 0.4) inset, - 0 ".$hoffset."px 0 -2px rgba(255, 255, 255, 0.2) inset, - -".$woffset."px 0 0 -2px rgba(255, 255, 255, 0.2) inset, - -".($woffset+1)."px 0 0 -2px rgba(0, 0, 0, 0.6) inset, - 0pt ".($hoffset+1)."px 8px rgba(0, 0, 0, 0.3) inset, - 0pt 1px 0px rgba(0, 0, 0, 0.2);"; - - echo "
$text
"; -} - // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> -- 2.30.2