Skip to content
Adam Chambers edited this page Jun 1, 2016 · 14 revisions

JavaScript API Reference

OpenShare JavaScript API reference.

new OpenShare.share(options, element)

Share Options

You can use the last word from all the data attributes in the data attributes API as Share options in the JS API.

Property Value
type Name of the service. e.g. 'Twitter', 'Facebook', 'Github', etc..

url: URL being shared.

bindClick: Boolean. Set true to allow 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.

classes: An array of classes to be added to the Share Node.

Twitter

text: String to tweet.

via: via @{twitter user}

hashtags: List of hashtags to tweet.

related: Sets related items to url.

tweetId: Tweet to retweet.

screenName: User to follow.

userId: User to follow.

Facebook

link: Link to share.

picture: Photo to share.

caption: Caption for picture.

description: Description of picture.

YouTube

video: Video ID to share.

user: User to subscribe to.

Pinterest

media: Photo to share.

description: Description of picture.

link: Link to share.

Email

to: Email address to send to.

subject: Subject of the email.

body: Body of the email.

Flickr, Instagram, Snapchat

username: Set the username to follow or share.

Google Maps

type: 'display', 'search', or 'directions'.

search: Sets a search query in Google Maps.

center: comma separated string of latitude,longitude.

views: 'satellite', 'traffic', or 'transit'.

zoom: An integer that specifies the zoom level of the map.

saddr: This can be a latitude,longitude or a query formatted address.

dadd: Sets the end point for directions searches. Has the same format and behavior as saddr.

directionsMode: Method of transportation. Can be set to: driving, transit, bicycling or walking.

Github

repo: Sets a repo to share or post a Github issue in.

issue: Sets the issue title for a Github issue.

body: Body of Github issue.

Dribbble

shot: Sets the Dribbble shot to share.

Codepen

username: Set the username to follow or share.

view: Sets the view to open Codepen in.

pen: Sets the pen to open.

new OpenShare.count(options, element)

Count Options

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