The datepicker is now localised

pull/1966/head
Michael Vogel 2015-10-17 10:48:13 +02:00
rodzic 8395f67351
commit 8a79e1afb3
1 zmienionych plików z 45 dodań i 30 usunięć

Wyświetl plik

@ -210,6 +210,18 @@ function timesel($format, $h, $m, $id='timepicker') {
if(! function_exists('datetimesel')) { if(! function_exists('datetimesel')) {
function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false) { function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '', $required = false) {
$a = get_app();
// First day of the week (0 = Sunday)
$firstDay = get_pconfig(local_user(),'system','first_day_of_week');
if ($firstDay === false) $firstDay=0;
$lang = substr(get_browser_language(), 0, 2);
// Check if the detected language is supported by the picker
if (!in_array($lang, array("ar", "ro", "id", "bg", "fa", "ru", "uk", "en", "el", "de", "nl", "tr", "fr", "es", "th", "pl", "pt", "ch", "se", "kr", "it", "da", "no", "ja", "vi", "sl", "cs", "hu")))
$lang = ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
$o = ''; $o = '';
$dateformat = ''; $dateformat = '';
if($pickdate) $dateformat .= 'Y-m-d'; if($pickdate) $dateformat .= 'Y-m-d';
@ -224,6 +236,7 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
if(!$pickdate) $pickers .= ',datepicker: false'; if(!$pickdate) $pickers .= ',datepicker: false';
if(!$picktime) $pickers .= ',timepicker: false'; if(!$picktime) $pickers .= ',timepicker: false';
$extra_js = ''; $extra_js = '';
$pickers .= ",dayOfWeekStart: ".$firstDay.",lang:'".$lang."'";
if($minfrom != '') if($minfrom != '')
$extra_js .= "\$('#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})"; $extra_js .= "\$('#$minfrom').data('xdsoft_datetimepicker').setOptions({onChangeDateTime: function (currentDateTime) { \$('#$id').data('xdsoft_datetimepicker').setOptions({minDate: currentDateTime})}})";
if($maxfrom != '') if($maxfrom != '')
@ -236,7 +249,9 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic
$readable_format = str_replace('i','MM',$readable_format); $readable_format = str_replace('i','MM',$readable_format);
$o .= "<div class='date'><input type='text' placeholder='$readable_format' name='$id' id='$id' $input_text />"; $o .= "<div class='date'><input type='text' placeholder='$readable_format' name='$id' id='$id' $input_text />";
$o .= '</div>'; $o .= '</div>';
$o .= "<script type='text/javascript'>\$(function () {var picker = \$('#$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})</script>"; $o .= "<script type='text/javascript'>";
$o .= "\$(function () {var picker = \$('#$id').datetimepicker({step:5,format:'$dateformat' $minjs $maxjs $pickers $defaultdatejs}); $extra_js})";
$o .= "</script>";
return $o; return $o;
}} }}