The module should use Drupal behaviors, so that Cufon is loaded on AJAX calls. I'm working on a similar issue on another module (that uses selectors), and will create a patch for this here later this week.

Basically, we can't just call the $(selectors + ':not(.cufonProcessed)') as usual, since they're all comma-separated. Thus, we need to add that in the hook_init call, using str_replace(',', ',:not(.cufonProcessed', $settings), and then cache the result so we don't do that on every page.

Comments

rwohleb’s picture

Status: Active » Needs review

I created a drupal behavior that only requires changing the cufon-drupal.js file. It's such a simple change so I'm not going to bother with rolling a patch right now. If I have time, I'll roll one.

It leaves the non-behavior code intact due to how Cufon works. Else, there would be issues with browsers like IE. The behavior is designed to skip the first global run, and also respect the context that is passed.

// $Id: cufon-drupal.js,v 1.1 2009/07/13 21:41:46 eads Exp $

// Initialize Cufon based on Drupal settings
for (o in Drupal.settings.cufonSelectors) { 
  s = Drupal.settings.cufonSelectors[o];
  Cufon.replace(s.selector, s.options)
}

// Work around Internet Explorer rendering delay
Cufon.now();

// Set a drupal behavior so that content added later can be replaced
Drupal.behaviors.cufon = function (context) {
  // Check to see if the first_run flag has been initialized
  if ( typeof Drupal.behaviors.cufon.first_run == 'undefined' ) {
      Drupal.behaviors.cufon.first_run = true;
  }
  
  // If not the first run, replace the new content.
  if (!Drupal.behaviors.cufon.first_run) {
    for (o in Drupal.settings.cufonSelectors) {
      s = Drupal.settings.cufonSelectors[o];
      Cufon.replace($(s.selector, context), s.options)
    }
  }
  
  Drupal.behaviors.cufon.first_run = false;
}
planctus’s picture

That's very cool :-)
It seems to work perfectly, thanks
Da.

lil.destro’s picture

StatusFileSize
new1.11 KB

Rolled this into a patch for review.

detot’s picture

Status: Needs review » Reviewed & tested by the community

Works here to, thanks!

detot’s picture

Status: Reviewed & tested by the community » Needs work

I'll take that back. It works if you use "h1" but not ".node h1" for example.

mediamash’s picture

nice solution, should include in the module

matshep1’s picture

Thank you...this was driving me nuts! Your patch works for me :)

jaydub’s picture

Status: Needs work » Needs review
StatusFileSize
new1.03 KB

Regarding the patch in #3 is it necessary to have the redundant logic? I rolled a patch before I found this issue and was wondering why a simpler approach wouldn't work. I guess there's IE to worry about?

game’s picture

Has anyone else managed to get this working recently? Im currently using the latest version of drupal and all modules. This patch didnt seem to do anything as the content was displayed the same as before I applied the patch :-/

troky’s picture

Status: Needs review » Fixed

Committed to 6.x-1.x-dev.

Re-open issue if problem persists.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.