From 6aab704144bba00ffc5dd759b3e17265c5998c14 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Mon, 10 May 2021 19:40:54 +1000 Subject: [PATCH] Trim content when copying to clipboard --- .../static/script/inventree/inventree.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/inventree.js b/InvenTree/InvenTree/static/script/inventree/inventree.js index 0c5cd2426c..b3209ca267 100644 --- a/InvenTree/InvenTree/static/script/inventree/inventree.js +++ b/InvenTree/InvenTree/static/script/inventree/inventree.js @@ -1,3 +1,14 @@ +function attachClipboard(selector) { + + new ClipboardJS(selector, { + text: function(trigger) { + var content = trigger.parentElement.parentElement.textContent; + + return content.trim(); + } + }); +} + function inventreeDocReady() { /* Run this function when the HTML document is loaded. * This will be called for every page that extends "base.html" @@ -50,11 +61,8 @@ function inventreeDocReady() { }); // Initialize clipboard-buttons - new ClipboardJS('.clip-btn', { - text: function(trigger) { - return trigger.parentElement.parentElement.textContent; - } - }); + attachClipboard('.clip-btn'); + } function isFileTransfer(transfer) {