Skip to content

Commit

Permalink
Fixes webcompat#1211: Added auto-expanding for bug reporting/comments…
Browse files Browse the repository at this point in the history
… area
  • Loading branch information
nj4710 committed Apr 4, 2017
1 parent 144ccc1 commit befa61a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
12 changes: 12 additions & 0 deletions webcompat/static/js/lib/bugform.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ function BugForm() {
// (after a page refresh, back button, etc.)
this.checkForm();

// Auto Expanding feature for form
this.autoExpand();

// Set up listener for message events from screenshot-enabled add-ons
window.addEventListener("message", _.bind(function(event) {
// Make sure the data is coming from ~*inside the house*~!
Expand Down Expand Up @@ -467,6 +470,15 @@ function BugForm() {
}, this));
};

// See function autoExpand in issues.js
this.autoExpand = function() {
var initialHeight = $("textarea.js-autoExpand").height();
$("textarea.js-autoExpand").on("input", function() {
$(this).css("height", initialHeight);
$(this).css({ "overflow":"hidden", "height": this.scrollHeight + "px"});
});
};

return this.init();
}

Expand Down
10 changes: 10 additions & 0 deletions webcompat/static/js/lib/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ issues.MainView = Backbone.View.extend({
this.initSubViews();
this.fetchModels();
this.handleKeyShortcuts();
this.autoExpand();
},
closeLabelEditor: function(e) {
var target = $(e.target);
Expand Down Expand Up @@ -489,6 +490,15 @@ issues.MainView = Backbone.View.extend({

handleKeyShortcuts: function() {
Mousetrap.bind("mod+enter", _.bind(this.addNewComment, this));
},

// See function autoExpand in bugform.js
autoExpand: function() {
var initialHeight = $("textarea.js-autoExpand").height();
$("textarea.js-autoExpand").on("input", function() {
$(this).css("height", initialHeight);
$(this).css({"overflow":"hidden", "height": this.scrollHeight + "px"});
});
}
});

Expand Down
2 changes: 1 addition & 1 deletion webcompat/templates/home-page/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h3 class="wc-Title--s">Report Site Issue</h3>
<div class="r-Grid r-Grid--withGutter ">
<div class="r-Grid-cell r-Grid-cell--alignBottom r-minS--1of2">
<div class="wc-Form-group js-Form-group">
{{ form.description.label(class_='wc-Form-label') }} {{ form.description(class_='wc-Form-item wc-Form-item--textarea', rows=7) }}
{{ form.description.label(class_='wc-Form-label') }} {{ form.description(class_='wc-Form-item wc-Form-item--textarea js-autoExpand', rows=7) }}
</div>
</div>
<div class="r-Grid-cell r-Grid-cell--alignBottom r-minS--1of2">
Expand Down
2 changes: 1 addition & 1 deletion webcompat/templates/issue/issue-comment-submit.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</div>
<div class="wc-Comment-body">
<label for="wc-Comment-text" class="wc-Accessibility">Comment Text</label>
<textarea class="wc-Comment-submit js-Comment-text mousetrap" placeholder="Leave a comment"></textarea>
<textarea class="wc-Comment-submit js-Comment-text mousetrap js-autoExpand" placeholder="Leave a comment"></textarea>
<div class="wc-Form-group js-ImageUploadView">
<script type="text/template" id="upload-input-tmpl">
<form>
Expand Down

0 comments on commit befa61a

Please sign in to comment.