Merge pull request #331 from MayhemYDG/master

Only listen to resize events with fitheight enabled.
This commit is contained in:
James Campos 2011-10-28 11:45:10 -07:00
commit b4aea00449
2 changed files with 28 additions and 16 deletions

View File

@ -2822,10 +2822,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;
@ -2868,7 +2865,7 @@
} }
}, },
typeChange: function() { typeChange: function() {
var klass; var form, klass;
switch (this.value) { switch (this.value) {
case 'full': case 'full':
klass = ''; klass = '';
@ -2882,7 +2879,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) {
@ -2957,7 +2964,7 @@
return $.prepend(form, controls); return $.prepend(form, controls);
}, },
resize: function() { 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:" + d.body.clientHeight + "px;}";
} }
}; };
firstRun = { firstRun = {
@ -3194,10 +3201,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

@ -2081,9 +2081,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
@ -2113,7 +2110,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
@ -2171,7 +2176,7 @@ imgExpand =
$.prepend form, controls $.prepend form, controls
resize: -> resize: ->
imgExpand.style.innerHTML = ".fitheight img[md5] + img {max-height:#{d.body.clientHeight}px;}" imgExpand.style.innerHTML = ".fitheight img + img {max-height:#{d.body.clientHeight}px;}"
firstRun = firstRun =
init: -> init: ->
@ -2457,10 +2462,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 */
} }