/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; /* import-globals-from ../contentSearchUI.js */ // IndexedDB storage constants. const DATABASE_NAME = "abouthome"; const DATABASE_VERSION = 1; const DATABASE_STORAGE = "persistent"; var searchText; // This global tracks if the page has been set up before, to prevent double inits var gInitialized = false; var gObserver = new MutationObserver(function (mutations) { for (let mutation of mutations) { // The addition of the restore session button changes our width: if (mutation.attributeName == "session") { fitToWidth(); } } }); window.addEventListener("pageshow", function () { // Delay search engine setup, cause browser.js::BrowserOnAboutPageLoad runs // later and may use asynchronous getters. window.gObserver.observe(document.documentElement, { attributes: true }); window.gObserver.observe(document.getElementById("launcher"), { attributes: true }); fitToWidth(); setupSearch(); window.addEventListener("resize", fitToWidth); // Ask chrome to update snippets. var event = new CustomEvent("AboutHomeLoad", {bubbles:true}); document.dispatchEvent(event); }); window.addEventListener("pagehide", function() { window.gObserver.disconnect(); window.removeEventListener("resize", fitToWidth); }); window.addEventListener("keypress", ev => { if (ev.defaultPrevented) { return; } // don't focus the search-box on keypress if something other than the // body or document element has focus - don't want to steal input from other elements // Make an exception for and