- Issue created by @Shane Birley
- 🇨🇦Canada Shane Birley
I went through everything to make sure I wasn't crazy, but I do think there are a couple of issues here. I ran through a few implementations of adding declarations in the theme and it works fine but the real issue is just an update of the module itself since it has particular requirements:
1. The ebt_countdown is making a declaration for Drupal.behaviors and it isn't available in Drupal 11. So I added the declarations I made in the theme in the modules libraries.yml file.
ebt_countdown: version: 1.x css: component: /libraries/flipdown/dist/flipdown.min.css: { minified: true } css/flipdown.css: {} js: /libraries/flipdown/dist/flipdown.min.js: { minified: true } js/ebt_countdown.js: {} dependencies: - core/jquery - core/once - core/drupal - core/drupalSettings new_year: css: component: css/new-year.css: {}
I then took a quick peek at the ebt_countdown.js and added the declarations:
(function ($, Drupal, drupalSettings) { /** * EBT Countdown behavior. */ Drupal.behaviors.ebtCountDown = { attach: function (context, settings) { // Initialize once behavior. var countdowns = once('ebt-countdown-block', '.ebt-countdown-date', context); countdowns.forEach(function(countdown) { // Get block ID. var countdownWrapper = countdown.closest('.ebt-block-countdown'); if (!countdownWrapper) { console.warn('EBT Countdown: Countdown wrapper not found.'); return; } var countdownWrapperId = countdownWrapper.getAttribute('id'); // Get block EBT settings. if (!drupalSettings['ebtCountdown'] || !drupalSettings['ebtCountdown'][countdownWrapperId]) { console.warn('EBT Countdown: Settings not found for ID: ' + countdownWrapperId); return; } var ebtOptions = drupalSettings['ebtCountdown'][countdownWrapperId]; // Prepare options for javascript plugin. var countdownTimestamp = parseInt(countdown.getAttribute('data-date'), 10); if (isNaN(countdownTimestamp)) { console.warn('EBT Countdown: Invalid timestamp for countdown.'); return; } var countdownId = countdown.getAttribute('id'); // Init javascript plugin. if (typeof FlipDown === 'function') { try { new FlipDown(countdownTimestamp, countdownId, { theme: ebtOptions['options']['color_theme'], headings: [ ebtOptions['options']['heading_days'], ebtOptions['options']['heading_hours'], ebtOptions['options']['heading_minutes'], ebtOptions['options']['heading_seconds'], ], }).start(); } catch (error) { console.error('EBT Countdown: Failed to initialize FlipDown.', error); } } else { console.warn('EBT Countdown: FlipDown library is missing or not loaded.'); } }); } }; })(jQuery, Drupal, drupalSettings);
Hopefully this helps.
- Merge request !2Updated ebt_countdown.js to safely inject (jQuery, Drupal, drupalSettings)... → (Open) created by Unnamed author
-
levmyshkin →
committed 50904cf1 on 1.4.x
Issue #3521289 by shane birley: Block Does Not Render for Anonymous...
-
levmyshkin →
committed 50904cf1 on 1.4.x
- 🇷🇸Serbia levmyshkin Novi Sad, Serbia
Hi Shane Birley, thank you for your report and patch! I applied it and released 1.4.6 version for EBT Countdown.