VulpesOS/gaia/tv_apps/browser/js/fte.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

76 lines
1.7 KiB
JavaScript
Executable file

/* 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/. */
/* global Browser */
/* global FTEWizard */
/* global ResourceLoader */
/* global SyncManagerBridge */
// XXX: If Firefox sign in is available outside of the browser app, we'll have
// to remove or redesign FTE.
'use strict';
(function (exports) {
if (localStorage.getItem('browserFTE.fteskip')) {
return;
}
var FTE = {
fteContainer: null,
fteWizard: null,
onuninit: function () {},
init(options) {
this.onuninit = options.onuninit;
ResourceLoader.loadByName('fte')
.then(node => {
document.body.appendChild(node);
this.fteContainer = document.getElementById('fte-container');
this.fteWizard = new FTEWizard('browserFTE');
this.fteWizard.init({
container: this.fteContainer,
propagateKeyEvent: true,
onfinish: () => {
SyncManagerBridge.enable();
this.uninit();
},
onskip: () => {
this.uninit();
}
});
document.addEventListener('visibilitychange', this);
});
},
handleEvent() {
if (!document.hidden) {
this.fteWizard.focus();
}
},
uninit() {
document.body.removeChild(this.fteContainer);
document.removeEventListener('visibilitychange', this);
ResourceLoader.unloadByName('fte');
this.onuninit();
}
};
exports.FTE = FTE;
exports.FTE.init({onuninit: () => {
Browser.switchCursorMode(true);
delete exports.FTE;
}});
})(window);