v1/web/modules/contrib/jquery_ui_datepicker/jquery_ui_datepicker.module

54 lines
2.3 KiB
PHP

<?php
/**
* @file
* Contains jquery_ui_datepicker.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Asset\AttachedAssetsInterface;
use Drupal\Core\Language\LanguageInterface;
/**
* Implements hook_help().
*/
function jquery_ui_datepicker_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.jquery_ui_datepicker':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Drupal 8 includes jQuery UI in core, however it is no longer actively maintained and has been marked deprecated. This module provides the jQuery UI Datepicker library for any themes and modules that require it.') . '</p>';
$output .= '<p>' . t('For more information about the deprecation of jQuery UI, see this <a href=":change-record">change record</a>', [':change-record' => 'https://www.drupal.org/node/3067969']) . '</p>';
$output .= '<p>' . t('Visit the <a href=":project_link">jQuery UI Datepicker project page</a> on Drupal.org for more information on this module.', [':project_link' => 'https://www.drupal.org/project/jquery_ui_datepicker']) . '</p>';
return $output;
}
}
/**
* Implements hook_library_info_alter().
*
* Provides the language support for the jQuery UI Date Picker.
*/
function jquery_ui_datepicker_library_info_alter(array &$libraries, $module) {
if ($module === 'jquery_ui_datepicker' && isset($libraries['datepicker']) && \Drupal::moduleHandler()->moduleExists('locale')) {
$libraries['datepicker']['dependencies'][] = 'jquery_ui_datepicker/locale';
$libraries['datepicker']['drupalSettings']['jquery']['ui']['datepicker'] = [
'isRTL' => NULL,
'firstDay' => NULL,
];
}
}
/**
* Implements hook_js_settings_alter().
*
* Generates the values for the altered jquery_ui_datepicker/datepicker library.
*/
function jquery_ui_datepicker_js_settings_alter(&$settings, AttachedAssetsInterface $assets) {
if (isset($settings['jquery']['ui']['datepicker'])) {
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
$settings['jquery']['ui']['datepicker']['isRTL'] = $language_interface->getDirection() == LanguageInterface::DIRECTION_RTL;
$settings['jquery']['ui']['datepicker']['firstDay'] = \Drupal::config('system.date')->get('first_day');
}
}