-
Notifications
You must be signed in to change notification settings - Fork 0
Plugins
Lasse S. Haslev edited this page Mar 1, 2018
·
1 revision
Out of the box this package automatically dispatchs events for Adapt Retail. Both for Adapt Rapports and Google Analytics.
You can also easily add plugins to dispatch other events like Google DoubleClick, AdForm, Delta Projects and other with the same API.
You can extend functionality of the AdaptEvent by adding plugins.
AdaptEvent.addPlugin( new AdForm );AdaptClickEvent is actually a plugin. Use it as a reference.
Here is an example of extending the AdaptEvent to trigger AdForm events when we trigger events.
class AdForm {
/**
* This method is called when
* the plugin is added to the plugin stack
* @return void
*/
mounted() {
console.log( 'Plugin is ready!' );
}
/**
* Gets called when AdaptEvent.dispatch
* is called.
*
* @param event
* @param description = null
* @param mousePosition Object = null
*
* @return void
*/
onDispatchEvent( name, description, event ) {
// Cancel if resources is not available
if (typeof dhtml === 'undefined') {
return;
}
// Do the logic
switch (name.toLowerCase()) {
case 'click':
dhtml.sendEvent( 5, 'Click' );
break;
case 'next':
dhtml.sendEvent( 4, 'Next' );
break;
case 'previous':
dhtml.sendEvent( 4, 'Previous' );
break;
}
}
}
// Add the plugin to AdaptEvent
AdaptEvent.addPlugin( new AdForm );