Modules (188)

StatusBar

Description

A status bar with support for file information and busy and status indicators. This is a semi-generic container; for the code that decides what content appears in the status bar, see client modules like EditorStatusBar. (Although in practice StatusBar's HTML structure and initialization assume it's only used for this one purpose, and all the APIs are on a singleton).

Dependencies

Functions

Public API

addIndicator

Registers a new status indicator

id string
Registration id of the indicator to be updated.
indicator optional (DOMNode, jQueryObject)
Optional DOMNode for the indicator
visible optional boolean
Shows or hides the indicator over the statusbar.
style optional string
Sets the attribute "class" of the indicator.
tooltip optional string
Sets the attribute "title" of the indicator.
insertBefore optional string
An id of an existing status bar indicator. The new indicator will be inserted before (i.e. to the left of) the indicator specified by this parameter.
    function addIndicator(id, indicator, visible, style, tooltip, insertBefore) {
        if (!_init) {
            console.error("StatusBar API invoked before status bar created");
            return;
        }

        indicator = indicator || window.document.createElement("div");
        tooltip = tooltip || "";
        style = style || "";
        id = id.replace(_indicatorIDRegexp, "-") || "";

        var $indicator = $(indicator);

        $indicator.attr("id", id);
        $indicator.attr("title", tooltip);
        $indicator.addClass("indicator");
        $indicator.addClass(style);

        if (!visible) {
            $indicator.hide();
        }

        // This code looks backwards because the DOM model is ordered
        // top-to-bottom but the UI view is ordered right-to-left. The concept
        // of "before" in the model is "after" in the view, and vice versa.
        if (insertBefore && $("#" + insertBefore).length > 0) {
            $indicator.insertAfter("#" + insertBefore);
        } else {
            // No positioning is provided, put on left end of indicators, but
            // to right of "busy" indicator (which is usually hidden).
            var $busyIndicator = $("#status-bar .spinner");
            $indicator.insertBefore($busyIndicator);
        }
    }
Public API

hide

Hide the statusbar

    function hide() {
        if (!_init) {
            console.error("StatusBar API invoked before status bar created");
            return;
        }

        if ($statusBar.is(":visible")) {
            $statusBar.hide();
            WorkspaceManager.recomputeLayout();
        }
    }
Public API

hideAllPanes

Hides all panels but not the status bar

    function hideAllPanes() {
        hideInformation();
        hideIndicators();
    }
Public API

hideBusyIndicator

Hides the 'busy' indicator

    function hideBusyIndicator() {
        if (!_init) {
            console.error("StatusBar API invoked before status bar created");
            return;
        }

        // Check if we are using the busyCursor class to avoid
        // unnecesary calls to $('*').removeClass()
        if (_busyCursor) {
            _busyCursor = false;
            $("*").removeClass("busyCursor");
        }

        $busyIndicator.removeClass("spin");
    }
Public API

hideIndicators

Hide the statusbar Indicators

    function hideIndicators() {
        $indicators.css("display", "none");
    }
Public API

hideInformation

Hide the statusbar Information Panel

    function hideInformation() {
        $statusInfo.css("display", "none");
    }
Public API

show

Show the statusbar

    function show() {
        if (!_init) {
            console.error("StatusBar API invoked before status bar created");
            return;
        }

        if (!$statusBar.is(":visible")) {
            $statusBar.show();
            WorkspaceManager.recomputeLayout();
        }
    }

    AppInit.htmlReady(function () {
        var $parent = $(".main-view .content");
        $parent.append(Mustache.render(StatusBarHTML, Strings));

        // Initialize items dependent on HTML DOM
        $statusBar          = $("#status-bar");
        $indicators         = $("#status-indicators");
        $busyIndicator      = $("#status-bar .spinner");
        $statusInfo         = $("#status-info");

        _init = true;

        // hide on init
        hide();
    });

    exports.hideInformation   = hideInformation;
    exports.showInformation   = showInformation;
    exports.showBusyIndicator = showBusyIndicator;
    exports.hideBusyIndicator = hideBusyIndicator;
    exports.hideIndicators    = hideIndicators;
    exports.showIndicators    = showIndicators;
    exports.hideAllPanes      = hideAllPanes;
    exports.showAllPanes      = showAllPanes;
    exports.addIndicator      = addIndicator;
    exports.updateIndicator   = updateIndicator;
    exports.hide              = hide;
    exports.show              = show;
});
Public API

showAllPanes

Shows all panels (will not show a hidden statusbar)

    function showAllPanes() {
        showInformation();
        showIndicators();
    }
Public API

showBusyIndicator

Shows the 'busy' indicator

updateCursor boolean
Sets the cursor to "wait"
    function showBusyIndicator(updateCursor) {
        if (!_init) {
            console.error("StatusBar API invoked before status bar created");
            return;
        }

        if (updateCursor) {
            _busyCursor = true;
            $("*").addClass("busyCursor");
        }

        $busyIndicator.addClass("spin");
    }
Public API

showIndicators

Show the statusbar Indicators

    function showIndicators() {
        $indicators.css("display", "");
    }
Public API

showInformation

Show the statusbar Information Panel

    function showInformation() {
        $statusInfo.css("display", "");
    }
Public API

updateIndicator

Updates a status indicator

id string
Registration id of the indicator to be updated.
visible boolean
Shows or hides the indicator over the statusbar.
style optional string
Sets the attribute "class" of the indicator.
tooltip optional string
Sets the attribute "title" of the indicator.
    function updateIndicator(id, visible, style, tooltip) {
        if (!_init && !!brackets.test) {
            console.error("StatusBar API invoked before status bar created");
            return;
        }

        var $indicator = $("#" + id.replace(_indicatorIDRegexp, "-"));

        if ($indicator) {

            if (visible) {
                $indicator.show();
            } else {
                $indicator.hide();
            }

            if (style) {
                $indicator.removeClass();
                $indicator.addClass(style);
            } else {
                $indicator.removeClass();
                $indicator.addClass("indicator");
            }

            if (tooltip) {
                $indicator.attr("title", tooltip);
            }
        }
    }