Bug 1381765 - Should show the first uncomplete tour by default;r=mossop,fischer draft
authorgasolin <gasolin@gmail.com>
Tue, 18 Jul 2017 18:23:47 +0800
changeset 613846 aa3c4c9ea3343891bc080b0298bf84a8ddacd48a
parent 613116 e99e3e62cfa8bbc7d430f64d4fbdf77ffb81e979
child 638736 3e70c9de0aedd1fb68253b343c56edc64a6d88ff
push id69870
push userbmo:gasolin@mozilla.com
push dateSun, 23 Jul 2017 07:44:25 +0000
reviewersmossop, fischer
bugs1381765
milestone56.0a1
Bug 1381765 - Should show the first uncomplete tour by default;r=mossop,fischer MozReview-Commit-ID: 4vDvR4lVE16
browser/extensions/onboarding/content/onboarding.js
--- a/browser/extensions/onboarding/content/onboarding.js
+++ b/browser/extensions/onboarding/content/onboarding.js
@@ -456,16 +456,18 @@ class Onboarding {
     switch (evt.target.id) {
       case "onboarding-overlay-button":
       case "onboarding-overlay-close-btn":
       // If the clicking target is directly on the outer-most overlay,
       // that means clicking outside the tour content area.
       // Let's toggle the overlay.
       case "onboarding-overlay":
         this.toggleOverlay();
+        let selectedTour = this._tours.find(tour => !this.isTourCompleted(tour.id)) || this._tours[0];
+        this.gotoPage(selectedTour.id);
         break;
       case "onboarding-notification-close-btn":
         this.hideNotification();
         this._removeTourFromNotificationQueue(this._notificationBar.dataset.targetTourId);
         break;
       case "onboarding-notification-action-btn":
         let tourId = this._notificationBar.dataset.targetTourId;
         this.toggleOverlay();
@@ -828,25 +830,25 @@ class Onboarding {
 
       div.id = `${tour.id}-page`;
       div.classList.add("onboarding-tour-page");
       div.style.display = "none";
       pagesFrag.appendChild(div);
       // Cache elements in arrays for later use to avoid cost of querying elements
       this._tourItems.push(li);
       this._tourPages.push(div);
+
+      this.markTourCompletionState(tour.id);
     }
-    tours.forEach(tour => this.markTourCompletionState(tour.id));
 
     let dialog = this._window.document.getElementById("onboarding-overlay-dialog");
     let ul = this._window.document.getElementById("onboarding-tour-list");
     ul.appendChild(itemsFrag);
     let footer = this._window.document.getElementById("onboarding-footer");
     dialog.insertBefore(pagesFrag, footer);
-    this.gotoPage(tours[0].id);
   }
 
   _loadCSS() {
     // Returning a Promise so we can inform caller of loading complete
     // by resolving it.
     return new Promise(resolve => {
       let doc = this._window.document;
       let link = doc.createElement("link");