Install
Works with Drupal: 7.xUsing Composer to manage Drupal site dependencies
Downloads
Release notes
- Issue #2333231 by matglas86, DamienMcKenna: Only insert the same addthis JS once per page #2333231: Only insert the same addthis JS once per page
Use update.php to rebuild the registry because of class changes.
If that does not work use the rebuild_registry module.
More importantly classes have been restructured and javascript loading
has been redesigned.
- Restructured test classes.
- Restructured the way widget.js is included, how loading is done and
how the addthis.js behaves.
- The addthis.js is always loaded but is used as a library instead of
executing everything directly like it was before.
- The include of AddThisJson and AddThisWidgetJs in AddThis::getInstance()
where removed because they should be autoloaded from the register.
Restructuring classes.
- In general the AddThis class has become a sort of module file that contains
all kinds of addthis related functions. This is bad design and therefore step
by step things are refactored. This breaks API but no official rc or release
has been given out yet.
- Classes are structured now in folders in a way namespace could be organised.
Because PHP 5.2 does not support namespaces we only use classes but the
structure is already there for future portability.
- AddThisScriptManager is added as a Service. This handles the attachment of
js and settings when needing addthis or widgets on your page. The AddThis->addWidgetJs,
AddThis->includeWidgetJs and AddThis->addConfigurationOptionsJs where
removed in favor of the AddThisScriptManager functionality.
- AddThisJson is moved to the Util directory.
- AddThisWidgetJs is renamed to AddThisWidgetJsUrl and moved to the Util
directory. The name changed because it better displays the purpose of the
class.
- AddThis->getServiceNamesAsCommaSeparatedString was made public to be usable
inside the AddThisScriptManager.
- getWidgetJsLoadType was renamed to getWidgetJsInclude because it displays
the type of information better.
- Related to the previous the WIDGET_JS_LOAD_TYPE was removed and split into
WIDGET_JS_LOAD_DOMREADY, WIDGET_JS_LOAD_ASYNC and WIDGET_JS_INCLUDE. The
reason beeing that the old way was misinterpreted. The DOMREADY and ASYNC
type of loading are two different things but where not possible separately.
Examples
- Expanded the example with a hook_page_build to run the attach functionality
on the whole page.
Test
- A test module was added to be able to test extra things but seperate it from
the main module.
- addthis.test contained two test classes. These where split into two sperate
files.