Modules (181)

NativeApp

Description

Dependencies

Functions

Private

_browserErrToFileError

    function _browserErrToFileError(err) {
        if (err === brackets.fs.ERR_NOT_FOUND) {
            return FileSystemError.NOT_FOUND;
        }

        // All other errors are mapped to the generic "unknown" error
        return FileSystemError.UNKNOWN;
    }

    var liveBrowserOpenedPIDs = [];
Public API

closeAllLiveBrowsers

closeAllLiveBrowsers Closes all the browsers that were tracked on open TODO: does not seem to work on Windows

Returns:
$.Promise
    function closeAllLiveBrowsers() {
        //make a copy incase the array is edited as we iterate
        var closeIDs = liveBrowserOpenedPIDs.concat();
        return Async.doSequentially(closeIDs, closeLiveBrowser, false);
    }
Public API

closeLiveBrowser

closeLiveBrowser

Returns:
$.Promise
    function closeLiveBrowser(pid) {
        var result = new $.Deferred();

        if (isNaN(pid)) {
            pid = 0;
        }
        brackets.app.closeLiveBrowser(function (err) {
            if (!err) {
                var i = liveBrowserOpenedPIDs.indexOf(pid);
                if (i !== -1) {
                    liveBrowserOpenedPIDs.splice(i, 1);
                }
                result.resolve();
            } else {
                result.reject(_browserErrToFileError(err));
            }
        }, pid);

        return result.promise();
    }
Public API

openLiveBrowser

openLiveBrowser Open the given URL in the user's system browser, optionally enabling debugging.

url
string
The URL to open.
enableRemoteDebugging
optional
boolean
Whether to turn on remote debugging. Default false.
Returns:
$.Promise
    function openLiveBrowser(url, enableRemoteDebugging) {
        var result = new $.Deferred();

        brackets.app.openLiveBrowser(url, !!enableRemoteDebugging, function onRun(err, pid) {
            if (!err) {
                // Undefined ids never get removed from list, so don't push them on
                if (pid !== undefined) {
                    liveBrowserOpenedPIDs.push(pid);
                }
                result.resolve(pid);
            } else {
                result.reject(_browserErrToFileError(err));
            }
        });

        return result.promise();
    }
Public API

openURLInDefaultBrowser

Opens a URL in the system default browser

    function openURLInDefaultBrowser(url) {
        brackets.app.openURLInDefaultBrowser(url);
    }


    // Define public API
    exports.openLiveBrowser = openLiveBrowser;
    exports.closeLiveBrowser = closeLiveBrowser;
    exports.closeAllLiveBrowsers = closeAllLiveBrowsers;
    exports.openURLInDefaultBrowser = openURLInDefaultBrowser;
});