I'm trying to use ZeroClipboard with EasyUI's menus. ZeroClipboard is a javascript + flash solution that allows you to copy to the clipboard. You can get the library from here:
https://github.com/zeroclipboard/ZeroClipboard/archive/v1.1.7.zipYou point it at an element and it throws a faked up flash movie element over the top of it, hijacking the click event so you satisfy the flash security restriction that setting the clipboard must come from an interactive click event.
Unfortunately, it and EasyUI appear to be incompatible. Here's my example code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Basic Menu with ZeroClipboard</title>
<link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.4/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.4/themes/icon.css">
<link rel="stylesheet" type="text/css" href="jquery-easyui-1.3.4/demo/demo.css">
<script type="text/javascript" src="jquery-easyui-1.3.4/jquery.min.js"></script>
<!--<script type="text/javascript" src="http://zeroclipboard.github.io/ZeroClipboard/javascripts/jquery.js"></script>-->
<script type="text/javascript" src="jquery-easyui-1.3.4/jquery.easyui.min.js"></script>
<script type="text/javascript" src="ZeroClipboard-1.1.7/ZeroClipboard.js"></script>
<script type="text/javascript">
$(document).ready(function () {
console.log('registering ZC');
//var clip = new ZeroClipboard($('#copybutton'), {
var clip = new ZeroClipboard($('#copymi'), {
moviePath:'ZeroClipboard-1.1.7/ZeroClipboard.swf'
});
clip.on( 'load', function(client) {
console.log('movie loaded');
} );
clip.on( 'complete', function(client, args) {
alert("Copied text to clipboard: " + args.text );
} );
clip.on( 'mouseover', function(client) {
console.log('mouseover');
} );
clip.on( 'mouseout', function(client) {
console.log("mouse out");
} );
clip.on( 'mousedown', function(client) {
console.log("mouse down");
} );
clip.on( 'mouseup', function(client) {
console.log("mouse up");
} );
clip.on( 'dataRequested', function (client, args) {
console.log('datarequested');
});
clip.on( 'wrongFlash', function ( client, args ) {
alert("Your flash is too old " + args.flashVersion);
} );
clip.on( 'wrongflash', function ( client, args ) {
alert("Your flash is too old " + args.flashVersion);
} );
clip.on( 'noflash', function ( client, args ) {
alert("You don't support flash");
} );
});
</script>
</head>
<body>
<button id="copybutton">copy via button</button>
<h2>Basic Menu</h2>
<div class="demo-info">
<div class="demo-tip icon-tip"></div>
<div>Right click on page to display menu.</div>
</div>
<div style="margin:10px 0;"></div>
<div id="mm" class="easyui-menu" style="width:120px;">
<div id="copymi">copy via menu</div>
</div>
<script>
$(function () {
$(document).bind('contextmenu', function (e) {
e.preventDefault();
$('#mm').menu('show', {
left:e.pageX,
top:e.pageY
});
});
});
</script>
</body>
</html>
Clicking on the menu item, you don't get any of the events you should, including the "complete" event when clicked on. If you switch the code to use the button instead, it works fine. I've also tried this with other versions of jQuery but the problem still happens.
Any ideas on how to get the two to be compatible? I've been looking around at other flash-clipboard libraries and this seems like the main option.
Thanks.