diff options
Diffstat (limited to 'utils/forms.php')
-rw-r--r-- | utils/forms.php | 25 |
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 |