Only listen to resize events with fitheight enabled.

This commit is contained in:
Nicolas Stepien 2011-10-14 16:29:34 +02:00
parent d95764e87a
commit 745ac1ec19
2 changed files with 30 additions and 18 deletions

View File

@ -2803,10 +2803,7 @@
imgExpand = {
init: function() {
g.callbacks.push(imgExpand.node);
imgExpand.dialog();
$.bind(window, 'resize', imgExpand.resize);
imgExpand.style = $.addStyle('');
return imgExpand.resize();
return imgExpand.dialog();
},
node: function(root) {
var a, thumb;
@ -2849,7 +2846,7 @@
}
},
typeChange: function(e) {
var klass;
var form, klass;
switch (this.value) {
case 'full':
klass = '';
@ -2863,7 +2860,17 @@
case 'fit screen':
klass = 'fitwidth fitheight';
}
return d.body.className = klass;
form = $('body > form');
form.className = klass;
if (form.classList.contains('fitheight')) {
$.bind(window, 'resize', imgExpand.resize);
if (!imgExpand.style) {
imgExpand.style = $.addStyle('');
return imgExpand.resize();
}
} else if (imgExpand.style) {
return $.unbind(window, 'resize', imgExpand.resize);
}
}
},
toggle: function(a) {
@ -2937,8 +2944,8 @@
delform = $('form[name=delform]');
return $.prepend(delform, controls);
},
resize: function(e) {
return imgExpand.style.innerHTML = ".fitheight img[md5] + img {max-height:" + d.body.clientHeight + "px;}";
resize: function() {
return imgExpand.style.innerHTML = ".fitheight img + img {max-height:" + innerHeight + "px;}";
}
};
firstRun = {
@ -3157,10 +3164,10 @@
float: left;\
pointer-events: none;\
}\
img[md5], img[md5] + img {\
img[md5], img + img {\
pointer-events: all;\
}\
body.fitwidth img[md5] + img {\
.fitwidth img + img {\
max-width: 100%;\
width: -moz-calc(100%); /* hack so only firefox sees this */\
}\

View File

@ -2062,9 +2062,6 @@ imgExpand =
init: ->
g.callbacks.push imgExpand.node
imgExpand.dialog()
$.bind window, 'resize', imgExpand.resize
imgExpand.style = $.addStyle ''
imgExpand.resize()
node: (root) ->
return unless thumb = $ 'img[md5]', root
@ -2094,7 +2091,15 @@ imgExpand =
klass = 'fitheight'
when 'fit screen'
klass = 'fitwidth fitheight'
d.body.className = klass
form = $('body > form')
form.className = klass
if form.classList.contains 'fitheight'
$.bind window, 'resize', imgExpand.resize
unless imgExpand.style
imgExpand.style = $.addStyle ''
imgExpand.resize()
else if imgExpand.style
$.unbind window, 'resize', imgExpand.resize
toggle: (a) ->
thumb = a.firstChild
@ -2151,8 +2156,8 @@ imgExpand =
delform = $ 'form[name=delform]'
$.prepend delform, controls
resize: (e) ->
imgExpand.style.innerHTML = ".fitheight img[md5] + img {max-height:#{d.body.clientHeight}px;}"
resize: ->
imgExpand.style.innerHTML = ".fitheight img + img {max-height:#{innerHeight}px;}"
firstRun =
init: ->
@ -2418,10 +2423,10 @@ Main =
float: left;
pointer-events: none;
}
img[md5], img[md5] + img {
img[md5], img + img {
pointer-events: all;
}
body.fitwidth img[md5] + img {
.fitwidth img + img {
max-width: 100%;
width: -moz-calc(100%); /* hack so only firefox sees this */
}