Javascript Implementation

Follow

Before beginning Javascript Implementation copy the load script from your Social Tools dashboard and place anywhere in your site/ template that will deploy site wide.  

Starting from v4 all public methods for working with our platform will be available through window.postPlatform.

PurposeDescriptionExample

New widget creation

window.postPlatform.createWidget(selector, options);
selector Selector (line) or DOM hub url.
options

Object with options from defaults Global Config. If this parameter is not specified, widget will be created anyway with options specified in window,pwidget_config or with default options.

Important: data-attributes have the top priority. If the element corresponding to selector has data-attributes, this section options will be ignored. Ex.:

<div id='case1' data-button-color='#000'></div>
<script>
window.postPlatform.createWidget('#case1', {
	butonColor: '#fff', // will be ignored. HTML code has priority
	url: 'http://pain.by' // will be active. 
});
</script>
							
<script>
window.postPlatform.createWidget('.my-widget', {
	hover: true,
	buttons: ['facebook', { id: 'twitter', size: '20'}] 
});
</script>
							

Update an existing widget

window.postPlatform.updateWidget(selector, options);
selector DOM Element, class, or id.
options

Object with new options from defaults Global Config

<script>
window.postPlatform.updateWidget('.my-widget', {
	buttonColor: '#000',
	buttonBackground: '#fff',
	hover: false,
	buttons: ['linkedin', { id: 'twitter', size: '48'}] 
});
</script>
							

Initialization

window.postPlatform.init(selectors);

This should only be used if init = lazy has been selected through a global configuration or the loading script

selector DOM Element, class, or id where the widget was created. Specifying a selector will speed up the processing time instead of searching the entire page.
<script>
window.postPlatform.init('#container');
</script>
							

Singer counter creation

window.postPlatform.createCounter(selector, options);

This should only be used if init = lazy has been selected through a global configuration or the loading script

selector DOM Element, class, or id.
options Box Counter
Box Counter
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Powered by Zendesk