Skip to content

Commit 2b0d2ba

Browse files
authored
Merge pull request #2234 from thostetler/bibcode-copy-btn
2 parents 4dcf9c4 + db98f5f commit 2b0d2ba

File tree

4 files changed

+45
-11
lines changed

4 files changed

+45
-11
lines changed

‎src/js/widgets/abstract/templates/abstract_template.html‎

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,22 @@ <h4 class="sr-only">Abstract</h4>
152152

153153
<dt>Bibcode:</dt>
154154
<dd>
155-
<a href="#abs/{{bibcode}}/abstract">
155+
<button
156+
class="btn btn-link copy-btn"
157+
style="padding: 0px"
158+
id="abs-bibcode-copy"
159+
data-clipboard-text="{{bibcode}}"
160+
aria-label="copy bibcode">
156161
{{ bibcode }}
157-
</a>
158-
<i
159-
class="icon-help"
160-
aria-hidden="true"
161-
data-toggle="popover"
162-
data-container="body"
163-
aria-hidden="true"
164-
data-content="The bibcode is assigned by the ADS as a unique identifier for the paper."
165-
></i>
162+
<i
163+
class="icon-help"
164+
aria-hidden="true"
165+
data-toggle="popover"
166+
data-container="body"
167+
data-content="The bibcode is assigned by the ADS as a unique identifier for the paper."
168+
></i>
169+
</button>
170+
<span id="abs-bibcode-copy-msg" class="text-info" style="display: none;">Copied!</span>
166171
</dd>
167172

168173
{{#if keyword}}

‎src/js/widgets/abstract/widget.js‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ define([
55
'marionette',
66
'js/components/api_request',
77
'js/components/api_targets',
8+
'clipboard',
89
'backbone',
910
'jquery',
1011
'underscore',
@@ -22,6 +23,7 @@ define([
2223
Marionette,
2324
ApiRequest,
2425
ApiTargets,
26+
Clipboard,
2527
Backbone,
2628
$,
2729
_,
@@ -264,6 +266,17 @@ define([
264266
);
265267
},
266268

269+
copyBibcode() {
270+
if (!this.bibcodeClipboard) {
271+
this.bibcodeClipboard = new Clipboard('#abs-bibcode-copy');
272+
this.bibcodeClipboard.on('success', () => {
273+
$('#abs-bibcode-copy-msg')
274+
.show()
275+
.fadeOut(1000);
276+
});
277+
}
278+
},
279+
267280
onRender: function() {
268281
this.$('.icon-help').popover({
269282
trigger: 'hover',
@@ -284,6 +297,7 @@ define([
284297
this.$('.s-abstract-text', this.el).get(0),
285298
]);
286299
}
300+
this.copyBibcode();
287301
},
288302
});
289303

‎src/js/wraps/abstract_page_manager/abstract-page-layout.html‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
<div class="main-content-container s-main-content-container" id="main-content" tabindex="-1">
2121
<div class="print-visible"><h2 style="margin-left:6.1%;">NASA/ADS</h2> </div>
2222

23-
<div id="abstract-title-container" class="s-abstract-title-container"></div>
2423
<div id="current-subview">
2524
<div data-widget="ShowAbstract"/>
2625
<div data-widget="ShowCitations"/>

‎src/styles/sass/ads-sass/abstract-page-widgets.scss‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,19 @@ $sciencewise-color: rgb(179, 27, 27);
327327
}
328328
}
329329
}
330+
331+
.copy-btn {
332+
text-decoration: none !important;
333+
334+
&:any-link {
335+
text-decoration: none !important;
336+
}
337+
338+
&:hover::after {
339+
font-family: 'FontAwesome';
340+
content: '\f0ea';
341+
text-decoration: inherit;
342+
color: black;
343+
margin-left: 3px;
344+
}
345+
}

0 commit comments

Comments
 (0)