This repository has been archived by the owner on Sep 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Fixed status bar so it can add indicators to itself again #6304
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c47783e
addIndicator now adds to DOM, add special case for CodeInspection module
lkcampbell 9ffd031
Small code cleanup
lkcampbell 462bea2
Make sure _beforeID element exists before inserting indicator before it
lkcampbell 77a0364
Add public parameter insertBefore to StatusBar.addIndicator()
lkcampbell 7c4197f
Update 'busy' indicator comments
lkcampbell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,13 +98,14 @@ define(function (require, exports, module) { | |
* @param {boolean=} visible Shows or hides the indicator over the statusbar. | ||
* @param {string=} style Sets the attribute "class" of the indicator. | ||
* @param {string=} tooltip Sets the attribute "title" of the indicator. | ||
* @param {string=} _beforeID For internal use by CodeInspection module. | ||
*/ | ||
function addIndicator(id, indicator, visible, style, tooltip) { | ||
function addIndicator(id, indicator, visible, style, tooltip, _beforeID) { | ||
if (!_init) { | ||
console.error("StatusBar API invoked before status bar created"); | ||
return; | ||
} | ||
|
||
indicator = indicator || document.createElement("div"); | ||
tooltip = tooltip || ""; | ||
style = style || ""; | ||
|
@@ -121,6 +122,13 @@ define(function (require, exports, module) { | |
$indicator.hide(); | ||
} | ||
|
||
if (_beforeID) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
|
||
$indicator.insertBefore("#" + _beforeID); | ||
} else { | ||
// The "busy" spinner should always be leftmost | ||
var $busyIndicator = $("#status-bar .spinner"); | ||
$indicator.insertBefore($busyIndicator); | ||
} | ||
} | ||
|
||
/** | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the preceding underscore should be removed. I don't see any reason why extensions shouldn't be allowed to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, it will be an API addition then. I have to make sure I understand exactly how it is to work so I name and document it correctly. When it was internal use, didn't have to worry about it.
First off, when I say BEFORE an indicator, I mean "to the left of" an indicator in the user interface. When I say AFTER an indicator, I mean "to the right of" an indicator in the user interface. This needs to be clarified because the DOM model of the indicator elements runs top-to-bottom, while the view of the indicators runs right-to-left. Makes it easy to confuse jQuery concepts of BEFORE and AFTER, with UI concepts of BEFORE and AFTER.
It seems like relative positioning should really have the ability to specific FIRST, LAST, and BEFORE, or AFTER, an existing element. So, one question is, is there any place we do not want to have extensions inserting indicators?
For example, putting an indicator FIRST would put it BEFORE the "busy" indicator. That would probably look weird.
Another example, putting an indicator LAST would put it AFTER the space/tab indicator. It seems like this messes with the user experience a bit.
But do we want to constrain relative positioning? Or do we allow it and let issue reports from users deal with the odd cases that crop up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon further reflection (i.e. a good night's sleep) we can probably pull this off with just beforeID. Except I am going to call it insertBefore because it is similar nomenclature to the jQuery method. In fact, I am going to paraphrase the jQuery documentation description as well because the purpose of this parameter is surprisingly difficult to describe without tying the sentence into knots:
An id of an existing status bar indicator. The new indicator will be inserted before (i.e. to the left of) the indicator specified by this parameter.
Ugh. Not great, but close enough.
The main side effect of only using insertBefore is that it is impossible to insert any indicator AFTER the space/tab indicator. I think this is a good thing though. It keeps the space/tab indicator in the lower right corner at all times.
We do need to decide, however, if we are going to prevent an insert BEFORE the "busy" indicator. If so, I need to update the parameter documentation a little and tweak the code. If not, we should be good to go with this next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we don't need to worry about inserting before the "busy" indicator because that indicator doesn't have an id. I suppose they could, theoretical, set the id to "status-bar .spinner", but the code discourages this behavior. So, we should be set with this next commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with keeping this simple.