forked from extern/egroupware
new option &128 to NOT require an extra trigger for date popup, clicking
into input box is enought and removing of extra separators to be more compact
This commit is contained in:
parent
d53b681f21
commit
0814820652
@ -24,6 +24,7 @@
|
||||
* &16 = prefix r/o display with dow
|
||||
* &32 = prefix r/o display with week-number
|
||||
* &64 = prefix r/o display with weeknumber and dow
|
||||
* &128 = no icon to trigger popup, click into input trigers it, also removing the separators to save space
|
||||
* This widget is independent of the UI as it only uses etemplate-widgets and has therefor no render-function.
|
||||
* Uses the adodb datelibary to overcome the windows-limitation to not allow dates before 1970
|
||||
*/
|
||||
@ -134,8 +135,8 @@ class date_widget
|
||||
{
|
||||
for($n = $i = 0; $n < strlen($data_format); ++$n)
|
||||
{
|
||||
$mdy[$n] = $data_format{$n};
|
||||
$len = $data_format{$n} == 'Y' ? 4 : 2;
|
||||
$mdy[$n] = $data_format[$n];
|
||||
$len = $data_format[$n] == 'Y' ? 4 : 2;
|
||||
$date[$n] = substr($value,$i,$len);
|
||||
$i += $len;
|
||||
}
|
||||
@ -280,7 +281,7 @@ class date_widget
|
||||
$dcell['type'] = 'html';
|
||||
$dcell['name'] = 'str';
|
||||
$jscaloptions = $cell['onchange'] ? ( "onchange='". ( (int)$cell['onchange'] === 1 ? "this.form.submit();'" : $cell['onchange']. "'" ) ) : '' ;
|
||||
$value['str'] = $this->jscal->input($name.'[str]',False,$value['Y'],$value['m'],$value['d'],lang($cell['help']),$jscaloptions);
|
||||
$value['str'] = $this->jscal->input($name.'[str]',False,$value['Y'],$value['m'],$value['d'],lang($cell['help']),$jscaloptions,false,!($options & 128));
|
||||
$n = 2; // no other fields
|
||||
$options &= ~2; // no set-today button
|
||||
}
|
||||
@ -293,7 +294,7 @@ class date_widget
|
||||
}
|
||||
if ($n == 4)
|
||||
{
|
||||
$dcell['label'] = ':'; // put a : between hour and minute
|
||||
$dcell['label'] = $options & 128 ? '' : ':'; // put a : between hour and minute
|
||||
}
|
||||
$dcell['no_lang'] = 2;
|
||||
$row[$tpl->num2chrs($i)] = &$dcell;
|
||||
@ -316,7 +317,7 @@ class date_widget
|
||||
$row[$tpl->num2chrs(++$i)] = &$dcell;
|
||||
unset($dcell);
|
||||
}
|
||||
if ($n == 2 && $type == 'date-time') // insert some space between date+time
|
||||
if ($n == 2 && $type == 'date-time' && !($options & 128)) // insert some space between date+time
|
||||
{
|
||||
$dcell = $tpl->empty_cell();
|
||||
$dcell['type'] = 'html';
|
||||
|
@ -82,9 +82,10 @@ class jscalendar
|
||||
* @param string $helpmsg='' a helpmessage for the statusline of the browser
|
||||
* @param string $options='' any other options to the inputfield
|
||||
* @param boolean $jsreturn=false
|
||||
* @param boolean $useicon=true true: use icon to trigger popup, false: click into input triggers popup
|
||||
* @return string html
|
||||
*/
|
||||
function input($name,$date,$year=0,$month=0,$day=0,$helpmsg='',$options='',$jsreturn=false)
|
||||
function input($name,$date,$year=0,$month=0,$day=0,$helpmsg='',$options='',$jsreturn=false,$useicon=true)
|
||||
{
|
||||
//echo "<p>jscalendar::input(name='$name', date='$date'='".date('Y-m-d',$date)."', year='$year', month='$month', day='$day')</p>\n";
|
||||
|
||||
@ -122,20 +123,21 @@ class jscalendar
|
||||
if ($jsreturn)
|
||||
{
|
||||
$return_array = array(
|
||||
'html' => '<input type="text" id="'.$name.'" name="'.$name.'" size="10" value="'.$date.'"'.$options.'/><img id="'.$name.'-trigger" src="'.common::find_image('phpgwpai','datepopup').'" title="'.lang('Select date').'" style="cursor:pointer; cursor:hand;"/>',
|
||||
'js' => 'Calendar.setup({inputField : "'.$name.'",button: "'.$name.'-trigger" });'
|
||||
'html' => '<input type="text" id="'.$name.'" name="'.$name.'" size="10" value="'.htmlspecialchars($date).'"'.$options.'/>'.
|
||||
($useicon ? '<img id="'.$name.'-trigger" src="'.common::find_image('phpgwpai','datepopup').'" title="'.lang('Select date').'" style="cursor:pointer; cursor:hand;"/>' : ''),
|
||||
'js' => 'Calendar.setup({inputField : "'.$name.'"'.($useicon ? ',button: "'.$name.'-trigger"' : '').' });'
|
||||
);
|
||||
|
||||
return $return_array;
|
||||
}
|
||||
return
|
||||
'<input type="text" id="'.$name.'" name="'.$name.'" size="10" value="'.$date.'"'.$options.'/>
|
||||
<script type="text/javascript">
|
||||
document.writeln(\'<img id="'.$name.'-trigger" src="'.common::find_image('phpgwpai','datepopup').'" title="'.lang('Select date').'" style="cursor:pointer; cursor:hand;"/>\');
|
||||
'<input type="text" id="'.$name.'" name="'.$name.'" size="10" value="'.htmlspecialchars($date).'"'.$options.'/>
|
||||
<script type="text/javascript">'.(!$useicon ? '' : '
|
||||
document.writeln(\'<img id="'.$name.'-trigger" src="'.common::find_image('phpgwpai','datepopup').'" title="'.lang('Select date').'" style="cursor:pointer; cursor:hand;"/>\');').'
|
||||
Calendar.setup(
|
||||
{
|
||||
inputField : "'.$name.'",
|
||||
button : "'.$name.'-trigger"
|
||||
inputField : "'.$name.'",'.(!$useicon ? '' : '
|
||||
button : "'.$name.'-trigger"').'
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user