From 0eaa231a286b6cd4c41af7184f84c35a447f9f33 Mon Sep 17 00:00:00 2001
From: Olimpia Magliulo <olimpiam@intern-ikts-MacBook-Air.local>
Date: Mon, 11 Dec 2017 13:55:09 +0100
Subject: [PATCH] Fix typo + update common javascript for clipboard.js

No need to have a postload for clipboard.js in templates.
Use the class "clipboard-btn" and match the data-clipboard-target with the right ID
(or other DOM-element).
---
 templates/error.twig        | 7 -------
 www/assets/js/src/script.js | 9 ++-------
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/templates/error.twig b/templates/error.twig
index d312c2cb3..5f89fa07e 100644
--- a/templates/error.twig
+++ b/templates/error.twig
@@ -1,13 +1,6 @@
 
 {% set pagetitle = dictTitle | trans %}
 {% extends "base.twig" %}
-
-{% block postload %}
-    <script type="text/javascript">
-        new Clipboard('.clipboard-btn');
-    </script>
-{% endblock %}
-
 {% block content %}
     <h2>{{ dictTitle | trans }}</h2>
     {{ dictDescr | trans(parameters) }}
diff --git a/www/assets/js/src/script.js b/www/assets/js/src/script.js
index 255b7d031..0ae37d351 100644
--- a/www/assets/js/src/script.js
+++ b/www/assets/js/src/script.js
@@ -39,12 +39,6 @@ function SimpleSAML_hide(id) {
 
   element.style.display = 'none';
 }
-
-function metadata(index) {
-    var clipboard = new Clipboard('#btn'+index);
-    console.log();
-}
-
 // Attach the `fileselect` event to all file inputs on the page
 $(document).on('change', ':file', function() {
     var input = $(this),
@@ -56,6 +50,7 @@ $(document).on('change', ':file', function() {
 $(document).ready(function() {
     $('.language-menu').selectize();
     $('#organization').selectize();
+    new Clipboard('.clipboard-btn');
 
     // Watch for custom `fileselect` event
     $(':file').on('fileselect', function(event, numFiles, label) {
@@ -69,7 +64,7 @@ $(document).ready(function() {
             if( log ) {
                 document.getElementById('show-file').innerHTML = log;
             }
-        };
+        }
     });
 
 });
-- 
GitLab