diff --git a/phpgwapi/js/egw_action/egw_action_popup.js b/phpgwapi/js/egw_action/egw_action_popup.js index e4e0de0dd6..02cf677e90 100644 --- a/phpgwapi/js/egw_action/egw_action_popup.js +++ b/phpgwapi/js/egw_action/egw_action_popup.js @@ -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 = {}; @@ -147,7 +149,7 @@ function egwPopupActionImplementation() // Stop action from bubbling up to parents e.stopPropagation(); e.cancelBubble = true; - + return false; }; @@ -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()); @@ -708,7 +740,7 @@ function egwPopupActionImplementation() { // Create an action to add selected to clipboard clipboard_action = mgr.addAction('popup', 'egw_os_clipboard', egw.lang('Copy to OS clipboard'), egw.image('copy'), function(action) { - + },true); clipboard_action.group = 2.5; }