summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorKohei Yoshino <kohei.yoshino@gmail.com>2018-07-17 05:26:46 +0200
committerDylan William Hardison <dylan@hardison.net>2018-07-17 05:26:46 +0200
commit03450656e24abb848f6ef8b4f599e876522120fb (patch)
treeed42e87215040221c0095ece21457f50e2ff83b0 /extensions
parentac995e4ebf84924b6be9dba3fe8358f0a5857ad1 (diff)
downloadbugzilla-03450656e24abb848f6ef8b4f599e876522120fb.tar.gz
bugzilla-03450656e24abb848f6ef8b4f599e876522120fb.tar.xz
Bug 1472961 - Copy Summary button should copy link as well
Diffstat (limited to 'extensions')
-rw-r--r--extensions/BugModal/template/en/default/bug_modal/header.html.tmpl3
-rw-r--r--extensions/BugModal/web/bug_modal.js40
2 files changed, 17 insertions, 26 deletions
diff --git a/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl
index b9a42caf3..47d97fb32 100644
--- a/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl
+++ b/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl
@@ -8,6 +8,7 @@
[%
PROCESS global/variables.none.tmpl;
+ USE Bugzilla;
# <title>
IF bugs.defined;
@@ -89,6 +90,8 @@
[%# expose useful data to js %]
BUGZILLA.bug_id = [% bug.id FILTER none %];
BUGZILLA.bug_title = '[% unfiltered_title FILTER js %]';
+ BUGZILLA.bug_summary = '[% bug.short_desc FILTER js %]';
+ BUGZILLA.bug_url = '[% Bugzilla.cgi.self_url FILTER js %]';
BUGZILLA.user = {
id: [% user.id FILTER none %],
login: '[% user.login FILTER js %]',
diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js
index 4a770e66c..c4bff9412 100644
--- a/extensions/BugModal/web/bug_modal.js
+++ b/extensions/BugModal/web/bug_modal.js
@@ -339,10 +339,6 @@ $(function() {
// copy summary to clipboard
- function clipboardSummary() {
- return 'Bug ' + BUGZILLA.bug_id + ' - ' + $('#field-value-short_desc').text();
- }
-
if ($('#copy-summary').length) {
var hasExecCopy = false;
try {
@@ -352,11 +348,24 @@ $(function() {
}
if (hasExecCopy) {
+ const url = BUGZILLA.bug_url;
+ const text = `Bug ${BUGZILLA.bug_id} - ${BUGZILLA.bug_summary}`;
+ const html = `<a href="${url}">${text}</a>`;
+
+ document.addEventListener('copy', event => {
+ if (event.target.nodeType === 1 && event.target.matches('#clip')) {
+ event.clipboardData.setData('text/uri-list', url);
+ event.clipboardData.setData('text/plain', text);
+ event.clipboardData.setData('text/html', html);
+ event.preventDefault();
+ }
+ });
+
$('#copy-summary')
.click(function() {
// execCommand("copy") only works on selected text
$('#clip-container').show();
- $('#clip').val(clipboardSummary()).select();
+ $('#clip').val(text).select();
$('#floating-message-text')
.text(document.execCommand("copy") ? 'Bug summary copied!' : 'Couldn’t copy bug summary');
$('#floating-message').fadeIn(250).delay(2500).fadeOut();
@@ -377,27 +386,6 @@ $(function() {
lb_show(this);
});
- // when copying the bug id and summary, reformat to remove \n and alias
- $(document).on(
- 'copy', function(event) {
- var selection = document.getSelection().toString().trim();
- var match = selection.match(/^(Bug \d+)\s*\n(.+)$/) ||
- selection.match(/^(Bug \d+)\s+\([^\)]+\)\s*\n(.+)$/);
- if (match) {
- var content = match[1] + ' - ' + match[2].trim();
- if (event.originalEvent.clipboardData) {
- event.originalEvent.clipboardData.setData('text/plain', content);
- }
- else if (window.clipboardData) {
- window.clipboardData.setData('Text', content);
- }
- else {
- return;
- }
- event.preventDefault();
- }
- });
-
// action button actions
// reset