##// END OF EJS Templates
Fixed image popup margin in rare cases
neko259 -
r1357:3a3fc639 default
parent child Browse files
Show More
@@ -23,6 +23,8 b''
23 for the JavaScript code in this page.
23 for the JavaScript code in this page.
24 */
24 */
25
25
26 var IMAGE_POPUP_MARGIN = 10;
27
26
28
27 var IMAGE_VIEWERS = [
29 var IMAGE_VIEWERS = [
28 ['simple', new SimpleImageViewer()],
30 ['simple', new SimpleImageViewer()],
@@ -69,8 +71,6 b' SimpleImageViewer.prototype.view = funct'
69
71
70 function PopupImageViewer() {}
72 function PopupImageViewer() {}
71 PopupImageViewer.prototype.view = function (post) {
73 PopupImageViewer.prototype.view = function (post) {
72 var margin = 20; //..change
73
74 var el = post;
74 var el = post;
75 var thumb_id = 'full' + el.find('img').attr('alt');
75 var thumb_id = 'full' + el.find('img').attr('alt');
76
76
@@ -89,11 +89,15 b' PopupImageViewer.prototype.view = functi'
89 // New image size
89 // New image size
90 var w_scale = 1;
90 var w_scale = 1;
91 var h_scale = 1;
91 var h_scale = 1;
92 if (full_img_w > win_w) {
92
93 w_scale = full_img_w / (win_w - margin);
93 var freeWidth = win_w - 2 * IMAGE_POPUP_MARGIN;
94 var freeHeight = win_h - 2 * IMAGE_POPUP_MARGIN;
95
96 if (full_img_w > freeWidth) {
97 w_scale = full_img_w / freeWidth;
94 }
98 }
95 if (full_img_h > win_h) {
99 if (full_img_h > freeHeight) {
96 h_scale = full_img_h / (win_h - margin);
100 h_scale = full_img_h / freeHeight;
97 }
101 }
98
102
99 var scale = Math.max(w_scale, h_scale)
103 var scale = Math.max(w_scale, h_scale)
General Comments 0
You need to be logged in to leave comments. Login now