https://github.com/caffeinalab/ti.sharer
Sharing widget heavily inspired by AirBNB, with default drivers and the ability to add custom drivers to share.
https://github.com/caffeinalab/ti.sharer
Last synced: 6 months ago
JSON representation
Sharing widget heavily inspired by AirBNB, with default drivers and the ability to add custom drivers to share.
- Host: GitHub
- URL: https://github.com/caffeinalab/ti.sharer
- Owner: caffeinalab
- License: mit
- Created: 2014-07-22T13:10:36.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-11-20T14:52:28.000Z (over 10 years ago)
- Last Synced: 2024-11-16T00:32:56.128Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 235 KB
- Stars: 23
- Watchers: 9
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Ti.Sharer
### com.caffeinalab.titanium.sharer
A simple **Sharing** widget heavy inspired to **AirBnb**, with default drivers and the ability to add custom drivers to share.
The widget use [Trimethyl.Share](https://github.com/CaffeinaLab/Trimethyl), so you **must** install Trimethyl to use it, or define your own custom drivers.

## Installation
#### Via Gittio
```
gittio install com.caffeinalab.titanium.sharer
```
#### Via Github
Download the latest release, unzip in `app/widgets` and add in your *config.json*, under `dependencies`:
```json
"dependencies": {
"com.caffeinalab.titanium.sharer": "*"
}
```
## Usage
```javascript
var Sharer = Alloy.createWidget('com.caffeinalab.titanium.sharer');
Sharer.show({
url: 'http://google.it',
text: "Your awesome message!"
});
```
## API
#### `show(so, [where]) `
The `so` object represents a `Trimethyl.share` argument.
* `url`: The link to share
* `text`: The personal share message to use, when supported by driver.
* `image`: The image to share. Can be a URL or `Ti.Blob`.
`where` is an Array of Strings of enabled drivers.
#### `hide()`
Close the mask.
#### `setDriver(name, def)`
Add/replace a driver definition.
A **driver definition** is in this form
```javascript
{
callback: function(e) { }, // The callback invoked on click (`e.source` represents the Button`
args: {} // The property passed to the button
}
```
An example:
```javascript
copytoclipboard: {
callback: function(e) {
Ti.UI.Clipboard.setText(e.shareObj.url);
e.source.titleid = L('Link copied!');
},
args: {
borderColor: '#fff',
titleid: L('Copy link')
}
}
```
### `extendDriverArgs(name, args)`
Extend a driver only at UI level.