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