Download & Extend

Incompatible between LABjs and AddToAny module

Project:Share Buttons (AddToAny) by Lockerz
Version:7.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

When I enable Labjs, the AddToAny module stops working.The same problem exists for the HeadJs module as well.

Comments

#1

Can you check again with the latest snapshot of LABjs (31 Jul)?

#2

But my I am using drupal 7.4, and the version you mentioned it for Drupal 6.
Because the AddToAny module has two inline scripts, one in the header and one in the footer respectively. If the Labjs could exclude them from the chain, I think things will be ok.

#3

I push the changes yesterday but I don't know why there is no new developement snapshot in 7.x branch yet. The changes are in http://drupalcode.org/project/labjs.git/commit/4c5e58a and http://drupalcode.org/project/labjs.git/commit/e4544d4

#4

I've found the problem. 7.x-1.x-dev was tracking in the master branch that I stopped on it for a while and switch to 7.x-1.x branch. I fixed it. Hope a new snapsnot will be available soon.

#5

Thank you jciso. I've checked the latest snapshot, but still not working. There's a inline js code output from AddToAny module which is not captured by Labjs, and it shouldn't executes before other two inline javascripts on which it depends.

#6

The following patch for addtoany will have inline script wrapped by LABjs. Well, it also a more D7-way to insert inline script.

But the way that AddToAny use async to do several attempts to load the script make it difficult for LABjs to intervene. I'll debug a little bit further.

AttachmentSize
addtoany.patch 700 bytes

#7

Title:Incompatible with AddToAny module» Incompatible between LABjs and AddToAny module
Project:LABjs» Share Buttons (AddToAny) by Lockerz
Version:7.x-1.1» 7.x-1.x-dev
Component:Compatibility» Code
Category:bug report» feature request

The problem is that when inline script is wrapped by LABjs, variable scope change.

$L = $L.wait(function() {
  var a2a_config=Drupal.a2a_config||{}, da2a = ...
});

After that block, a2a_config and da2a is no longer available. There are two solutions:
- Wrap them into Drupal (like Drupal.a2a.config = ..., Drupal.a2a.d = ...)
- Put them into a JS file (like the case "Drupal" variable is put into misc/drupal.js).

I'm sorry to pass this issue into a2a. But it's a more "Drupal way" to do ;-)

#8

So appreciated to see your patch on a2a and two constructive solutions. Although it's not working yet, I don't see the 'da2a not defined' error anymore. I am not good at javascript and know little about drupal's js mechanism, but you really help me with understanding this issue a lot. Thank you very much :)