Mercurial > hg > mgallery
annotate mgallery.js @ 250:3af3b3f50cb0
Add settings for med_format and tn_format (currently allowed values are
"jpeg" and "webp") to specify the med/tn image formats. The default is JPEG.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 08 Dec 2018 15:51:02 +0200 |
parents | 548a349bc015 |
children | ffcd1225e85c |
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 |
221
ba89afea0f29
Rename a function argument.
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
50 function mgalProcessKeyPress(evt) |
149
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 { |
221
ba89afea0f29
Rename a function argument.
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
52 evt = evt || window.event; |
246
548a349bc015
Finally fix Chrome/Chromium support for keyboard navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
230
diff
changeset
|
53 var key = evt.keyCode ? evt.keyCode : (evt.charCode ? evt.charCode : evt.which); |
149
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 |
221
ba89afea0f29
Rename a function argument.
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
80 evt.preventDefault(); |
149
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"); |
210
0a0a2936d779
Adjust image adjustment etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
119 var ewin = mgalGetElementOrWindowSize("pageImageBox"); |
209
671b7cfebf87
Various fixes and adjustments to style.
Matti Hamalainen <ccr@tnsp.org>
parents:
208
diff
changeset
|
120 var madj = 0.99; |
210
0a0a2936d779
Adjust image adjustment etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
121 if (eimg && ewin != 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"; |
210
0a0a2936d779
Adjust image adjustment etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
127 if (eimg.height > ewin[1] * madj) |
149
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"; |
210
0a0a2936d779
Adjust image adjustment etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
130 eimg.style.height = (ewin[1] * madj)+"px"; |
149
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%"; |
210
0a0a2936d779
Adjust image adjustment etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
137 |
0a0a2936d779
Adjust image adjustment etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
138 if (eimg.height > ewin[1] * madj) |
0a0a2936d779
Adjust image adjustment etc.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
139 eimg.style.height = (ewin[1] * madj)+"px"; |
149
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 adjustPID = -1; |
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 |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
146 function mgalAdjustImage() |
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 if (adjustPID == -1) |
174
915cf0469d9f
Change image adjust timeout to faster value.
Matti Hamalainen <ccr@tnsp.org>
parents:
173
diff
changeset
|
149 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
|
150 } |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
151 |
b4751909c48f
Move some Javascript code to a separate file and make the location configurable.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
152 |
152
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
153 function mgalDisplayInfo(mvstate) |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
154 { |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
155 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
|
156 var mvnbut = document.getElementById("pageUpNaviButton"); |
226 | 157 var mvinfo = document.getElementById("pageInfoHeader"); |
158 var mviinfo = document.getElementById("infoBox"); | |
229 | 159 |
226 | 160 mvinfo.style.display = mvstate ? "block" : "none"; |
230
6b34b61b956b
Add a horrible kludge for using the info button to display also the image info on mobile.
Matti Hamalainen <ccr@tnsp.org>
parents:
229
diff
changeset
|
161 |
6b34b61b956b
Add a horrible kludge for using the info button to display also the image info on mobile.
Matti Hamalainen <ccr@tnsp.org>
parents:
229
diff
changeset
|
162 if (window.getComputedStyle(mviinfo).opacity == 1) |
6b34b61b956b
Add a horrible kludge for using the info button to display also the image info on mobile.
Matti Hamalainen <ccr@tnsp.org>
parents:
229
diff
changeset
|
163 mviinfo.style.display = mvstate ? "block" : "none"; |
6b34b61b956b
Add a horrible kludge for using the info button to display also the image info on mobile.
Matti Hamalainen <ccr@tnsp.org>
parents:
229
diff
changeset
|
164 |
226 | 165 mvbut.style.display = !mvstate ? "block" : "none"; |
166 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
|
167 mvInfoOpen = mvstate; |
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 |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
171 function mgalOpenInfo() |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
172 { |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
173 mgalDisplayInfo(true); |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
174 } |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
175 |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
176 |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
177 function mgalCloseInfo() |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
178 { |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
179 mgalDisplayInfo(false); |
606b05c31d5e
Improve mobile experience and also desktop image display, maybe.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
180 } |
196
9db200b610ea
Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
181 |
9db200b610ea
Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
182 |
9db200b610ea
Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
183 function mgalPreventDefault(ev) |
9db200b610ea
Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
184 { |
9db200b610ea
Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
185 ev.preventDefault(); |
9db200b610ea
Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
186 ev.target.click(); |
9db200b610ea
Add mgalPreventDefault(event) function. Not used yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
174
diff
changeset
|
187 } |
222
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
188 |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
189 |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
190 var mgalTouchX = null, mgalTouchY = null; |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
191 |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
192 function mgalTouchStart(evt) |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
193 { |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
194 mgalTouchX = evt.touches[0].clientX; |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
195 mgalTouchY = evt.touches[0].clientY; |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
196 } |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
197 |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
198 |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
199 function mgalTouchMove(evt) |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
200 { |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
201 if (mgalTouchX != null && mgalTouchY != null && evt) |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
202 { |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
203 var deltaX = mgalTouchX - evt.touches[0].clientX; |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
204 var deltaY = mgalTouchY - evt.touches[0].clientY; |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
205 |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
206 if (Math.abs(deltaX) > Math.abs(deltaY)) |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
207 { |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
208 if (deltaX < 0) |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
209 mgalNavigateTo(mgalPrevURL); |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
210 else |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
211 mgalNavigateTo(mgalNextURL); |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
212 } |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
213 } |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
214 mgalTouchX = mgalTouchY = null; |
27e541d02be8
Implement left/right swipe gesture navigation.
Matti Hamalainen <ccr@tnsp.org>
parents:
221
diff
changeset
|
215 } |