Repository: incubator-guacamole-client Updated Branches: refs/heads/master 96e9318db -> ab88eb2ff
GUACAMOLE-310: Use input element select() function when available. Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/7e0cdd2a Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/7e0cdd2a Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/7e0cdd2a Branch: refs/heads/master Commit: 7e0cdd2adf156b6aa15ddf96a7e78a41c8f47c9a Parents: 47acaf5 Author: Michael Jumper <[email protected]> Authored: Sun Sep 3 17:07:24 2017 -0700 Committer: Michael Jumper <[email protected]> Committed: Sun Sep 3 17:08:34 2017 -0700 ---------------------------------------------------------------------- .../app/clipboard/services/clipboardService.js | 24 ++++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/7e0cdd2a/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js ---------------------------------------------------------------------- diff --git a/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js b/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js index 311dbc0..07091f3 100644 --- a/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js +++ b/guacamole/src/main/webapp/app/clipboard/services/clipboardService.js @@ -135,14 +135,23 @@ angular.module('clipboard').factory('clipboardService', ['$injector', */ var selectAll = function selectAll(element) { - // Generate a range which selects all nodes within the given element - var range = document.createRange(); - range.selectNodeContents(element); + // Use the select() function defined for input elements, if available + if (element.select) + element.select(); - // Replace any current selection with the generated range - var selection = $window.getSelection(); - selection.removeAllRanges(); - selection.addRange(range); + // Fallback to manual manipulation of the selection + else { + + // Generate a range which selects all nodes within the given element + var range = document.createRange(); + range.selectNodeContents(element); + + // Replace any current selection with the generated range + var selection = $window.getSelection(); + selection.removeAllRanges(); + selection.addRange(range); + + } }; @@ -175,6 +184,7 @@ angular.module('clipboard').factory('clipboardService', ['$injector', } // Select all data within the clipboard target + clipboardContent.focus(); selectAll(clipboardContent); // Attempt to copy data from clipboard element into local clipboard
