5 this.removeAttr("width").removeAttr("height"); // Remove |
5 this.removeAttr("width").removeAttr("height"); // Remove |
6 // compute image size / max allowed size to fit screen |
6 // compute image size / max allowed size to fit screen |
7 var imgHSize = this.width(); |
7 var imgHSize = this.width(); |
8 var maxHSize = $(window).width() - ($(document).width() - imgHSize); |
8 var maxHSize = $(window).width() - ($(document).width() - imgHSize); |
9 var imgVSize = this.height(); |
9 var imgVSize = this.height(); |
10 var maxVSize = $(window).height() - ($(document).height() - imgVSize); |
10 // we don't mind if content in [content]footer moved out of the screen |
|
11 var maxVSize = $(window).height() - ($(document).height() - imgVSize) + $('#footer').height() + $('#contentfooter').height(); |
11 if (maxHSize > 0 && maxVSize > 0) { |
12 if (maxHSize > 0 && maxVSize > 0) { |
12 // if image don't fit screen, set width or height so that |
13 // if image don't fit screen, set width or height so that |
13 // browser keep img ratio, ensuring the other dimension will |
14 // browser keep img ratio, ensuring the other dimension will |
14 // also fit the screen |
15 // also fit the screen |
15 if (imgHSize > maxHSize && ((maxHSize / maxVSize) * imgVSize) < maxVSize) { |
16 if (imgHSize > maxHSize && ((imgVSize / imgHSize) * maxHSize) <= maxVSize) { |
16 this.css("width", maxHSize); |
17 this.css("width", maxHSize); |
17 } else if (imgVSize > maxVSize && ((maxVSize / maxHSize) * imgHSize) < maxHSize) { |
18 } else if (imgVSize > maxVSize && ((imgHSize / imgVSize) * maxVSize) <= maxHSize) { |
18 this.css("height", maxVSize); |
19 this.css("height", maxVSize); |
19 } // else image already fit in screen, don't scale it up |
20 } |
|
21 else { |
|
22 // image already fit in screen, don't scale it up |
|
23 } |
20 } else { |
24 } else { |
21 // XXX can't fit image, don't do anything |
25 // can't fit image in, don't do anything |
22 } |
26 } |
23 }; |
27 }; |
24 |
28 |
25 |
29 |
26 $(document).ready(function() { |
30 $(document).ready(function() { |