More cleanup

This commit is contained in:
Rob Garrison 2017-07-16 12:01:39 -05:00
parent 1940318f0f
commit 24dd0cb562

View File

@ -441,9 +441,11 @@ document.addEventListener('wheel', event => {
queryTabs({currentWindow: true}).then(tabs => { queryTabs({currentWindow: true}).then(tabs => {
const windowId = tabs[0].windowId; const windowId = tabs[0].windowId;
if (prefs.get('openEditInWindow')) { if (prefs.get('openEditInWindow')) {
if (sessionStorage.saveSizeOnClose if (
&& 'left' in prefs.get('windowPosition', {}) sessionStorage.saveSizeOnClose &&
&& !isWindowMaximized()) { 'left' in prefs.get('windowPosition', {}) &&
!isWindowMaximized()
) {
// window was reopened via Ctrl-Shift-T etc. // window was reopened via Ctrl-Shift-T etc.
chrome.windows.update(windowId, prefs.get('windowPosition')); chrome.windows.update(windowId, prefs.get('windowPosition'));
} }
@ -481,10 +483,10 @@ function goBackToManage(event) {
} }
function isWindowMaximized() { function isWindowMaximized() {
return window.screenLeft == 0 return window.screenLeft == 0 &&
&& window.screenTop == 0 window.screenTop == 0 &&
&& window.outerWidth == screen.availWidth window.outerWidth == screen.availWidth &&
&& window.outerHeight == screen.availHeight; window.outerHeight == screen.availHeight;
} }
window.onbeforeunload = () => { window.onbeforeunload = () => {
@ -570,8 +572,10 @@ function addSection(event, section) {
item.querySelector('.applies-value').value.trim()); item.querySelector('.applies-value').value.trim());
div.classList.toggle('has-regexp', show); div.classList.toggle('has-regexp', show);
appliesTo.oninput = appliesTo.oninput || show && (event => { appliesTo.oninput = appliesTo.oninput || show && (event => {
if (event.target.matches('.applies-value') if (
&& event.target.parentElement.querySelector('.applies-type').value == 'regexp') { event.target.matches('.applies-value') &&
event.target.parentElement.querySelector('.applies-type').value == 'regexp'
) {
showRegExpTester(null, div); showRegExpTester(null, div);
} }
}); });
@ -736,8 +740,11 @@ function setupGlobalSearch() {
const rxQuery = typeof state.query == 'object' const rxQuery = typeof state.query == 'object'
? state.query : stringAsRegExp(state.query, shouldIgnoreCase(state.query) ? 'i' : ''); ? state.query : stringAsRegExp(state.query, shouldIgnoreCase(state.query) ? 'i' : '');
if (document.activeElement && document.activeElement.name == 'applies-value' if (
&& searchAppliesTo(activeCM)) { document.activeElement &&
document.activeElement.name == 'applies-value' &&
searchAppliesTo(activeCM)
) {
return; return;
} }
let cm = activeCM; let cm = activeCM;