Detect Flash player click-to-play mode and inform user how to allow it for copy to clipboard from context menu

- Fix hovering over copy to clipboard brings a wierd small grey box
This commit is contained in:
Hadi Nategh 2015-02-16 15:18:25 +00:00
parent 42413373b5
commit f3de318e81

View File

@ -16,7 +16,9 @@
/phpgwapi/js/zeroclipboard/dist/ZeroClipboard.min.js;
*/
ZeroClipboard.config( { swfPath: egw.webserverUrl+"/phpgwapi/js/zeroclipboard/dist/ZeroClipboard.swf" } );
/* Set flashLoadTimeout to something close to immediate as we need to inspect error event, right when
* we open the context menu in order to detect Flash player's click-to-play mode*/
ZeroClipboard.config( { swfPath: egw.webserverUrl+"/phpgwapi/js/zeroclipboard/dist/ZeroClipboard.swf", flashLoadTimeout: 400} );
if (typeof window._egwActionClasses == "undefined")
window._egwActionClasses = {};
@ -345,6 +347,36 @@ function egwPopupActionImplementation()
// Bindings for copy to system clipboard
menu.instance.dhtmlxmenu.attachEvent("onShow", function(zoneId,ev) {
var client = new ZeroClipboard($j('#'+this.idPrefix+'egw_os_clipboard', this.base));
// We need to check if the browser settings for Flash player is set to click-to-play
// then prompting user in order to allow or block Flash player
jQuery('#global-zeroclipboard-html-bridge').hover(function (){
var $zeroClip = jQuery(this);
if ($zeroClip.hasClass('flash-deactivated'))
{
$zeroClip.addClass('flash-click-to-play-dialog');
egw.message("In order to copy to clipboard, you need to allow Flash player by clicking on gray box.\nYou can permanently allow Flash player for EGroupware in your browser settings.","info")
}
else
{
$zeroClip.removeClass('flash-click-to-play-dialog')
}
});
client.on({
error:function (e){
// Detect if the Flash player is on click-to-play mode or is deactivated
if (e.name == "flash-deactivated")
{
// Indicate both flash-deactivated and click-to-play mode
jQuery('#global-zeroclipboard-html-bridge').addClass('flash-deactivated');
}
else
{
jQuery('#global-zeroclipboard-html-bridge').removeClass('flash-deactivated');
}
}
})
client.on("copy",function(event) {
event.clipboardData.setData('text/plain', $j(_links.egw_os_clipboard.actionObj.data.target).text().trim());
event.clipboardData.setData('text/html', $j(_links.egw_os_clipboard.actionObj.data.target).html());