diff options
author | Byron Jones <glob@mozilla.com> | 2015-04-08 17:31:57 +0200 |
---|---|---|
committer | Byron Jones <glob@mozilla.com> | 2015-04-08 17:31:57 +0200 |
commit | 3eb141e49b918a4c1d8fa837cfcb72ae1dfef108 (patch) | |
tree | e9d3696860cdeca42ab6554e8bd1d2fb47f5e08c /extensions/BugModal/web | |
parent | 023ed1b6992ed5ea5780c30e7f145af65d9f6a97 (diff) | |
download | bugzilla-3eb141e49b918a4c1d8fa837cfcb72ae1dfef108.tar.gz bugzilla-3eb141e49b918a4c1d8fa837cfcb72ae1dfef108.tar.xz |
Bug 1150448: Replace the newline with " - " when the bug's id and summary are copied
Diffstat (limited to 'extensions/BugModal/web')
-rw-r--r-- | extensions/BugModal/web/bug_modal.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js index 09e7a81cf..babbdbe14 100644 --- a/extensions/BugModal/web/bug_modal.js +++ b/extensions/BugModal/web/bug_modal.js @@ -218,6 +218,27 @@ $(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(); + } + }); + // // anything after this point is only executed for logged in users // |