From 9292de403b0a67cd015250955a18af9468ec18ac Mon Sep 17 00:00:00 2001
From: Dorian Merz <merz@ub.uni-leipzig.de>
Date: Wed, 13 Nov 2019 10:37:07 +0100
Subject: [PATCH] refs #15969 [fid_bbi] Permalink

* adds JS functionality to permalink
* copies URL to clipboard
---
 fid_bbi/languages/de.ini                            |  3 +++
 fid_bbi/languages/en.ini                            |  3 +++
 .../RecordDriver/DefaultRecord/toolbar.phtml        | 13 ++++++++++++-
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/fid_bbi/languages/de.ini b/fid_bbi/languages/de.ini
index 347480bb074..5784dacadb3 100644
--- a/fid_bbi/languages/de.ini
+++ b/fid_bbi/languages/de.ini
@@ -436,3 +436,6 @@ report_errors_send_success = "Vielen Dank für Ihr Feedback."
 
 # 15575
 history_saved_searches  = "Meine gespeicherten Suchen"
+
+#15969
+copied_link_to_clipboard = "Link in Zwischenablage kopiert"
\ No newline at end of file
diff --git a/fid_bbi/languages/en.ini b/fid_bbi/languages/en.ini
index eb6ff71457e..f64e548a518 100644
--- a/fid_bbi/languages/en.ini
+++ b/fid_bbi/languages/en.ini
@@ -429,3 +429,6 @@ report_errors_send_success = "Thank you for your feedback!"
 # 15575
 Your Profile = "My Profile"
 history_saved_searches  = "My Saved Searches"
+
+#15969
+copied_link_to_clipboard = "Copied Link to Clipboard"
\ No newline at end of file
diff --git a/themes/fid_bbi/templates/RecordDriver/DefaultRecord/toolbar.phtml b/themes/fid_bbi/templates/RecordDriver/DefaultRecord/toolbar.phtml
index a78e22e8cf2..cb52242732d 100644
--- a/themes/fid_bbi/templates/RecordDriver/DefaultRecord/toolbar.phtml
+++ b/themes/fid_bbi/templates/RecordDriver/DefaultRecord/toolbar.phtml
@@ -61,7 +61,7 @@ $cartId = $this->driver->getSourceIdentifier() . '|' . $this->driver->getUniqueI
     <a href="javascript:window.print()"><i class="fa fa-printer" aria-hidden="true"></i> <?=$this->transEsc('Print')?></a>
   </li>
   <li>
-    <a href="<?=$this->url('record', ['action' => 'record', 'id' => $this->driver->getUniqueId()], ['force_canonical' => true])?>"><i class="fa fa-copy" aria-hidden="true"></i> <?=$this->transEsc('Permalink')?></a>
+    <a id="permalink" href="<?=$this->url('record', ['action' => 'record', 'id' => $this->driver->getUniqueId()], ['force_canonical' => true])?>"><i class="fa fa-copy" aria-hidden="true"></i> <?=$this->transEsc('Permalink')?></a>
   </li>
   <li>
     <a class="feedbackLink item" data-lightbox href="<?=$this->recordLink()->getActionUrl($this->driver, 'ReportErrors')?>" rel="nofollow"><i class="fa fa-envelope" aria-hidden="true"></i> <?=$this->transEsc('ReportErrors')?></a>
@@ -70,4 +70,15 @@ $cartId = $this->driver->getSourceIdentifier() . '|' . $this->driver->getUniqueI
     <a class="feedbackLink item" data-lightbox href="<?=$this->recordLink()->getActionUrl($this->driver, 'Acquisition')?>" rel="nofollow"><i class="fa fa-envelope" aria-hidden="true"></i> <?=$this->transEsc('Book Suggestion')?></a>
   </li>
 </ul>
+<script>
+    document.getElementById('permalink').onclick=function(e){
+        e.preventDefault();
+        var $temp = $("<input>");
+        $("body").append($temp);
+        $temp.val($(this).attr("href").trim()).select();
+        document.execCommand("copy");
+        alert("<?=$this->translate('copied_link_to_clipboard')?>");
+        $temp.remove();
+    }
+</script>
 <!-- fid_bbi: recordDriver - DefaultRecord - toolbar - END -->
-- 
GitLab