syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From skylar...@apache.org
Subject syncope git commit: [SYNCOPE-1237] Fix for copy-to-clipboard feature in multiple-opened toggle menus - full compatibility for Firefox and Chrome browsers
Date Mon, 11 Dec 2017 11:54:26 GMT
Repository: syncope
Updated Branches:
  refs/heads/2_0_X 93e143590 -> 3538e3345


[SYNCOPE-1237] Fix for copy-to-clipboard feature in multiple-opened toggle menus - full compatibility
for Firefox and Chrome browsers


Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/3538e334
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/3538e334
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/3538e334

Branch: refs/heads/2_0_X
Commit: 3538e33453a9c8ffdd9f1b9a9fda71c8418fb7ea
Parents: 93e1435
Author: skylark17 <matteo.alessandroni@tirasa.net>
Authored: Mon Dec 11 12:53:52 2017 +0100
Committer: skylark17 <matteo.alessandroni@tirasa.net>
Committed: Mon Dec 11 12:53:52 2017 +0100

----------------------------------------------------------------------
 .../META-INF/resources/js/copyToClipboard.js     | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/3538e334/client/console/src/main/resources/META-INF/resources/js/copyToClipboard.js
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/META-INF/resources/js/copyToClipboard.js b/client/console/src/main/resources/META-INF/resources/js/copyToClipboard.js
index b6d8634..ab85e1c 100644
--- a/client/console/src/main/resources/META-INF/resources/js/copyToClipboard.js
+++ b/client/console/src/main/resources/META-INF/resources/js/copyToClipboard.js
@@ -29,16 +29,29 @@ if (typeof copyToClipboard === 'undefined') {
     temp.style.height = 0;
 
     // Append it to the page somewhere, in this case <body>
-    $(document.body).append(temp);
+    $elem.append(temp);
 
     // Copy whatever is in the div to our new textarea
     temp.value = $elem.attr(tag_value_to_copy);
+    $(temp).text(temp.value);
 
     // Copy whatever inside the textarea to clipboard
     $(temp).focus().select();
-
     document.execCommand('SelectAll');
-    document.execCommand("Copy", false, null);
+    document.execCommand("copy", false, null);
+
+    if ($.browser.mozilla && !$.browser.chrome) {
+      try {
+        var range = document.createRange();
+        range.selectNodeContents(temp);
+        var selection = window.getSelection();
+        selection.removeAllRanges();
+        selection.addRange(range);
+
+        document.execCommand("Copy", false, null);
+      } catch (e) {
+      }
+    }
 
     // Remove the textarea
     $(temp).remove();


Mime
View raw message