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

View File

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