Major Refactor & Feature Release

Fully backward compatible - run update.php after upgrading to migrate existing configurations.

Overview

This release represents a complete architectural overhaul of the Countdown module while maintaining full backward compatibility. The module now features a powerful dual-mode rendering system with an advanced JavaScript countdown library and extensive customization options.

Key Features

Dual Rendering Modes

  • Static Mode (PHP-based): Server-side rendering with SEO benefits, updates on page refresh, zero JavaScript dependency
  • Real-time Mode (JavaScript): Dynamic countdown with millisecond precision, smooth animations, and live updates

Advanced CountdownTimer Library

  • Lightweight, optimized JavaScript library (v1.0.0-alpha3)
  • Drift compensation for long-running timers
  • Multiple precision levels: minutes, seconds, tenths, hundredths, milliseconds
  • Event-driven architecture with comprehensive API

Display Styles & Customization

  • Automatic: Default HH:MM:SS format based on precision
  • Verbose: Human-readable format (e.g., "3 days, 2 hours, 1 minute")
  • Compact: Space-efficient format (e.g., "3d 2h 1m")
  • Custom Templates: Token-based formatting (DD, HH, MM, SS, mmm)

Completion Actions

  • Hide block with fade animation
  • Display custom completion message
  • Redirect to specified URL
  • Auto-reload page
  • Switch to elapsed time (count-up mode)
  • Trigger custom JavaScript events

Timer Modes

  • Countdown: Count down to future events
  • Countup: Count up from past events
  • Elapsed: Automatic switch to elapsed time after completion

Technical Enhancements

JavaScript API

// Get timer instance
var timer = Drupal.countdown.getTimer("block_id");
// Control operations
Drupal.countdown.controlTimer("block_id", "start|pause|resume|stop|reset");
// Event listeners
$("#countdown-block_id").on("countdown:complete", function(e, time, timer) {
// Custom logic
});

Performance Optimizations

  • Efficient drift compensation algorithm
  • Configurable update frequency
  • Minimal DOM manipulation
  • WeakMap for memory-efficient instance management
  • Optimized rendering pipeline

Developer Features

  • Debug mode with console logging
  • Timezone support with display options
  • Start offset for fine-tuning
  • Auto-start configuration
  • JavaScript event system for custom integrations
  • Comprehensive test coverage (CountdownBlockTest)

Migration & Compatibility

Backward Compatibility

100% backward compatible. Existing countdown blocks will continue to work in static mode without any changes required.

Automatic Migration

  • Update hook countdown_update_8101() automatically migrates existing configurations
  • Old url field migrated to event_link
  • All existing blocks default to static mode (preserving current behavior)
  • No manual intervention required

Upgrade Path

# Standard update process
drush updb
drush cr

New Files & Structure

JavaScript Libraries

  • js/lib/countdown.js - Core CountdownTimer library
  • js/countdown.integration.js - Drupal integration layer
  • js/countdown.admin.js - Admin UI enhancements

Stylesheets

  • css/countdown.admin.css - Enhanced admin form styling

System Files

  • countdown.install - Update hooks and requirements
  • Extended schema with 25+ new configuration options
  • Comprehensive help documentation

Breaking Changes

None. This release maintains full backward compatibility while adding new optional features.

Bug Fixes

  • Fixed timezone calculation issues
  • Resolved memory leaks in long-running timers
  • Corrected elapsed time display for past events
  • Fixed URL validation and handling

Performance Impact

  • Static mode: No change in performance
  • Real-time mode: ~2KB JavaScript (gzipped), negligible CPU usage
  • Memory: Efficient WeakMap usage prevents memory leaks

Configuration Changes

New configuration options (all optional with sensible defaults):

  • render_mode: static|realtime
  • timer_mode: countdown|countup
  • precision: minutes|seconds|tenths|hundredths|milliseconds
  • display_style: auto|verbose|compact|custom
  • completion_action: none|hide|message|redirect|reload|elapsed|event
  • 20+ additional customization options

Security

  • XSS protection in all user inputs
  • CSRF token validation for forms
  • Proper HTML escaping in templates
  • No external dependencies or CDN calls

Documentation

  • Comprehensive module help at /admin/help/countdown
  • Inline code documentation with JSDoc and PHPDoc
  • Updated README with examples and API documentation
  • Schema documentation for all configuration options

Credits

Major refactor by Mahyar SBT with the introduction of the CountdownTimer library and real-time rendering capabilities.


Recommended update: This is a feature-rich update with no breaking changes. Testing in a development environment is advised for sites with custom countdown integrations.

VCS Label
8.x-1.11
Core compatibility
Release type
Short description
Major refactor introducing real-time JavaScript countdown with CountdownTimer library, completion actions, and custom templates. Fully backward compatible - run update.php to migrate existing blocks.
Packaged Git sha1
b84f19ab2ca7bdc184b98251e9315a4acd1ec276
Release files