Skip to content

Instantly share code, notes, and snippets.

@KoryNunn
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save KoryNunn/9699502 to your computer and use it in GitHub Desktop.

Select an option

Save KoryNunn/9699502 to your computer and use it in GitHub Desktop.
gaffa clipboard action
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