Highlighting the row, which is in the URL
Review Request #5706 — Created April 12, 2014 and submitted
Highlighting the row, which is in the URL. This is the part 2 of my project. The goal is to highlight the row, which is in the URL (example:
localhost:8080/r/1/diff/#file2,1072) based on the file and the line number.
Testing done on my development server locally, works fine there
Description | From | Last Updated |
---|---|---|
It would be nice to combine this a bit with the selector passed into diffReviewableView. How about this in the … |
david | |
This could also be defined in the initial variable definition instead of as a separate statement. |
david | |
Spacing is a bit weird here. Add a space between if and (, and remove one of the two after … |
david | |
Please add spaces around the + characters. |
david | |
Put the })); on the next line. |
david | |
You should probably merge the code above with this--we don't want to add a second anchor if one already exists, … |
david | |
You use this hex color in two places--mind defining a variable for it in defs.less? Also, add a space after … |
david | |
This should use a variable for the color, and include a space after the : |
david | |
This should use a variable for the color, and include a space after the : |
david | |
This should use a variable for the color, and include a space after the : |
david | |
This is closer, but still doesn't do quite the right thing for the case of comment anchors which are added … |
david | |
There are a ton of typos in this comment. |
david | |
This change exposed an existing bug in the code. If the URL contains any hash, we want to strip it … |
david | |
If this._startAtAnchorName is null, this line will fail (and break the diff viewer). Can you change this line to just … |
david |
- Groups:
-
-
It would be nice to combine this a bit with the selector passed into diffReviewableView. How about this in the variable definitions:
var elementName = 'file' + diffReviewable.get('fileDiffID'), diffReviewableView = new RB.DiffReviewableView({ el: $('#' + elementName'), model: diffReviewable }), ...
-
-
-
-
-
You should probably merge the code above with this--we don't want to add a second anchor if one already exists, and it would be nice to keep these things next to each other.
- Change Summary:
-
Adding the highlight color, refacotring the code and moving out of WIP
- Summary:
-
[WIP] Highlighting the row, which is in the URLHighlighting the row, which is in the URL
- Testing Done:
-
+ Testing done on my development server locally, works fine there
- Commit:
-
2c6dd42904ca4bfd2b7bc7b8c84cc2bdfd4985f71de791cc02b5bbba9d00d8f3c1089d375b1409c7
- Change Summary:
-
ElementName fixed
- Commit:
-
1de791cc02b5bbba9d00d8f3c1089d375b1409c7581e587514ec864ccb63ce84c6a787de730524a2
-
-
You use this hex color in two places--mind defining a variable for it in defs.less?
Also, add a space after the :
-
-
-
-
This is closer, but still doesn't do quite the right thing for the case of comment anchors which are added by the template. I think probably what you need is something more like the following. Note that I haven't tested it, it's just a proposal for how to structure this code.
if (this._startAtAnchorName) { $anchor = $('a[name]"' + this._startAtAnchorName + '"]'); /* * Some anchors are added by the template (such as those at * comment locations), but not all are. If the anchor isn't found, * but the URL hash is indicating that we want to start at a * location within this file, add the anchor. * / if ($anchor.length === 0 && urlSplit.length === 2 && elementName === urlSplit[0]) { $anchor = $(this.anchorTemplate({ anchorName: this._startAtAnchorName }); diffReviewableView.$el .find("tr[line='" + urlSplit[1] + "']) .addClass('highlight-anchor') .append($anchor); } if ($anchor.length !== 0) { this.selectAnchor($anchor); this._startAtAnchorName = null; } }
-
- Change Summary:
-
Fixed the stylesheet issues and refactored the code according to the comments
- Commit:
-
581e587514ec864ccb63ce84c6a787de730524a2bb3e76e0a33f65b647cdd339349a4109ef81ad40
-
Just a couple small changes left!
-
This change exposed an existing bug in the code. If the URL contains any hash, we want to strip it out here (otherwise if you copy a URL from a page which was navigated to you might end up with something like "diff/1/file1672,3#file1672,4" which doesn't work. Can you change this to just be
if (window.location.hash)
? -
If
this._startAtAnchorName
is null, this line will fail (and break the diff viewer). Can you change this line to just define the variable, and then assign it within theif (this._startAtAnchorName)
block?