annotate client/digitallibrary/modules/contextMenu.js @ 146:acfcafefe5b7

corrected bugs with Java2D on Linux...
author robcast
date Wed, 20 Aug 2003 00:25:37 +0200
parents 9a3fc958fb43
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
1 /****************************************************************************
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
2 * - module for digilib: adds a menu for digilib functionality *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
3 * *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
4 * pressing [ctrl] + [left mousebutton] to bring it up *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
5 * *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
6 * to install this module, you do not just have to load it in *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
7 * dlImage.jsp (like every module), but you also have to put the *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
8 * following three lines in the <body> of dlImage.jsp: *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
9 * *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
10 * <script language="JavaScript"> *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
11 * cm_htmlCode(); *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
12 * </script> *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
13 * *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
14 * christian luginbuehl (luginbuehl@student.unibe.ch) *
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
15 ****************************************************************************/
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
16
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
17 browser = new checkBrowser();
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
18
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
19 var menu = false;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
20
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
21 if (browser.ns4) {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
22 document.captureEvents(Event.MOUSEDOWN);
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
23 document.onmousedown = showmenu;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
24 } else if (browser.ns6) {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
25 document.addEventListener("mousedown", showmenu, true);
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
26 } else {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
27 document.onmousedown = showmenu;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
28 }
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
29
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
30
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
31 function checkBrowser() {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
32
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
33 this.ua = navigator.userAgent;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
34 this.ver = navigator.appVersion;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
35 this.dom = ( document.getElementById );
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
36 this.opera = ( this.dom ) && ( this.ua.toLowerCase().indexOf("opera") > -1 );
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
37 this.ie4 = ( document.all ) && ( !this.dom );
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
38 this.ie5 = ( this.ver.indexOf("MSIE 5") > -1 ) && ( this.dom );
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
39 this.ie6 = ( this.ver.indexOf("MSIE 6") > -1 ) && ( this.dom );
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
40 this.ns4 = ( document.layers ) && ( !this.dom );
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
41 this.ns6 = ( this.dom ) && ( parseInt(this.ver) >= 5 ) && ( !this.opera );
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
42 this.ns = ( this.ns4 ) || ( this.ns6 );
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
43 this.ie = ( this.ie4 ) || ( this.ie5 ) || ( this.ie6 );
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
44
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
45 return this;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
46 }
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
47
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
48
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
49 function showmenu(event) {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
50
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
51 if (browser.ns4) {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
52 if (event.which == 1 && (event.modifiers == Event.CONTROL_MASK) && !menu) {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
53 menu = true;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
54 document.layers["menu"].left = Math.min(event.pageX + 3, innerWidth - 160 + pageXOffset);
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
55 document.layers["menu"].top = Math.min(event.pageY + 3, innerHeight - 180 + pageYOffset);
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
56 document.layers["menu"].clip.width = 140;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
57 document.layers["menu"].bgColor = "#DDDDDD";
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
58 document.layers["menu"].margin = 4;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
59 document.layers["menu"].visibility = "show";
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
60 } else if (menu) {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
61 menu = false;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
62 document.layers["menu"].visibility = "hide";
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
63 }
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
64
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
65 } else if (browser.ns6) {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
66 if (event.which == 1 && event.ctrlKey && !menu) {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
67 menu = true;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
68 document.getElementById("menu").style.left = Math.min(event.pageX + 3, innerWidth - 160 + pageXOffset);
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
69 document.getElementById("menu").style.top = Math.min(event.pageY + 3, innerHeight - 160 + pageYOffset);
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
70 document.getElementById("menu").style.visibility = "visible";
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
71 } else if (menu) {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
72 menu = false;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
73 document.getElementById("menu").style.visibility = "hidden";
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
74 }
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
75 } else {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
76 event = window.event;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
77
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
78 if (event.button == 1 && event.ctrlKey && !menu) {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
79 menu = true;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
80 document.all["menu"].style.left = event.x + 3;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
81 document.all["menu"].style.top = event.y + 3;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
82 document.all["menu"].style.visibility = "visible";
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
83 } else if (menu) {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
84 menu = false;
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
85 document.all["menu"].style.visibility = "hidden";
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
86 }
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
87 }
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
88 }
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
89
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
90
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
91 function cm_htmlCode() {
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
92
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
93 document.write('<style type="text/css">\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
94 document.write(' table {border-left: 1px solid #CCCCCC; border-top: 1px solid #CCCCCC; border-right: 1px solid #000000; border-bottom: 1px solid #000000; }\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
95 document.write(' td {font-family: verdana; color: #666666; font-size: 11px; text-decoration: none}\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
96 document.write(' a:link, a:visited, a:active {font-family: verdana; color: #666666; font-size: 11px; font-weight: bold; text-decoration: none}\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
97 document.write(' a:hover {font-family: verdana; color: #000000; font-size: 11px; text-decoration: none}\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
98 document.write('</style>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
99 document.write('<div ID="menu" style="position:absolute; width: 140px; background-color: #DDDDDD; visibility:hidden">\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
100 document.write(' <table width="140" align="center" cellspacing="0" cellpadding="0">\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
101 document.write(' <tr><td><a href="#" onmousedown="backPage(false)">&nbsp;&nbsp;prev</a></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
102 document.write(' <tr><td><a href="#" onmousedown="nextPage(false)">&nbsp;&nbsp;next</a></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
103 document.write(' <tr><td><a href="#" onmousedown="page(false)">&nbsp;&nbsp;page #</a></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
104 document.write(' <tr><td align="center"><img src="modules/cm_separator.gif" width="136" height="3"></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
105 document.write(' <tr><td><a href="#" onmousedown="mark()">&nbsp;&nbsp;mark</a></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
106 document.write(' <tr><td>&nbsp;&nbsp;reference <a href="#" onmousedown="ref(1)">html</a> <a href="#" onmousedown="ref(0)">latex</a></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
107 document.write(' <tr><td align="center"><img src="modules/cm_separator.gif" width="136" height="3"></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
108 document.write(' <tr><td><a href="#" onmousedown="zoomArea()">&nbsp;&nbsp;zoom area</a></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
109 document.write(' <tr><td><a href="#" onmousedown="zoomPoint()">&nbsp;&nbsp;zoom point</a></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
110 document.write(' <tr><td><a href="#" onmousedown="moveTo()">&nbsp;&nbsp;move to</a></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
111 document.write(' <tr><td><a href="#" onmousedown="zoomOut()">&nbsp;&nbsp;zoom out</a></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
112 document.write(' <tr><td align="center"><img src="modules/cm_separator.gif" width="136" height="3"></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
113 document.write(' <tr><td>&nbsp;&nbsp;scale <a href="#" onmousedown="scale(0.7)">0.7</a> <a href="#" onmousedown="scale(1.0)">1.0</a> <a href="#" onmousedown="scale(2.0)">2.0</a> <a href="#" onmousedown="scale(3.0)">3.0</a></td></tr>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
114 document.write(' </table>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
115 document.write('</div>\n');
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
116
9a3fc958fb43 bugfixes and new module
luginbue
parents:
diff changeset
117 }