/** * Adds an option to the selectmenu. * * @param string $name The label * @param mixed $value The value * @param string $icon An image as icon * @return void */ public function AddOption($name, $value, $icon = false) { $opt = new Control("option"); $opt->value = $value; $opt->content($name); if ($icon) { $opt->class = $this->addIcon($icon); } $this->content($opt); }
/** * @param int $defvalue Initial value (seconds) * @param string $onchange onChange JS code */ function __initialize($defvalue = 0, $onchange = "") { parent::__initialize("div"); $defvalue = intval($defvalue); $m = floor($defvalue / 60); $s = $defvalue % 60; $id = $this->id; $this->class = "timeinput ui-widget-content ui-widget ui-corner-all"; $this->css("border", "1px solid transparent"); $this->onmouseover = "\$(this).css({border:''});"; $this->onmouseout = "\$(this).css({border:'1px solid transparent'});"; $minutes = new uiSlider(); $minutes->id = "{$id}_euro"; $minutes->range = 'min'; $minutes->min = 0; $minutes->max = 120; $minutes->value = $m; $minutes->css("margin-bottom", "8px"); $minutes->onslide = "function(event, ui){ \$('#{$id}_euro_value').text(ui.value<10?'0'+ui.value:ui.value);"; $minutes->onslide .= "\$('#{$id}_hidden').val( parseInt(\$('#{$id}_euro_value').text())*60 + parseInt(\$('#{$id}_cent_value').text()) ).change(); }"; $minutes->onmouseover = "\$('#{$id}_euro_value').css({color:'red'});"; $minutes->onmouseout = "\$('#{$id}_euro_value').css({color:'black'});"; $seconds = new uiSlider(); $seconds->id = "{$id}_cent"; $seconds->range = 'min'; $seconds->min = 0; $seconds->max = 59; $seconds->value = $s; $seconds->onslide = "function(event, ui){ \$('#{$id}_cent_value').text(ui.value<10?'0'+ui.value:ui.value); "; $seconds->onslide .= "\$('#{$id}_hidden').val( parseInt(\$('#{$id}_euro_value').text())*60 + parseInt(\$('#{$id}_cent_value').text()) ).change(); }"; $seconds->onmouseover = "\$('#{$id}_cent_value').css({color:'red'});"; $seconds->onmouseout = "\$('#{$id}_cent_value').css({color:'black'});"; $container = new Control("div"); $container->class = "container"; $container->content($minutes); $container->content($seconds); $value = new Control("div"); $value->class = "value"; $minuteval = new Control("div"); $minuteval->id = "{$id}_euro_value"; $minuteval->css("float", "left"); $minuteval->content($m < 9 ? "0{$m}" : $m); $secval = new Control("div"); $secval->id = "{$id}_cent_value"; $secval->css("float", "left"); $secval->content($s < 9 ? "0{$s}" : $s); $value->content($minuteval); $value->content("<div style='float:left'>:</div>"); $value->content($secval); $this->content($container); $this->content($value); $this->content("<input type='hidden' id='{$id}_hidden' name='{$id}' value='{$defvalue}' onchange='{$onchange}'/>"); $this->content("<br style='clear:both; line-height:0'/>"); }
protected function RenderPager() { $pages = ceil($this->TotalItems / $this->ItemsPerPage); if ($pages < 2) { return; } log_debug("RenderPager: {$this->CurrentPage}/{$pages}"); $ui = new Control('div'); $ui->addClass("pager"); if ($this->CurrentPage > 1) { $ui->content(new Anchor("javascript: \$('#{$this->id}').gotoPage(1)", "|<")); $ui->content(new Anchor("javascript: \$('#{$this->id}').gotoPage(" . ($this->CurrentPage - 1) . ")", "<")); } $start = 1; while ($pages > $this->MaxPagesToShow && $this->CurrentPage > $start + $this->MaxPagesToShow / 2) { $start++; } for ($i = $start; $i <= $pages && $i < $start + $this->MaxPagesToShow; $i++) { if ($i == $this->CurrentPage) { $ui->content("<span class='current'>{$i}</span>"); } else { $ui->content(new Anchor("javascript: \$('#{$this->id}').gotoPage({$i})", $i)); } } if ($this->CurrentPage < $pages) { $ui->content(new Anchor("javascript: \$('#{$this->id}').gotoPage(" . ($this->CurrentPage + 1) . ")", ">")); $ui->content(new Anchor("javascript: \$('#{$this->id}').gotoPage({$pages})", ">|")); } return $ui; }
/** * @param float $defvalue Initial value * @param string $onchange onChange JS code */ function __initialize($defvalue = 0, $onchange = "") { parent::__initialize("div"); $this->InitFunctionName = false; $defvalue = floatval(str_replace(",", ".", $defvalue)); $e = floor($defvalue); $c = round($defvalue - $e, 2) * 100; $id = $this->id; $this->class = "currencyinput ui-widget-content ui-widget ui-corner-all"; $this->css("border", "1px solid transparent"); $this->onmouseover = "\$(this).css({border:''});"; $this->onmouseout = "\$(this).css({border:'1px solid transparent'});"; $euro = new uiSlider(); $euro->id = "{$id}_euro"; $euro->range = 'min'; $euro->min = 0; $euro->max = 100; $euro->value = $e; $euro->css("margin-bottom", "8px"); $euro->onslide = "function(event, ui){ \$('#{$id}_euro_value').text(ui.value); "; $euro->onslide .= "\$('#{$id}_hidden').val( \$('#{$id}_euro_value').text()+'.'+\$('#{$id}_cent_value').text() ).change(); }"; $euro->onmouseover = "\$('#{$id}_euro_value').css({color:'red'});"; $euro->onmouseout = "\$('#{$id}_euro_value').css({color:'black'});"; $cent = new uiSlider(); $cent->id = "{$id}_cent"; $cent->range = 'min'; $cent->min = 0; $cent->max = 99; $cent->value = $c; $cent->onslide = "function(event, ui){ \$('#{$id}_cent_value').text(ui.value<10?'0'+ui.value:ui.value); "; $cent->onslide .= "\$('#{$id}_hidden').val( \$('#{$id}_euro_value').text()+'.'+\$('#{$id}_cent_value').text() ).change(); }"; $cent->onmouseover = "\$('#{$id}_cent_value').css({color:'red'});"; $cent->onmouseout = "\$('#{$id}_cent_value').css({color:'black'});"; $container = new Control("div"); $container->class = "container"; $container->content($euro); $container->content($cent); $value = new Control("div"); $value->class = "value"; $euroval = new Control("div"); $euroval->id = "{$id}_euro_value"; $euroval->css("float", "left"); $euroval->content($e); $centval = new Control("div"); $centval->id = "{$id}_cent_value"; $centval->css("float", "left"); $centval->content($c < 9 ? "0{$c}" : $c); $value->content("<div style='float:left'>€</div>"); $value->content($euroval); $value->content("<div style='float:left'>,</div>"); $value->content($centval); $this->content($container); $this->content($value); $this->content("<input type='hidden' id='{$id}_hidden' name='{$id}' value='{$defvalue}' onchange='{$onchange}'/>"); $this->content("<br style='clear:both; line-height:0'/>"); }
/** * Creates an option element. * * @param mixed $value The value * @param mixed $label An optional label * @param bool $selected True if selected (hint: use <Select::SetCurrentValue> instead of evaluating selected state for each option) * @param Control $opt_group If given the option will be added to this optgroup element. Create one via <Select::CreateGroup>. * @return Select `$this` */ function AddOption($value, $label = "", $selected = false, $opt_group = false) { $label = $label == "" ? $value : $label; $this->_options[$value] = $label; if (!$this->_first_option_value) { $this->_first_option_value = $value; } if (!$selected && $this->_current !== false) { $selected = $value == $this->_current; } $selected = $selected ? " selected='selected'" : ""; // $opt = "<option value='$value'$selected>".htmlspecialchars($label)."</option>\r\n"; $opt = "<option "; if ($value !== '') { $opt .= "value='{$value}'"; } $opt .= "{$selected}>" . $label . "</option>\r\n"; if ($opt_group) { $opt_group->content($opt); } else { $this->content($opt); } return $this; }