From 987619130b99bf4548d5d31ac453cdf48c818eff Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 24 Nov 2015 14:15:28 +0100 Subject: some event heavy lifting - please test and report issues --- include/datetime.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index 63287d023..22232fe24 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -198,7 +198,7 @@ function timesel($format, $h, $m, $id='timepicker') { * @todo Once browser support is better this could probably be replaced with * native HTML5 date picker. */ -function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false, $first_day = 0) { +function datetimesel($format, $min, $max, $default = 'bla', $label, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false, $first_day = 0) { $o = ''; $dateformat = ''; @@ -207,11 +207,11 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic if($pickdate && $picktime) $dateformat .= ' '; if($picktime) $dateformat .= 'H:i'; - $minjs = $min ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : ''; - $maxjs = $max ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : ''; + $minjs = $min->getTimestamp() ? ",minDate: new Date({$min->getTimestamp()}*1000), yearStart: " . $min->format('Y') : ''; + $maxjs = $max->getTimestamp() ? ",maxDate: new Date({$max->getTimestamp()}*1000), yearEnd: " . $max->format('Y') : ''; - $input_text = $default ? 'value="' . date($dateformat, $default->getTimestamp()) . '"' : ''; - $defaultdatejs = $default ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : ''; + $input_text = $default->getTimestamp() ? date($dateformat, $default->getTimestamp()) : ''; + $defaultdatejs = $default->getTimestamp() ? ",defaultDate: new Date({$default->getTimestamp()}*1000)" : ''; $pickers = ''; if(!$pickdate) $pickers .= ',datepicker: false'; @@ -219,10 +219,10 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic $extra_js = ''; if($minfrom != '') - $extra_js .= "\$('#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})"; + $extra_js .= "\$('#id_$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})"; if($maxfrom != '') - $extra_js .= "\$('#$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})"; + $extra_js .= "\$('#id_$maxfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#id_$id').data('xdsoft_datetimepicker').setOptions({maxDate: currentDateTime})}})"; $readable_format = $dateformat; $readable_format = str_replace('Y','yyyy',$readable_format); @@ -231,10 +231,11 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic $readable_format = str_replace('H','HH',$readable_format); $readable_format = str_replace('i','MM',$readable_format); - $o .= "
"; - $o .= (($required) ? '*' : ''); - $o .= '
'; - $o .= ""; + $tpl = get_markup_template('field_input.tpl'); + $o .= replace_macros($tpl,array( + '$field' => array($id, $label, $input_text, (($required) ? t('Required') : ''), (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'), + )); + $o .= ""; return $o; } -- cgit v1.2.3 From 5a12944b392a2996257ca24318c0e3319003ed9d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 24 Nov 2015 14:18:29 +0100 Subject: oups :) --- include/datetime.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index 22232fe24..ab9b061b6 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -198,7 +198,7 @@ function timesel($format, $h, $m, $id='timepicker') { * @todo Once browser support is better this could probably be replaced with * native HTML5 date picker. */ -function datetimesel($format, $min, $max, $default = 'bla', $label, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false, $first_day = 0) { +function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false, $first_day = 0) { $o = ''; $dateformat = ''; -- cgit v1.2.3 From bae7b034e6c370ef0d8a62583db490842588bf77 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 24 Nov 2015 14:54:13 -0800 Subject: add (blank?) label param to other instances of datetimesel --- include/datetime.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index ab9b061b6..f7df70a36 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -153,7 +153,7 @@ function dob($dob) { * id and name of datetimepicker (defaults to "datetimepicker") */ function datesel($format, $min, $max, $default, $id = 'datepicker') { - return datetimesel($format, $min, $max, $default, $id,true, false, '', ''); + return datetimesel($format, $min, $max, $default, '', $id,true, false, '', ''); } /** @@ -168,7 +168,7 @@ function datesel($format, $min, $max, $default, $id = 'datepicker') { * id and name of datetimepicker (defaults to "timepicker") */ function timesel($format, $h, $m, $id='timepicker') { - return datetimesel($format,new DateTime(),new DateTime(),new DateTime("$h:$m"),$id,false,true); + return datetimesel($format,new DateTime(),new DateTime(),new DateTime("$h:$m"),'', $id,false,true); } /** -- cgit v1.2.3 From 5cb71fa5da219e97a4c105c6025ff9b79553a38c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 26 Nov 2015 21:00:04 +0100 Subject: default timepicker to 15 min steps. abbr -> span --- include/datetime.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/datetime.php') diff --git a/include/datetime.php b/include/datetime.php index f7df70a36..1d10e7ad7 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -235,7 +235,7 @@ function datetimesel($format, $min, $max, $default, $label, $id = 'datetimepicke $o .= replace_macros($tpl,array( '$field' => array($id, $label, $input_text, (($required) ? t('Required') : ''), (($required) ? '*' : ''), 'placeholder="' . $readable_format . '"'), )); - $o .= ""; + $o .= ""; return $o; } -- cgit v1.2.3