diff --git a/app/views/my/_sidebar.html.erb b/app/views/my/_sidebar.html.erb index e372425aa..ec86aaaef 100644 --- a/app/views/my/_sidebar.html.erb +++ b/app/views/my/_sidebar.html.erb @@ -22,9 +22,10 @@
<% if @user.api_token %> <%= l(:label_api_access_key_created_on, distance_of_time_in_words(Time.now, @user.api_token.created_on)) %> diff --git a/app/views/my/show_api_key.js.erb b/app/views/my/show_api_key.js.erb index 73b0ee029..d21d39871 100644 --- a/app/views/my/show_api_key.js.erb +++ b/app/views/my/show_api_key.js.erb @@ -1 +1,2 @@ $('#api-access-key').html('<%= escape_javascript @user.api_key %>').toggle(); +$('#copy-api-access-key').toggle(); diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 019b45dc4..b4caeddcf 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -570,6 +570,21 @@ function randomKey(size) { return key; } +function copyTextToClipboard(id) { + var target = document.getElementById(id); + if (target) { + var temp = document.createElement('textarea'); + temp.value = target.innerText; + document.body.appendChild(temp); + temp.select(); + document.execCommand('copy'); + if (temp.parentNode) { + temp.parentNode.removeChild(temp); + } + } + return false; +} + function updateIssueFrom(url, el) { $('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){ $(this).data('valuebeforeupdate', $(this).val()); diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 1dc44f3f2..6172df4ff 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -91,6 +91,7 @@ pre, code {font-family: Consolas, Menlo, "Liberation Mono", Courier, monospace;} #sidebar ul li, ul.flat li {list-style-type:none;margin: 0px 2px 0px 0px; padding: 0px 0px 0px 0px;} #sidebar div.wiki ul {margin:inherit; padding-left:40px;} #sidebar div.wiki ul li {list-style-type:inherit;} +#sidebar #copy-api-access-key {float:right;} #content { flex-grow: 1; background-color: #fff; margin: 0px; padding: 6px 10px 10px 10px; overflow-x: auto;} html>body #content { min-height: 600px; }