it("should create a parameter object and get three parameters", function () { params.parse("http://www.brackets.io?one=1&two=true&three=foobar"); expect(params.get("one")).toEqual("1"); expect(params.get("two")).toEqual("true"); expect(params.get("three")).toEqual("foobar"); });
it("should create a parameter object with no parameters", function () { params.parse("http://www.brackets.io"); expect(params.get("one")).toBeUndefined(); expect(params.get("two")).toBeUndefined(); expect(params.get("three")).toBeUndefined(); });
it("should parse a random number (used to circumvent browser cache)", function () { params.parse("http://www.brackets.io?28945893575608"); expect(params.get("28945893575608")).toEqual(""); expect(params.isEmpty()).toBeFalsy(); expect(params.toString()).toEqual("28945893575608="); });
it("should create a parameter object with three parameters with empty string values", function () { params.parse("http://www.brackets.io?one&two&three"); expect(params.get("one")).toEqual(""); expect(params.get("two")).toEqual(""); expect(params.get("three")).toEqual(""); });
/** * Load extensions. * * @param {?Array.<string>} A list containing references to extension source * location. A source location may be either (a) a folder name inside * src/extensions or (b) an absolute path. * @return {!$.Promise} A promise object that is resolved when all extensions complete loading. */ function init(paths) { var params = new UrlParams(); if (_init) { // Only init once. Return a resolved promise. return new $.Deferred().resolve().promise(); } if (!paths) { params.parse(); if (params.get("reloadWithoutUserExts") === "true") { paths = ["default"]; } else { paths = [ getDefaultExtensionPath(), "dev", getUserExtensionPath() ]; } } // Load extensions before restoring the project // Get a Directory for the user extension directory and create it if it doesn't exist. // Note that this is an async call and there are no success or failure functions passed // in. If the directory *doesn't* exist, it will be created. Extension loading may happen // before the directory is finished being created, but that is okay, since the extension // loading will work correctly without this directory. // If the directory *does* exist, nothing else needs to be done. It will be scanned normally // during extension loading. var extensionPath = getUserExtensionPath(); FileSystem.getDirectoryForPath(extensionPath).create(); // Create the extensions/disabled directory, too. var disabledExtensionPath = extensionPath.replace(/\/user$/, "/disabled"); FileSystem.getDirectoryForPath(disabledExtensionPath).create(); var promise = Async.doSequentially(paths, function (item) { var extensionPath = item; // If the item has "/" in it, assume it is a full path. Otherwise, load // from our source path + "/extensions/". if (item.indexOf("/") === -1) { extensionPath = FileUtils.getNativeBracketsDirectoryPath() + "/extensions/" + item; } return loadAllExtensionsInNativeDirectory(extensionPath); }, false); promise.always(function () { _init = true; }); return promise; }
AppInit.extensionsLoaded(function () { var params = new UrlParams(); params.parse(); if (params.get("reloadWithoutUserExts") === "true") { _showErrors = false; } _initCommandAndKeyMaps(); _loadUserKeyMap(); });
describe("Parse and Get URL parameters", function () { var params = new UrlParams(); it("should create a parameter object and get three parameters", function () { params.parse("http://www.brackets.io?one=1&two=true&three=foobar"); expect(params.get("one")).toEqual("1"); expect(params.get("two")).toEqual("true"); expect(params.get("three")).toEqual("foobar"); }); it("should create a parameter object with three parameters with empty string values", function () { params.parse("http://www.brackets.io?one&two&three"); expect(params.get("one")).toEqual(""); expect(params.get("two")).toEqual(""); expect(params.get("three")).toEqual(""); }); it("should create a parameter object with no parameters", function () { params.parse("http://www.brackets.io"); expect(params.get("one")).toBeUndefined(); expect(params.get("two")).toBeUndefined(); expect(params.get("three")).toBeUndefined(); }); });
describe("Test for malformed or unusual query strings", function () { var params = new UrlParams(); it("should parse a missing query string as an empty object", function () { params.parse("http://www.brackets.io?"); expect(params.isEmpty()).toBeTruthy(); expect(params.toString()).toEqual(""); }); it("should parse a query string of whitespace as an empty object", function () { params.parse("http://www.brackets.io? "); expect(params.isEmpty()).toBeTruthy(); expect(params.toString()).toEqual(""); }); it("should parse a random number (used to circumvent browser cache)", function () { params.parse("http://www.brackets.io?28945893575608"); expect(params.get("28945893575608")).toEqual(""); expect(params.isEmpty()).toBeFalsy(); expect(params.toString()).toEqual("28945893575608="); }); });
/** Initialize LiveDevelopment */ function init() { prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_KEY); params.parse(); Inspector.init(config); LiveDevelopment.init(config); _loadStyles(); _setupGoLiveButton(); _setupGoLiveMenu(); /* _setupHighlightButton(); FUTURE - Highlight button */ if (config.debug) { _setupDebugHelpers(); } // trigger autoconnect if (config.autoconnect && window.sessionStorage.getItem("live.enabled") === "true") { AppInit.appReady(function () { if (DocumentManager.getCurrentDocument()) { _handleGoLiveCommand(); } else { $(DocumentManager).on("currentDocumentChange", _handleGoLiveCommand); window.setTimeout(function () { $(DocumentManager).off("currentDocumentChange", _handleGoLiveCommand); }, 200); } }); } }
AppInit.appReady(function () { params.parse(); Inspector.init(config); LiveDevelopment.init(config); _loadStyles(); _setupGoLiveButton(); _setupGoLiveMenu(); _updateHighlightCheckmark(); if (config.debug) { _setupDebugHelpers(); } // trigger autoconnect if (config.autoconnect && window.sessionStorage.getItem("live.enabled") === "true" && DocumentManager.getCurrentDocument()) { _handleGoLiveCommand(); } // Redraw highlights when window gets focus. This ensures that the highlights // will be in sync with any DOM changes that may have occurred. $(window).focus(function () { if (Inspector.connected() && config.highlight) { LiveDevelopment.redrawHighlight(); } }); });
// TODO: (issue 1029) Add timeout to main extension loading promise, so that we always call this function // Making this fix will fix a warning (search for issue 1029) related to the global brackets 'ready' event. function _initExtensions() { // allow unit tests to override which plugin folder(s) to load var paths = params.get("extensions"); if (!paths) { paths = "default,dev," + _getUserExtensionPath(); } return Async.doInParallel(paths.split(","), function (item) { var extensionPath, relativePath; // If the item has "/" in it, assume it is a full path. Otherwise, load // from our source path + "/extensions/". if (item.indexOf("/") === -1) { extensionPath = FileUtils.getNativeBracketsDirectoryPath() + "/extensions/" + item; relativePath = "extensions/" + item; } else { extensionPath = item; relativePath = PathUtils.makePathRelative(extensionPath, FileUtils.getNativeBracketsDirectoryPath() + "/"); } return ExtensionLoader.loadAllExtensionsInNativeDirectory( extensionPath, relativePath ); }); }
ProjectManager.openProject(initialProjectPath).always(function () { _initTest(); // WARNING: AppInit.appReady won't fire if ANY extension fails to // load or throws an error during init. To fix this, we need to // make a change to _initExtensions (filed as issue 1029) _initExtensions().always(function () { AppInit._dispatchReady(AppInit.APP_READY); }); // If this is the first launch, and we have an index.html file in the project folder (which should be // the samples folder on first launch), open it automatically. (We explicitly check for the // samples folder in case this is the first time we're launching Brackets after upgrading from // an old version that might not have set the "afterFirstLaunch" pref.) var prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_CLIENT_ID); if (!params.get("skipSampleProjectLoad") && !prefs.getValue("afterFirstLaunch")) { prefs.setValue("afterFirstLaunch", "true"); if (ProjectManager.isWelcomeProjectPath(initialProjectPath)) { var dirEntry = new NativeFileSystem.DirectoryEntry(initialProjectPath); dirEntry.getFile("index.html", {}, function (fileEntry) { CommandManager.execute(Commands.FILE_ADD_TO_WORKING_SET, { fullPath: fileEntry.fullPath }); }); } } });
ProjectManager.openProject(initialProjectPath).always(function () { _initTest(); // Create a new DirectoryEntry and call getDirectory() on the user extension // directory. If the directory doesn't exist, it will be created. // Note that this is an async call and there are no success or failure functions passed // in. If the directory *doesn't* exist, it will be created. Extension loading may happen // before the directory is finished being created, but that is okay, since the extension // loading will work correctly without this directory. // If the directory *does* exist, nothing else needs to be done. It will be scanned normally // during extension loading. new NativeFileSystem.DirectoryEntry().getDirectory(_getUserExtensionPath(), {create: true}); // WARNING: AppInit.appReady won't fire if ANY extension fails to // load or throws an error during init. To fix this, we need to // make a change to _initExtensions (filed as issue 1029) _initExtensions().always(function () { AppInit._dispatchReady(AppInit.APP_READY); }); // If this is the first launch, and we have an index.html file in the project folder (which should be // the samples folder on first launch), open it automatically. (We explicitly check for the // samples folder in case this is the first time we're launching Brackets after upgrading from // an old version that might not have set the "afterFirstLaunch" pref.) var prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_CLIENT_ID); if (!params.get("skipSampleProjectLoad") && !prefs.getValue("afterFirstLaunch")) { prefs.setValue("afterFirstLaunch", "true"); if (ProjectManager.isWelcomeProjectPath(initialProjectPath)) { var dirEntry = new NativeFileSystem.DirectoryEntry(initialProjectPath); dirEntry.getFile("index.html", {}, function (fileEntry) { CommandManager.execute(Commands.FILE_ADD_TO_WORKING_SET, { fullPath: fileEntry.fullPath }); }); } } });
LanguageManager.ready.always(function () { // Load all extensions. This promise will complete even if one or more // extensions fail to load. var extensionLoaderPromise = ExtensionLoader.init(params.get("extensions")); // Load the initial project after extensions have loaded extensionLoaderPromise.always(function () { // Finish UI initialization var initialProjectPath = ProjectManager.getInitialProjectPath(); ProjectManager.openProject(initialProjectPath).always(function () { _initTest(); // If this is the first launch, and we have an index.html file in the project folder (which should be // the samples folder on first launch), open it automatically. (We explicitly check for the // samples folder in case this is the first time we're launching Brackets after upgrading from // an old version that might not have set the "afterFirstLaunch" pref.) var prefs = PreferencesManager.getPreferenceStorage(module), deferred = new $.Deferred(); //TODO: Remove preferences migration code PreferencesManager.handleClientIdChange(prefs, "com.adobe.brackets.startup"); if (!params.get("skipSampleProjectLoad") && !prefs.getValue("afterFirstLaunch")) { prefs.setValue("afterFirstLaunch", "true"); if (ProjectManager.isWelcomeProjectPath(initialProjectPath)) { var dirEntry = new NativeFileSystem.DirectoryEntry(initialProjectPath); dirEntry.getFile("index.html", {}, function (fileEntry) { var promise = CommandManager.execute(Commands.FILE_ADD_TO_WORKING_SET, { fullPath: fileEntry.fullPath }); promise.pipe(deferred.resolve, deferred.reject); }, deferred.reject); } else { deferred.resolve(); } } else { deferred.resolve(); } deferred.always(function () { // Signal that Brackets is loaded AppInit._dispatchReady(AppInit.APP_READY); PerfUtils.addMeasurement("Application Startup"); }); // See if any startup files were passed to the application if (brackets.app.getPendingFilesToOpen) { brackets.app.getPendingFilesToOpen(function (err, files) { files.forEach(function (filename) { CommandManager.execute(Commands.FILE_OPEN, { fullPath: filename }); }); }); } }); }); });
it("should remove parameter one", function () { params.parse("http://www.brackets.io?one=1&two=true&three=foobar"); expect(params.get("one")).toEqual("1"); expect(params.get("two")).toEqual("true"); expect(params.get("three")).toEqual("foobar"); params.remove("one"); expect(params.get("one")).toBeUndefined(); expect(params.get("two")).toEqual("true"); expect(params.get("three")).toEqual("foobar"); });
LanguageManager.ready.always(function () { // Load all extensions. This promise will complete even if one or more // extensions fail to load. var extensionPathOverride = params.get("extensions"); // used by unit tests var extensionLoaderPromise = ExtensionLoader.init(extensionPathOverride ? extensionPathOverride.split(",") : null); // Load the initial project after extensions have loaded extensionLoaderPromise.always(function () { // Finish UI initialization var initialProjectPath = ProjectManager.getInitialProjectPath(); ProjectManager.openProject(initialProjectPath).always(function () { _initTest(); // If this is the first launch, and we have an index.html file in the project folder (which should be // the samples folder on first launch), open it automatically. (We explicitly check for the // samples folder in case this is the first time we're launching Brackets after upgrading from // an old version that might not have set the "afterFirstLaunch" pref.) var prefs = PreferencesManager.getPreferenceStorage(module), deferred = new $.Deferred(); if (!params.get("skipSampleProjectLoad") && !prefs.getValue("afterFirstLaunch")) { prefs.setValue("afterFirstLaunch", "true"); if (ProjectManager.isWelcomeProjectPath(initialProjectPath)) { FileSystem.resolve(initialProjectPath + "index.html", function (err, file) { if (!err) { var promise = CommandManager.execute(Commands.FILE_ADD_TO_WORKING_SET, { fullPath: file.fullPath }); promise.then(deferred.resolve, deferred.reject); } else { deferred.reject(); } }); } else { deferred.resolve(); } } else { deferred.resolve(); } deferred.always(function () { // Signal that Brackets is loaded AppInit._dispatchReady(AppInit.APP_READY); PerfUtils.addMeasurement("Application Startup"); }); // See if any startup files were passed to the application if (brackets.app.getPendingFilesToOpen) { brackets.app.getPendingFilesToOpen(function (err, files) { DragAndDrop.openDroppedFiles(files); }); } }); }); });
function _onReady() { // Add the platform (mac or win) to the body tag so we can have platform-specific CSS rules $("body").addClass("platform-" + brackets.platform); EditorManager.setEditorHolder($("#editor-holder")); // Let the user know Brackets doesn't run in a web browser yet if (brackets.inBrowser) { Dialogs.showModalDialog( Dialogs.DIALOG_ID_ERROR, Strings.ERROR_BRACKETS_IN_BROWSER_TITLE, Strings.ERROR_BRACKETS_IN_BROWSER ); } _initDragAndDropListeners(); _initCommandHandlers(); KeyBindingManager.init(); Menus.init(); // key bindings should be initialized first _initWindowListeners(); // Read "build number" SHAs off disk at the time the matching Brackets JS code is being loaded, instead // of later, when they may have been updated to a different version BuildInfoUtils.init(); // Use quiet scrollbars if we aren't on Lion. If we're on Lion, only // use native scroll bars when the mouse is not plugged in or when // using the "Always" scroll bar setting. var osxMatch = /Mac OS X 10\D([\d+])\D/.exec(navigator.userAgent); if (osxMatch && osxMatch[1] && Number(osxMatch[1]) >= 7) { // test a scrolling div for scrollbars var $testDiv = $("<div style='position:fixed;left:-50px;width:50px;height:50px;overflow:auto;'><div style='width:100px;height:100px;'/></div>").appendTo(window.document.body); if ($testDiv.outerWidth() === $testDiv.get(0).clientWidth) { $(".sidebar").removeClass("quiet-scrollbars"); } $testDiv.remove(); } PerfUtils.addMeasurement("Application Startup"); // finish UI initialization before loading extensions var initialProjectPath = ProjectManager.getInitialProjectPath(); ProjectManager.openProject(initialProjectPath).done(function () { _initTest(); _initExtensions().always(_onBracketsReady); }); // Check for updates if (!params.get("skipUpdateCheck")) { UpdateNotification.checkForUpdate(); } }
it("should change the value of parameter two", function () { params.parse("http://www.brackets.io?one=1&two=true&three=foobar"); expect(params.get("one")).toEqual("1"); expect(params.get("two")).toEqual("true"); expect(params.get("three")).toEqual("foobar"); params.put("two", "false"); expect(params.get("one")).toEqual("1"); expect(params.get("two")).toEqual("false"); expect(params.get("three")).toEqual("foobar"); });
it("should put a new parameter three in the list", function () { params.parse("http://www.brackets.io?one=1&two=true"); expect(params.get("one")).toEqual("1"); expect(params.get("two")).toEqual("true"); expect(params.get("three")).toBeUndefined(); params.put("three", "foobar"); expect(params.get("one")).toEqual("1"); expect(params.get("two")).toEqual("true"); expect(params.get("three")).toEqual("foobar"); });
// TODO: (issue 1029) Add timeout to main extension loading promise, so that we always call this function // Making this fix will fix a warning (search for issue 1029) related to the global brackets 'ready' event. function _initExtensions() { // allow unit tests to override which plugin folder(s) to load var paths = params.get("extensions") || "default,user"; return Async.doInParallel(paths.split(","), function (item) { return ExtensionLoader.loadAllExtensionsInNativeDirectory( FileUtils.getNativeBracketsDirectoryPath() + "/extensions/" + item, "extensions/" + item ); }); }
ProjectManager.openProject(initialProjectPath).always(function () { _initTest(); // If this is the first launch, and we have an index.html file in the project folder (which should be // the samples folder on first launch), open it automatically. (We explicitly check for the // samples folder in case this is the first time we're launching Brackets after upgrading from // an old version that might not have set the "afterFirstLaunch" pref.) var deferred = new $.Deferred(); if (!params.get("skipSampleProjectLoad") && !PreferencesManager.getViewState("afterFirstLaunch")) { PreferencesManager.setViewState("afterFirstLaunch", "true"); if (ProjectManager.isWelcomeProjectPath(initialProjectPath)) { FileSystem.resolve(initialProjectPath + "index.html", function (err, file) { if (!err) { var promise = CommandManager.execute(Commands.FILE_ADD_TO_WORKING_SET, { fullPath: file.fullPath }); promise.then(deferred.resolve, deferred.reject); } else { deferred.reject(); } }); } else { deferred.resolve(); } } else { deferred.resolve(); } deferred.always(function () { // Signal that Brackets is loaded AppInit._dispatchReady(AppInit.APP_READY); PerfUtils.addMeasurement("Application Startup"); if (PreferencesManager._isUserScopeCorrupt()) { Dialogs.showModalDialog( DefaultDialogs.DIALOG_ID_ERROR, Strings.ERROR_PREFS_CORRUPT_TITLE, Strings.ERROR_PREFS_CORRUPT ) .done(function () { CommandManager.execute(Commands.FILE_OPEN_PREFERENCES); }); } }); // See if any startup files were passed to the application if (brackets.app.getPendingFilesToOpen) { brackets.app.getPendingFilesToOpen(function (err, files) { DragAndDrop.openDroppedFiles(files); }); } });
runs(function () { // Position popup windows in the lower right so they're out of the way var testWindowWid = 1000, testWindowHt = 700, testWindowX = window.screen.availWidth - testWindowWid, testWindowY = window.screen.availHeight - testWindowHt, optionsStr = "left=" + testWindowX + ",top=" + testWindowY + ",width=" + testWindowWid + ",height=" + testWindowHt; var params = new UrlParams(); // setup extension loading in the test window params.put("extensions", _doLoadExtensions ? "default,dev," + ExtensionLoader.getUserExtensionPath() : "default"); // disable update check in test windows params.put("skipUpdateCheck", true); // disable loading of sample project params.put("skipSampleProjectLoad", true); // disable initial dialog for live development params.put("skipLiveDevelopmentInfo", true); _testWindow = window.open(getBracketsSourceRoot() + "/index.html?" + params.toString(), "_blank", optionsStr); _testWindow.isBracketsTestWindow = true; _testWindow.executeCommand = function executeCommand(cmd, args) { return _testWindow.brackets.test.CommandManager.execute(cmd, args); }; });
_loadExtensionTests(suite).done(function () { var jasmineEnv = jasmine.getEnv(); // Initiailize unit test preferences for each spec beforeEach(function () { // Unique key for unit testing localStorage.setItem("preferencesKey", SpecRunnerUtils.TEST_PREFERENCES_KEY); }); afterEach(function () { // Clean up preferencesKey localStorage.removeItem("preferencesKey"); }); jasmineEnv.updateInterval = 1000; // Create the reporter, which is really a model class that just gathers // spec and performance data. reporter = new UnitTestReporter(jasmineEnv, topLevelFilter, params.get("spec")); // Optionally emit JSON for automated runs if (params.get("resultsPath")) { $(reporter).on("runnerEnd", _runnerEndHandler); } jasmineEnv.addReporter(reporter); // Create the view that displays the data from the reporter. (Usually in // Jasmine this is part of the reporter, but we separate them out so that // we can more easily grab just the model data for output during automatic // testing.) reporterView = new BootstrapReporterView(document, reporter); // remember the suite for the next unit test window launch localStorage.setItem("SpecRunner.suite", suite); $(window.document).ready(_documentReadyHandler); });
_loadExtensionTests(selectedSuites).done(function () { var jasmineEnv = jasmine.getEnv(); // Initiailize unit test preferences for each spec beforeEach(function () { // Unique key for unit testing localStorage.setItem("preferencesKey", SpecRunnerUtils.TEST_PREFERENCES_KEY); // Reset preferences from previous test runs localStorage.removeItem("doLoadPreferences"); localStorage.removeItem(SpecRunnerUtils.TEST_PREFERENCES_KEY); }); afterEach(function () { // Clean up preferencesKey localStorage.removeItem("preferencesKey"); }); jasmineEnv.updateInterval = 1000; // Create the reporter, which is really a model class that just gathers // spec and performance data. reporter = new UnitTestReporter(jasmineEnv, topLevelFilter, params.get("spec")); // Optionally emit JUnit XML file for automated runs if (resultsPath) { if (resultsPath.substr(-4) === ".xml") { _patchJUnitReporter(); jasmineEnv.addReporter(new jasmine.JUnitXmlReporter(null, true, false)); } // Close the window $(reporter).on("runnerEnd", _runnerEndHandler); } else { _writeResults.resolve(); } jasmineEnv.addReporter(reporter); // Create the view that displays the data from the reporter. (Usually in // Jasmine this is part of the reporter, but we separate them out so that // we can more easily grab just the model data for output during automatic // testing.) reporterView = new BootstrapReporterView(document, reporter); // remember the suite for the next unit test window launch localStorage.setItem("SpecRunner.suite", selectedSuites); $(window.document).ready(_documentReadyHandler); });
runs(function () { // Position popup windows in the lower right so they're out of the way var testWindowWid = 1000, testWindowHt = 700, testWindowX = window.screen.availWidth - testWindowWid, testWindowY = window.screen.availHeight - testWindowHt, optionsStr = "left=" + testWindowX + ",top=" + testWindowY + ",width=" + testWindowWid + ",height=" + testWindowHt; var params = new UrlParams(); // setup extension loading in the test window params.put("extensions", _doLoadExtensions ? "default,dev," + ExtensionLoader.getUserExtensionPath() : "default"); // disable update check in test windows params.put("skipUpdateCheck", true); // disable loading of sample project params.put("skipSampleProjectLoad", true); // disable initial dialog for live development params.put("skipLiveDevelopmentInfo", true); // option to launch test window with either native or HTML menus if (options && options.hasOwnProperty("hasNativeMenus")) { params.put("hasNativeMenus", (options.hasNativeMenus ? "true" : "false")); } _testWindow = window.open(getBracketsSourceRoot() + "/index.html?" + params.toString(), "_blank", optionsStr); _testWindow.isBracketsTestWindow = true; _testWindow.executeCommand = function executeCommand(cmd, args) { return _testWindow.brackets.test.CommandManager.execute(cmd, args); }; _testWindow.closeAllFiles = function closeAllFiles() { runs(function () { var promise = _testWindow.executeCommand(_testWindow.brackets.test.Commands.FILE_CLOSE_ALL); _testWindow.brackets.test.Dialogs.cancelModalDialogIfOpen( _testWindow.brackets.test.DefaultDialogs.DIALOG_ID_SAVE_CLOSE, _testWindow.brackets.test.DefaultDialogs.DIALOG_BTN_DONTSAVE ); waitsForDone(promise, "Close all open files in working set"); }); }; });
describe("Test for Empty parameter list", function () { var params = new UrlParams(); it("should show that the parameter object is empty", function () { params.parse("http://www.brackets.io"); expect(params.isEmpty()).toBeTruthy(); expect(params.toString()).toEqual(""); }); it("should show that the parameter object is NOT empty", function () { params.parse("http://www.brackets.io?one=1&two=true&three=foobar"); expect(params.isEmpty()).toBeFalsy(); expect(params.toString()).toNotEqual(""); }); });
/** Toggles LiveDevelopment and synchronizes the state of UI elements that reports LiveDevelopment status */ function _handleGoLiveCommand() { if (LiveDevelopment.status >= LiveDevelopment.STATUS_CONNECTING) { LiveDevelopment.close(); } else { if (!params.get("skipLiveDevelopmentInfo") && !prefs.getValue("afterFirstLaunch")) { prefs.setValue("afterFirstLaunch", "true"); Dialogs.showModalDialog( Dialogs.DIALOG_ID_INFO, Strings.LIVE_DEVELOPMENT_INFO_TITLE, Strings.LIVE_DEVELOPMENT_INFO_MESSAGE ).done(function (id) { LiveDevelopment.open(); }); } else { LiveDevelopment.open(); } } }
Async.waitForAll([LanguageManager.ready, PreferencesManager.ready]).always(function () { // Load all extensions. This promise will complete even if one or more // extensions fail to load. var extensionPathOverride = params.get("extensions"); // used by unit tests var extensionLoaderPromise = ExtensionLoader.init(extensionPathOverride ? extensionPathOverride.split(",") : null); // Load the initial project after extensions have loaded extensionLoaderPromise.always(function () { // Signal that extensions are loaded AppInit._dispatchReady(AppInit.EXTENSIONS_LOADED); // Finish UI initialization ViewCommandHandlers.restoreFontSize(); // XXXBramble: the project loading logic happens based on a message // from the hosting app. See extensions/default/bramble/main.js }); });
/** * Toggles LiveDevelopment and synchronizes the state of UI elements that reports LiveDevelopment status * * Stop Live Dev when in an active state (ACTIVE, OUT_OF_SYNC, SYNC_ERROR). * Start Live Dev when in an inactive state (ERROR, INACTIVE). * Do nothing when in a connecting state (CONNECTING, LOADING_AGENTS). */ function _handleGoLiveCommand() { if (LiveDevelopment.status >= LiveDevelopment.STATUS_ACTIVE) { LiveDevelopment.close(); } else if (LiveDevelopment.status <= LiveDevelopment.STATUS_INACTIVE) { if (!params.get("skipLiveDevelopmentInfo") && !PreferencesManager.getViewState("livedev.afterFirstLaunch")) { PreferencesManager.setViewState("livedev.afterFirstLaunch", "true"); Dialogs.showModalDialog( DefaultDialogs.DIALOG_ID_INFO, Strings.LIVE_DEVELOPMENT_INFO_TITLE, Strings.LIVE_DEVELOPMENT_INFO_MESSAGE ).done(function (id) { LiveDevelopment.open(); }); } else { LiveDevelopment.open(); } } }
ProjectManager.openProject(initialProjectPath).always(function () { _initTest(); // If this is the first launch, and we have an index.html file in the project folder (which should be // the samples folder on first launch), open it automatically. (We explicitly check for the // samples folder in case this is the first time we're launching Brackets after upgrading from // an old version that might not have set the "afterFirstLaunch" pref.) var prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_CLIENT_ID), deferred = new $.Deferred(); if (!params.get("skipSampleProjectLoad") && !prefs.getValue("afterFirstLaunch")) { prefs.setValue("afterFirstLaunch", "true"); if (ProjectManager.isWelcomeProjectPath(initialProjectPath)) { var dirEntry = new NativeFileSystem.DirectoryEntry(initialProjectPath); dirEntry.getFile("index.html", {}, function (fileEntry) { var promise = CommandManager.execute(Commands.FILE_ADD_TO_WORKING_SET, { fullPath: fileEntry.fullPath }); promise.pipe(deferred.resolve, deferred.reject); }, deferred.reject); } else { deferred.resolve(); } } else { deferred.resolve(); } deferred.always(function () { // Signal that Brackets is loaded AppInit._dispatchReady(AppInit.APP_READY); PerfUtils.addMeasurement("Application Startup"); }); // See if any startup files were passed to the application if (brackets.app.getPendingFilesToOpen) { brackets.app.getPendingFilesToOpen(function (err, files) { files.forEach(function (filename) { CommandManager.execute(Commands.FILE_OPEN, { fullPath: filename }); }); }); } });