summaryrefslogtreecommitdiff
path: root/utils/forms.php
diff options
context:
space:
mode:
authordeva <deva>2009-04-28 07:36:01 +0000
committerdeva <deva>2009-04-28 07:36:01 +0000
commit3cb7a7f16be016f2d563762379222fdea5767986 (patch)
treeb53f875ae6c3f5b6eaa68c5e1623f32793e94732 /utils/forms.php
parent1a8817ea76efb61240a9baa1673b95438e8770d9 (diff)
Added icon module, and made the news module use it. Also made the ImageComboBox use it if supplied as the values parameter.
Diffstat (limited to 'utils/forms.php')
-rw-r--r--utils/forms.php25
1 files changed, 18 insertions, 7 deletions
diff --git a/utils/forms.php b/utils/forms.php
index d946c34..a450463 100644
--- a/utils/forms.php
+++ b/utils/forms.php
@@ -209,7 +209,12 @@ class ImageComboBox {
public function render($indent = "")
{
- $width = 100;
+ $selheight = 64;
+ $height = $selheight * 0.8;
+
+ if(get_class($this->values) == "Icons") $numicons = sizeof($this->values->icons);
+ else $numicons = sizeof($this->values);
+
$str = $indent . "<div class=\"input\">\n";
$str .= $indent . " <div class=\"label\">".$this->label."</div>\n";
$str .= $indent . " <div class=\"widget\">\n";
@@ -220,18 +225,24 @@ class ImageComboBox {
$str .= $indent . " var container = document.getElementById('icons');\n";
$str .= $indent . " var icons = document.getElementsByName('icon');\n";
$str .= $indent . " for(i = 0; i < icons.length; i++) {\n";
- $str .= $indent . " if(icons[i].src == value) icons[i].width = ".$width.";\n";
- $str .= $indent . " else icons[i].width = ".($width - 10).";\n";
+ $str .= $indent . " if(icons[i].alt == value) icons[i].height = ".$selheight.";\n";
+ $str .= $indent . " else icons[i].height = ".$height.";\n";
// $str .= $indent . " if(icons[i].src == value) icons[i].style.border = '10px blue';\n";
// $str .= $indent . " else { icons[i].style.border = '0px' }\n";
$str .= $indent . " }\n";
$str .= $indent . " }\n";
$str .= $indent . " </script>\n";
- $str .= $indent . " <div style=\"width:300px;overflow:scroll;\">\n";
- $str .= $indent . " <div id=\"icons\" style=\"width:".($width + 6)*sizeof($this->values)."px;\">\n";
+ $str .= $indent . " <div style=\"width:300px;overflow:auto;height:".($selheight+24)."px;\">\n";
+ $str .= $indent . " <div id=\"icons\" style=\"text-align: left; height: ".$selheight."px; width:".(($height+8)*($numicons-1)+$selheight)."px; display: block;\">\n";
$str .= $indent . " <input id=\"".$this->name."\" name=\"vars[".$this->name."]\" type=\"hidden\" value=\"\"/>\n";
- foreach($this->values as $k => $v) {
- $str .= $indent . " <img name=\"icon\" src=\"".$v."\" style=\"max-width: ".$width."\" onclick=\"setSelection('".$v."')\"/>\n";
+ if(get_class($this->values) == "Icons") {
+ foreach($this->values->icons as $icon) {
+ $str .= $indent . " <img name=\"icon\" alt=\"".$icon->file."\" src=\"".$icon->prefix.$icon->file."\" onclick=\"setSelection('".$icon->file."')\"/>\n";
+ }
+ } else {
+ foreach($this->values as $k => $v) {
+ $str .= $indent . " <img name=\"icon\" alt=\"".$v."\" src=\"".$v."\" onclick=\"setSelection('".$v."')\"/>\n";
+ }
}
$str .= $indent . " </div>\n"; // box
$str .= $indent . " </div>\n"; // overflow