From ddde44ea3cd12ba22ea75a3103d7608c27278288 Mon Sep 17 00:00:00 2001
From: Ralf Becker
Date: Mon, 27 Mar 2006 12:21:29 +0000
Subject: [PATCH] added precision to the float widget
---
etemplate/doc/reference.html | 3 ++-
etemplate/inc/class.uietemplate.inc.php | 8 ++++++--
etemplate/inc/class.xul_io.inc.php | 2 +-
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/etemplate/doc/reference.html b/etemplate/doc/reference.html
index fe806bee17..57ec7229fd 100644
--- a/etemplate/doc/reference.html
+++ b/etemplate/doc/reference.html
@@ -430,10 +430,11 @@ implement only a subset of XUL. Here are the main differences:
a input-field to enter a float
In the html-UI this is rendered as <input ...>. The input-validation is done at the moment only on server-side,
clientside validation and input-restriction to only numbers is planed.
- Options has 3 comma-separated fields:
+ Options has 4 comma-separated fields:
xml: min: minimum value, default none, empty values are Ok, as long as needed is not set
xml: max: maximum value, default none, empty values are Ok, as long as needed is not set
xml: size: the length in chars of the input-field, default 5
+ xml: precision: precision of the float number, default maximum
diff --git a/etemplate/inc/class.uietemplate.inc.php b/etemplate/inc/class.uietemplate.inc.php
index 6c52747dfb..23ab2baf5b 100644
--- a/etemplate/inc/class.uietemplate.inc.php
+++ b/etemplate/inc/class.uietemplate.inc.php
@@ -893,13 +893,17 @@
list($extra_link,$extra_link_target,$extra_link_popup) = explode(',',$cell_options);
$html .= $value;
break;
- case 'int': // size: [min][,[max][,len]]
+ case 'int': // size: [min],[max],[len],[precission (only float)]
case 'float':
- list($min,$max,$cell_options) = explode(',',$cell_options);
+ list($min,$max,$cell_options,$pre) = explode(',',$cell_options);
if ($cell_options == '')
{
$cell_options = $cell['type'] == 'int' ? 5 : 8;
}
+ if ($type == 'float' && $value && $pre)
+ {
+ $value = round($value,$pre);
+ }
$cell_options .= ',,'.($cell['type'] == 'int' ? '/^-?[0-9]*$/' : '/^-?[0-9]*[,.]?[0-9]*$/');
// fall-through
case 'text': // size: [length][,maxLength[,preg]]
diff --git a/etemplate/inc/class.xul_io.inc.php b/etemplate/inc/class.xul_io.inc.php
index ec45c0df20..0fdeda8ff5 100644
--- a/etemplate/inc/class.xul_io.inc.php
+++ b/etemplate/inc/class.xul_io.inc.php
@@ -79,7 +79,7 @@
'float' => array(
'.name' => 'textbox',
'.set' => 'type=float',
- 'size' => 'min,max,size'
+ 'size' => 'min,max,size,precision'
),
'select' => array(
'.name' => 'menulist,menupopup',