0.0.2 • Published 7 years ago
pure-copyright v0.0.2
pure-copyright
pure JavaScript version of copyright
Install
npm i -S pure-copyright
Usage
import Copyright from 'pure-copyright'
or
<script src="https://unpkg.com/pure-copyright@latest"></script>
new Copyright(document.body)
Options
You can pass an options object in plugin init method.
text
: The text that will be added when copying (Default:"<br>Original: " + window.location.href
);minlength
: The minimum length of the copied text when running the plugin (Default:0
).processing
: Function to process the copied text (Default:undefined
).
new Copyright(document.body, {
text: "<br><br>Reference: " + window.location.href,
minlength: 100,
processing: function(text) {
console.log(text)
}
})
Methods:
- destory:Stop the plugin
Events:
You can listen Copyright events.
beforeCopy
afterCopy
new Copyright(document.body, {
processing: function (text) {
console.log(text)
}
}).on('beforeCopy', () => {
console.log(+ new Date())
}).on('afterCopy', () => {
console.log(+ new Date())
})
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Credits
Author
pure-copyright © sinchang, Released under the MIT License. Authored and maintained by sinchang with help from contributors (list).
sinchang.me · GitHub @sinchang · Twitter @sinchangwen