mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +00:00
GUACAMOLE-310: Use input element select() function when available.
This commit is contained in:
@@ -135,14 +135,23 @@ angular.module('clipboard').factory('clipboardService', ['$injector',
|
|||||||
*/
|
*/
|
||||||
var selectAll = function selectAll(element) {
|
var selectAll = function selectAll(element) {
|
||||||
|
|
||||||
// Generate a range which selects all nodes within the given element
|
// Use the select() function defined for input elements, if available
|
||||||
var range = document.createRange();
|
if (element.select)
|
||||||
range.selectNodeContents(element);
|
element.select();
|
||||||
|
|
||||||
// Replace any current selection with the generated range
|
// Fallback to manual manipulation of the selection
|
||||||
var selection = $window.getSelection();
|
else {
|
||||||
selection.removeAllRanges();
|
|
||||||
selection.addRange(range);
|
// 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
|
// Select all data within the clipboard target
|
||||||
|
clipboardContent.focus();
|
||||||
selectAll(clipboardContent);
|
selectAll(clipboardContent);
|
||||||
|
|
||||||
// Attempt to copy data from clipboard element into local clipboard
|
// Attempt to copy data from clipboard element into local clipboard
|
||||||
|
Reference in New Issue
Block a user