new SharePolyfill(optionsopt)
https://developer.mozilla.org/en-US/docs/Web/API/Web_Share_API
Setup a instance with custom options
Parameters:
Name |
Type |
Attributes |
Description |
options |
Object
|
<optional>
|
optional options :)
Properties
Name |
Type |
Attributes |
Default |
Description |
forcePolyfill |
|
<optional>
|
false
|
allows you to override default navigator share |
registerNativeTargets |
|
<optional>
|
false
|
todo: allow us to extend native share and add our custom targets |
defaultTargets |
|
<optional>
|
true
|
weather to include the default targets in this share |
shareTargets |
Array.<ShareTarget>
|
<optional>
|
|
An array of additional share targets to add |
|
- Source:
Methods
(static) getDefaultShareTargets()
- Source:
Example
https://github.com/bradvin/social-share-urls
return {
'add.this': 'http://www.addthis.com/bookmark.php?url=' + url,
'blogger': 'https://www.blogger.com/blog-this.g?u=' + url + '&n=' + title + '&t=' + desc,
'buffer': 'https://buffer.com/add?text=' + text + '&url=' + url,
'diaspora': 'https://share.diasporafoundation.org/?title=' + title + '&url=' + url,
'douban': 'http://www.douban.com/recommend/?url=' + url + '&title=' + text,
'email': 'mailto:' + email_address + '?subject=' + title + '&body=' + desc,
'evernote': 'https://www.evernote.com/clip.action?url=' + url + '&title=' + text,
'getpocket': 'https://getpocket.com/edit?url=' + url,
'facebook': 'http://www.facebook.com/sharer.php?u=' + url,
'flattr': 'https://flattr.com/submit/auto?user_id=' + user_id + '&url=' + url + '&title=' + title + '&description=' + text + '&language=' + language + '&tags=' + hash_tags + '&hidden=HIDDEN&category=' + category,
'flipboard': 'https://share.flipboard.com/bookmarklet/popout?v=2&title=' + text + '&url=' + url,
'gmail': 'https://mail.google.com/mail/?view=cm&to=' + email_address + '&su=' + title + '&body=' + url + '&bcc=' + bcc_email_address + '&cc=' + cc_email_address,
'google.bookmarks': 'https://www.google.com/bookmarks/mark?op=edit&bkmk=' + url + '&title=' + title + '&annotation=' + text + '&labels=' + hash_tags + '',
'instapaper': 'http://www.instapaper.com/edit?url=' + url + '&title=' + title + '&description=' + desc,
'line.me': 'https://lineit.line.me/share/ui?url=' + url + '&text=' + text,
'linkedin': 'https://www.linkedin.com/sharing/share-offsite/?url=' + url,
'livejournal': 'http://www.livejournal.com/update.bml?subject=' + text + '&event=' + url,
'hacker.news': 'https://news.ycombinator.com/submitlink?u=' + url + '&t=' + title,
'ok.ru': 'https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=' + url,
'pinterest': 'http://pinterest.com/pin/create/button/?url=' + url,
'qzone': 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + url,
'reddit': 'https://reddit.com/submit?url=' + url + '&title=' + title,
'renren': 'http://widget.renren.com/dialog/share?resourceUrl=' + url + '&srcUrl=' + url + '&title=' + text + '&description=' + desc,
'skype': 'https://web.skype.com/share?url=' + url + '&text=' + text,
'sms': 'sms:' + phone_number + '?body=' + text,
'surfingbird.ru': 'http://surfingbird.ru/share?url=' + url + '&description=' + desc + '&screenshot=' + image + '&title=' + title,
'telegram.me': 'https://t.me/share/url?url=' + url + '&text=' + text + '&to=' + phone_number,
'threema': 'threema://compose?text=' + text + '&id=' + user_id,
'tumblr': 'https://www.tumblr.com/widgets/share/tool?canonicalUrl=' + url + '&title=' + title + '&caption=' + desc + '&tags=' + hash_tags,
'twitter': 'https://twitter.com/intent/tweet?url=' + url + '&text=' + text + '&via=' + via + '&hashtags=' + hash_tags,
'vk': 'http://vk.com/share.php?url=' + url + '&title=' + title + '&comment=' + desc,
'weibo': 'http://service.weibo.com/share/share.php?url=' + url + '&appkey=&title=' + title + '&pic=&ralateUid=',
'whatsapp': 'https://api.whatsapp.com/send?text=' + text + '%20' + url,
'xing': 'https://www.xing.com/spi/shares/new?url=' + url,
'yahoo': 'http://compose.mail.yahoo.com/?to=' + email_address + '&subject=' + title + '&body=' + text,
};
}
_share(data, options) → {Promise}
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share
This creates the share popup
Parameters:
Name |
Type |
Description |
data |
|
the share data
Properties
Name |
Type |
Description |
url |
String
|
OFFICIAL A string representing a URL to be shared. |
text |
String
|
OFFICIAL A string representing text to be shared. |
title |
String
|
OFFICIAL A string representing a title to be shared. May be ignored by the target. |
files |
Array.<File>
|
OFFICIAL An array of File objects representing files to be shared. See below for shareable file types. |
desc |
String
|
See ShareTarget.constructor for full unoffical target docs |
|
options |
|
optional options. can disable any target by name === false |
- Source:
Returns:
- resolve undifined or reject Exception/Error
-
Type
-
Promise
registerShareTarget(shareTarget)
https://web.dev/web-share-target/
Register a posible url if the one you want is not provided
Parameters:
Name |
Type |
Description |
shareTarget |
ShareTarget
|
an instance of share target object see docs; |
- Source:
share(data, optionsopt) → {Promise}
https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share
Perform a share
Parameters:
Name |
Type |
Attributes |
Description |
data |
ShareData
|
|
An object containing data to share
Properties that are unknown to the user agent are ignored; share data is only assessed on properties understood by the user agent. All properties are optional but at least one known data property must be specified.
Possible values are:
Properties
Name |
Type |
Description |
url |
string
|
A string representing a URL to be shared. |
url |
string
|
A string representing text to be shared. |
url |
string
|
A string representing a title to be shared. May be ignored by the target. |
|
options |
Object
|
<optional>
|
SharePolyfill Extended Options ignored in native more and optional |
- Source:
Returns:
-
Type
-
Promise
shareTo(name, data, options) → {*}
This function is called by the share dialog thing, and is what actually triggers the ShareTarget action
Parameters:
Name |
Type |
Description |
name |
|
|
data |
|
|
options |
|
|
- Source:
Returns:
-
Type
-
*