/* See license.txt for terms of usage */

"use strict";

const self = require("sdk/self");

const { Trace, TraceError } = require("./sdk/core/trace.js").get(module.id);
const { prefs } = require("sdk/simple-prefs");
const { StartButton } = require("./start-button.js");
const { getMostRecentBrowserWindow } = require("sdk/window/utils");

/**
 * xxxHonza TODO docs
 */
var FirstRun =
/** @lends FirstRun */
{
  // Initialization

  initialize: function(options) {
    if (!prefs.firstRun) {
      return;
    }

    // Do not show the notification again the next time.
    prefs.firstRun = false;

    var panel = require("sdk/panel").Panel({
      contentURL: "./notification.html",
      contentScriptFile: "./notification-content.js"
    });

    panel.port.on("start", function(url) {
      StartButton.onTogglePixelPerfect();
    });

    let browser = getMostRecentBrowserWindow();
    let doc = browser.document;
    let startButton = doc.getElementById("pixel-perfect-start-button");

    let config = {
      height: 230,
      width: 390
    };

    // Show first-run notification message.
    panel.show(config, startButton);
  },
}

// Exports from this module
exports.FirstRun = FirstRun;

@@ -343,26 +343,169 @@
 %0A * 
-xxxHonza TODO docs
+This module implements first run experience. It displays simple%0A * notification message about Pixel Perfect. It's displayed only%0A * once just after installation.
 %0A */
@@ -878,24 +878,332 @@
 s%22%0A    %7D);%0A%0A
+    // Communication with the panel is done through a 'port'.%0A    // Read more about ports on MDN:%0A    // https://developer.mozilla.org/en-US/Add-ons/SDK/Guides/Content_Scripts/using_port%0A    // The only message sent from the panel is 'start'. It's fired when the%0A    // use clicks on 'Start Pixel Perfect'.%0A
     panel.po

Update JS docs first run experience