I have initiated a backport (requiring minimal effort) of this module to Drupal 5.

With jQuery Update 5.x-2.0 installed the examples on the admin help page appear, but don't work due to the following JavaScript runtime error:

Error: Drupal.behaviors is undefined
Source File: http://mysite/sites/all/modules/jquery_countdown/jquery_countdown.js
Line: 6

Line 6 of jquery_countdown.js reads:

Drupal.behaviors.jquery_countdown = function(context) {

I'm still investigating the matter, but thought I would throw this out there in case someone has a quick solution.

CommentFileSizeAuthor
#4 jquerycountdown5.patch1.6 KBrobloach

Comments

johnhanley’s picture

The above is due to the introduction of the Drupal.behaviors object in Drupal 6.

robloach’s picture

Status: Active » Fixed

http://drupal.org/cvs?commit=295108 :-)

Adding the following fixed what you were running into:

/**
 * Drupal 6 compatibility.
 */
Drupal.behaviors = Drupal.behaviors || {};
$(document).ready(function() {
  Drupal.behaviors.jquery_countdown();
});

jQuery Countdown 5.x-1.x-dev opened up. If you run into problems with it, please feel free to post a comment here, or open up a new issue ;-) .

johnhanley’s picture

Sweet--that's exactly what was needed. My prelim testing now shows everything working as expected.

In summary the backport changes simply amounted to:

above function added to jquery_countdown.js
jquery_countdown_help() parameter and switch change in jquery_countdown.module
definition differences in jquery_countdown.info
jquery_countdown.jq.inc unchanged
cleared $id$ values in above files

The system variable 'preprocess_js' doesn't exist in Drupal 5, but I don't see any reason to change the logic in jquery_countdown_add(), do you?

robloach’s picture

Title: Drupal 5 backport » Drupal 5 backport followup
Status: Fixed » Needs review
StatusFileSize
new1.6 KB

Also, I don't think global $language was around then either. Not sure how to translate JavaScript in Drupal 5...... hmmm.

johnhanley’s picture

Well, for authenticated users (and assuming the Locale module is enabled) we can do this:

    // Enable localization if available.
    global $user;
    if ($user->language) {
      $localization = drupal_get_path('module', 'jquery_countdown') .'/jquery_countdown/jquery.countdown-'. $user->language .'.js';
      if (file_exists($localization)) {
        drupal_add_js($localization);
      }
    }

I haven't ever messed with multilingual support for anonymous users. There might be a third-party module available to mimic Drupal 6 behavior.

Letharion’s picture

Assigned: johnhanley » Unassigned
Status: Needs review » Closed (won't fix)

With D5 core not being supported anymore, I think we can close this one.