Merge pull request #660 from mozilla/new-tab-long-press-onboarding
add onboarding panel for long-press
This commit is contained in:
commit
268da1350a
5 changed files with 87 additions and 22 deletions
|
@ -2,7 +2,7 @@
|
||||||
"name": "testpilot-containers",
|
"name": "testpilot-containers",
|
||||||
"title": "Containers Experiment",
|
"title": "Containers Experiment",
|
||||||
"description": "Containers works by isolating cookie jars using separate origin-attributes defined visually by colored ‘Container Tabs’. This add-on is a modified version of the containers feature for Firefox Test Pilot.",
|
"description": "Containers works by isolating cookie jars using separate origin-attributes defined visually by colored ‘Container Tabs’. This add-on is a modified version of the containers feature for Firefox Test Pilot.",
|
||||||
"version": "2.3.0",
|
"version": "2.4.0",
|
||||||
"author": "Andrea Marchesini, Luke Crouch and Jonathan Kingston",
|
"author": "Andrea Marchesini, Luke Crouch and Jonathan Kingston",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/mozilla/testpilot-containers/issues"
|
"url": "https://github.com/mozilla/testpilot-containers/issues"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const MAJOR_VERSIONS = ["2.3.0"];
|
const MAJOR_VERSIONS = ["2.3.0", "2.4.0"];
|
||||||
const LOOKUP_KEY = "$ref";
|
const LOOKUP_KEY = "$ref";
|
||||||
|
|
||||||
const assignManager = {
|
const assignManager = {
|
||||||
|
|
|
@ -9,11 +9,14 @@ const DEFAULT_COLOR = "blue";
|
||||||
const DEFAULT_ICON = "circle";
|
const DEFAULT_ICON = "circle";
|
||||||
const NEW_CONTAINER_ID = "new";
|
const NEW_CONTAINER_ID = "new";
|
||||||
|
|
||||||
|
const ONBOARDING_STORAGE_KEY = "onboarding-stage";
|
||||||
|
|
||||||
// List of panels
|
// List of panels
|
||||||
const P_ONBOARDING_1 = "onboarding1";
|
const P_ONBOARDING_1 = "onboarding1";
|
||||||
const P_ONBOARDING_2 = "onboarding2";
|
const P_ONBOARDING_2 = "onboarding2";
|
||||||
const P_ONBOARDING_3 = "onboarding3";
|
const P_ONBOARDING_3 = "onboarding3";
|
||||||
const P_ONBOARDING_4 = "onboarding4";
|
const P_ONBOARDING_4 = "onboarding4";
|
||||||
|
const P_ONBOARDING_5 = "onboarding5";
|
||||||
const P_CONTAINERS_LIST = "containersList";
|
const P_CONTAINERS_LIST = "containersList";
|
||||||
const P_CONTAINERS_EDIT = "containersEdit";
|
const P_CONTAINERS_EDIT = "containersEdit";
|
||||||
const P_CONTAINER_INFO = "containerInfo";
|
const P_CONTAINER_INFO = "containerInfo";
|
||||||
|
@ -89,18 +92,52 @@ const Logic = {
|
||||||
|
|
||||||
// Routing to the correct panel.
|
// Routing to the correct panel.
|
||||||
// If localStorage is disabled, we don't show the onboarding.
|
// If localStorage is disabled, we don't show the onboarding.
|
||||||
if (!localStorage || localStorage.getItem("onboarded4")) {
|
const data = await browser.storage.local.get([ONBOARDING_STORAGE_KEY]);
|
||||||
this.showPanel(P_CONTAINERS_LIST);
|
let onboarded = data[ONBOARDING_STORAGE_KEY];
|
||||||
} else if (localStorage.getItem("onboarded3")) {
|
if (!onboarded) {
|
||||||
this.showPanel(P_ONBOARDING_4);
|
// Legacy local storage used before panel 5
|
||||||
} else if (localStorage.getItem("onboarded2")) {
|
if (localStorage.getItem("onboarded4")) {
|
||||||
this.showPanel(P_ONBOARDING_3);
|
onboarded = 4;
|
||||||
} else if (localStorage.getItem("onboarded1")) {
|
} else if (localStorage.getItem("onboarded3")) {
|
||||||
this.showPanel(P_ONBOARDING_2);
|
onboarded = 3;
|
||||||
} else {
|
} else if (localStorage.getItem("onboarded2")) {
|
||||||
this.showPanel(P_ONBOARDING_1);
|
onboarded = 2;
|
||||||
|
} else if (localStorage.getItem("onboarded1")) {
|
||||||
|
onboarded = 1;
|
||||||
|
} else {
|
||||||
|
onboarded = 0;
|
||||||
|
}
|
||||||
|
this.setOnboardingStage(onboarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (onboarded) {
|
||||||
|
case 5:
|
||||||
|
this.showPanel(P_CONTAINERS_LIST);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
this.showPanel(P_ONBOARDING_5);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
this.showPanel(P_ONBOARDING_4);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
this.showPanel(P_ONBOARDING_3);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
this.showPanel(P_ONBOARDING_2);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
default:
|
||||||
|
this.showPanel(P_ONBOARDING_1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
setOnboardingStage(stage) {
|
||||||
|
return browser.storage.local.set({
|
||||||
|
[ONBOARDING_STORAGE_KEY]: stage
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
async clearBrowserActionBadge() {
|
async clearBrowserActionBadge() {
|
||||||
|
@ -313,8 +350,8 @@ Logic.registerPanel(P_ONBOARDING_1, {
|
||||||
initialize() {
|
initialize() {
|
||||||
// Let's move to the next panel.
|
// Let's move to the next panel.
|
||||||
[...document.querySelectorAll(".onboarding-start-button")].forEach(startElement => {
|
[...document.querySelectorAll(".onboarding-start-button")].forEach(startElement => {
|
||||||
Logic.addEnterHandler(startElement, () => {
|
Logic.addEnterHandler(startElement, async function () {
|
||||||
localStorage.setItem("onboarded1", true);
|
await Logic.setOnboardingStage(1);
|
||||||
Logic.showPanel(P_ONBOARDING_2);
|
Logic.showPanel(P_ONBOARDING_2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -337,8 +374,8 @@ Logic.registerPanel(P_ONBOARDING_2, {
|
||||||
initialize() {
|
initialize() {
|
||||||
// Let's move to the containers list panel.
|
// Let's move to the containers list panel.
|
||||||
[...document.querySelectorAll(".onboarding-next-button")].forEach(nextElement => {
|
[...document.querySelectorAll(".onboarding-next-button")].forEach(nextElement => {
|
||||||
Logic.addEnterHandler(nextElement, () => {
|
Logic.addEnterHandler(nextElement, async function () {
|
||||||
localStorage.setItem("onboarded2", true);
|
await Logic.setOnboardingStage(2);
|
||||||
Logic.showPanel(P_ONBOARDING_3);
|
Logic.showPanel(P_ONBOARDING_3);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -361,8 +398,8 @@ Logic.registerPanel(P_ONBOARDING_3, {
|
||||||
initialize() {
|
initialize() {
|
||||||
// Let's move to the containers list panel.
|
// Let's move to the containers list panel.
|
||||||
[...document.querySelectorAll(".onboarding-almost-done-button")].forEach(almostElement => {
|
[...document.querySelectorAll(".onboarding-almost-done-button")].forEach(almostElement => {
|
||||||
Logic.addEnterHandler(almostElement, () => {
|
Logic.addEnterHandler(almostElement, async function () {
|
||||||
localStorage.setItem("onboarded3", true);
|
await Logic.setOnboardingStage(3);
|
||||||
Logic.showPanel(P_ONBOARDING_4);
|
Logic.showPanel(P_ONBOARDING_4);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -383,8 +420,29 @@ Logic.registerPanel(P_ONBOARDING_4, {
|
||||||
// This method is called when the object is registered.
|
// This method is called when the object is registered.
|
||||||
initialize() {
|
initialize() {
|
||||||
// Let's move to the containers list panel.
|
// Let's move to the containers list panel.
|
||||||
document.querySelector("#onboarding-done-button").addEventListener("click", () => {
|
Logic.addEnterHandler(document.querySelector("#onboarding-done-button"), async function () {
|
||||||
localStorage.setItem("onboarded4", true);
|
await Logic.setOnboardingStage(4);
|
||||||
|
Logic.showPanel(P_ONBOARDING_5);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// This method is called when the panel is shown.
|
||||||
|
prepare() {
|
||||||
|
return Promise.resolve(null);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// P_ONBOARDING_5: Fifth page for Onboarding: new tab long-press behavior
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Logic.registerPanel(P_ONBOARDING_5, {
|
||||||
|
panelSelector: ".onboarding-panel-5",
|
||||||
|
|
||||||
|
// This method is called when the object is registered.
|
||||||
|
initialize() {
|
||||||
|
// Let's move to the containers list panel.
|
||||||
|
Logic.addEnterHandler(document.querySelector("#onboarding-longpress-button"), async function () {
|
||||||
|
await Logic.setOnboardingStage(5);
|
||||||
Logic.showPanel(P_CONTAINERS_LIST);
|
Logic.showPanel(P_CONTAINERS_LIST);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Containers Experiment",
|
"name": "Containers Experiment",
|
||||||
"version": "2.3.0",
|
"version": "2.4.0",
|
||||||
|
|
||||||
"description": "Containers works by isolating cookie jars using separate origin-attributes defined visually by colored ‘Container Tabs’. This add-on is a modified version of the containers feature for Firefox Test Pilot.",
|
"description": "Containers works by isolating cookie jars using separate origin-attributes defined visually by colored ‘Container Tabs’. This add-on is a modified version of the containers feature for Firefox Test Pilot.",
|
||||||
"icons": {
|
"icons": {
|
||||||
|
|
|
@ -57,7 +57,14 @@
|
||||||
<img class="onboarding-img" alt="How to assign sites to containers" src="/img/onboarding-4.png" />
|
<img class="onboarding-img" alt="How to assign sites to containers" src="/img/onboarding-4.png" />
|
||||||
<h3 class="onboarding-title">Always open sites in the containers you want.</h3>
|
<h3 class="onboarding-title">Always open sites in the containers you want.</h3>
|
||||||
<p>Right-click inside a container tab to assign the site to always open in the container.</p>
|
<p>Right-click inside a container tab to assign the site to always open in the container.</p>
|
||||||
<a href="#" id="onboarding-done-button" class="onboarding-button">Done</a>
|
<a href="#" id="onboarding-done-button" class="onboarding-button">Next</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="panel onboarding onboarding-panel-5 hide" id="onboarding-panel-5">
|
||||||
|
<img class="onboarding-img" alt="Long-press the New Tab button to create a new container tab." src="/img/onboarding-3.png" />
|
||||||
|
<h3 class="onboarding-title">Container tabs when you need them.</h3>
|
||||||
|
<p>Long-press the New Tab button to create a new container tab.</p>
|
||||||
|
<a href="#" id="onboarding-longpress-button" class="onboarding-button">Done</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel container-panel hide" id="container-panel">
|
<div class="panel container-panel hide" id="container-panel">
|
||||||
|
|
Loading…
Add table
Reference in a new issue