-
Notifications
You must be signed in to change notification settings - Fork 0
/
fullTest.html
111 lines (109 loc) · 2.38 KB
/
fullTest.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
107
108
109
110
111
<html>
<head>
<title>Custom Context</title>
<style type="text/css">
p {
width: 200px;
height: 200px;
background: red;
}
div {
width: 300px;
height: 300px;
background: blue;
}
div#smallDiv {
width: 100px;
position: absolute;
height: 50px;
background: green;
top: 350px;
left: 350px;
}
#customListItem {
color: green;
border: 3px solid red;
height: 40px;
font-size: 40px;
}
#customListItem:hover {
background: black;
height: 45px;
}
</style>
<script src="/../customContextMenu.js"></script>
</head>
<body id="body">
<h1>Right-click anywhere to see custom context menus</h1>
<div id="customDiv">
<h2>Custom div menu</h2>
<p id="customPar">Custom paragraph menu</p>
</div>
<div id="smallDiv">Small div</div>
<ul id="smallDivMenu" class="customContextMenu">
<li onClick="alert('4')">2 + 2</li>
<li onClick="console.log(document.getElementById('smallDivMenu'))">This is a DOM context menu</li>
</ul>
<script>
var customContext = new customContext(
[
{
target: "customDiv",
menu: [
{
text: "Custom Style Class",
onClick: function() {console.log('Option 1 clicked')},
id: "customListItem"
},
{
text: "Bold Text",
onClick: function() {console.log('Option 2 clicked')},
style: "font-weight: bold"
},
{
onClick: function() {console.log('Empty option clicked')},
style: "background: black"
}
]
},
{
target: "customPar",
menu: [
{
text: "Disable This",
onClick: function() {customContext.disableTarget("customPar")}
},
{
text: "Alert",
onClick: function() {alert("Alerting!")}
},
{
text: "Kill All Menus",
onClick: function() {customContext.clearAllMenus()}
}
]
},
{
target: document.body,
menu: [
{
text: "Enable all menus",
onClick: function() {
customContext.enableTarget("customPar");
customContext.enableTarget("customDiv");
}
},
{
text: "Go to Github",
onClick: function() {window.open("https://github.com/dankramp/customContextMenu.js", '_blank')}
}
]
},
{
target: "smallDiv",
menu: document.getElementById("smallDivMenu")
}
]);
</script>
</body>
</html>