From 3cf8dcf8352124fc0d2044f12baad61e69f86d83 Mon Sep 17 00:00:00 2001 From: Daniel Rodriguez <danrod@gmail.com> Date: Sat, 12 Apr 2025 13:58:59 -0400 Subject: [PATCH 1/6] Issue # 3518920: Modified initial files to support the new library --- .eslintignore | 1 - composer.json | 10 ---------- composer.libraries.json | 10 ---------- 3 files changed, 21 deletions(-) delete mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 4f28114..0000000 --- a/.eslintignore +++ /dev/null @@ -1 +0,0 @@ -infusion/* diff --git a/composer.json b/composer.json index 442a04c..bc5aa46 100644 --- a/composer.json +++ b/composer.json @@ -5,16 +5,6 @@ "license": "GPL-2.0+", "homepage": "https://www.drupal.org/project/timepicker", "authors": [ - { - "name": "Ivan Tibezh (tibezh)", - "homepage": "https://www.drupal.org/u/tibezh", - "role": "Maintainer" - }, - { - "name": "Lilian Catanoi (liliancatanoi90)", - "homepage": "https://www.drupal.org/u/liliancatanoi90", - "role": "Maintainer" - }, { "name": "Daniel Rodriguez (danrod)", "homepage": "https://www.drupal.org/u/danrod", diff --git a/composer.libraries.json b/composer.libraries.json index 7fed2f3..fba92c0 100644 --- a/composer.libraries.json +++ b/composer.libraries.json @@ -5,16 +5,6 @@ "license": "GPL-2.0+", "homepage": "https://www.drupal.org/project/timepicker", "authors": [ - { - "name": "Ivan Tibezh (tibezh)", - "homepage": "https://www.drupal.org/u/tibezh", - "role": "Maintainer" - }, - { - "name": "Lilian Catanoi (liliancatanoi90)", - "homepage": "https://www.drupal.org/u/liliancatanoi90", - "role": "Maintainer" - }, { "name": "Daniel Rodriguez (danrod)", "homepage": "https://www.drupal.org/u/danrod", -- GitLab From 92dd9e468cacb6902510ad5a766800e57aebfe7a Mon Sep 17 00:00:00 2001 From: Daniel Rodriguez <danrod@gmail.com> Date: Sat, 19 Apr 2025 10:22:11 -0400 Subject: [PATCH 2/6] Issue # 3518920 by danrod: Forgot to include the working files XD --- composer.libraries.json | 22 +++++++++++++++++++--- js/flatpickr.js | 35 +++++++++++++++++++++++++++++++++++ timepicker.libraries.yml | 28 +++++++++++++++++++++++++--- timepicker.module | 16 ++++++++++++++++ 4 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 js/flatpickr.js diff --git a/composer.libraries.json b/composer.libraries.json index 9bb2e5c..b0b0ac5 100644 --- a/composer.libraries.json +++ b/composer.libraries.json @@ -52,10 +52,10 @@ } } }, - "jquery-timepicker-addon": { + "jquery-addon-timepicker": { "type": "package", "package": { - "name": "jquery-timepicker-addon/jquery-timepicker-addon", + "name": "jquery-addon-timepicker/jquery-addon-timepicker", "version": "1.6.3", "type": "drupal-library", "extra": { @@ -66,12 +66,28 @@ "type": "zip" } } + }, + "flatpickr-library": { + "type": "package", + "package": { + "name": "flatpickr/flatpickr", + "version": "4.6.13", + "type": "drupal-library", + "extra": { + "installer-name": "flatpickr" + }, + "dist": { + "url": "https://github.com/flatpickr/flatpickr/archive/refs/tags/v4.6.13.zip", + "type": "zip" + } + } } }, "require": { "jonthornton-jquery-timepicker/jonthornton-jquery-timepicker": "1.14.1", "jquery-ui-timepicker/jquery-ui-timepicker": "0.3.3", - "jquery-timepicker-addon/jquery-timepicker-addon": "1.6.3" + "jquery-addon-timepicker/jquery-addon-timepicker": "1.6.3", + "flatpickr-library/flatpickr-library": "4.6.13" } } \ No newline at end of file diff --git a/js/flatpickr.js b/js/flatpickr.js new file mode 100644 index 0000000..5b84623 --- /dev/null +++ b/js/flatpickr.js @@ -0,0 +1,35 @@ +/** + * @file + * + * Callback for flatpickr. + */ + +(function ($) { + $.fn.flatpickr = $.fn.flatpickr; + + Drupal.behaviors.flatpickr = { + attach:(context, settings) => { + + let fieldName = []; + + Object.keys(settings.timepicker.flatpickr_timepicker).forEach((key, index) => { + if (key !== null) { + fieldName[index] = key; + } + }); + + const requiredOptions = { + enableTime: true, + noCalendar: true, + dateFormat: "H:i", + }; + + for (let i = 0; i < fieldName.length; i++) { + $('input[name="' + fieldName + '[' + i + '][0][value][time]"').flatpickr(requiredOptions); + } + + $('input[name="field_presentation_time[0][value][time]"').flatpickr(requiredOptions); + } + }; + +}(jQuery)); diff --git a/timepicker.libraries.yml b/timepicker.libraries.yml index 4815882..520cce8 100644 --- a/timepicker.libraries.yml +++ b/timepicker.libraries.yml @@ -23,6 +23,14 @@ jquery-addon-timepicker: - core/jquery - timepicker/jquery.ui.timepicker.addon +flatpickr-timepicker: + version: VERSION + js: + js/flatpickr.js: { } + dependencies: + - core/jquery + - timepicker/flatpickr-library + # Define third-party libraries. jonthornton-jquery-timepicker: remote: https://github.com/jonthornton/jquery-timepicker @@ -61,13 +69,27 @@ jquery.ui.timepicker.addon: gpl-compatible: false css: theme: - /libraries/jquery-timepicker-addon/dist/jquery-ui-timepicker-addon.css: { } + /libraries/jquery-addon-timepicker/dist/jquery-ui-timepicker-addon.css: { } js: - libraries/jquery-ui/jquery-ui.min.js: {} - /libraries/jquery-timepicker-addon/dist/jquery-ui-timepicker-addon.js: { } + /libraries/jquery-addon-timepicker/dist/jquery-ui-timepicker-addon.js: { } dependencies: - core/jquery-ui - jquery_ui/core - jquery_ui/widget - jquery_ui_datepicker/datepicker - jquery_ui/jquery.ui.slider + +flatpickr-library: + remote: https://github.com/flatpickr/flatpickr + version: VERSION + license: + name: MIT + url: https://github.com/flatpickr/flatpickr/blob/master/LICENSE.md + gpl-compatible: false + css: + theme: + /libraries/flatpickr/dist/flatpickr.css: { } + js: + /libraries/flatpickr/dist/flatpickr.js: { } + dependencies: + - core/jquery \ No newline at end of file diff --git a/timepicker.module b/timepicker.module index 1b3b73c..ff86267 100644 --- a/timepicker.module +++ b/timepicker.module @@ -114,6 +114,22 @@ function timepicker_timepicker_libraries() { 'http://trentrichardson.com/examples/timepicker/#tp-options', ], ], + 'timepicker_flatpickr' => [ + 'title' => 'Flatpickr JS', + 'callback library' => [ + 'extension' => 'timepicker', + 'name' => 'flatpickr-timepicker', + ], + 'depended library' => [ + 'extension' => 'timepicker', + 'name' => 'flatpickr-library', + 'download url' => + 'https://github.com/flatpickr/flatpickr/archive/master.zip', + 'library path' => '/libraries/flatpickr', + 'js options reference url' => + 'https://flatpickr.js.org/getting-started', + ], + ], ]; } -- GitLab From d725d02fedcb86d467721a962ee4f5c9e984f489 Mon Sep 17 00:00:00 2001 From: Daniel Rodriguez <danrod@gmail.com> Date: Sat, 19 Apr 2025 10:48:25 -0400 Subject: [PATCH 3/6] Issue # 3518920 by danrod: ESLint fixes --- js/flatpickr.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/js/flatpickr.js b/js/flatpickr.js index 5b84623..8239743 100644 --- a/js/flatpickr.js +++ b/js/flatpickr.js @@ -5,8 +5,6 @@ */ (function ($) { - $.fn.flatpickr = $.fn.flatpickr; - Drupal.behaviors.flatpickr = { attach:(context, settings) => { @@ -25,10 +23,8 @@ }; for (let i = 0; i < fieldName.length; i++) { - $('input[name="' + fieldName + '[' + i + '][0][value][time]"').flatpickr(requiredOptions); + $('input[name="' + fieldName[i] + '[' + i + '][value][time]"').flatpickr(requiredOptions); } - - $('input[name="field_presentation_time[0][value][time]"').flatpickr(requiredOptions); } }; -- GitLab From 1f8992343037f6d57474b106edc4bd6bb44667c0 Mon Sep 17 00:00:00 2001 From: Daniel Rodriguez <danrod@gmail.com> Date: Sat, 19 Apr 2025 11:00:21 -0400 Subject: [PATCH 4/6] Issue # 3518920 by danrod: More ESLint fixes --- js/flatpickr.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/flatpickr.js b/js/flatpickr.js index 8239743..ec8ab7a 100644 --- a/js/flatpickr.js +++ b/js/flatpickr.js @@ -8,7 +8,7 @@ Drupal.behaviors.flatpickr = { attach:(context, settings) => { - let fieldName = []; + const fieldName = []; Object.keys(settings.timepicker.flatpickr_timepicker).forEach((key, index) => { if (key !== null) { -- GitLab From d343ef535bc6e6fba3de936b87271482985b6f36 Mon Sep 17 00:00:00 2001 From: Daniel Rodriguez <danrod@gmail.com> Date: Sat, 19 Apr 2025 11:27:23 -0400 Subject: [PATCH 5/6] Issue # 3518920 by danrod: Updates in the README.md file with extra information about the new library --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e4e60e..cc7bd13 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Table of contents Introduction ------------ -The Date Timepicker module adds one of 3 jQuery plugins to any DateTime field in +The Date Timepicker module adds one of 4 jQuery plugins to any DateTime field in the Widget settings. Features: @@ -38,6 +38,7 @@ The Date Timepicker module requires the following JavaScript libraries: - [jQuery UI Timepicker](https://github.com/fgelinas/timepicker) - [jQuery Timepicker Addon](https://github.com/trentrichardson/jQuery -Timepicker-Addon) +- [Flatpickr Plugin](https://flatpickr.js.org/#introduction) Follow the installation instructions below for installing the module and the libraries. @@ -71,7 +72,23 @@ Installation "/libraries/jquery-ui-timepicker" folder. - Extract the jQuery Timepicker Addon library into the "/libraries/jquery-timepicker-addon" folder. +- Extrart the Flatpickr library into the + "/libraries/flatpickr" + There is also a `composer.libraries.json` which you can use to copy and paste the library repositories in your site's `composer.json` file and use composer to download the libraries + + ``` + composer require "jonthornton-jquery-timepicker/jonthornton-jquery-timepicker" + composer require "jquery-ui-timepicker/jquery-ui-timepicker" + composer require "jquery-addon-timepicker/jquery-addon-timepicker + composer require "flatpickr-library/flatpickr-library" + ``` +6. Additional steps for installing the **flatpickr** library + + You will need **NodeJS** and **npm** installed for these steps, go to the **/libraries/flatpickr** directory and run: + + - `npm install` to install the library dependencies + - `npm run build` to compile the library and create a **dist** directory with the js and css files that the module needs. Configuration ------------- -- GitLab From 4ce9ffb856928fc76b01260e6557e5bb86152da7 Mon Sep 17 00:00:00 2001 From: Daniel Rodriguez <danrod@gmail.com> Date: Sat, 19 Apr 2025 11:32:59 -0400 Subject: [PATCH 6/6] Issue # 3518920 by danrod: Updates in the README.md file with extra information about the new library --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc7bd13..14b5e11 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ Installation "/libraries/jquery-ui-timepicker" folder. - Extract the jQuery Timepicker Addon library into the "/libraries/jquery-timepicker-addon" folder. -- Extrart the Flatpickr library into the +- Extract the Flatpickr library into the "/libraries/flatpickr" There is also a `composer.libraries.json` which you can use to copy and paste the library repositories in your site's `composer.json` file and use composer to download the libraries -- GitLab