Skip to content

Commit

Permalink
Moves advanced section to the bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
zenorocha committed Oct 4, 2015
1 parent 83a8eff commit 8e56ee6
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,32 @@ Truth is, you don't even need another element to copy its content from. You can
</button>
```

## Advanced Usage
## Events

There are cases where you'd like to show some user feedback or capture what has been selected after a copy/cut operation.

That's why we fire custom events such as `success` and `error` for you to listen and implement your custom logic.

```js
var clipboard = new Clipboard('.btn');

clipboard.on('success', function(e) {
console.info('Action:', e.action);
console.info('Text:', e.text);
console.info('Trigger:', e.trigger);

e.clearSelection();
});

clipboard.on('error', function(e) {
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
});
```

For a live demonstration, open this [site](https://zenorocha.github.io/clipboard.js/) and just your console :)

## Advanced Options

If you don't want to modify your HTML, there's a pretty handy imperative API for you to use. All you need to do is declare a function, do your thing, and return a value.

Expand Down Expand Up @@ -138,31 +163,6 @@ var clipboard = new Clipboard('.btn');
clipboard.destroy();
```

## Events

There are cases where you'd like to show some user feedback or capture what has been selected after a copy/cut operation.

That's why we fire custom events such as `success` and `error` for you to listen and implement your custom logic.

```js
var clipboard = new Clipboard('.btn');

clipboard.on('success', function(e) {
console.info('Action:', e.action);
console.info('Text:', e.text);
console.info('Trigger:', e.trigger);

e.clearSelection();
});

clipboard.on('error', function(e) {
console.error('Action:', e.action);
console.error('Trigger:', e.trigger);
});
```

For a live demonstration, open this [site](https://zenorocha.github.io/clipboard.js/) and just your console :)

## Browser Support

This library relies on both [Selection](https://developer.mozilla.org/en-US/docs/Web/API/Selection) and [execCommand](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand) APIs. The second one is supported in the following browsers.
Expand Down

0 comments on commit 8e56ee6

Please sign in to comment.