File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 109109 padding : 0 ;
110110 border-radius : var (--border-radius-s );
111111 flex-shrink : 0 ;
112+ transition : color 0.3s ease;
113+ }
114+
115+ .downloads-table-card__copy-btn .is-copied {
116+ color : var (--color-text-link-accent );
117+ }
118+
119+ .downloads-table-card__copy-btn .is-error {
120+ color : var (--color-text-error );
112121}
113122
114123.js-copy-enabled .downloads-table-card__copy-btn {
Original file line number Diff line number Diff line change 5555 </ table >
5656 </ div >
5757{% endif %}
58+
59+ {% block footer_js %}
60+ < script >
61+ ( function ( ) {
62+ document . querySelectorAll ( '.downloads-table-card__wrapper' ) . forEach ( function ( wrapper ) {
63+ wrapper . classList . add ( 'js-copy-enabled' ) ;
64+ } ) ;
65+ document . querySelectorAll ( '.downloads-table-card__copy-btn' ) . forEach ( function ( btn ) {
66+ btn . addEventListener ( 'click' , function ( ) {
67+ const text = btn . getAttribute ( 'data-copy-text' ) ;
68+ if ( ! text ) return ;
69+
70+ function showFeedback ( className ) {
71+ btn . classList . add ( className ) ;
72+ setTimeout ( function ( ) {
73+ btn . classList . remove ( className ) ;
74+ } , 2000 ) ;
75+ }
76+
77+ if ( navigator . clipboard && navigator . clipboard . writeText ) {
78+ navigator . clipboard . writeText ( text ) . then (
79+ function ( ) { showFeedback ( 'is-copied' ) ; } ,
80+ function ( ) { showFeedback ( 'is-error' ) ; }
81+ ) ;
82+ }
83+ } ) ;
84+ } ) ;
85+ } ) ( ) ;
86+ </ script >
87+ {% endblock %}
Original file line number Diff line number Diff line change 4444 </ div >
4545 {% endif %}
4646{% endblock %}
47-
48- {% block footer_js %}
49- < script >
50- ( function ( ) {
51- document . querySelectorAll ( '.downloads-table-card__wrapper' ) . forEach ( function ( wrapper ) {
52- wrapper . classList . add ( 'js-copy-enabled' ) ;
53- } ) ;
54- document . querySelectorAll ( '.downloads-table-card__copy-btn' ) . forEach ( function ( btn ) {
55- btn . addEventListener ( 'click' , function ( ) {
56- var text = btn . getAttribute ( 'data-copy-text' ) ;
57- if ( text && navigator . clipboard ) {
58- navigator . clipboard . writeText ( text ) ;
59- }
60- } ) ;
61- } ) ;
62- } ) ( ) ;
63- </ script >
64- {% endblock %}
You can’t perform that action at this time.
0 commit comments