<commit_before>/* See license.txt for terms of usage */

FBL.ns(function() { with (FBL) {

// ********************************************************************************************* //
// Constants

const Cc = Components.classes;
const Ci = Components.interfaces;

var appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
var versionChecker = Cc["@mozilla.org/xpcom/version-comparator;1"].getService(Ci.nsIVersionComparator);

var popup = $("fbStatusContextMenu");
var statusBar = $("fbStatusBar");
var statusText = $("fbStatusText");

// ********************************************************************************************* //
// Module Implementation

/**
 * @module StartButton module represents the UI entry point to Firebug. This "start buttton"
 * formerly known as "the status bar icon" is automatically appended into Firefox toolbar
 * (since Firefox 4).
 * 
 * Start button is associated with a menu (fbStatusContextMenu) that contains basic actions
 * such as panel activation and also indicates whether Firebug is activated/deactivated for
 * the current page (by changing its color).
 */
Firebug.StartButton = extend(Firebug.Module,
/** @lends Firebug.StartButton */
{
    initializeUI: function()
    {
        Firebug.Module.initializeUI.apply(this, arguments);

        // Associate a popup-menu with the start button (the same as it's
        // used for the obsolete status bar icon.
        var startButton = $("firebug-button");
        if (startButton)
        {
            startButton.appendChild(popup.cloneNode(true));

            // Append the button into Firefox toolbar automatically.
            this.appendToToolbar();

            // If Firefox version is 4+, let's
            if (versionChecker.compare(appInfo.version, "4.0*") >= 0)
                startButton.setAttribute("firefox", "4");

        }
    },

    shutdown: function()
    {
    },

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    /**
     * Appends Firebug start button into Firefox toolbar automatically after installation.
     * The button is appended only once so, if the user removes it, it isn't appended again.
     */
    appendToToolbar: function()
    {
        if (Firebug.getPref(Firebug.prefDomain, "toolbarCustomizationDone"))
            return;

        Firebug.setPref(Firebug.prefDomain, "toolbarCustomizationDone", true);

        // Get the current navigation bar button set (a string of button IDs) and append
        // ID of the Firebug start button into it.
        var startButtonId = "firebug-button";
        var afterId = "urlbar-container";
        var navBar = $("nav-bar");
        var curSet = navBar.currentSet.split(",");

        // Append only if the button is not already there.
        if (curSet.indexOf(startButtonId) == -1)
        {
            var set = curSet.concat(startButtonId);

            navBar.setAttribute("currentset", set.join(","));
            navBar.currentSet = set.join(",");
            document.persist(navBar.id, "currentset");

            try
            {
                BrowserToolboxCustomizeDone(true);
            }
            catch (e)
            {
                if (FBTrace.DBG_ERRORS)
                    FBTrace.sysout("startButton; appendToToolbar EXCEPTION " + e, e);
            }
        }

        // Don't forget to show the navigation bar - just in case it's hidden.
        // setToolbarVisibility() comes from browser.js
        collapse(navBar, true);
        document.persist("nav-bar", "collapsed");
    },

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    // Support for the status bar (OBSOLETE in Fx4)

    onClickStatusText: function(context, event)
    {
        if (event.button != 0)
            return;

        if (!context || !context.errorCount)
            return;

        var panel = Firebug.chrome.getSelectedPanel();
        if (panel && panel.name != "console")
        {
            Firebug.chrome.selectPanel("console");
            cancelEvent(event);
        }
    },

    onClickStatusIcon: function(context, event)
    {
        if (event.button != 0)
            return;
        else if (isControl(event))
            Firebug.toggleDetachBar(true);
        else if (context && context.errorCount)
            Firebug.toggleBar(undefined, "console");
        else
            Firebug.toggleBar();
    },

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    // Error count

    showCount: function(errorCount)
    {
        if (!statusBar)
            return;

        var firebugButton = $("firebug-button");
        if (errorCount && Firebug.showErrorCount)
        {
            statusBar.setAttribute("showErrors", "true")
            statusText.setAttribute("value", $STRP("plural.Error_Count2", [errorCount]));

            if (firebugButton)
            {
                firebugButton.setAttribute("showErrors", "true");
                firebugButton.setAttribute("errorCount", errorCount);
            }
        }
        else
        {
            statusBar.removeAttribute("showErrors");
            statusText.setAttribute("value", "");

            if (firebugButton)
            {
                firebugButton.removeAttribute("showErrors");
                
                // Use '0' so, the horizontal space for the number is still allocated.
                // The button will cause re-layout if there is more than 9 errors.
                firebugButton.setAttribute("errorCount", "0");
            }
        }
    },
});

// ********************************************************************************************* //
// Registration

Firebug.registerModule(Firebug.StartButton);

// ********************************************************************************************* //
}});<commit_msg>Issue 4086: 	SeaMonkey 2.1 first-run experience: Navigation Toolbar empty except for Firebug button<commit_after>/* See license.txt for terms of usage */

FBL.ns(function() { with (FBL) {

// ********************************************************************************************* //
// Constants

const Cc = Components.classes;
const Ci = Components.interfaces;

var appInfo = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULAppInfo);
var versionChecker = Cc["@mozilla.org/xpcom/version-comparator;1"].getService(Ci.nsIVersionComparator);

var popup = $("fbStatusContextMenu");
var statusBar = $("fbStatusBar");
var statusText = $("fbStatusText");

// ********************************************************************************************* //
// Module Implementation

/**
 * @module StartButton module represents the UI entry point to Firebug. This "start buttton"
 * formerly known as "the status bar icon" is automatically appended into Firefox toolbar
 * (since Firefox 4).
 *
 * Start button is associated with a menu (fbStatusContextMenu) that contains basic actions
 * such as panel activation and also indicates whether Firebug is activated/deactivated for
 * the current page (by changing its color).
 */
Firebug.StartButton = extend(Firebug.Module,
/** @lends Firebug.StartButton */
{
    initializeUI: function()
    {
        Firebug.Module.initializeUI.apply(this, arguments);

        // Associate a popup-menu with the start button (the same as it's
        // used for the obsolete status bar icon.
        var startButton = $("firebug-button");
        if (startButton)
        {
            startButton.appendChild(popup.cloneNode(true));

            // Append the button into Firefox toolbar automatically.
            this.appendToToolbar();

            // If Firefox version is 4+, let's
            if (versionChecker.compare(appInfo.version, "4.0*") >= 0)
                startButton.setAttribute("firefox", "4");
        }
        if (FBTrace.DBG_INITIALIZE)
            FBTrace.sysout("Startbutton initializeUI "+startButton);
    },

    shutdown: function()
    {
    },

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

    /**
     * Appends Firebug start button into Firefox toolbar automatically after installation.
     * The button is appended only once so, if the user removes it, it isn't appended again.
     */
    appendToToolbar: function()
    {
        if (Firebug.getPref(Firebug.prefDomain, "toolbarCustomizationDone"))
            return;

        Firebug.setPref(Firebug.prefDomain, "toolbarCustomizationDone", true);

        // Get the current navigation bar button set (a string of button IDs) and append
        // ID of the Firebug start button into it.
        var startButtonId = "firebug-button";
        var afterId = "urlbar-container";
        var navBar = $("nav-bar");
        var curSet = navBar.currentSet.split(",");

        // Append only if the button is not already there.
        if (curSet.indexOf(startButtonId) == -1)
        {
            var set = curSet.concat(startButtonId);

            navBar.setAttribute("currentset", set.join(","));
            navBar.currentSet = set.join(",");
            document.persist(navBar.id, "currentset");

            try
            {
                BrowserToolboxCustomizeDone(true);
            }
            catch (e)
            {
                if (FBTrace.DBG_ERRORS)
                    FBTrace.sysout("startButton; appendToToolbar EXCEPTION " + e, e);
            }
        }

        // Don't forget to show the navigation bar - just in case it's hidden.
        collapse(navBar, false);
        document.persist("nav-bar", "collapsed");
    },

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    // Support for the status bar (OBSOLETE in Fx4)

    onClickStatusText: function(context, event)
    {
        if (event.button != 0)
            return;

        if (!context || !context.errorCount)
            return;

        var panel = Firebug.chrome.getSelectedPanel();
        if (panel && panel.name != "console")
        {
            Firebug.chrome.selectPanel("console");
            cancelEvent(event);
        }
    },

    onClickStatusIcon: function(context, event)
    {
        if (event.button != 0)
            return;
        else if (isControl(event))
            Firebug.toggleDetachBar(true);
        else if (context && context.errorCount)
            Firebug.toggleBar(undefined, "console");
        else
            Firebug.toggleBar();
    },

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    // Error count

    showCount: function(errorCount)
    {
        if (!statusBar)
            return;

        var firebugButton = $("firebug-button");
        if (errorCount && Firebug.showErrorCount)
        {
            statusBar.setAttribute("showErrors", "true")
            statusText.setAttribute("value", $STRP("plural.Error_Count2", [errorCount]));

            if (firebugButton)
            {
                firebugButton.setAttribute("showErrors", "true");
                firebugButton.setAttribute("errorCount", errorCount);
            }
        }
        else
        {
            statusBar.removeAttribute("showErrors");
            statusText.setAttribute("value", "");

            if (firebugButton)
            {
                firebugButton.removeAttribute("showErrors");

                // Use '0' so, the horizontal space for the number is still allocated.
                // The button will cause re-layout if there is more than 9 errors.
                firebugButton.setAttribute("errorCount", "0");
            }
        }
    },
});

// ********************************************************************************************* //
// Registration

Firebug.registerModule(Firebug.StartButton);

// ********************************************************************************************* //
}});
{'fraction_non_alphanumeric': 0.18743743743743743, 'fraction_numerical': 0.0031698365031698366, 'mean_word_length': 2.203045685279188, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2012642', 'n_tokens_mistral': 3305, 'n_tokens_neox': 3167, 'n_words': 761}