mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-08 23:19:04 +01:00
Add copy to system clipboard to context menu
This commit is contained in:
parent
66bbe734d8
commit
4eeed35c6c
@ -13,6 +13,7 @@
|
||||
jquery.jquery;
|
||||
egw_menu;
|
||||
/phpgwapi/js/jquery/jquery-tap-and-hold/jquery.tapandhold.js;
|
||||
/phpgwapi/js/zeroclipboard/dist/ZeroClipboard.min.js;
|
||||
*/
|
||||
|
||||
if (typeof window._egwActionClasses == "undefined")
|
||||
@ -334,6 +335,14 @@ function egwPopupActionImplementation()
|
||||
var menu = ai._buildMenu(_links, _selected, _target);
|
||||
menu.showAt(_context.posx, _context.posy);
|
||||
|
||||
// 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));
|
||||
client.on("copy",function(event) {
|
||||
event.clipboardData.setData('text/plain', _links.egw_os_clipboard.actionObj.data.target.innerText);
|
||||
event.clipboardData.setData('text/html', _links.egw_os_clipboard.actionObj.data.target.innerHTML);
|
||||
});
|
||||
});
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -607,6 +616,7 @@ function egwPopupActionImplementation()
|
||||
var mgr = _selected[0].manager;
|
||||
var copy_action = mgr.getActionById('egw_copy');
|
||||
var add_action = mgr.getActionById('egw_copy_add');
|
||||
var clipboard_action = mgr.getActionById('egw_os_clipboard');
|
||||
var paste_action = mgr.getActionById('egw_paste');
|
||||
|
||||
// Fake UI so we can simulate the position of the drop
|
||||
@ -692,6 +702,17 @@ function egwPopupActionImplementation()
|
||||
add_action.group = 2.5;
|
||||
|
||||
}
|
||||
if(clipboard_action == null)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
var os_clipboard_caption = event.target.innerText.trim();
|
||||
clipboard_action.set_caption(egw.lang('Copy "%1"', os_clipboard_caption.length>20 ? os_clipboard_caption.substring(0,20)+'...':os_clipboard_caption));
|
||||
clipboard_action.data.target = event.target;
|
||||
if(typeof _links[copy_action.id] == 'undefined')
|
||||
{
|
||||
_links[copy_action.id] = {
|
||||
@ -710,6 +731,15 @@ function egwPopupActionImplementation()
|
||||
"cnt": 0
|
||||
};
|
||||
}
|
||||
if(typeof _links[clipboard_action.id] == 'undefined')
|
||||
{
|
||||
_links[clipboard_action.id] = {
|
||||
"actionObj": clipboard_action,
|
||||
"enabled": os_clipboard_caption.length > 0,
|
||||
"visible": os_clipboard_caption.length > 0,
|
||||
"cnt": 0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Create default paste menu item
|
||||
|
@ -101,8 +101,8 @@ egwMenuImpl.prototype._translateStructure = function(_structure, _parentId, _idC
|
||||
|
||||
for (var i = 0; i < _structure.length; i++)
|
||||
{
|
||||
var id = 'elem_' + (_idCnt + counter);
|
||||
var elem = _structure[i];
|
||||
var id = elem.id || 'elem_' + (_idCnt + counter);
|
||||
|
||||
counter++;
|
||||
|
||||
|
8
phpgwapi/js/zeroclipboard/LICENSE
Normal file
8
phpgwapi/js/zeroclipboard/LICENSE
Normal file
@ -0,0 +1,8 @@
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2009-2014 Jon Rohan, James M. Greene
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
92
phpgwapi/js/zeroclipboard/README.md
Normal file
92
phpgwapi/js/zeroclipboard/README.md
Normal file
@ -0,0 +1,92 @@
|
||||
### WARNING
|
||||
**This `master` branch contains the `v2.x` codebase for ZeroClipboard! For the `v1.x` codebase, see the [`1.x-master`](https://github.com/zeroclipboard/zeroclipboard/tree/1.x-master) branch instead.**
|
||||
|
||||
|
||||
# ZeroClipboard
|
||||
[![GitHub Latest Release](https://badge.fury.io/gh/zeroclipboard%2Fzeroclipboard.png)](https://github.com/zeroclipboard/zeroclipboard) [![Build Status](https://secure.travis-ci.org/zeroclipboard/zeroclipboard.png?branch=master)](https://travis-ci.org/zeroclipboard/zeroclipboard) [![Coverage Status](https://coveralls.io/repos/zeroclipboard/zeroclipboard/badge.png?branch=master)](https://coveralls.io/r/zeroclipboard/zeroclipboard?branch=master) [![Dependency Status](https://david-dm.org/zeroclipboard/zeroclipboard.png?theme=shields.io)](https://david-dm.org/zeroclipboard/zeroclipboard) [![Dev Dependency Status](https://david-dm.org/zeroclipboard/zeroclipboard/dev-status.png?theme=shields.io)](https://david-dm.org/zeroclipboard/zeroclipboard#info=devDependencies)
|
||||
|
||||
The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible [Adobe Flash](http://en.wikipedia.org/wiki/Adobe_Flash) movie and a [JavaScript](http://en.wikipedia.org/wiki/JavaScript) interface. The "Zero" signifies that the library is invisible and the user interface is left entirely up to you.
|
||||
|
||||
This is achieved by automatically floating the invisible movie on top of a [DOM](http://en.wikipedia.org/wiki/Document_Object_Model) element of your choice. Standard mouse events are even propagated out to your DOM element, so you can still have rollover and mousedown effects.
|
||||
|
||||
|
||||
## Limitations
|
||||
|
||||
### User Interaction Required
|
||||
|
||||
Due to browser and Flash security restrictions, this clipboard injection can _**ONLY**_ occur when
|
||||
the user clicks on the invisible Flash movie. A simulated `click` event from JavaScript will not
|
||||
suffice as this would enable [clipboard poisoning](http://www.computerworld.com/s/article/9117268/Adobe_patches_Flash_clickjacking_and_clipboard_poisoning_bugs).
|
||||
|
||||
### Other Limitations
|
||||
|
||||
For a complete list of limitations, see [docs/instructions.md#limitations](docs/instructions.md#limitations).
|
||||
|
||||
|
||||
## Simple Example
|
||||
|
||||
```html
|
||||
<html>
|
||||
<body>
|
||||
<button id="copy-button" data-clipboard-text="Copy Me!" title="Click to copy me.">Copy to Clipboard</button>
|
||||
<script src="ZeroClipboard.js"></script>
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
```js
|
||||
// main.js
|
||||
var client = new ZeroClipboard( document.getElementById("copy-button") );
|
||||
|
||||
client.on( "ready", function( readyEvent ) {
|
||||
// alert( "ZeroClipboard SWF is ready!" );
|
||||
|
||||
client.on( "aftercopy", function( event ) {
|
||||
// `this` === `client`
|
||||
// `event.target` === the element that was clicked
|
||||
event.target.style.display = "none";
|
||||
alert("Copied text to clipboard: " + event.data["text/plain"] );
|
||||
} );
|
||||
} );
|
||||
```
|
||||
|
||||
See [docs/instructions.md](docs/instructions.md) for more advanced options in using the library on your site.
|
||||
See [docs/api/ZeroClipboard.md](docs/api/ZeroClipboard.md) for the complete API documentation.
|
||||
|
||||
Here is a working [test page](http://zeroclipboard.org/#demo) where you can try out ZeroClipboard in your browser.
|
||||
|
||||
|
||||
## Testing ZeroClipboard Locally
|
||||
|
||||
To test the page [demo page](http://zeroclipboard.org/#demo) locally, clone the [website repo](https://github.com/zeroclipboard/zeroclipboard.org).
|
||||
|
||||
|
||||
## Support
|
||||
|
||||
This library is fully compatible with Flash Player 11.0.0 and above, which requires
|
||||
that the clipboard copy operation be initiated by a user click event inside the
|
||||
Flash movie. This is achieved by automatically floating the invisible movie on top
|
||||
of a [DOM](http://en.wikipedia.org/wiki/Document_Object_Model) element of your
|
||||
choice. Standard mouse events are even propagated out to your DOM element, so you
|
||||
can still have rollover and mousedown effects with just a _little_ extra effort.
|
||||
|
||||
ZeroClipboard `v2.x` is expected to work in IE9+ and all of the evergreen browsers.
|
||||
Although support for IE7 & IE8 was officially dropped in `v2.0.0`, it was actually
|
||||
still _technically_ supported through `v2.0.2`.
|
||||
|
||||
## Contributing
|
||||
|
||||
see [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||
|
||||
|
||||
## Releases
|
||||
|
||||
Starting with version [1.1.7](https://github.com/zeroclipboard/zeroclipboard/releases/tag/v1.1.7), ZeroClipboard uses [semantic versioning](http://semver.org/).
|
||||
|
||||
see [releases](https://github.com/zeroclipboard/zeroclipboard/releases)
|
||||
|
||||
|
||||
## Roadmap
|
||||
|
||||
see [roadmap.md](docs/roadmap.md)
|
1913
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.Core.js
vendored
Normal file
1913
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.Core.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
10
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.Core.min.js
vendored
Normal file
10
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.Core.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.Core.min.map
vendored
Normal file
1
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.Core.min.map
vendored
Normal file
File diff suppressed because one or more lines are too long
2478
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.js
vendored
Normal file
2478
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
10
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.min.js
vendored
Normal file
10
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.min.map
vendored
Normal file
1
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.min.map
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.swf
vendored
Normal file
BIN
phpgwapi/js/zeroclipboard/dist/ZeroClipboard.swf
vendored
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user