Skip to content

Commit b5b6064

Browse files
authored
Merge branch 'main' into issue1514-search-bar-autocomplete
2 parents 58ace93 + ed44f6e commit b5b6064

File tree

12 files changed

+112
-32
lines changed

12 files changed

+112
-32
lines changed

resource/css/skosmos.css

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ body {
8585
margin: 0 5px;
8686
}
8787

88-
#main-container.termpage .fa-copy {
89-
color: var(--vocab-text);
90-
font-size: 30px;
91-
position: relative;
92-
bottom: -3px;
93-
}
94-
9588
#main-container.searchpage .fa-arrow-right, #main-container.searchpage-multi-vocab .fa-arrow-right {
9689
color: var(--vocab-text);
9790
font-size: 12px;
@@ -105,11 +98,6 @@ body {
10598
text-align: center;
10699
}
107100

108-
#main-container.searchpage .fa-copy, #main-container.searchpage-multi-vocab .fa-copy {
109-
position: relative;
110-
bottom: 5px;
111-
}
112-
113101
.fa-magnifying-glass {
114102
color: var(--search-button-text);
115103
font-size: 22px;
@@ -734,16 +722,26 @@ body {
734722
}
735723

736724
#concept-label h1 {
737-
float: left;
725+
display: inline;
738726
}
739727

740-
.copy-clipboard {
741-
border: none;
742-
font-size: 20px;
728+
#copy-preflabel {
729+
color: var(--vocab-text);
730+
font-size: 30px;
731+
position: relative;
732+
bottom: 10px;
733+
left: 5px;
743734
}
744735

745-
.copy-clipboard:active, .copy-clipboard:focus, .copy-clipboard:active:focus {
746-
border: none;
736+
#copy-uri {
737+
color: var(--vocab-text);
738+
position: relative;
739+
bottom: 4px;
740+
}
741+
742+
.copy-clipboard:focus {
743+
border: 1px solid var(--vocab-text);
744+
border-radius: 3px;
747745
}
748746

749747
.property ul, .property li {
@@ -891,6 +889,15 @@ body {
891889
border-radius: 0;
892890
}
893891

892+
/* About page
893+
*****************************************/
894+
#about-content a {
895+
font-size: 1.0em;
896+
color: var(--vocab-link);
897+
text-decoration: underline var(--secondary-medium-color) solid;
898+
font-weight: 700;
899+
}
900+
894901
/* Footer
895902
*****************************************/
896903
#footer p {

resource/js/copy-to-clipboard.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// function for copying the content from a specific element (by id) to the clipboard
2+
function copyToClipboard (id) {
3+
const copyElem = document.getElementById(id)
4+
const sel = window.getSelection()
5+
const range = document.createRange()
6+
range.selectNodeContents(copyElem)
7+
sel.removeAllRanges()
8+
sel.addRange(range)
9+
10+
navigator.clipboard.writeText(copyElem.innerText).catch((err) =>
11+
console.error('Failed to copy text to clipboard: ', err))
12+
}
13+
14+
function registerCopyToClipboardEvents () {
15+
const copyPrefElem = document.getElementById('copy-preflabel')
16+
if (copyPrefElem) {
17+
copyPrefElem.addEventListener('click', () => copyToClipboard('concept-preflabel'))
18+
}
19+
20+
const copyUriElem = document.getElementById('copy-uri')
21+
if (copyUriElem) {
22+
copyUriElem.addEventListener('click', () => copyToClipboard('concept-uri'))
23+
}
24+
}
25+
26+
// register the copyToClipboard function as event an handler for the copy buttons
27+
registerCopyToClipboardEvents()
28+
29+
// re-register the event handlers after partial page loads
30+
document.addEventListener('loadConceptPage', registerCopyToClipboardEvents)

resource/translations/skosmos_en.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,3 +879,6 @@ msgstr "Information"
879879

880880
msgid "Breadcrumbs"
881881
msgstr "Breadcrumbs"
882+
883+
msgid "Copy to clipboard"
884+
msgstr "Copy to clipboard"

resource/translations/skosmos_fi.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,3 +888,6 @@ msgstr "Tietoja"
888888

889889
msgid "Breadcrumbs"
890890
msgstr "Murupolut"
891+
892+
msgid "Copy to clipboard"
893+
msgstr "Kopioi leikepöydälle"

resource/translations/skosmos_sv.po

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,3 +887,6 @@ msgstr "Information"
887887

888888
msgid "Breadcrumbs"
889889
msgstr "Brödsmulor"
890+
891+
msgid "Copy to clipboard"
892+
msgstr "Kopiera till urklipp"

src/view/about-info.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{# This is the template for the about page. You can enter any html here and show different language versions by using the lang value in a twig conditional as demonstrated below. #}
22
{% block content %}
3+
<div id="about-content">
34
{% if request.lang == 'fi' %}
4-
<h4>Tietoja sanastoselaimesta</h4>
5+
<h2>Tietoja sanastoselaimesta</h2>
56
<p>Skosmos on web-pohjainen sanasto ja ontologiaselain.</p>
67
<a href="http://github.com/NatLibFi/Skosmos">Skosmos GitHub-repositorio</a>
78
{% elseif request.lang == 'sv' %}
@@ -13,4 +14,5 @@
1314
<p>Skosmos is a web based open source ontology browser.</p>
1415
<a href="http://github.com/NatLibFi/Skosmos">Skosmos GitHub repository</a>
1516
{% endif %}
17+
</div>
1618
{% endblock %}

src/view/base-template.twig

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@
1818
<link href="{{ ServiceCustomCss }}" media="screen, print" rel="stylesheet" type="text/css">
1919
{% endif %}
2020
{% for plugin, files in request.plugins.pluginsCSS %}{% for file in files %}<link href="{{ file }}" media="screen, print" rel="stylesheet" type="text/css">{% endfor %}{% endfor %}
21-
2221
<title>{{ ServiceName }}{% block title %}{% endblock %}</title>
2322
</head>
2423
<body{% if request.vocabid == '' and request.page != 'feedback' and request.page != 'about' and request.page != 'search' %} class="bg-light frontpage-logo"{% else %} class="bg-medium vocab-{{ request.vocabid }}"{% endif %}>
25-
<noscript>
26-
<strong>We're sorry but Skosmos doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
27-
</noscript>
28-
<a class="visually-hidden" id="skiptocontent" href="{{ request.langurl }}#maincontent">Skip to main</a>
2924
<header>
25+
<a class="visually-hidden" id="skiptocontent" href="{{ request.langurl }}#maincontent">Skip to main</a>
3026
<div class="container-fluid bg-dark d-flex my-auto py-3 px-4 text-bg-dark">
3127
{% if request.vocabid == '' and request.page != 'about' and request.page != 'feedback' %}
3228
<span class="fs-6 py-3 text-light">Yhteishaku sanastoista v</span>
@@ -62,7 +58,6 @@
6258
{% endif %}
6359
</ul>
6460
</div>
65-
6661
<div class="container-fluid bg-light py-4 px-4" id="headerbar">
6762
{% if request.vocabid == '' %}
6863
<div id="skosmos-logo">
@@ -82,6 +77,9 @@
8277
</header>
8378
<main id="main-container" class="{% if request.vocabid == '' or global_search %} frontpage{% elseif concept_uri != '' %} termpage{% elseif request.vocab != '' %} vocabpage{% if list_style %} {{ list_style }}{% endif %}{% endif %}">
8479
<div class="container">
80+
<noscript>
81+
<strong>We're sorry but Skosmos doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
82+
</noscript>
8583
<div class="row" tabindex="-1">
8684
{% block content %}
8785
{% endblock %}

src/view/concept-card.inc

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@
3030
<div class="row" id="concept-heading">
3131
<div class="col-sm-4 px-0" id="concept-property-label">{{ "skos:prefLabel" | trans }}</div>
3232
<div class="col-sm-8" id="concept-label">
33-
<h1 class="mb-0">{{ concept.label }}</h1>
34-
<button class="btn btn-default copy-clipboard" type="button"
33+
<h1 id="concept-preflabel"
34+
class="mb-0 user-select-all">{{ concept.label }}</h1><button
35+
class="btn btn-default copy-clipboard px-1" type="button" id="copy-preflabel"
3536
data-bs-toggle="tooltip" data-bs-placement="button" title="{{ 'Copy to clipboard' | trans }}">
36-
<i class="fa-regular fa-copy"></i>
37+
<i class="fa-regular fa-copy"></i>
3738
</button>
3839
</div>
3940
</div>
@@ -87,7 +88,14 @@
8788
{% endif %}
8889
<div class="row property prop-uri">
8990
<div class="col-sm-4 px-0 property-label"><h2>URI</h2></div>
90-
<div class="col-sm-8" id="concept-uri"><a href="#">{{ concept.uri }}</a></div>
91+
<div class="col-sm-8">
92+
<span id="concept-uri"
93+
class="user-select-all">{{ concept.uri }}</span><button
94+
class="btn btn-default copy-clipboard px-1" type="button" id="copy-uri"
95+
data-bs-toggle="tooltip" data-bs-placement="button" title="{{ 'Copy to clipboard' | trans }}">
96+
<i class="fa-regular fa-copy"></i>
97+
</button>
98+
</div>
9199
</div>
92100
<div class="row property prop-download">
93101
<div class="col-sm-4 px-0 property-label">

src/view/scripts.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const SKOSMOS = {
2424
{%- if request.plugins.callbacks ~%}
2525
"pluginCallbacks": [{% for function in request.plugins.callbacks %}{% if not loop.first %}, {% endif %}"{{ function }}"{% endfor %}],
2626
{%- endif ~%}
27-
"language_strings" :{ "fi": { "fi": "suomi",
27+
"language_strings": { "fi": { "fi": "suomi",
2828
"en": "englanti",
2929
"se": "pohjoissaame",
3030
"sv": "ruotsi",
@@ -76,3 +76,6 @@ const SKOSMOS = {
7676
<script src="resource/js/tab-alpha.js"></script>
7777
<script src="resource/js/tab-hierarchy.js"></script>
7878
<script src="resource/js/vocab-search.js"></script>
79+
80+
<!-- Other (non-Vue) JS functionality -->
81+
<script src="resource/js/copy-to-clipboard.js"></script>

src/view/search-results.inc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@
103103
<li class="list-group-item px-0 py-1">
104104
<span class="uri-icon">URI</span>
105105
<span class="search-result-uri">{{ concept.uri }}</span>
106-
<i class="fa-regular fa-copy"></i> <!-- no copy to clipboard functionality yet -->
107106
</li>
108107
{%~ endif ~%}
109108
</ul>

0 commit comments

Comments
 (0)