/** * @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'/>"); }
/** * @param int $defvalue Initial value (seconds) * @param string $onchange onChange JS code */ function __initialize($defvalue = 0, $onchange = "") { parent::__initialize("div"); $this->InitFunctionName = false; $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'/>"); }