Skip to content

Commit

Permalink
Add surrounding code for each error in the information pane - Fixes j…
Browse files Browse the repository at this point in the history
  • Loading branch information
dudeOFprosper committed Sep 15, 2015
1 parent 5051bc1 commit 45f7d4a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
7 changes: 6 additions & 1 deletion plugins/shared/info-panel/error.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@
{{{title}}}
</div>
</a>
<div class="tota11y-info-error-description tota11y-collapsed"></div>
<div class="tota11y-info-error-description tota11y-collapsed">
<div class="tota11y-info-error-description-code">
Surrounding code:
<code></code>
</div>
</div>
</li>
9 changes: 8 additions & 1 deletion plugins/shared/info-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ class InfoPanel {
// so that functionality can be inserted.
$error
.find(".tota11y-info-error-description")
.append(error.$description);
.prepend(error.$description);

$errors.append($error);

Expand Down Expand Up @@ -279,6 +279,13 @@ class InfoPanel {
// highlight when scrolling to the element with the button.
annotate.toggleHighlight(error.$el, $trigger);
annotate.toggleHighlight(error.$el, $scroll);

// Add surrounding code from error.$el to the information panel
// The code will appear in the error description inside
// tota11y-info-error-description-code

let surroundingCode = $(error.$el).parent().html().trim();
$error.find('.tota11y-info-error-description-code code').text(surroundingCode);
});

$errorsTab = $activeTab = this._addTab("Errors", $errors);
Expand Down
13 changes: 13 additions & 0 deletions plugins/shared/info-panel/style.less
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,19 @@
padding: 10px 0 0;
user-select: text;

&-code {
margin-top: 10px;

code {
display: -webkit-box;
margin-top: 10px;
overflow: hidden;
padding: 3px;
word-wrap: break-word;
-webkit-line-clamp: 25;
-webkit-box-orient: vertical;
}
}
&.tota11y-collapsed {
display: none
}
Expand Down

0 comments on commit 45f7d4a

Please sign in to comment.