diff --git a/README.md b/README.md index 3aa81231f74..a0d9c4f3d02 100644 --- a/README.md +++ b/README.md @@ -310,6 +310,7 @@ a number of read-only getters are available in order to access state information * `getTheme()` - returns the name of the current theme. * `getFontSize()` - returns the current font size as a string (e.g., `"12px"`). * `getWordWrap()` - returns the current word wrap setting as a `Boolean` (i.e., enabled or disabled). +* `getAutocomplete()` - returns the current autocomplete settings as a `Boolean` (i.e., enabled or disabled). * `getAutoCloseTags()` - returns the current close tags setting as an `Object` with three properties: `whenOpening` a boolean that determines whether opening tags are closed upon typing ">", `whenClosing` a boolean that determines whether closing tags are closed upon typing "/", and an array of tags `indentTags`, that when opened, has a blank line. These values default to, respectively: `true`, `true`, and an empty array. * `getTutorialExists()` - returns `true` or `false` depending on whether or not there is a tutorial in the project (i.e., if `tutorial.html` is present) * `getTutorialVisible()` - returns `true` or `false` depending on whether or not the preview browser is showing a tutorial or not. diff --git a/src/bramble/client/StateManager.js b/src/bramble/client/StateManager.js index 97189ffce3b..968539cb758 100644 --- a/src/bramble/client/StateManager.js +++ b/src/bramble/client/StateManager.js @@ -139,6 +139,10 @@ define(function() { get: function() { return getBool(storage, "allowJavaScript"); }, set: function(v) { storage.setItem(prefix("allowJavaScript"), v); } }, + allowAutocomplete: { + get: function() { return getBool(storage, "allowAutocomplete"); }, + set: function(v) { storage.setItem(prefix("allowAutocomplete"), v); } + }, autoUpdate: { get: function() { return getBool(storage, "autoUpdate"); }, set: function(v) { storage.setItem(prefix("autoUpdate"), v); } diff --git a/src/bramble/client/main.js b/src/bramble/client/main.js index eb68d09c34e..c264bb8fb58 100644 --- a/src/bramble/client/main.js +++ b/src/bramble/client/main.js @@ -204,6 +204,7 @@ define([ self.getSidebarVisible = function() { return _state.sidebarVisible; }; self.getRootDir = function() { return _root; }; self.getWordWrap = function() { return _state.wordWrap; }; + self.getAutocomplete = function() { return _state.allowAutocomplete; }; self.getAutoCloseTags = function() { return _state.autoCloseTags; }; self.getAllowJavaScript = function() { return _state.allowJavaScript; }; self.getAutoUpdate = function() { return _state.autoUpdate; }; @@ -267,6 +268,7 @@ define([ _state.wordWrap = data.wordWrap; _state.autoCloseTags = data.autoCloseTags; _state.allowJavaScript = data.allowJavaScript; + _state.autocomplete = data.autocomplete; _state.autoUpdate = data.autoUpdate; setReadyState(Bramble.READY); @@ -309,6 +311,8 @@ define([ _state.allowJavaScript = data.allowJavaScript; } else if (eventName === "tutorialVisibilityChange") { _tutorialVisible = data.visible; + } else if (eventName === "autocompleteChange") { + _state.allowAutocomplete = data.value; } else if (eventName === "autoUpdateChange") { _state.autoUpdate = data.autoUpdate; } @@ -426,6 +430,7 @@ define([ previewMode: _state.previewMode, wordWrap: _state.wordWrap, allowJavaScript: _state.allowJavaScript, + allowAutocomplete: _state.allowAutocomplete, autoCloseTags: _state.autoCloseTags, autoUpdate: _state.autoUpdate } @@ -909,6 +914,14 @@ define([ this._executeRemoteCommand({commandCategory: "bramble", command: "BRAMBLE_DISABLE_SCRIPTS"}, callback); }; + BrambleProxy.prototype.enableAutocomplete = function(callback) { + this._executeRemoteCommand({commandCategory: "bramble", command: "BRAMBLE_ENABLE_AUTOCOMPLETE"}, callback); + }; + + BrambleProxy.prototype.disableAutocomplete = function(callback) { + this._executeRemoteCommand({commandCategory: "bramble", command: "BRAMBLE_DISABLE_AUTOCOMPLETE"}, callback); + }; + BrambleProxy.prototype.enableInspector = function(callback) { this._executeRemoteCommand({commandCategory: "bramble", command: "BRAMBLE_ENABLE_INSPECTOR"}, callback); }; diff --git a/src/extensions/default/bramble/lib/RemoteCommandHandler.js b/src/extensions/default/bramble/lib/RemoteCommandHandler.js index 3771c0b9e71..f74b7bc0fa5 100644 --- a/src/extensions/default/bramble/lib/RemoteCommandHandler.js +++ b/src/extensions/default/bramble/lib/RemoteCommandHandler.js @@ -102,6 +102,19 @@ define(function (require, exports, module) { case "BRAMBLE_ENABLE_INSPECTOR": MouseManager.enableInspector(); break; + case "BRAMBLE_ENABLE_AUTOCOMPLETE": + PreferencesManager.set("codehint.TagHints", true); + PreferencesManager.set("codehint.AttrHints", true); + PreferencesManager.set("codehint.JSHints", true); + PreferencesManager.set("codehint.CssPropHints", true); + break; + case "BRAMBLE_DISABLE_AUTOCOMPLETE": + PreferencesManager.set("codehint.TagHints", false); + PreferencesManager.set("codehint.AttrHints", false); + PreferencesManager.set("codehint.JSHints", false); + PreferencesManager.set("codehint.CssPropHints", false); + break; + case "BRAMBLE_DISABLE_INSPECTOR": // Disable the inspector, and clear any marks in the preview/editor MouseManager.disableInspector(true); diff --git a/src/extensions/default/bramble/lib/RemoteEvents.js b/src/extensions/default/bramble/lib/RemoteEvents.js index 462ab32c01b..a8ec16710b0 100644 --- a/src/extensions/default/bramble/lib/RemoteEvents.js +++ b/src/extensions/default/bramble/lib/RemoteEvents.js @@ -157,6 +157,40 @@ define(function (require, exports, module) { }); }); + // Listen for changes to TagHints + PreferencesManager.on("change", "codehint.TagHints", function () { + sendEvent({ + type: "bramble:autocompleteChange", + value: PreferencesManager.get("codehint.TagHints") + }); + }); + + // Listen for changes to AttrHints + PreferencesManager.on("change", "codehint.AttrHints", function () { + sendEvent({ + type: "bramble:autocompleteChange", + value: PreferencesManager.get("codehint.AttrHints") + }); + }); + + + // Listen for changes to JSHints + PreferencesManager.on("change", "codehint.JSHints", function () { + sendEvent({ + type: "bramble:autocompleteChange", + value: PreferencesManager.get("codehint.JSHints") + }); + }); + + + // Listen for changes to CssPropHints + PreferencesManager.on("change", "codehint.CssPropHints", function () { + sendEvent({ + type: "bramble:autocompleteChange", + value: PreferencesManager.get("codehint.CssPropHints") + }); + }); + //Listen for changes to auto update PreferencesManager.on("change", "autoUpdate", function () { sendEvent({ diff --git a/src/extensions/default/bramble/lib/UI.js b/src/extensions/default/bramble/lib/UI.js index 2368fc456df..043923746fa 100644 --- a/src/extensions/default/bramble/lib/UI.js +++ b/src/extensions/default/bramble/lib/UI.js @@ -98,6 +98,14 @@ define(function (require, exports, module) { PreferencesManager.set("allowJavaScript", allowJavaScript); } + var allowAutocomplete = BrambleStartupState.ui("allowAutocomplete"); + if(typeof allowAutocomplete === "boolean") { + PreferencesManager.set("codehint.AttrHints", allowAutocomplete); + PreferencesManager.set("codehint.TagHints", allowAutocomplete); + PreferencesManager.set("codehint.JSHints", allowAutocomplete); + PreferencesManager.set("codehint.CssPropHints", allowAutocomplete); + } + var autoUpdate = BrambleStartupState.ui("autoUpdate"); if(typeof autoUpdate === "boolean") { PreferencesManager.set("autoUpdate", autoUpdate); diff --git a/src/extensions/default/bramble/main.js b/src/extensions/default/bramble/main.js index 54e0a8cd345..1e2afefee46 100644 --- a/src/extensions/default/bramble/main.js +++ b/src/extensions/default/bramble/main.js @@ -190,6 +190,7 @@ define(function (require, exports, module) { previewMode: data.state.previewMode, wordWrap: data.state.wordWrap, allowJavaScript: data.state.allowJavaScript, + allowAutocomplete: data.state.allowAutocomplete, autoCloseTags: data.state.autoCloseTags, autoUpdate: data.state.autoUpdate });