Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions src/bramble/client/StateManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ define(function() {
get: function() { return getBool(storage, "allowJavaScript"); },
set: function(v) { storage.setItem(prefix("allowJavaScript"), v); }
},
allowLint:{
get: function() { return getBool(storage, "interactive-linter"); },
set: function(v) { storage.setItem(prefix("interactive-linter"), v); }
}
autoUpdate: {
get: function() { return getBool(storage, "autoUpdate"); },
set: function(v) { storage.setItem(prefix("autoUpdate"), v); }
Expand Down
16 changes: 14 additions & 2 deletions src/bramble/client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ define([
self.getRootDir = function() { return _root; };
self.getWordWrap = function() { return _state.wordWrap; };
self.getAllowJavaScript = function() { return _state.allowJavaScript; };
self.getAllowLint = function() { return _state.allowLint; };
self.getAutoUpdate = function() { return _state.autoUpdate; };
self.getTutorialExists = function() { return _tutorialExists; };
self.getTutorialVisible = function() { return _tutorialVisible; };
Expand Down Expand Up @@ -265,6 +266,7 @@ define([
_state.theme = data.theme;
_state.wordWrap = data.wordWrap;
_state.allowJavaScript = data.allowJavaScript;
_state.allowLint = data.allowLint
_state.autoUpdate = data.autoUpdate;

setReadyState(Bramble.READY);
Expand Down Expand Up @@ -303,7 +305,9 @@ define([
_state.wordWrap = data.wordWrap;
} else if (eventName === "allowJavaScriptChange") {
_state.allowJavaScript = data.allowJavaScript;
} else if (eventName === "tutorialVisibilityChange") {
} else if (eventName == "allowLintChange"){
_state.allowLint = data.allowLint ;
}else if (eventName === "tutorialVisibilityChange") {
_tutorialVisible = data.visible;
} else if (eventName === "autoUpdateChange") {
_state.autoUpdate = data.autoUpdate;
Expand Down Expand Up @@ -422,6 +426,7 @@ define([
previewMode: _state.previewMode,
wordWrap: _state.wordWrap,
allowJavaScript: _state.allowJavaScript,
allowLint = _state.allowLint,
autoUpdate: _state.autoUpdate
}
};
Expand Down Expand Up @@ -903,6 +908,13 @@ define([
BrambleProxy.prototype.disableJavaScript = function(callback) {
this._executeRemoteCommand({commandCategory: "bramble", command: "BRAMBLE_DISABLE_SCRIPTS"}, callback);
};
BrambleProxy.prototype.enableLint = function(callback) {
this._executeRemoteCommand({commandCategory: "bramble", command: "BRAMBLE_ENABLE_LINT"}, callback);
};

BrambleProxy.prototype.disableLint = function(callback) {
this._executeRemoteCommand({commandCategory: "bramble", command: "BRAMBLE_DISABLE_Lint"}, callback);
};

BrambleProxy.prototype.enableInspector = function(callback) {
this._executeRemoteCommand({commandCategory: "bramble", command: "BRAMBLE_ENABLE_INSPECTOR"}, callback);
Expand Down Expand Up @@ -953,7 +965,7 @@ define([
BrambleProxy.prototype.export = function(callback) {
this._executeRemoteCommand({commandCategory: "bramble", command: "BRAMBLE_EXPORT"}, callback);
};

BrambleProxy.prototype.addCodeSnippet = function(options, callback) {
this._executeRemoteCommand({
commandCategory: "bramble",
Expand Down
2 changes: 1 addition & 1 deletion src/command/Commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ define(function (require, exports, module) {
exports.TOGGLE_ACTIVE_LINE = "view.toggleActiveLine"; // EditorOptionHandlers.js _getToggler()
exports.TOGGLE_WORD_WRAP = "view.toggleWordWrap"; // EditorOptionHandlers.js _getToggler()
exports.TOGGLE_ALLOW_JAVASCRIPT = "cmd.toggleAllowJavaScript"; // EditorOptionsHandlers.js _getToggler()
exports.TOGGLE_ALLOW_LINT = "cmd.toggleAllowLint"; // EditorOptionsHandlers.js _getToggler()
Copy link

Choose a reason for hiding this comment

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

Don't need this file changed.

exports.TOGGLE_AUTO_UPDATE = "cmd.toggleAutoUpdate"; // EditorOptionsHandlers.js _getToggler()

exports.CMD_OPEN = "cmd.open";
Expand Down Expand Up @@ -181,4 +182,3 @@ define(function (require, exports, module) {
DeprecationWarning.deprecateConstant(exports, "SORT_WORKINGSET_BY_TYPE", "CMD_WORKINGSET_SORT_BY_TYPE");
DeprecationWarning.deprecateConstant(exports, "SORT_WORKINGSET_AUTO", "CMD_WORKING_SORT_TOGGLE_AUTO");
});

32 changes: 24 additions & 8 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ define(function (require, exports, module) {
WORD_WRAP = "wordWrap",
INDENT_LINE_COMMENT = "indentLineComment",
ALLOW_JAVASCRIPT = "allowJavaScript",
ALLOW_LINT = "interactive-linter",
Copy link

Choose a reason for hiding this comment

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

Don't need any of the changes to this file, you can revert all this.

AUTO_UPDATE = "autoUpdate";


var cmOptions = {};

Expand Down Expand Up @@ -129,7 +130,9 @@ define(function (require, exports, module) {
cmOptions[TAB_SIZE] = "tabSize";
cmOptions[USE_TAB_CHAR] = "indentWithTabs";
cmOptions[WORD_WRAP] = "lineWrapping";
cmOptions[ALLOW_JAVASCRIPT] = "allowJavaScript";
cmOptions[ALLOW_JAVASCRIPT] = "interactive-linter";
cmOptions[ALLOW_LINT] = "allowLint";


PreferencesManager.definePreference(CLOSE_BRACKETS, "boolean", true, {
description: Strings.DESCRIPTION_CLOSE_BRACKETS
Expand Down Expand Up @@ -213,14 +216,17 @@ define(function (require, exports, module) {
PreferencesManager.definePreference(WORD_WRAP, "boolean", true, {
description: Strings.DESCRIPTION_WORD_WRAP
});

PreferencesManager.definePreference(INDENT_LINE_COMMENT, "boolean", false, {
description: Strings.DESCRIPTION_INDENT_LINE_COMMENT
});

PreferencesManager.definePreference(ALLOW_JAVASCRIPT, "boolean", true, {
description: Strings.DESCRIPTION_ALLOW_JAVASCRIPT
});
PreferencesManager.definePreference(ALLOW_LINT, "boolean", true, {
description: Strings.DESCRIPTION_ALLOW_LINT
});

PreferencesManager.definePreference(AUTO_UPDATE, "boolean", true, {
description: Strings.DESCRIPTION_AUTO_UPDATE
Expand Down Expand Up @@ -350,7 +356,7 @@ define(function (require, exports, module) {

// To track which pane the editor is being attached to if it's a full editor
this._paneId = null;

// To track the parent editor ( host editor at that time of creation) of an inline editor
this._hostEditor = null;

Expand Down Expand Up @@ -416,6 +422,7 @@ define(function (require, exports, module) {
lineWiseCopyCut : currentOptions[LINEWISE_COPY_CUT],
lineWrapping : currentOptions[WORD_WRAP],
allowJavaScript : currentOptions[ALLOW_JAVASCRIPT],
allowLint : currentOptions[ALLOW_LINT],
matchBrackets : { maxScanLineLength: 50000, maxScanLines: 1000 },
matchTags : { bothTags: true },
scrollPastEnd : !range && currentOptions[SCROLL_PAST_END],
Expand Down Expand Up @@ -1022,7 +1029,7 @@ define(function (require, exports, module) {
this._codeMirror.on("focus", function () {
self._focused = true;
self.trigger("focus", self);

});

this._codeMirror.on("blur", function () {
Expand Down Expand Up @@ -2552,7 +2559,7 @@ define(function (require, exports, module) {

/**
* Sets lineCommentIndent option.
*
*
* @param {boolean} value
* @param {string=} fullPath Path to file to get preference for
* @return {boolean} true if value was valid
Expand All @@ -2561,7 +2568,7 @@ define(function (require, exports, module) {
var options = fullPath && {context: fullPath};
return PreferencesManager.set(INDENT_LINE_COMMENT, value, options);
};

/**
* Returns true if word wrap is enabled for the specified or current file
* @param {string=} fullPath Path to file to get preference for
Expand All @@ -2570,7 +2577,7 @@ define(function (require, exports, module) {
Editor.getIndentLineComment = function (fullPath) {
return PreferencesManager.get(INDENT_LINE_COMMENT, _buildPreferencesContext(fullPath));
};

Editor.setAllowJavaScript = function (value, fullPath) {
var options = fullPath && {context: fullPath};
return PreferencesManager.set(ALLOW_JAVASCRIPT, value, options);
Expand All @@ -2580,6 +2587,15 @@ define(function (require, exports, module) {
return PreferencesManager.get(ALLOW_JAVASCRIPT, _buildPreferencesContext(fullPath));
};

Editor.setAllowLint = function (value, fullPath) {
var options = fullPath && {context: fullPath};
return PreferencesManager.set(ALLOW_LINT, value, options);
};

Editor.getAllowLint = function (fullPath) {
return PreferencesManager.get(ALLOW_LINT, _buildPreferencesContext(fullPath));
};

/**
* Runs callback for every Editor instance that currently exists
* @param {!function(!Editor)} callback
Expand Down
3 changes: 3 additions & 0 deletions src/editor/EditorOptionHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ define(function (require, exports, module) {
STYLE_ACTIVE_LINE = "styleActiveLine",
WORD_WRAP = "wordWrap",
Copy link

Choose a reason for hiding this comment

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

Don't need any of these changes.

ALLOW_JAVASCRIPT = "allowJavaScript",
ALLOW_LINT = "allowLint",
CLOSE_BRACKETS = "closeBrackets",
AUTO_UPDATE = "autoUpdate";

Expand All @@ -50,6 +51,7 @@ define(function (require, exports, module) {
_optionMapping[STYLE_ACTIVE_LINE] = Commands.TOGGLE_ACTIVE_LINE;
_optionMapping[WORD_WRAP] = Commands.TOGGLE_WORD_WRAP;
_optionMapping[ALLOW_JAVASCRIPT] = Commands.TOGGLE_ALLOW_JAVASCRIPT;
_optionMapping[ALLOW_LINT] = Commands.TOGGLE_ALLOW_LINT ;
_optionMapping[CLOSE_BRACKETS] = Commands.TOGGLE_CLOSE_BRACKETS;
_optionMapping[AUTO_UPDATE] = Commands.TOGGLE_AUTO_UPDATE;

Expand Down Expand Up @@ -104,6 +106,7 @@ define(function (require, exports, module) {

// XXXBramble
CommandManager.registerInternal(Commands.TOGGLE_ALLOW_JAVASCRIPT, _getToggler(ALLOW_JAVASCRIPT));
CommandManager.registerInternal(Commands.TOGGLE_ALLOW_LINT, _getToggler(ALLOW_LINT));
CommandManager.registerInternal(Commands.TOGGLE_AUTO_UPDATE, _getToggler(AUTO_UPDATE));

AppInit.htmlReady(_init);
Expand Down
8 changes: 8 additions & 0 deletions src/extensions/default/bramble/lib/RemoteCommandHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ define(function (require, exports, module) {
PreferencesManager.set("allowJavaScript", false);
PostMessageTransport.reload();
break;
case "BRAMBLE_ENABLE_LINT":
PreferencesManager.set("allowLint", true);
Copy link

Choose a reason for hiding this comment

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

You have to set this for the proper pref in your extension:

PreferencesManager.getExtensionPrefs("interactive-linter").set("enabled" true);

I think. Test that.

PostMessageTransport.reload();
break;
case "BRAMBLE_DISABLE_LINT":
PreferencesManager.set("allowLint", false);
Copy link

Choose a reason for hiding this comment

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

Same thing here.

PostMessageTransport.reload();
break;
case "BRAMBLE_ENABLE_INSPECTOR":
MouseManager.enableInspector();
break;
Expand Down
11 changes: 10 additions & 1 deletion src/extensions/default/bramble/lib/RemoteEvents.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,22 @@ define(function (require, exports, module) {
wordWrap: PreferencesManager.get("wordWrap")
});
});

// Listen for changes to allow javascript
PreferencesManager.on("change", "allowJavaScript", function () {
sendEvent({
type: "bramble:allowJavaScriptChange",
allowJavaScript: PreferencesManager.get("allowJavaScript")
});
});
// Listen for changes to allow javascript
var Lint = PreferencesManager.getExtensionPrefs("interactive-linter");
Copy link

Choose a reason for hiding this comment

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

var lintPrefs

Lint.on("change", "allowLint", function () {
Copy link

Choose a reason for hiding this comment

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

This is wrong. Check out https://github.com/mozilla/brackets/pull/702/files which is pretty similar to what you're doing.

sendEvent({
type: "bramble:allowLintChange",
allowLint: PreferencesManager.get("enabled")
});
});

//Listen for changes to auto update
PreferencesManager.on("change", "autoUpdate", function () {
Expand Down Expand Up @@ -174,6 +182,7 @@ define(function (require, exports, module) {
theme: Theme.getTheme(),
wordWrap: PreferencesManager.get("wordWrap"),
allowJavaScript: PreferencesManager.get("allowJavaScript"),
allowLint: PreferencesManager.getExtensionPrefs("interactive-linter").get("enabled"),
autoUpdate: PreferencesManager.get("autoUpdate")
});
}
Expand Down
8 changes: 6 additions & 2 deletions src/extensions/default/bramble/lib/UI.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ define(function (require, exports, module) {
if(typeof allowJavaScript === "boolean") {
PreferencesManager.set("allowJavaScript", allowJavaScript);
}
var allowLint = BrambleStartupState.ui("interactive-linter");
if(typeof allowLint === "boolean") {
PreferencesManager.getExtensionPrefs("interactive-linter").set("enabled", allowLint);
}

var autoUpdate = BrambleStartupState.ui("autoUpdate");
if(typeof autoUpdate === "boolean") {
Expand All @@ -116,11 +120,11 @@ define(function (require, exports, module) {

var secondPaneWidth = BrambleStartupState.ui("secondPaneWidth");
var firstPaneWidth = BrambleStartupState.ui("firstPaneWidth");

firstPaneWidth = firstPaneWidth * 100 / (
((firstPaneWidth)? firstPaneWidth : 0) +
((secondPaneWidth)? secondPaneWidth : 0)); // calculate width in %

if(firstPaneWidth) {
$("#first-pane").width((firstPaneWidth + "%"));
}
Expand Down
3 changes: 2 additions & 1 deletion src/extensions/default/bramble/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ define(function (require, exports, module) {
// Setup the iframe browser and Blob URL live dev servers and
// load the initial document into the preview.
startLiveDev();

BrambleCodeSnippets.init();

UI.initUI(finishStartup);
Expand Down Expand Up @@ -192,6 +192,7 @@ define(function (require, exports, module) {
previewMode: data.state.previewMode,
wordWrap: data.state.wordWrap,
allowJavaScript: data.state.allowJavaScript,
allowLint: data.state.allowLint,
autoUpdate: data.state.autoUpdate
});

Expand Down