forked from EnlighterJS/EnlighterJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jquery.html
106 lines (89 loc) · 3.48 KB
/
jquery.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>EnlighterJS with jQuery</title>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" />
<!-- EnlighterJS CSS !-->
<link rel="stylesheet" href="../dist/enlighterjs.min.css" />
</head>
<body>
<main>
<div class="container">
<div class="px-3 py-3 pt-md-5 pb-md-4 mx-auto text-center">
<h1 class="display-4">EnlighterJS</h1>
<p class="lead">jQuery Example</p>
<p>
<button type="button" class="btn btn-success btn-sm" id="btn-enable">Highlight Code</button>
<button type="button" class="btn btn-danger btn-sm" id="btn-disable">Remove Highlighting</button>
<button type="button" class="btn btn-outline-dark btn-sm" disabled>Rendering Time: <strong id="timer">X</strong>ms</button>
</p>
</div>
<h2>jQuery Code used on this page</h2>
<pre data-enlighter-language="javascript" class="toggler">
jQuery(function(jq){
// enlight all pre elements with class "toggler"
jq('#btn-enable').click(function(){
jq('pre.toggler').enlight({
theme: 'bootstrap4'
});
});
// remove highlighting from all pre elements with class "toggler"
jq('#btn-disable').click(function(){
jq('pre.toggler').enlight(false);
});
});</pre>
<h2>Another codeblock</h2>
<!-- Code to highlight -->
<pre data-enlighter-language="less" class="toggler">
// buttons used in codegroups + toolbar
.enlighter-btn{
display: inline-block;
margin: 0px 5px 0px 5px;
padding: 3px 5px 3px 5px;
border: solid 1px #333333;
background-color: #f0f0f0;
cursor: pointer;
}
// buttons
.enlighter-btn-raw{
background-image: data-uri('icons/enlighter_code.svg');
}
.enlighter-btn-window{
background-image: data-uri('icons/enlighter_rawcode.svg');
}
.enlighter-btn-website{
background-image: data-uri('icons/enlighter_icon_white.svg');
}
</pre>
</div>
</main>
<!-- load jQuery BEFORE EnlighterJS-->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha256-3edrmyuQ0w65f8gfBsqowzjJe2iM6n0nKciPUp8y+7E=" crossorigin="anonymous"></script>
<!-- EnlighterJS -->
<script type="text/javascript" src="../dist/enlighterjs.min.js"></script>
<!-- Init Code -->
<script type="text/javascript">
jQuery(function(jq){
// enlight all pre elements with class "toggle"
jq('#btn-enable').click(function(){
var start = Date.now();
// highlight elements
jq('pre.toggler').enlight({
theme: 'bootstrap4'
});
// show elapsed time
var stop = Date.now();
jq('#timer').text(stop-start);
});
// remove highlighting from all pre elements with class "toggle"
jq('#btn-disable').click(function(){
jq('pre.toggler').enlight(false);
});
});
</script>
</body>
</html>