better remember and detect resizing of editor; FF-compatibility

This commit is contained in:
tophf 2017-08-27 14:56:04 +03:00
parent dba3de7a86
commit 738846a614

View File

@ -489,20 +489,33 @@ function goBackToManage(event) {
} }
function isWindowMaximized() { function isWindowMaximized() {
return window.screenLeft === 0 && return (
window.screenTop === 0 && window.screenX <= 0 &&
window.outerWidth === screen.availWidth && window.screenY <= 0 &&
window.outerHeight === screen.availHeight; window.outerWidth >= screen.availWidth &&
window.outerHeight >= screen.availHeight &&
window.screenX > -10 &&
window.screenY > -10 &&
window.outerWidth < screen.availWidth + 10 &&
window.outerHeight < screen.availHeight + 10
);
}
function rememberWindowSize() {
if (!isWindowMaximized() && prefs.get('openEditInWindow')) {
prefs.set('windowPosition', {
left: window.screenX,
top: window.screenY,
width: window.outerWidth,
height: window.outerHeight,
});
}
} }
window.onbeforeunload = () => { window.onbeforeunload = () => {
if (saveSizeOnClose && !isWindowMaximized()) { if (saveSizeOnClose) {
prefs.set('windowPosition', { rememberWindowSize();
left: screenLeft,
top: screenTop,
width: outerWidth,
height: outerHeight
});
} }
document.activeElement.blur(); document.activeElement.blur();
if (isCleanGlobal()) { if (isCleanGlobal()) {
@ -1336,6 +1349,10 @@ function initHooks() {
document.getElementById('lint-help').addEventListener('click', showLintHelp); document.getElementById('lint-help').addEventListener('click', showLintHelp);
document.getElementById('lint').addEventListener('click', gotoLintIssue); document.getElementById('lint').addEventListener('click', gotoLintIssue);
window.addEventListener('resize', resizeLintReport); window.addEventListener('resize', resizeLintReport);
window.addEventListener('load', function _() {
window.removeEventListener('load', _);
window.addEventListener('resize', () => debounce(rememberWindowSize, 100));
});
// touch devices don't have onHover events so the element we'll be toggled via clicking (touching) // touch devices don't have onHover events so the element we'll be toggled via clicking (touching)
if ('ontouchstart' in document.body) { if ('ontouchstart' in document.body) {