Last active
August 29, 2015 13:57
-
-
Save KoryNunn/9699502 to your computer and use it in GitHub Desktop.
gaffa clipboard action
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Gaffa = require('gaffa'); | |
| function Clipboard(){} | |
| Clipboard = Gaffa.createSpec(Clipboard, Gaffa.Action); | |
| Clipboard.prototype.type = 'clipboard'; | |
| Clipboard.prototype.trigger = function(parent, scope, event){ | |
| scope = scope || {}; | |
| scope.data = this.source.value; | |
| if (window.clipboardData && window.clipboardData.setData) { | |
| clipboardData.setData("Text", this.source.value); | |
| this.triggerActions('success', scope, event); | |
| }else{ | |
| scope.error = 'Clipboard is not available in this browser'; | |
| this.triggerActions('error', scope, event); | |
| } | |
| }; | |
| Clipboard.prototype.source = new Gaffa.Property(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment