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
Date Wed, 06 Dec 2017 10:03:10 GMT
Repository: syncope
Updated Branches:
  refs/heads/2_0_X 8c6e60592 -> 280df019d


[SYNCOPE-1237] Fix for copy-to-clipboard feature in multiple-opened toggle menus


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

Branch: refs/heads/2_0_X
Commit: 280df019d82c37c9c7e46ac1c457ec291caeae73
Parents: 8c6e605
Author: skylark17 <matteo.alessandroni@tirasa.net>
Authored: Wed Dec 6 11:03:02 2017 +0100
Committer: skylark17 <matteo.alessandroni@tirasa.net>
Committed: Wed Dec 6 11:03:02 2017 +0100

----------------------------------------------------------------------
 .../client/console/panels/TogglePanel.java      |  5 +--
 .../META-INF/resources/js/copyToClipboard.js    | 38 ++++++++++----------
 .../client/console/panels/TogglePanel.html      |  2 +-
 3 files changed, 23 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/280df019/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
b/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
index a2960a1..6db536b 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/panels/TogglePanel.java
@@ -66,7 +66,7 @@ public abstract class TogglePanel<T extends Serializable> extends
WizardMgtPanel
     private static final long serialVersionUID = -2025535531121434056L;
 
     protected static final Logger LOG = LoggerFactory.getLogger(TogglePanel.class);
-    
+
     protected static final int HEADER_FIRST_ABBREVIATION = 25;
 
     private enum Status {
@@ -211,7 +211,8 @@ public abstract class TogglePanel<T extends Serializable> extends
WizardMgtPanel
         } else if (modelObject instanceof EntityTO) {
             key = ((EntityTO) modelObject).getKey();
         } else if (modelObject instanceof StatusBean) {
-            key = ((StatusBean) modelObject).getKey();
+            key = StringUtils.isNotBlank(((StatusBean) modelObject).getResource())
+                    ? ((StatusBean) modelObject).getResource() : ((StatusBean) modelObject).getKey();
         } else if (modelObject instanceof PolicyRuleDirectoryPanel.PolicyRuleWrapper) {
             key = ((PolicyRuleDirectoryPanel.PolicyRuleWrapper) modelObject).getName();
         } else if (modelObject instanceof PolicyRuleDirectoryPanel.PolicyRuleWrapper) {

http://git-wip-us.apache.org/repos/asf/syncope/blob/280df019/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 9598c77..b6d8634 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
@@ -16,50 +16,50 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-// Copy to clipboard
 if (typeof copyToClipboard === 'undefined') {
   copyToClipboard = function (element, tag_value_to_copy, fake_textarea_ID, feedback_selector)
{
-    // creating new textarea element and giveing it id 't'
+    var $elem = $(element);
+
+    // creating new textarea element and giveing it an ID
     var temp = document.createElement('textarea');
     temp.id = fake_textarea_ID;
+    temp.style.display = 'block';
 
-    // Optional step to make less noise in the page, if any!
+    // Make less noise in the page
     temp.style.height = 0;
 
-    // You have to append it to your page somewhere, I chose <body>
+    // Append it to the page somewhere, in this case <body>
     $(document.body).append(temp);
 
-    // Copy whatever is in your div to our new textarea
-    temp.value = $(element).attr(tag_value_to_copy);
+    // Copy whatever is in the div to our new textarea
+    temp.value = $elem.attr(tag_value_to_copy);
 
-    // Now copy whatever inside the textarea to clipboard
-    var selector = document.querySelector("#" + fake_textarea_ID);
-    selector.select();
+    // Copy whatever inside the textarea to clipboard
+    $(temp).focus().select();
 
-    document.execCommand('copy');
+    document.execCommand('SelectAll');
+    document.execCommand("Copy", false, null);
 
     // Remove the textarea
     $(temp).remove();
 
-    $(feedback_selector).fadeIn();
+    $elem.siblings(feedback_selector).fadeIn();
 
-    // Remove Message of feedback
-    setTimeout(function () {
-      $(feedback_selector).fadeOut();
+    // Remove feedback element
+    window.setTimeout(function () {
+      $elem.siblings(feedback_selector).fadeOut();
     }, 1000);
   };
 
-  $(document).off('click', '.label-with-key:visible');
-  $(document).on('click', '.label-with-key:visible', function (e) {
+  function doCopyToClipboard(el) {
     var feedback_selector = '.copy-clipboard-feedback';
     var fake_textarea_selector = 'tttt';
     var tag_value_to_copy = 'data-value';
 
     if (!$(feedback_selector + ":visible").length) {
-      copyToClipboard(this, tag_value_to_copy, fake_textarea_selector, feedback_selector);
+      copyToClipboard(el, tag_value_to_copy, fake_textarea_selector, feedback_selector);
     }
-    e.stopPropagation();
-  });
+  }
 }
 
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/280df019/client/console/src/main/resources/org/apache/syncope/client/console/panels/TogglePanel.html
----------------------------------------------------------------------
diff --git a/client/console/src/main/resources/org/apache/syncope/client/console/panels/TogglePanel.html
b/client/console/src/main/resources/org/apache/syncope/client/console/panels/TogglePanel.html
index 659872a..95a1b22 100644
--- a/client/console/src/main/resources/org/apache/syncope/client/console/panels/TogglePanel.html
+++ b/client/console/src/main/resources/org/apache/syncope/client/console/panels/TogglePanel.html
@@ -119,7 +119,7 @@ under the License.
           <div class="copy-clipboard-feedback" style="display: none"> 
             <wicket:message key="copy_to_clipboard.feedback"/>
           </div>
-          <label wicket:id="label" class="label-with-key"/>
+          <label wicket:id="label" class="label-with-key" onclick="doCopyToClipboard(this)"/>
 
         </div>
         <div class="close">


Mime
View raw message