File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,4 +27,5 @@ import "packs/autocomplete";
2727import "packs/dictionary" ;
2828import "packs/network" ;
2929import "packs/styling" ;
30+ import "packs/copyable" ;
3031
Original file line number Diff line number Diff line change 1+ $ ( document ) . on ( "turbolinks:load" , function ( ) {
2+ $ ( ".copyable:not(:has(.copyer))" ) . each ( function ( ) {
3+ var elem = $ ( this ) ;
4+ var cont = elem . text ( ) . replace ( / \s + / gm, " " ) ;
5+ var copied = $ (
6+ '<span style="display: none;" class="small">' +
7+ 'Copied to the clipboard</span>'
8+ ) ;
9+ var btn = $ (
10+ '<a class="badge badge-pill badge-primary mx-2 copyer" type="button">' +
11+ '<i class="fas fa-copy mr-1"> </i> Copy</a>'
12+ ) ;
13+ btn . on ( "click" , function ( ) {
14+ navigator . clipboard . writeText ( cont ) ;
15+ copied . fadeIn ( 200 ) . delay ( 800 ) . fadeOut ( 800 ) ;
16+ } ) ;
17+ elem . append ( btn ) ;
18+ elem . append ( copied ) ;
19+ } ) ;
20+ } ) ;
21+
Original file line number Diff line number Diff line change 138138 <% end %>
139139
140140 < dt > <%= fa_icon ( 'barcode' ) %> Canonical URL</ dt >
141- < dd >
141+ < dd class =" copyable " >
142142 <%= @name . seqcode_url %>
143143 </ dd >
144144</ dl >
Original file line number Diff line number Diff line change 1717 < div class ="row pl-3 ">
1818 < dl class ="col-md-7 ">
1919 < dt > <%= fa_icon ( :barcode ) %> SeqCode Registry Accession</ dt >
20- < dd > <%= @register . acc_url %> </ dd >
20+ < dd class =" copyable " > <%= @register . acc_url %> </ dd >
2121
2222 < dt > <%= fa_icon ( 'clipboard-check' ) %> Status</ dt >
2323 < dd >
5252
5353 <% if @register . validated? %>
5454 < dt > <%= fa_icon ( 'book-open' ) %> How to cite</ dt >
55- < dd >
55+ < dd class =" copyable " >
5656 <%= @register . user . display_name %>
5757 (<%= @register . validated_at . year %> ).
5858 <%= @register . propose_title . gsub ( /\. \z / , '' ) %> .
You can’t perform that action at this time.
0 commit comments