One problem with the current codebase is that the AddThis config code is inserted in the footer for every widget displayed on the page. If you happen to load the widget on every node teaser, you end up having a lot of duplicate JS code.

Comments

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new1.02 KB

In local testing this worked reasonably well.

damienmckenna’s picture

Resolves a problem if $configurationOptionsJavascript is not an array.

damienmckenna’s picture

StatusFileSize
new1.15 KB
matglas86’s picture

I rewrote the whole management of adding script to the page. This should solve a lot of problems. Maybe you could review this and see if it works correctly.

Its in my guthub account in the branch features/script-manager

https://github.com/matglas/addthis/tree/features/script-manager

matglas86’s picture

StatusFileSize
new69.45 KB

Here is the patch comming from the github branch mentioned in #4.

matglas86’s picture

StatusFileSize
new0 bytes

My patch did not apply. Sorry. Here is a new one.

matglas86’s picture

StatusFileSize
new62.12 KB

The last upload did not work somehow.

socialnicheguru’s picture

if I do an update:

The following updates are pending:

addthis module :
7402 -

Do you wish to run all pending updates? (y/n): y
PHP Fatal error: Undefined class constant 'WIDGET_JS_LOAD_TYPE' in /var/aegir/platforms/7/modules/all/addthis/addthis.install on line 77
PHP Stack trace:
PHP 1. {main}() /usr/share/php/drush/drush.php:0
PHP 2. drush_main() /usr/share/php/drush/drush.php:16
PHP 3. _drush_bootstrap_and_dispatch() /usr/share/php/drush/drush.php:61
PHP 4. drush_dispatch() /usr/share/php/drush/drush.php:92
PHP 5. call_user_func_array() /usr/share/php/drush/includes/command.inc:175
PHP 6. drush_command() /usr/share/php/drush/includes/command.inc:175
PHP 7. _drush_invoke_hooks() /usr/share/php/drush/includes/command.inc:208
PHP 8. call_user_func_array() /usr/share/php/drush/includes/command.inc:334
PHP 9. drush_core_updatedb_batch_process() /usr/share/php/drush/includes/command.inc:334
PHP 10. _update_batch_command() /usr/share/php/drush/commands/core/core.drush.inc:1097
PHP 11. drush_batch_command() /usr/share/php/drush/commands/core/drupal/update_7.inc:246
PHP 12. _drush_batch_command() /usr/share/php/drush/includes/batch.inc:93
PHP 13. _drush_batch_worker() /usr/share/php/drush/commands/core/drupal/batch.inc:99
PHP 14. call_user_func_array() /usr/share/php/drush/commands/core/drupal/batch.inc:149
PHP 15. drush_update_do_one() /usr/share/php/drush/commands/core/drupal/batch.inc:149
PHP 16. addthis_update_7402() /usr/share/php/drush/commands/core/drupal/update_7.inc:73

Fatal error: Undefined class constant 'WIDGET_JS_LOAD_TYPE' in /var/aegir/platforms/7/modules/all/addthis/addthis.install on line 77

And the module is not updated.

where is Widget_js_load_type defined?

matglas86’s picture

Status: Needs review » Needs work

I see the bug. I tried to remove the old variable. But that does not work as the static var with the key is removed from the AddThis class. I do need to fix that. The update statement should be changed to use the old key for WIDGET_JS_LOAD_TYPE.

socialnicheguru’s picture

I am only getting multiple js added to a page if I goto advanced, check the box, and add the addthis code.

matglas86’s picture

Status: Needs work » Needs review
StatusFileSize
new64.55 KB

I updated some thing based on feedback I received in https://github.com/matglas/addthis/pull/4.

Here is a new patch.
Things that changed.

  1. The addthis.js is loaded always but widget.js is loaded dynamicly.
  2. Attached was done incorrectly.
  3. Test funtionality is moved to a seperate module
  4. Https test is using global now.
matglas86’s picture

StatusFileSize
new66.54 KB

This is my latest patch. I'm ready to commit it. I tested upgrade from alpha4 without a problem.

  • matglas86 authored 112edac on 7.x-4.x
    Issue #2333231 by matglas86, DamienMcKenna: Only insert the same addthis...
matglas86’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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