Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Fix for issue #1561 #1707

Merged
merged 7 commits into from
Oct 3, 2012
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions src/LiveDevelopment/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ define(function main(require, exports, module) {
function _handleGoLiveCommand() {
if (LiveDevelopment.status >= LiveDevelopment.STATUS_CONNECTING) {
LiveDevelopment.close();
// TODO Ty: when checkmark support lands, remove checkmark
} else {
if (!params.get("skipLiveDevelopmentInfo") && !prefs.getValue("afterFirstLaunch")) {
prefs.setValue("afterFirstLaunch", "true");
Expand All @@ -132,7 +131,6 @@ define(function main(require, exports, module) {
} else {
LiveDevelopment.open();
}
// TODO Ty: when checkmark support lands, add checkmark
}
}

Expand All @@ -155,6 +153,20 @@ define(function main(require, exports, module) {
// Initialize tooltip for 'not connected' state
_setLabel(_$btnGoLive, null, _statusStyle[1], _statusTooltip[1]);
}

/** Maintains state of the menu item */
function _setupGoLiveMenu() {
$(LiveDevelopment).on("statusChange", function statusChange(event, status) {
// Update the checkmark next to 'Live Preview' menu item
// Add checkmark when status is STATUS_ACTIVE
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the following logic is simple, it would be cleaner to replace the whole if statement with:

CommandManager.get(Commands.FILE_LIVE_FILE_PREVIEW).setChecked(status === LiveDevelopment.STATUS_ACTIVE);

if (status === LiveDevelopment.STATUS_ACTIVE) {
CommandManager.get(Commands.FILE_LIVE_FILE_PREVIEW).setChecked(true);
} else {
// Remove checkmark in all other cases
CommandManager.get(Commands.FILE_LIVE_FILE_PREVIEW).setChecked(false);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only show the checkmark when the status is STATUS_ACTIVE, then you could just remove it in all other cases.

}
});
}

/** Create the menu item "Highlight" */
function _setupHighlightButton() {
Expand Down Expand Up @@ -191,6 +203,8 @@ define(function main(require, exports, module) {
LiveDevelopment.init(config);
_loadStyles();
_setupGoLiveButton();
_setupGoLiveMenu();

/* _setupHighlightButton(); FUTURE - Highlight button */
if (config.debug) {
_setupDebugHelpers();
Expand All @@ -211,7 +225,7 @@ define(function main(require, exports, module) {
}
}
window.setTimeout(init);

CommandManager.register(Strings.CMD_LIVE_FILE_PREVIEW, Commands.FILE_LIVE_FILE_PREVIEW, _handleGoLiveCommand);

// Export public functions
Expand Down