New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lintingrefactoring #1808

Closed
wants to merge 21 commits into
base: master
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+28 −6
Diff settings

Always

Just for now

Viewing a subset of changes. View all

enabled preferences to save linting enabled state

  • Loading branch information...
mikechambers committed Oct 9, 2012
commit cfaebe774e3c6c68431839e01d7d4c6dab0e58ed
@@ -12,6 +12,7 @@ define(function (require, exports, module) {
var BottomPanel = brackets.getModule("widgets/BottomPanel");
var AppInit = brackets.getModule("utils/AppInit");
var StatusBar = brackets.getModule("widgets/StatusBar");
var PreferencesManager = brackets.getModule("preferences/PreferencesManager");
//todo: readd scrolling code
//todo: save enabled settings and update menu
@@ -22,8 +23,13 @@ define(function (require, exports, module) {
var DOCUMENT_SAVED = "documentSaved";
var CURRENT_DOCUMENT_CHANGED = "currentDocumentChange";
var id = "brackets.linter";
var LINTER = "LINTER";
var _prefs;
var command;
//whether or not linting is enabled
var enabled = true;
@@ -161,9 +167,26 @@ define(function (require, exports, module) {
_lintCurrentDocument();
}
function _initPrefs() {
_prefs = PreferencesManager.getPreferenceStorage(id, { enabled: true });
enabled = _prefs.getValue("enabled");
command.setChecked(enabled);
}
function _initMenu() {
var menu = Menus.getMenu(Menus.AppMenuBar.VIEW_MENU);
menu.addMenuDivider();
menu.addMenuItem(LINTER);
}
function _toggleLinting() {
enabled = !enabled;
command.setChecked(enabled);
_prefs.setValue("enabled", enabled);
if (enabled) {
$(DocumentManager).on(DOCUMENT_SAVED + " " + CURRENT_DOCUMENT_CHANGED, _onDocumentUpdated);
} else {
@@ -173,11 +196,10 @@ define(function (require, exports, module) {
//todo: externalize this for localization?
//todo: What tense should the menu item be?
CommandManager.register("Enable Linting", LINTER, _toggleLinting);
command = CommandManager.register("Enable Linting", LINTER, _toggleLinting);
var menu = Menus.getMenu(Menus.AppMenuBar.VIEW_MENU);
menu.addMenuDivider();
menu.addMenuItem(LINTER);
_initMenu();
_initPrefs();
//todo: need to pull preference on whether linting is enabled, and only
//register for this if it is enabled
@@ -189,7 +211,7 @@ define(function (require, exports, module) {
}
AppInit.htmlReady(function () {
StatusBar.addIndicator(module.id, $("#gold-star"), false);
StatusBar.addIndicator(id, $("#gold-star"), false);
});
exports.lintDocument = lintDocument;
@@ -14,7 +14,7 @@ define(function (require, exports, module) {
var close = function() {
console.log("close");
};
*/
*/
function clearContent() {
$("#bottom-panel").empty();
ProTip! Use n and p to navigate between commits in a pull request.