1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Closes #108, Issue #133 and may correct Issue #335 - Datepicker updated and should now be working with times also. eg. 7:30PM

This commit is contained in:
Cameron
2013-05-25 16:03:53 -07:00
parent 8b21e8c9b0
commit beca1115c5
11 changed files with 96 additions and 51 deletions

View File

@@ -1306,7 +1306,7 @@ class admin_newspost
$ix = new news; $ix = new news;
// jQuery UI temporary date-time fix - inputdatetime -> inputdate // jQuery UI temporary date-time fix - inputdatetime -> inputdate
$_POST['news_start'] = vartrue(e107::getDate()->convert($_POST['news_start'],'inputdate'), 0); $_POST['news_start'] = vartrue(e107::getDate()->convert($_POST['news_start'],'inputdatetime'), 0);
if($_POST['news_start']) if($_POST['news_start'])
{ {
@@ -1319,7 +1319,7 @@ class admin_newspost
if($_POST['news_end']) if($_POST['news_end'])
{ {
$_POST['news_end'] = e107::getDate()->convert($_POST['news_end'],'inputdate'); $_POST['news_end'] = e107::getDate()->convert($_POST['news_end'],'inputdatetime');
} }
else else
{ {
@@ -1328,7 +1328,7 @@ class admin_newspost
if($_POST['news_datestamp']) if($_POST['news_datestamp'])
{ {
$_POST['news_datestamp'] = e107::getDate()->convert($_POST['news_datestamp'],'inputdate'); $_POST['news_datestamp'] = e107::getDate()->convert($_POST['news_datestamp'],'inputdatetime');
} }
else else
{ {
@@ -2427,7 +2427,7 @@ class admin_newspost
<div class='field-spacer'> <div class='field-spacer'>
"; ";
$text .= $frm->datepicker("news_datestamp",vartrue($_POST['news_datestamp']),"type=date"); //XXX should be 'datetime' when working correctly. $text .= $frm->datepicker("news_datestamp",vartrue($_POST['news_datestamp']),"type=datetime"); //XXX should be 'datetime' when working correctly.
$text .= "</div>"; $text .= "</div>";
/* /*

View File

@@ -1969,7 +1969,7 @@ class pluginBuilder
switch ($type) switch ($type)
{ {
case 'date': case 'date':
$text = $frm->datepicker($name, time(), 'dateformat=yyyy-mm-dd'.$req); $text = $frm->datepicker($name, time(), 'format=yyyy-mm-dd'.$req);
break; break;
case 'description': case 'description':

View File

@@ -634,7 +634,7 @@ TEMPLATE;
switch ($type) switch ($type)
{ {
case 'date': case 'date':
$text = $frm->datepicker($name, time(), 'dateformat=yyyy-mm-dd'.$req); $text = $frm->datepicker($name, time(), 'format=yyyy-mm-dd'.$req);
break; break;
case 'description': case 'description':

View File

@@ -123,17 +123,17 @@ class convert
'%a' => 'D', // An abbreviated textual representation of the day '%a' => 'D', // An abbreviated textual representation of the day
'%b' => 'M', // Abbreviated month name, based on the locale '%b' => 'M', // Abbreviated month name, based on the locale
'%h' => 'M', // Abbreviated month name, based on the locale (an alias of %b) '%h' => 'M', // Abbreviated month name, based on the locale (an alias of %b)
'%I' => 'HH', // Two digit representation of the hour in 12-hour format
'%l' => 'H', // 12 hour format - no leading zero
'%l' => 'h', // 12 hour format - no leading zero
'%I' => 'hh', // 12 hour format - leading zero
'%H' => 'hh', // 24 hour format - leading zero '%H' => 'hh', // 24 hour format - leading zero
'%M' => 'mm', '%M' => 'ii', // Two digit representation of the minute
'%S' => 'ss', '%S' => 'ss', // Two digit representation of the second
'%p' => 'TT', // %p UPPER-CASE 'AM' or 'PM' based on the given time '%P' => 'p', // %P lower-case 'am' or 'pm' based on the given time
'%P' => 'tt', // %P lower-case 'am' or 'pm' based on the given time '%p' => 'P', // %p UPPER-CASE 'AM' or 'PM' based on the given time
'%T' => 'hh:mm:ss', '%T' => 'hh:mm:ss',
'%r' => "hh:mmm:ss TT" // 12 hour format '%r' => "hh:mmm:ss TT" // 12 hour format
); );
$s = array_keys($convert); $s = array_keys($convert);

View File

@@ -611,7 +611,7 @@ class e_form
* @param array or str * @param array or str
* @example $frm->datepicker('my_field',time(),'type=date'); * @example $frm->datepicker('my_field',time(),'type=date');
* @example $frm->datepicker('my_field',time(),'type=datetime&inline=1'); * @example $frm->datepicker('my_field',time(),'type=datetime&inline=1');
* @example $frm->datepicker('my_field',time(),'type=date&dateformat=yyyy-mm-dd'); * @example $frm->datepicker('my_field',time(),'type=date&format=yyyy-mm-dd');
* *
* @url http://trentrichardson.com/examples/timepicker/ * @url http://trentrichardson.com/examples/timepicker/
*/ */
@@ -622,17 +622,23 @@ class e_form
parse_str($options,$options); parse_str($options,$options);
} }
$dateFormat = varset($options['dateformat']) ? trim($options['dateformat']) :e107::getPref('inputdate', '%Y-%m-%d');
$timeFormat = varset($options['timeformat']) ? trim($options['timeformat']) :e107::getPref('inputtime', '%H:%M:%S');
$type = varset($options['type']) ? trim($options['type']) : "date"; // 'datetime' $type = varset($options['type']) ? trim($options['type']) : "date"; // 'datetime'
$dateFormat = varset($options['format']) ? trim($options['format']) :e107::getPref('inputdate', '%Y-%m-%d');
// $timeFormat = varset($options['timeformat']) ? trim($options['timeformat']) :e107::getPref('inputtime', '%H:%M:%S');
if($type == 'datetime' && !varset($options['format']))
{
$dateFormat .= " ".e107::getPref('inputtime', '%H:%M:%S');
}
// echo "TYPE=".$type; // echo "TYPE=".$type;
$ampm = (preg_match("/%l|%I|%p|%P/",$timeFormat)) ? 'true' : 'false'; $ampm = (preg_match("/%l|%I|%p|%P/",$dateFormat)) ? 'true' : 'false';
$dformat = e107::getDate()->toMask($dateFormat); $dformat = e107::getDate()->toMask($dateFormat);
$tformat = e107::getDate()->toMask($timeFormat); // $tformat = e107::getDate()->toMask($timeFormat);
$id = $this->name2id($name); $id = $this->name2id($name);
@@ -645,7 +651,7 @@ class e_form
$def = array( $def = array(
'date' => $dateFormat, 'date' => $dateFormat,
// 'time' => $timeFormat, // 'time' => $timeFormat,
'datetime' => $dateFormat." ".$timeFormat 'datetime' => $dateFormat // ." ".$timeFormat
); );
$defdisp = (isset($def[$type])) ? $def[$type] : $def['date']; $defdisp = (isset($def[$type])) ? $def[$type] : $def['date'];
@@ -665,7 +671,7 @@ class e_form
if(vartrue($options['inline'])) if(vartrue($options['inline']))
{ {
$text .= "<div class='{$class}' id='inline-{$id}' data-date-format='{$dformat}' data-time-format='{$tformat}' data-date-ampm='{$ampm}' data-date-firstday='{$firstDay}' ></div> $text .= "<div class='{$class}' id='inline-{$id}' data-date-format='{$dformat}' data-date-ampm='{$ampm}' data-date-firstday='{$firstDay}' ></div>
<input type='hidden' name='{$name}' id='{$id}' value='{$value}' data-date-format='{$dformat}' data-time-format='{$tformat}' data-date-ampm='{$ampm}' data-date-firstday='{$firstDay}' /> <input type='hidden' name='{$name}' id='{$id}' value='{$value}' data-date-format='{$dformat}' data-time-format='{$tformat}' data-date-ampm='{$ampm}' data-date-firstday='{$firstDay}' />
"; ";
} }
@@ -684,10 +690,11 @@ class e_form
*/ */
$text .= "<input class='{$class}' type='text' size='{$size}' name='{$name}' id='{$id}' value='{$value}' data-date-format='{$dformat}' data-time-format='{$tformat}' data-date-ampm='{$ampm}' data-date-firstday='{$firstDay}' {$required} />"; $text .= "<input class='{$class} input-xlarge' type='text' size='{$size}' name='{$name}' id='{$id}' value='{$value}' data-date-format='{$dformat}' data-date-ampm='{$ampm}' data-date-firstday='{$firstDay}' {$required} />";
} }
// $text .= " ({$dformat}) ".$value; // $text .= "ValueFormat: ".$defdisp." Value: ".$value;
// $text .= " ({$dformat}) type:".$defdisp." ".$value;
return $text; return $text;

View File

@@ -1458,8 +1458,8 @@ class mailoutAdminClass extends e107MailManager
$options = array( $options = array(
'type' => 'datetime', 'type' => 'datetime',
'dateformat' => $dFormat, 'format' => $dFormat." ".$tFormat,
'timeformat' => $tFormat, // 'timeformat' => $tFormat,
'firstDay' => 1, // 0 = Sunday. 'firstDay' => 1, // 0 = Sunday.
'size' => 12 'size' => 12
); );

View File

@@ -829,7 +829,7 @@ class e107_user_extended
break; break;
case EUF_DATE : //date case EUF_DATE : //date
return e107::getForm()->datepicker($fname,$curval,'dateformat=yyyy-mm-dd'); return e107::getForm()->datepicker($fname,$curval,'format=yyyy-mm-dd');
break; break;
case EUF_LANGUAGE : // language case EUF_LANGUAGE : // language

View File

@@ -16,11 +16,11 @@ thead tr {
min-height:50px; min-height:50px;
} }
.datepicker { .datetimepicker {
background-color: #191919; background-color: #191919;
} }
.datepicker thead tr:first-child th:hover, .datepicker tfoot tr:first-child th:hover { .datetimepicker thead tr:first-child th:hover, .datetimepicker tfoot tr:first-child th:hover {
background-color: #191919; background-color: #191919;
} }
@@ -31,7 +31,7 @@ min-height:50px;
tr.highlight-odd { background-color: #212121; } tr.highlight-odd { background-color: #212121; }
tr.highlight-even { background-color: #212121; } tr.highlight-even { background-color: #212121; }
.datepicker table tr td.day:hover { .datetimepicker table tr td.day:hover {
color: black; color: black;
} }

View File

@@ -32,7 +32,7 @@
top: 0; top: 0;
left: 0; left: 0;
} }
.datetimepicker-dropdown:before { [class*=" datetimepicker-dropdown"]:before {
content: ''; content: '';
display: inline-block; display: inline-block;
border-left: 7px solid transparent; border-left: 7px solid transparent;
@@ -40,40 +40,64 @@
border-bottom: 7px solid #ccc; border-bottom: 7px solid #ccc;
border-bottom-color: rgba(0, 0, 0, 0.2); border-bottom-color: rgba(0, 0, 0, 0.2);
position: absolute; position: absolute;
top: -7px;
left: 6px;
} }
.datetimepicker-dropdown:after { [class*=" datetimepicker-dropdown"]:after {
content: ''; content: '';
display: inline-block; display: inline-block;
border-left: 6px solid transparent; border-left: 6px solid transparent;
border-right: 6px solid transparent; border-right: 6px solid transparent;
border-bottom: 6px solid #ffffff; border-bottom: 6px solid #ffffff;
position: absolute; position: absolute;
top: -6px;
left: 7px;
} }
.datetimepicker-dropdown-left:before { [class*=" datetimepicker-dropdown-top"]:before {
content: ''; content: '';
display: inline-block; display: inline-block;
border-left: 7px solid transparent; border-left: 7px solid transparent;
border-right: 7px solid transparent; border-right: 7px solid transparent;
border-bottom: 7px solid #ccc; border-top: 7px solid #ccc;
border-bottom-color: rgba(0, 0, 0, 0.2); border-top-color: rgba(0, 0, 0, 0.2);
position: absolute; border-bottom: 0;
}
[class*=" datetimepicker-dropdown-top"]:after {
content: '';
display: inline-block;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-top: 6px solid #ffffff;
border-bottom: 0;
}
.datetimepicker-dropdown-bottom-right:before {
top: -7px; top: -7px;
right: 6px; right: 6px;
} }
.datetimepicker-dropdown-left:after { .datetimepicker-dropdown-bottom-right:after {
content: '';
display: inline-block;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #ffffff;
position: absolute;
top: -6px; top: -6px;
right: 7px; right: 7px;
} }
.datetimepicker-dropdown-bottom-left:before {
top: -7px;
left: 6px;
}
.datetimepicker-dropdown-bottom-left:after {
top: -6px;
left: 7px;
}
.datetimepicker-dropdown-top-right:before {
bottom: -7px;
right: 6px;
}
.datetimepicker-dropdown-top-right:after {
bottom: -6px;
right: 7px;
}
.datetimepicker-dropdown-top-left:before {
bottom: -7px;
left: 6px;
}
.datetimepicker-dropdown-top-left:after {
bottom: -6px;
left: 7px;
}
.datetimepicker > div { .datetimepicker > div {
display: none; display: none;
} }

File diff suppressed because one or more lines are too long

View File

@@ -156,12 +156,26 @@ $(document).ready(function()
// https://github.com/smalot/bootstrap-datetimepicker // https://github.com/smalot/bootstrap-datetimepicker
$("input.e-date").each(function() { $("input.e-date").each(function() {
$(this).datepicker({
format: $(this).attr("data-date-format"), $(this).datetimepicker({
weekStart: $(this).attr("data-date-firstday") minView: 'month',
maxView: 'decade',
autoclose: true,
format: $(this).attr("data-date-format"),
weekStart: $(this).attr("data-date-firstday")
}); });
}); });
$("input.e-datetime").each(function() {
$(this).datetimepicker({
autoclose: true,
format: $(this).attr("data-date-format"),
weekStart: $(this).attr("data-date-firstday"),
showMeridian: $(this).attr("data-date-ampm")
});
});
/* /*
$("input.e-date").each(function() { $("input.e-date").each(function() {
$(this).datepicker({ $(this).datepicker({