MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / data / preset / imagegallery / jstemplate.js
blob773dbaa3267351e71dc3a09cdc79fbfb5e8f2ea5
1 var maxHeight = 550;
2 var maxListHeight = 120;
4 function init() {
5     if (document.getElementById("singleimage")) single();
6     /*else if (document.getElementById("pictures")) list();*/
9 function list() {
10     imageDivs = document.getElementsByName("listimage");
11     for (i=0; i < imageDivs.length; i++) {
12         currentHeight = imageDivs[i].offsetHeight;
13         currentWidth = imageDivs[i].offsetWidth;
15         if (currentHeight > maxListHeight) {
16             ratio = maxListHeight / currentHeight;
17             imageDivs[i].style.width = (currentWidth*ratio) + 'px';
18             imageDivs[i].style.height = (currentHeight*ratio) + 'px';
19             imageDivs[i].firstChild.style.height = '100%';
20             imageDivs[i].firstChild.style.width = '100%';
21         }
22     }
25 function single() {
26     var imageDiv = document.getElementById("singleimage");
28     if (imageDiv) {
29         currentHeight = imageDiv.offsetHeight;
30         currentWidth  = imageDiv.offsetWidth;
32         if (currentHeight > maxHeight) {
33             ratio = maxHeight / currentHeight;
34             imageDiv.style.width = (currentWidth*ratio) + 'px';
35             imageDiv.style.height = (currentHeight*ratio) + 'px';
37         }
38     }
41 window.onload = init;