Hey guys, I decided to use this module instead of writing my own integration - I don't need the text-filters nor field settings for now, just the library itself (with a nice settings form that you did).

Anyway, here in lazy.js:

      var options = settings.lazy.bLazy ? settings.lazy.bLazy : {};
      new Blazy(options);

It would be nice if you'd export it to the global scope, under Drupal variable:

      var options = settings.lazy.bLazy ? settings.lazy.bLazy : {};
      Drupal.blazy = new Blazy(options);

This would allow me and others use global blazy functions within my theme (like Drupal.blazy.revalidate()).

I'll attach the patch below, thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Nikro created an issue. See original summary.

Nikro’s picture

Here's the patch :)

Nikro’s picture

Status: Active » Needs review
Nikro’s picture

Okayyy, in some cases adding Drupal to the top, yields errors, reverting just to 1 line change.

Brainstormer59’s picture

Hi Nikro, I needed the same functionality as you.
Your patch#4 works great.

// I needed to revalidate blazy after a carousel state change like this:
$('#slick-slider').on('afterChange', function(){Drupal.blazy.revalidate();});

Thanks again for your patch.

Brainstormer59’s picture

Hi Nikro, I needed the same functionality as you.
Your patch works great.

I needed to revalidate blazy after a carousel state change like this:
$('#slick-slider').on('afterChange', function(){Drupal.blazy.revalidate();});

Thanks again for your patch.

mrconnerton’s picture

Status: Needs review » Reviewed & tested by the community

Patch in #4 works well. Very useful for revalidate in theme.

  • osman committed bea26cd on 7.x-1.x
    Issue #3015862 by Nikro: Export instance to Global Scope
    
osman’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the patch and reviews. It's now fixed in 7.x-1.x-dev.

Notice that the namespace is Drupal.lazy; not Drupal.blazy as the patch suggests, since it should match to module name.

Status: Fixed » Closed (fixed)

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