Skip to content

Commit

Permalink
moves to 'be.comments' removes possibility of nested form and adds ke…
Browse files Browse the repository at this point in the history
…yup event handling to ease the situation
Aleck Landgraf committed Feb 20, 2015
1 parent 8153681 commit 7a438ef
Showing 7 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "be-comments",
"version": "0.0.3",
"version": "0.0.4",
"homepage": "https://github.com/buildingenergy/be-comments",
"authors": [
"Aleck Landgraf <[email protected]>",
12 changes: 11 additions & 1 deletion build/js/comments.js
Original file line number Diff line number Diff line change
@@ -51,6 +51,16 @@ angular.module('be.comments', [])
$scope.commentText = "";
commentsService.scrollToBottom(self.$element);
};

/**
* submits on enter key
*/
$scope.submitOnEnter = function (event) {
if (event.keyCode === 13) {
$scope.submitAComment();
}
};

scope.$watch('commentsData', function () {
commentsService.scrollToBottom(self.$element);
});
@@ -73,4 +83,4 @@ angular.module('be.comments', [])
};
});

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>");}]);
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>");}]);
2 changes: 1 addition & 1 deletion build/js/comments.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/js/comments.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "be-comments",
"version": "0.0.3",
"version": "0.0.4",
"repository": "https://github.com/buildingenergy/be-comments",
"dependencies": {},
"description": "dynamic and reusable AngularJS comments",
10 changes: 10 additions & 0 deletions source/js/comments.js
Original file line number Diff line number Diff line change
@@ -51,6 +51,16 @@ angular.module('be.comments', [])
$scope.commentText = "";
commentsService.scrollToBottom(self.$element);
};

/**
* submits on enter key
*/
$scope.submitOnEnter = function (event) {
if (event.keyCode === 13) {
$scope.submitAComment();
}
};

scope.$watch('commentsData', function () {
commentsService.scrollToBottom(self.$element);
});
14 changes: 7 additions & 7 deletions source/templates/be.comments.html
Original file line number Diff line number Diff line change
@@ -29,14 +29,14 @@
</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 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>
</ng-form>
</div>
</div>
</div>
</div>
</div>

0 comments on commit 7a438ef

Please sign in to comment.