mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 22:28:51 +01:00
DateTime Field with better I18N Support - Updated Javascripts DateTimePicker & MomentJS
This commit is contained in:
parent
e988030b14
commit
129aac10d5
1022
js/bootstrap-datetimepicker.js
vendored
1022
js/bootstrap-datetimepicker.js
vendored
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
$('.hhtml-datetime-field').each(function(index, element) {
|
||||
|
||||
var $element = $(element)
|
||||
, dateTimepickerDefaultOptions = {
|
||||
pickDate: true,
|
||||
@ -8,9 +9,11 @@ $(document).ready(function() {
|
||||
useMinutes: true,
|
||||
useSeconds: false,
|
||||
showToday: true,
|
||||
language: 'en',
|
||||
language: localeId.replace("\_", "\-"),
|
||||
use24hours: true,
|
||||
sideBySide: false,
|
||||
// Initally use DB Timestamp Format
|
||||
// After that we switch to locale format
|
||||
format: 'YYYY-MM-DD hh:mm'
|
||||
}
|
||||
, $dateInput = $element.clone()
|
||||
@ -41,10 +44,20 @@ $(document).ready(function() {
|
||||
var datepicker = $dateInput.data("DateTimePicker");
|
||||
|
||||
if (typeof $element.attr('data-options-displayFormat') === "undefined") {
|
||||
if (!dateTimepickerOptions.pickTime) {
|
||||
datepicker.format = "DD.MM.YYYY";
|
||||
} else {
|
||||
datepicker.format = "DD.MM.YYYY - HH:mm";
|
||||
// Switch to format given by locale
|
||||
localeData = moment().localeData();
|
||||
datepicker.format = (datepicker.options.pickDate ? localeData.longDateFormat('L') : '');
|
||||
if (datepicker.options.pickDate && datepicker.options.pickTime) {
|
||||
datepicker.format += ' ';
|
||||
}
|
||||
datepicker.format += (datepicker.options.pickTime ? localeData.longDateFormat('LT') : '');
|
||||
if (datepicker.options.useSeconds) {
|
||||
if (localeData.longDateFormat('LT').indexOf(' A') !== -1) {
|
||||
datepicker.format = datepicker.format.split(' A')[0] + ':ss A';
|
||||
}
|
||||
else {
|
||||
datepicker.format += ':ss';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
datepicker.format = $element.attr('data-options-displayFormat');
|
||||
|
10
js/moment-with-locales.min.js
vendored
Normal file
10
js/moment-with-locales.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2400
js/moment.js
2400
js/moment.js
File diff suppressed because it is too large
Load Diff
@ -79,6 +79,7 @@ class Controller extends EController
|
||||
Yii::app()->clientScript->setJavascriptVariable('csrfName', Yii::app()->request->csrfTokenName);
|
||||
Yii::app()->clientScript->setJavascriptVariable('csrfValue', Yii::app()->request->csrfToken);
|
||||
Yii::app()->clientScript->setJavascriptVariable('baseUrl', Yii::app()->getBaseUrl(true));
|
||||
Yii::app()->clientScript->setJavascriptVariable('localeId', Yii::app()->locale->id);
|
||||
|
||||
$this->initAjaxCsrfToken();
|
||||
|
||||
|
@ -292,7 +292,7 @@ class HHtml extends CHtml
|
||||
{
|
||||
// load js for datetimepicker component
|
||||
Yii::app()->clientScript->registerScriptFile(
|
||||
Yii::app()->baseUrl . '/js/moment.js', CClientScript::POS_END
|
||||
Yii::app()->baseUrl . '/js/moment-with-locales.min.js', CClientScript::POS_END
|
||||
);
|
||||
Yii::app()->clientScript->registerScriptFile(
|
||||
Yii::app()->baseUrl . '/js/bootstrap-datetimepicker.js', CClientScript::POS_END
|
||||
|
Loading…
x
Reference in New Issue
Block a user