Skip to content

Commit 7a438ef

Browse files
author
Aleck Landgraf
committed
moves to 'be.comments' removes possibility of nested form and adds keyup event handling to ease the situation
1 parent 8153681 commit 7a438ef

File tree

7 files changed

+32
-12
lines changed

7 files changed

+32
-12
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "be-comments",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"homepage": "https://github.com/buildingenergy/be-comments",
55
"authors": [
66
"Aleck Landgraf <[email protected]>",

build/js/comments.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ angular.module('be.comments', [])
5151
$scope.commentText = "";
5252
commentsService.scrollToBottom(self.$element);
5353
};
54+
55+
/**
56+
* submits on enter key
57+
*/
58+
$scope.submitOnEnter = function (event) {
59+
if (event.keyCode === 13) {
60+
$scope.submitAComment();
61+
}
62+
};
63+
5464
scope.$watch('commentsData', function () {
5565
commentsService.scrollToBottom(self.$element);
5666
});
@@ -73,4 +83,4 @@ angular.module('be.comments', [])
7383
};
7484
});
7585

76-
angular.module("be.comments").run(["$templateCache", function($templateCache) {$templateCache.put("be.comments.html","<div class=\"section_content_container\"><div class=\"section_content with_padding with_top_padding\"><div class=\"comment_section_container\"><div class=\"comment_section_title\"><ng-pluralize count=\"commentsData.length\" when=\"{\'0\': \'Comments\', \'1\': \'1 Comment\', \'other\': \'{} Comments\'}\"></ng-pluralize></div><div class=\"comment_container\"><table ng-class=\"{contacts_comment: c.email !== email, user_comment: c.email === email}\" ng-repeat=\"c in commentsData\"><tbody><tr><td colspan=\"2\" class=\"time_stamp\" ng-hide=\"true\">thu 2:08 pm</td></tr><tr><td><div ng-if=\"c.email !== email\">{{ c.name | initials }}</div></td><td><div class=\"comment\">{{ c.text }}</div></td><td></td></tr></tbody></table></div><div class=\"comment_input\"><ng-form name=\"commentForm\" ng-submit=\"submitAComment()\"><div class=\"form-group\"><div class=\"input-group\"><input name=\"commentText\" type=\"text\" class=\"form-control\" id=\"commentText\" placeholder=\"Write a comment...\" ng-model=\"commentText\"> <a class=\"input-group-addon\" ng-click=\"submitAComment()\"><i class=\"fa fa-comment-o\" ng-if=\"commentText.length == 0 || !commentText\"></i><i class=\"fa fa-comment\" ng-if=\"commentText.length > 0\"></i></a></div></div></ng-form></div></div></div></div>");}]);
86+
angular.module("be.comments").run(["$templateCache", function($templateCache) {$templateCache.put("be.comments.html","<div class=\"section_content_container\"><div class=\"section_content with_padding with_top_padding\"><div class=\"comment_section_container\"><div class=\"comment_section_title\"><ng-pluralize count=\"commentsData.length\" when=\"{\'0\': \'Comments\', \'1\': \'1 Comment\', \'other\': \'{} Comments\'}\"></ng-pluralize></div><div class=\"comment_container\"><table ng-class=\"{contacts_comment: c.email !== email, user_comment: c.email === email}\" ng-repeat=\"c in commentsData\"><tbody><tr><td colspan=\"2\" class=\"time_stamp\" ng-hide=\"true\">thu 2:08 pm</td></tr><tr><td><div ng-if=\"c.email !== email\">{{ c.name | initials }}</div></td><td><div class=\"comment\">{{ c.text }}</div></td><td></td></tr></tbody></table></div><div class=\"comment_input\"><div name=\"commentForm\" ng-submit=\"submitAComment()\"><div class=\"form-group\"><div class=\"input-group\"><input name=\"commentText\" type=\"text\" class=\"form-control\" id=\"commentText\" placeholder=\"Write a comment...\" ng-model=\"commentText\" ng-keyup=\"submitOnEnter($event)\"> <a class=\"input-group-addon\" ng-click=\"submitAComment()\"><i class=\"fa fa-comment-o\" ng-if=\"commentText.length == 0 || !commentText\"></i><i class=\"fa fa-comment\" ng-if=\"commentText.length > 0\"></i></a></div></div></div></div></div></div></div>");}]);

build/js/comments.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/js/comments.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "be-comments",
3-
"version": "0.0.3",
3+
"version": "0.0.4",
44
"repository": "https://github.com/buildingenergy/be-comments",
55
"dependencies": {},
66
"description": "dynamic and reusable AngularJS comments",

source/js/comments.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ angular.module('be.comments', [])
5151
$scope.commentText = "";
5252
commentsService.scrollToBottom(self.$element);
5353
};
54+
55+
/**
56+
* submits on enter key
57+
*/
58+
$scope.submitOnEnter = function (event) {
59+
if (event.keyCode === 13) {
60+
$scope.submitAComment();
61+
}
62+
};
63+
5464
scope.$watch('commentsData', function () {
5565
commentsService.scrollToBottom(self.$element);
5666
});

source/templates/be.comments.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
</table>
3030
</div>
3131
<div class="comment_input">
32-
<ng-form name="commentForm" ng-submit="submitAComment()">
33-
<div class="form-group">
34-
<div class="input-group">
35-
<input name="commentText" type="text" class="form-control" id="commentText" placeholder="Write a comment..." ng-model="commentText">
36-
<a class="input-group-addon" ng-click="submitAComment()"><i class="fa fa-comment-o" ng-if="commentText.length == 0 || !commentText"></i><i class="fa fa-comment" ng-if="commentText.length > 0"></i></a>
37-
</div>
32+
<div name="commentForm" ng-submit="submitAComment()">
33+
<div class="form-group">
34+
<div class="input-group">
35+
<input name="commentText" type="text" class="form-control" id="commentText" placeholder="Write a comment..." ng-model="commentText" ng-keyup="submitOnEnter($event)">
36+
<a class="input-group-addon" ng-click="submitAComment()"><i class="fa fa-comment-o" ng-if="commentText.length == 0 || !commentText"></i><i class="fa fa-comment" ng-if="commentText.length > 0"></i></a>
3837
</div>
39-
</ng-form>
38+
</div>
39+
</div>
4040
</div>
4141
</div>
4242
</div>

0 commit comments

Comments
 (0)