annotate mgallery.js @ 209:671b7cfebf87

Various fixes and adjustments to style.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 22 Mar 2018 13:41:36 +0200
parents cdccda315a0f
children 0a0a2936d779
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 //
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 // Yet Another Image Gallery
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 // -- Main Javascript utility functions file
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 // Programmed and designed by Matti 'ccr' Hamalainen <ccr@tnsp.org>
169
f68d97717b9f Bump copyright year.
Matti Hamalainen <ccr@tnsp.org>
parents: 168
diff changeset
5 // (C) Copyright 2015-2018 Tecnic Software productions (TNSP)
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 //
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8
154
0b87e7c1675c Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
9 function mgalAddEventOb(obname, evobj, evtype, evcallback)
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 if (evobj == null || typeof(evobj) == 'undefined')
154
0b87e7c1675c Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
12 {
0b87e7c1675c Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
13 console.log("Event object '"+ obname +"' == null.");
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 return;
154
0b87e7c1675c Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
15 }
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 if (evobj.addEventListener)
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 evobj.addEventListener(evtype, evcallback, false);
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 else
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 if (evobj.attachEvent)
154
0b87e7c1675c Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
21 evobj.attachEvent("on"+evtype, evcallback);
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 else
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 evobj["on"+evtype] = evcallback;
154
0b87e7c1675c Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
24 }
0b87e7c1675c Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
25
0b87e7c1675c Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
26
173
903a7e1cccbd Add new helper function mgalAddEventsToClass() to add events to named DOM classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
27 function mgalAddEventsToClass(clname, evtype, evcallback)
903a7e1cccbd Add new helper function mgalAddEventsToClass() to add events to named DOM classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
28 {
903a7e1cccbd Add new helper function mgalAddEventsToClass() to add events to named DOM classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
29 var elist = document.getElementsByClassName(clname);
903a7e1cccbd Add new helper function mgalAddEventsToClass() to add events to named DOM classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
30 for (var index = 0; index < elist.length; index++)
903a7e1cccbd Add new helper function mgalAddEventsToClass() to add events to named DOM classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
31 {
903a7e1cccbd Add new helper function mgalAddEventsToClass() to add events to named DOM classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
32 mgalAddEventOb(clname, elist[index], evtype, evcallback);
903a7e1cccbd Add new helper function mgalAddEventsToClass() to add events to named DOM classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
33 }
903a7e1cccbd Add new helper function mgalAddEventsToClass() to add events to named DOM classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
34 }
903a7e1cccbd Add new helper function mgalAddEventsToClass() to add events to named DOM classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
35
903a7e1cccbd Add new helper function mgalAddEventsToClass() to add events to named DOM classes.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
36
154
0b87e7c1675c Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
37 function mgalAddEvent(obname, evtype, evcallback)
0b87e7c1675c Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
38 {
0b87e7c1675c Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
39 mgalAddEventOb(obname, document.getElementById(obname), evtype, evcallback);
0b87e7c1675c Improve the JavaScript event hook functions.
Matti Hamalainen <ccr@tnsp.org>
parents: 152
diff changeset
40 }
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 function mgalNavigateTo(url)
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 if (url != "")
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 window.location = url;
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 }
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 function mgalProcessKeyPress(ev)
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 ev = ev || window.event;
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 var key = ev.keyCode ? ev.keyCode : ev.which;
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 switch (key)
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 case 37:
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 case 65:
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 case 52:
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 // left
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 mgalNavigateTo(mgalPrevURL);
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 break;
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 case 39:
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 case 68:
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 case 54:
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 // right
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 mgalNavigateTo(mgalNextURL);
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 break;
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 case 38:
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 case 56:
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 // up
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 mgalNavigateTo(mgalUpURL);
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 break;
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 default:
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 return true;
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 }
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 ev.preventDefault();
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 return false;
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 }
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84
208
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
85 function mgalGetElementOrWindowSize(nelem)
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 {
208
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
87 if (nelem)
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
88 {
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
89 var elem = document.getElementById(nelem);
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
90 if (elem)
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
91 return [elem.clientWidth, elem.clientHeight];
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
92 }
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
93
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 if (typeof(window.innerWidth) == 'number')
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 // Non-MSIE
208
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
97 return [window.innerWidth, window.innerHeight];
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 }
208
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
99
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 // MSIE 6+ in 'standards compliant mode'
208
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
103 return [document.documentElement.clientWidth, document.documentElement.clientHeight];
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 }
208
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
105
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 if (document.body && (document.body.clientWidth || document.body.clientHeight))
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 // MSIE 4 compatible
208
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
109 return [document.body.clientWidth, document.body.clientHeight];
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 }
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111
208
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
112 return null;
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 }
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 function mgalAdjustImageDo()
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 var eimg = document.getElementById("imageImage");
209
671b7cfebf87 Various fixes and adjustments to style.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
119 var win = mgalGetElementOrWindowSize("pageImageBox");
671b7cfebf87 Various fixes and adjustments to style.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
120 var madj = 0.99;
208
cdccda315a0f Change mgalGetWindowSize() to mgalGetElementOrWindowSize(elemname) that
Matti Hamalainen <ccr@tnsp.org>
parents: 196
diff changeset
121 if (eimg && win != null)
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 if (eimg.width > eimg.height)
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 eimg.style.width = "100%";
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 eimg.style.height = "auto";
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 if (eimg.height > win[1] * madj)
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 eimg.style.width = "auto";
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 eimg.style.height = (win[1] * madj)+"px";
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 }
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 }
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 else
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 eimg.style.width = "auto";
209
671b7cfebf87 Various fixes and adjustments to style.
Matti Hamalainen <ccr@tnsp.org>
parents: 208
diff changeset
136 eimg.style.height = "100%";
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 if (eimg.height > win[1] * madj)
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 eimg.style.height = (win[1] * madj)+"px";
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 }
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 }
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 adjustPID = -1;
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 }
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 function mgalAdjustImage()
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 {
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 if (adjustPID == -1)
174
915cf0469d9f Change image adjust timeout to faster value.
Matti Hamalainen <ccr@tnsp.org>
parents: 173
diff changeset
148 adjustPID = setTimeout(mgalAdjustImageDo, 10);
149
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 }
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150
b4751909c48f Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151
152
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
152 function mgalDisplayInfo(mvstate)
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
153 {
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
154 var mvbut = document.getElementById("pageInfoButton");
168
ba02d12cb4be Add "up" navigation button, to go back to the main gallery from image page.
Matti Hamalainen <ccr@tnsp.org>
parents: 154
diff changeset
155 var mvnbut = document.getElementById("pageUpNaviButton");
152
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
156 var mvelem = document.getElementById("pageInfoHeader");
168
ba02d12cb4be Add "up" navigation button, to go back to the main gallery from image page.
Matti Hamalainen <ccr@tnsp.org>
parents: 154
diff changeset
157 mvelem.style.display = mvstate ? "block" : "none";
ba02d12cb4be Add "up" navigation button, to go back to the main gallery from image page.
Matti Hamalainen <ccr@tnsp.org>
parents: 154
diff changeset
158 mvbut.style.display = !mvstate ? "block" : "none";
ba02d12cb4be Add "up" navigation button, to go back to the main gallery from image page.
Matti Hamalainen <ccr@tnsp.org>
parents: 154
diff changeset
159 mvnbut.style.display = !mvstate ? "block" : "none";
152
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
160 mvInfoOpen = mvstate;
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
161 }
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
162
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
163
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
164 function mgalOpenInfo()
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
165 {
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
166 mgalDisplayInfo(true);
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
167 }
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
168
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
169
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
170 function mgalCloseInfo()
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
171 {
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
172 mgalDisplayInfo(false);
606b05c31d5e Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
173 }
196
9db200b610ea Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
174
9db200b610ea Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
175
9db200b610ea Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
176 function mgalPreventDefault(ev)
9db200b610ea Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
177 {
9db200b610ea Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
178 ev.preventDefault();
9db200b610ea Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
179 ev.target.click();
9db200b610ea Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 174
diff changeset
180 }