-
-
Save jcmoore/134d7430f160b4d21808 to your computer and use it in GitHub Desktop.
This file contains 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
requirejs.config({ | |
"baseUrl": "", | |
"paths": { | |
"ZeroClipboard": "http://cdnjs.cloudflare.com/ajax/libs/zeroclipboard/2.1.1/ZeroClipboard" | |
} | |
}); | |
requirejs(['ZeroClipboard'], function(ZeroClipboard) { | |
var client = new ZeroClipboard( document.getElementById("copy-button") ), | |
bridge = document.querySelector("#"+ZeroClipboard.config().swfObjectId), | |
container = bridge.parentNode; | |
// following logic accounts for Polymer | |
if (typeof unwrap === "function" && | |
unwrap(bridge).ZeroClipboard !== ZeroClipboard) { | |
unwrap(bridge).ZeroClipboard = ZeroClipboard; | |
container.removeChild(bridge); | |
container.appendChild(bridge); | |
} | |
client.on("error", function(event){ | |
console.log("ZeroClipboard error: "+ event.name + " message: " + event.message) | |
}) | |
client.on( "ready", function( readyEvent ) { | |
alert( "ZeroClipboard SWF is ready!" ); | |
client.on( "aftercopy", function( event ) { | |
alert("Copied text to clipboard: " + event.data["text/plain"] ); | |
}); | |
}); | |
}); |
This file contains 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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<script language="javascript" src="//cdnjs.cloudflare.com/ajax/libs/polymer/0.3.2/platform.js"></script> | |
<script data-main="app" src="//cdnjs.cloudflare.com/ajax/libs/require.js/2.1.11/require.min.js"></script> | |
</head> | |
<body> | |
<button id="copy-button" data-clipboard-text="Copy Me!" title="Click to copy me.">Copy to Clipboard</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment