-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathContextMenu.htm
163 lines (105 loc) · 4.26 KB
/
ContextMenu.htm
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ContextMenu</title>
<link rel="stylesheet" type="text/css" href="jWebForm.css" />
<script type="text/javascript" src="jWebForm.js"></script>
<script type="text/javascript" src="DragObj.js"></script>
<script type="text/javascript" src="PictureBoxFit.js"></script>
<script type="text/javascript" src="ContextMenu.js"></script>
<script type="text/javascript">
var _drag;
var _picBox;
var _contextMenu;
$j.Page_Load = function Page_Load() {
_picBox = $j("picBox1");
_picBox.Images(
[
"images/美女1-1.jpg",
"images/美女1-2.jpg",
"images/美女1-3.jpg"
]
);
_picBox.Play();
var picBoxElement = _picBox.Element();
picBoxElement.oncontextmenu = function (e) {
if (!_contextMenu) {
var divContextMenu = document.getElementById("divContextMenu");
_contextMenu = $j.ContextMenu(divContextMenu);
}
_contextMenu.Show(e.clientX, e.clientY);
return false;
}
_drag = $j.DragObj(picBoxElement);
_drag.Width("200px");
_drag.Height("300px");
_drag.Show();
}
function ClosePlay() {
_drag.Close();
_contextMenu.Close();
}
function ShowImageInfo() {
var url = _picBox.CurrentImageUrl();
url = decodeURI(url);
ShowInfoTip("图片信息", url);
_contextMenu.Close();
}
function ShowInfoTip(title, info) {
var drag = $j.DragObj();
drag.Width("500px");
drag.Height("150px");
drag.MinWidth("500px");
drag.MinHeight("150px");
var divDialog = document.getElementById("divInfoTip");
var elemt = drag.Element();
elemt.innerHTML = divDialog.outerHTML;
var spanTitle = $j.getElementById(elemt, "spanTitle");
spanTitle.innerText = title;
var spanClose = $j.getElementById(elemt, "spanClose");
spanClose.addEventListener("click", function () {
drag.Close();
});
drag.NotDrag(spanClose);
var divInfo = $j.getElementById(elemt, "divInfo");
divInfo.innerText = info;
drag.NotDrag(divInfo);
drag.Show();
}
/**/</script>
</head>
<body>
<div style="font-size:20px">
右键菜单 示例<br />
右键关闭 图片播放磁贴<br /><br />
拖拖看<br />
可将鼠标放在对话框边缘调整 图片贴 大小<br />
每 5 秒 播放一张图片<br />
通过这个原理,可以实现和 Windows 8 的 磁贴(Tip) 相似的效果
</div>
<j:PictureBoxFit id="picBox1" Width="100%" Height="100%"></j:PictureBoxFit>
<div style="display:none">
<div id="divContextMenu" style="width:100%; height:100%; background-color:cornsilk; border:solid 1px cornflowerblue; cursor:default">
<div onclick="ClosePlay();">关闭</div>
<div onclick="ShowImageInfo();">图片信息</div>
</div>
</div>
<div id="divTemplates" style="display:none">
<div id="divInfoTip" style="box-sizing:border-box; border: 1px solid gray; padding:5px; padding-bottom:10px; height: 100%; background-color:white; overflow:hidden;">
<table id="table1" style="width:100%; height:100%;">
<tr>
<td style="height:1px; padding-bottom:5px; border-bottom:solid 1px gray">
<div><span id="spanTitle"></span><span id="spanClose" style="float:right; cursor:default">×</span></div>
</td>
</tr>
<tr>
<td style="border-bottom:solid 1px gray;">
<div id="divInfo" style="word-break:break-all;"></div>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>