File tree Expand file tree Collapse file tree 3 files changed +76
-1
lines changed Expand file tree Collapse file tree 3 files changed +76
-1
lines changed Original file line number Diff line number Diff line change 7
7
padding-left : 8px ;
8
8
}
9
9
10
+ .code-copy {
11
+ color : # 272822 ;
12
+ background-color : # fff ;
13
+ border-color : # 272822 ;
14
+ border : 1px solid;
15
+ border-radius : 4px 4px 0px 0px ;
16
+ display : block;
17
+ margin-left : auto;
18
+ margin-right : 0 ;
19
+ margin-bottom : -12px ;
20
+ padding : 3px 8px ;
21
+ font-size : 0.8em ;
22
+ }
23
+
24
+ .code-copy : hover {
25
+ cursor : pointer;
26
+ background-color : # 009639 ;
27
+ color : # ffffff ;
28
+ border-color : # 272822!important ;
29
+ border : 1px solid;
30
+ }
31
+
32
+ .code-copy : focus {
33
+ outline : 0px solid transparent;
34
+ background-color : # e6e6e6 ;
35
+ }
36
+
37
+ .code-copy : active {
38
+ background-color : # d9d9d9 ;
39
+ }
40
+
10
41
.button {
11
42
text-transform : uppercase;
12
43
font-size : 14px ;
@@ -742,6 +773,10 @@ pre {
742
773
border-radius : 4px ;
743
774
}
744
775
776
+ pre .chroma {
777
+ border-radius : 4px 0px 4px 4px ;
778
+ }
779
+
745
780
code {
746
781
font-family : Courier;
747
782
color : # 343434 ;
@@ -1152,4 +1187,7 @@ ol.breadcrumb > li:first-child {
1152
1187
1153
1188
.fa , .far , .fas {
1154
1189
padding-right : 4px ;
1155
- }
1190
+ }
1191
+
1192
+
1193
+
Original file line number Diff line number Diff line change
1
+ function CopyCode ( clipboard ) {
2
+ document . querySelectorAll ( 'pre > code' ) . forEach ( function ( codeBlock ) {
3
+ var button = document . createElement ( 'button' ) ;
4
+ button . className = 'code-copy' ;
5
+ button . type = 'button' ;
6
+ button . innerHTML = '<i class="fas fa-copy"></i> Copy' ;
7
+
8
+ button . addEventListener ( 'click' , function ( ) {
9
+ clipboard . writeText ( codeBlock . textContent ) . then (
10
+ function ( ) {
11
+ button . blur ( ) ; /* Chrome fix */
12
+ button . innerHTML = '<i class="fas fa-check"></i> Copied!' ;
13
+ setTimeout ( function ( ) {
14
+ button . innerHTML = '<i class="fas fa-copy"></i> Copy' ;
15
+ } , 2000 ) ;
16
+ } ,
17
+ function ( error ) {
18
+ button . innerHTML = '<i class="fas fa-exclamation"></i> Error' ;
19
+ console . error ( error ) ;
20
+ }
21
+ ) ;
22
+ } ) ;
23
+
24
+ var pre = codeBlock . parentNode ;
25
+ if ( pre . parentNode . classList . contains ( 'highlight' ) ) {
26
+ var highlight = pre . parentNode ;
27
+ highlight . parentNode . insertBefore ( button , highlight ) ;
28
+ } else {
29
+ pre . parentNode . insertBefore ( button , pre ) ;
30
+ }
31
+ } ) ;
32
+ }
33
+
34
+ CopyCode ( navigator . clipboard ) ;
Original file line number Diff line number Diff line change 10
10
{{ $jsBootstrap := resources.Get "js/bootstrap.bundle.min.js" | fingerprint "sha512" }}
11
11
< script src ="{{ $jsBootstrap.RelPermalink }} " type ="text/javascript " integrity ="{{ $jsBootstrap.Data.Integrity }} "> </ script >
12
12
13
+ <!-- load code copy js -->
14
+ {{ $codecopy := resources.Get "/js/code-copy.js" | fingerprint "sha512" }}
15
+ < script src ="{{ $codecopy.RelPermalink }} " type ="text/javascript " > </ script >
13
16
14
17
15
18
<!-- START COVEO -->
You can’t perform that action at this time.
0 commit comments