Skip to content
Jacob Burden edited this page Jun 8, 2016 · 14 revisions

You can also initialize OpenShare nodes in JavaScript for more fine-grained control over share and count node generation.

Sharing

You can use the last word from all data attributes in the data attributes API as options in the JS API as well as a few extras:

new OpenShare.share({
    type: 'twitter',
    innerHTML: 'Check it out!'
}, document.querySelector('[data-my-element]');
Property Value
type Name of the service. e.g. 'Twitter', 'Facebook', 'Github', etc..
bindClick Boolean. (Default true) Set false to disallow Share Node to share when clicked.
appendTo Element to append the Share Node to.
innerHTML Sets a string as innerHtml to the Share Node.
element Element to create the share node as rather than appending to element arg
classes An array of classes to be added to the Share Node.

Counting

You can also generate count nodes using the JavaScript API:

new OpenShare.count({
    type: 'facebook',
    url: 'http://www.digitalsurgeons.com',
    appendTo: document.querySelector('[data-my-element]')
}, function (node) {
  console.log('count node:', node, 'returned after successful XHR');
});
Property Value
type The service to get a count from.
url URL to get a count from.
element Element to create a count node of. (Default: <span>)
classes Array of classes to give the count node.
appendTo Element to append the count node to.
Clone this wiki locally