Permalink
Browse files

The "show hints" checkbox now uses Preferences to store its state.

  • Loading branch information...
1 parent 11b48a4 commit 960cdc6ca8309feaeeacaa940cb94a3ab630ed55 @toolness toolness committed Aug 20, 2012
Showing with 18 additions and 31 deletions.
  1. +8 −23 js/fc/ui/context-sensitive-help.js
  2. +10 −8 js/fc/ui/editor-toolbar.js
@@ -4,10 +4,9 @@
// the current cursor position.
define([
"jquery",
- "underscore",
- "backbone",
+ "fc/prefs",
"./mark-tracker"
-], function($, _, Backbone, MarkTracker) {
+], function($, Preferences, MarkTracker) {
return function ContextSensitiveHelp(options) {
var self = {};
var codeMirror = options.codeMirror;
@@ -18,7 +17,6 @@ define([
var lastEvent = null;
var timeout = null;
var lastHelp = null;
- var isEnabled = true;
var HELP_DISPLAY_DELAY = 250;
// The escape key should close hints
@@ -84,7 +82,7 @@ define([
codeMirror.on("cursor-activity", function() {
clearTimeout(timeout);
- if (!isEnabled)
+ if (Preferences.get("showHints") === false)
return;
// If the editor widget doesn't have input focus, this event
@@ -109,25 +107,12 @@ define([
}
});
- self.isEnabled = function() {
- return isEnabled;
- };
-
- self.setEnabled = function(value) {
- if (isEnabled != value) {
- isEnabled = value;
- if (!isEnabled)
- clearHelp();
- self.trigger("set-enabled", isEnabled);
- }
- };
-
- self.toggleEnabled = function() {
- self.setEnabled(!isEnabled);
- };
-
- _.extend(self, Backbone.Events);
+ Preferences.on("change:showHints", function() {
+ if (Preferences.get("showHints") === false)
+ clearHelp();
+ });
+ Preferences.trigger("change:showHints");
return self;
};
});
@@ -1,26 +1,29 @@
define(function(require) {
var $ = require("jquery-tipsy"),
+ Preferences = require("fc/prefs"),
HistoryUI = require("fc/ui/history"),
NavOptionsTemplate = require("template!nav-options"),
TextUI = require("fc/ui/text");
function HintsUI(options) {
var self = {},
- cursorHelp = options.cursorHelp,
hintsNavItem = options.navItem,
hintsCheckbox = hintsNavItem.find(".checkbox");
- function onChange() {
- if (!this.isEnabled())
+ Preferences.on("change:showHints", function() {
+ if (Preferences.get("showHints") === false)
hintsCheckbox.removeClass("on").addClass("off");
else
hintsCheckbox.removeClass("off").addClass("on");
- }
+ });
- cursorHelp.on("set-enabled", onChange);
- hintsNavItem.click(function() { cursorHelp.toggleEnabled(); });
- onChange.call(cursorHelp);
+ hintsNavItem.click(function() {
+ var isDisabled = (Preferences.get("showHints") === false);
+ Preferences.set("showHints", isDisabled);
+ Preferences.save();
+ });
+ Preferences.trigger("change:showHints");
return self;
}
@@ -43,7 +46,6 @@ define(function(require) {
navItem: navOptions.find(".text-nav-item")
});
var hintsUI = HintsUI({
- cursorHelp: editor.cursorHelp,
navItem: navOptions.find(".hints-nav-item")
});

0 comments on commit 960cdc6

Please sign in to comment.