Position dialogs relative to closest edge of screen.

This fixes a bug where the expansion of a QR dialog upon captcha
loading would push the response field off the bottom of the screen.
This commit is contained in:
ccd0 2014-08-31 20:35:10 -07:00
parent a6aee3ce59
commit 7d6566b4cb

View File

@ -255,31 +255,20 @@ UI = do ->
drag = (e) -> drag = (e) ->
{clientX, clientY} = e {clientX, clientY} = e
left = clientX - @dx x = clientX - @dx
left = if left < 10 y = clientY - @dy
0
else if @width - left < 10
null
else
left / @screenWidth * 100 + '%'
top = clientY - @dy left = right = top = bottom = null
top = if top < (10 + @topBorder)
@topBorder + 'px'
else if @height - top < (10 + @bottomBorder)
null
else
top / @screenHeight * 100 + '%'
right = if left is null if x <= @width / 2
0 left = if x < 10 then '0px' else x / @screenWidth * 100 + '%'
else else
null right = if @width - x < 10 then '0px' else (@width - x) / @screenWidth * 100 + '%'
bottom = if top is null if y <= @height / 2
@bottomBorder + 'px' top = if y < 10 + @topBorder then @topBorder + 'px' else y / @screenHeight * 100 + '%'
else else
null bottom = if @height - y < 10 + @bottomBorder then @bottomBorder + 'px' else (@height - y) / @screenHeight * 100 + '%'
{style} = @ {style} = @
style.left = left style.left = left