Mercurial > hg > mgallery
annotate mgallery.js @ 207:34c9eca1c726
Cosmetics.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 21 Mar 2018 18:07:42 +0200 |
parents | 9db200b610ea |
children | cdccda315a0f |
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 | 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 |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 function mgalGetWindowSize() |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 { |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 var winW = 0, winH = 0; |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 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
|
89 { |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 // Non-MSIE |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 winW = window.innerWidth; |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 winH = window.innerHeight; |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 } |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 else |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 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
|
96 { |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 // MSIE 6+ in 'standards compliant mode' |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 winW = document.documentElement.clientWidth; |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 winH = 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
|
100 } |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 else |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 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
|
103 { |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 // MSIE 4 compatible |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 winW = document.body.clientWidth; |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 winH = 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 |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 return [winW, winH]; |
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 |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
113 function mgalAdjustImageDo() |
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 var eimg = document.getElementById("imageImage"); |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 var win = mgalGetWindowSize(); |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
117 var madj = 0.92; |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 if (eimg) |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
119 { |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 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
|
121 { |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 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
|
123 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
|
124 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
|
125 { |
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.width = "auto"; |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
127 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
|
128 } |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 } |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
130 else |
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 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
|
133 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
|
134 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
|
135 else |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
136 eimg.style.height = "100%"; |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
137 } |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
138 } |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
139 adjustPID = -1; |
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 |
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 function mgalAdjustImage() |
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 if (adjustPID == -1) |
174
915cf0469d9f
Change image adjust timeout to faster value.
Matti Hamalainen <ccr@tnsp.org>
parents:
173
diff
changeset
|
146 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
|
147 } |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
148 |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
149 |
152
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
150 function mgalDisplayInfo(mvstate) |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
151 { |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
152 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
|
153 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
|
154 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
|
155 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
|
156 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
|
157 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
|
158 mvInfoOpen = mvstate; |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
159 } |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
160 |
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 function mgalOpenInfo() |
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 mgalDisplayInfo(true); |
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 |
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 function mgalCloseInfo() |
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 mgalDisplayInfo(false); |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
171 } |
196
9db200b610ea
Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
172 |
9db200b610ea
Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
173 |
9db200b610ea
Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
174 function mgalPreventDefault(ev) |
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 ev.preventDefault(); |
9db200b610ea
Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
177 ev.target.click(); |
9db200b610ea
Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
178 } |