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

Commit 006b360

Browse files
committed
Merge pull request #4509 from adobe/pflynn/jslint-tooltip
Fix #4486 (No JSLint icon tooltip in some states) & small cleanups
2 parents bb93dfc + 78c0c04 commit 006b360

4 files changed

Lines changed: 38 additions & 27 deletions

File tree

src/extensions/default/JSLint/jslint.css

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
#status-indicators #jslint-status {
22
border: none;
3-
cursor: default;
3+
cursor: default;
44
width: 13px;
55
}
66

77
.jslint-disabled {
88
background: url(images/topcoat-inactive-15.svg) 9px 5px no-repeat;
9-
pointer-events: none;
109
}
1110

1211
.jslint-errors {
@@ -23,7 +22,6 @@
2322

2423
.jslint-valid {
2524
background: url(images/topcoat-okay-15.svg) 9px 5px no-repeat;
26-
pointer-events: none;
2725
}
2826

2927
#jslint-results .line { /* To make the line number line up with editor line numbers */

src/extensions/default/JSLint/main.js

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ define(function (require, exports, module) {
9797
*/
9898
var _gotoEnabled = false;
9999

100+
/**
101+
* @private
102+
* @type {boolean}
103+
*/
104+
var _hasErrors = false;
105+
106+
100107
/**
101108
* Enable or disable the "Go to First JSLint Error" command
102109
* @param {boolean} gotoEnabled Whether it is enabled.
@@ -139,8 +146,10 @@ define(function (require, exports, module) {
139146
perfTimerDOM = PerfUtils.markStart("JSLint DOM:\t" + (!currentDoc || currentDoc.file.fullPath));
140147

141148
if (!result) {
142-
// Remove the null errors for the template
149+
// Remove any null error (early-abort indicator) before rendering results
143150
var errors = JSLINT.errors.filter(function (err) { return err !== null; });
151+
152+
// Update results table
144153
var html = Mustache.render(ResultsTemplate, {reportList: errors});
145154
var $selectedRow;
146155

@@ -164,16 +173,16 @@ define(function (require, exports, module) {
164173
EditorManager.focusEditor();
165174
});
166175

176+
_hasErrors = true;
167177
if (!_collapsed) {
168178
Resizer.show($lintResults);
169179
}
170180
if (JSLINT.errors.length === 1) {
171181
StatusBar.updateIndicator(INDICATOR_ID, true, "jslint-errors", Strings.JSLINT_ERROR_INFORMATION);
172182
} else {
173-
// Return the number of non-null errors
183+
// Error count string: if we filtered out a null above, there was a stop error so the
184+
// total number of errors is indeterminate. Append a '+' to indicate that.
174185
var numberOfErrors = errors.length;
175-
// If there was a null value it means there was a stop notice and an indeterminate
176-
// upper bound on the number of JSLint errors, which we'll represent by appending a '+'
177186
if (numberOfErrors !== JSLINT.errors.length) {
178187
// First discard the stop notice
179188
numberOfErrors -= 1;
@@ -185,6 +194,7 @@ define(function (require, exports, module) {
185194
setGotoEnabled(true);
186195

187196
} else {
197+
_hasErrors = false;
188198
Resizer.hide($lintResults);
189199
StatusBar.updateIndicator(INDICATOR_ID, true, "jslint-valid", Strings.JSLINT_NO_ERRORS);
190200
setGotoEnabled(false);
@@ -194,6 +204,7 @@ define(function (require, exports, module) {
194204

195205
} else {
196206
// JSLint is disabled or does not apply to the current file, hide the results
207+
_hasErrors = false;
197208
Resizer.hide($lintResults);
198209
StatusBar.updateIndicator(INDICATOR_ID, true, "jslint-disabled", Strings.JSLINT_DISABLED);
199210
setGotoEnabled(false);
@@ -291,29 +302,34 @@ define(function (require, exports, module) {
291302
AppInit.htmlReady(function () {
292303
ExtensionUtils.loadStyleSheet(module, "jslint.css");
293304

305+
// Create bottom panel to list error details
294306
var jsLintHtml = Mustache.render(JSLintTemplate, Strings);
295307
var resultsPanel = PanelManager.createBottomPanel("jslint.results", $(jsLintHtml), 100);
296308
$lintResults = $("#jslint-results");
297309

298310
var lintStatusHtml = Mustache.render("<div id=\"lint-status\" title=\"{{JSLINT_NO_ERRORS}}\">&nbsp;</div>", Strings);
299311
$(lintStatusHtml).insertBefore("#status-language");
300-
StatusBar.addIndicator(INDICATOR_ID, $("#lint-status"));
301312
$("#jslint-results .close").click(function () {
302313
toggleCollapsed(true);
303314
});
315+
316+
// Create status bar indicator
317+
StatusBar.addIndicator(INDICATOR_ID, $("#lint-status"));
304318

305-
$("#jslint-status").click(function () {
306-
toggleCollapsed();
319+
$("#jslint-status").click(function (event) {
320+
// Clicking indicator toggles error panel, if any errors in current file
321+
if (_hasErrors) {
322+
toggleCollapsed();
323+
}
307324
});
308-
309-
310-
// Called on HTML ready to trigger the initial UI state
325+
326+
// Set initial UI state
311327
setEnabled(_prefs.getValue("enabled"));
312328

313329
toggleCollapsed(_prefs.getValue("collapsed"));
314-
315330
});
316331

332+
317333
// for unit tests
318334
exports.setEnabled = setEnabled;
319335
});

src/nls/root/strings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ define({
195195
"CMD_FILE_DELETE" : "Delete",
196196
"CMD_INSTALL_EXTENSION" : "Install Extension\u2026",
197197
"CMD_EXTENSION_MANAGER" : "Extension Manager\u2026",
198-
"CMD_FILE_REFRESH" : "Refresh",
198+
"CMD_FILE_REFRESH" : "Refresh File Tree",
199199
"CMD_QUIT" : "Quit",
200200
// Used in native File menu on Windows
201201
"CMD_EXIT" : "Exit",

src/widgets/StatusBar.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,12 @@ define(function (require, exports, module) {
9494
/**
9595
* Registers a new status indicator
9696
* @param {string} id Registration id of the indicator to be updated.
97-
* @param {DOMNode} indicator Optional DOMNode for the indicator
98-
* @param {boolean} visible Shows or hides the indicator over the statusbar.
99-
* @param {string} style Sets the attribute "class" of the indicator.
100-
* @param {string} tooltip Sets the attribute "title" of the indicator.
101-
* @param {string} command Optional command name to execute on the indicator click.
102-
* TODO Unused command parameter. Include command functionality for statusbar indicators.
97+
* @param {(DOMNode|jQueryObject)=} indicator Optional DOMNode for the indicator
98+
* @param {boolean=} visible Shows or hides the indicator over the statusbar.
99+
* @param {string=} style Sets the attribute "class" of the indicator.
100+
* @param {string=} tooltip Sets the attribute "title" of the indicator.
103101
*/
104-
function addIndicator(id, indicator, visible, style, tooltip, command) {
102+
function addIndicator(id, indicator, visible, style, tooltip) {
105103
if (!_init) {
106104
console.error("StatusBar API invoked before status bar created");
107105
return;
@@ -117,7 +115,7 @@ define(function (require, exports, module) {
117115
$indicator.attr("id", id);
118116
$indicator.attr("title", tooltip);
119117
$indicator.addClass("indicator");
120-
$indicator.addClass("style");
118+
$indicator.addClass(style);
121119

122120
if (!visible) {
123121
$indicator.hide();
@@ -129,11 +127,10 @@ define(function (require, exports, module) {
129127
* Updates a status indicator
130128
* @param {string} id Registration id of the indicator to be updated.
131129
* @param {boolean} visible Shows or hides the indicator over the statusbar.
132-
* @param {string} style Sets the attribute "class" of the indicator.
133-
* @param {string} tooltip Sets the attribute "title" of the indicator.
134-
* @param {string} command Optional command name to execute on the indicator click.
130+
* @param {string=} style Sets the attribute "class" of the indicator.
131+
* @param {string=} tooltip Sets the attribute "title" of the indicator.
135132
*/
136-
function updateIndicator(id, visible, style, tooltip, command) {
133+
function updateIndicator(id, visible, style, tooltip) {
137134
if (!_init) {
138135
console.error("StatusBar API invoked before status bar created");
139136
return;

0 commit comments

Comments
 (0)