From de544cc905fa0d952d5587b0d69d553598173495 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 7 Dec 2017 12:05:10 +0100 Subject: [PATCH] Add possibility to use localized date format as datepicker input placeholder Need to be supported by skin. Elastic support is comming. --- plugins/jqueryui/jqueryui.php | 14 +++++++++++++- program/js/app.js | 3 ++- program/localization/en_US/labels.inc | 7 +++++++ program/steps/addressbook/search.inc | 2 +- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/jqueryui/jqueryui.php b/plugins/jqueryui/jqueryui.php index f74957d58..78c96c1c1 100644 --- a/plugins/jqueryui/jqueryui.php +++ b/plugins/jqueryui/jqueryui.php @@ -65,7 +65,7 @@ class jqueryui extends rcube_plugin } // Date format for datepicker - $date_format = $rcmail->config->get('date_format', 'Y-m-d'); + $date_format = $date_format_localized = $rcmail->config->get('date_format', 'Y-m-d'); $date_format = strtr($date_format, array( 'y' => 'y', 'Y' => 'yy', @@ -74,7 +74,19 @@ class jqueryui extends rcube_plugin 'd' => 'dd', 'j' => 'd', )); + + $replaces = array('Y' => 'yyyy', 'y' => 'yy', 'm' => 'mm', 'd' => 'dd', 'j' => 'd', 'n' => 'm'); + + foreach (array_keys($replaces) as $key) { + if ($rcmail->text_exists("dateformat$key")) { + $replaces[$key] = $rcmail->gettext("dateformat$key"); + } + } + + $date_format_localized = strtr($date_format_localized, $replaces); + $rcmail->output->set_env('date_format', $date_format); + $rcmail->output->set_env('date_format_localized', $date_format_localized); } public static function miniColors() diff --git a/program/js/app.js b/program/js/app.js index 7f124faa7..6097bfd11 100644 --- a/program/js/app.js +++ b/program/js/app.js @@ -6341,7 +6341,6 @@ function rcube_webmail() yearRange: '-120:+10', showOtherMonths: true, selectOtherMonths: true -// onSelect: function(dateText) { $(this).focus().val(dateText); } }); $('input.datepicker').datepicker(); } @@ -6656,6 +6655,8 @@ function rcube_webmail() if (!colprop.count) colprop.count = 0; if (++colprop.count == colprop.limit && colprop.limit) $(menu).children('option[value="' + col + '"]').prop('disabled', true); + + this.triggerEvent('insert-edit-field', input); } } } diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc index 00317f8e2..47580cbf0 100644 --- a/program/localization/en_US/labels.inc +++ b/program/localization/en_US/labels.inc @@ -630,6 +630,13 @@ $labels['license'] = 'License'; $labels['support'] = 'Get support'; $labels['savedsearches'] = 'Saved searches'; +$labels['dateformatY'] = 'YYYY'; +$labels['dateformaty'] = 'YY'; +$labels['dateformatm'] = 'MM'; +$labels['dateformatd'] = 'DD'; +$labels['dateformatj'] = 'D'; +$labels['dateformatn'] = 'M'; + // units $labels['B'] = 'B'; $labels['KB'] = 'KB'; diff --git a/program/steps/addressbook/search.inc b/program/steps/addressbook/search.inc index 9f7a5501b..b370a5b6b 100644 --- a/program/steps/addressbook/search.inc +++ b/program/steps/addressbook/search.inc @@ -302,7 +302,7 @@ function rcmail_contact_search_form($attrib) $label = isset($colprop['label']) ? $colprop['label'] : $RCMAIL->gettext($col); $category = $colprop['category'] ?: 'other'; - // load jquery UI datepicker for date fields + // load jquery UI datepicker for date fields if ($colprop['type'] == 'date') { $colprop['class'] .= ($colprop['class'] ? ' ' : '') . 'datepicker'; }