diff --git a/www/plugins/es/js/controllers/common-controllers.js b/www/plugins/es/js/controllers/common-controllers.js index 247708f449c0465177b5ecba86bcd44a0f4d75ea..330c40e0aa69c5ffb8e93fbb7b9cfdf2b650544e 100644 --- a/www/plugins/es/js/controllers/common-controllers.js +++ b/www/plugins/es/js/controllers/common-controllers.js @@ -214,6 +214,14 @@ function ESCommentsController($scope, $filter, $state, $focus, UIUtils) { }); }; + $scope.onKeypress = function(event) { + // If Ctrl + Enter: submit + if (event && event.charCode == 10 && event.ctrlKey) { + $scope.save(); + event.preventDefault(); + } + }; + $scope.save = function() { if (!$scope.formData.message || !$scope.formData.message.length) return; diff --git a/www/plugins/es/templates/common/view_comments.html b/www/plugins/es/templates/common/view_comments.html index 84de35c5af02aee95f58e91a905114a3c73be399..150dc46fc198e3bd384c4fe824a05e22638f2fc4 100644 --- a/www/plugins/es/templates/common/view_comments.html +++ b/www/plugins/es/templates/common/view_comments.html @@ -1,5 +1,5 @@ -<div class="comments" ng-controller="ESCommentsCtrl"> +<form class="comments" ng-controller="ESCommentsCtrl" ng-submit="save()"> <div class="item item-divider"> <i class="icon ion-chatboxes"></i> @@ -48,10 +48,11 @@ id="comment-form-textarea" rows="3" placeholder="{{formData.replyTo ? 'COMMENTS.COMMENT_HELP_REPLY_TO' : 'COMMENTS.COMMENT_HELP'|translate}}" - ng-model="formData.message"> + ng-model="formData.message" + ng-keypress="onKeypress($event)"> </textarea> <div class="card-footer text-right"> - <button class="button button-small button-small-padding" + <button type="button" class="button button-small button-small-padding" ng-class="{'button-positive': formData.message.length}" ng-if="!formData.id" ng-click="save()" translate> @@ -59,11 +60,11 @@ </button> <!-- Edit buttons --> <ng-if ng-if="formData.id"> - <button class="button button-small button-small-padding" + <button type="button" class="button button-small button-small-padding" ng-click="cancel()" translate> COMMON.BTN_CANCEL </button> - <button class="button button-small button-small-padding button-positive" + <button type="button" class="button button-small button-small-padding button-positive" ng-click="save()" translate> COMMON.BTN_SAVE </button> @@ -105,11 +106,11 @@ placeholder="{{'COMMENTS.COMMENT_HELP'|translate}}" on-return="save();" ng-model="formData.message"/> - <button class="button button-small button-small-padding button-icon button-dark button-icon gray" ng-click="save()"> + <button type="submit" class="button button-small button-small-padding button-icon button-dark button-icon gray"> <i class="icon ion-android-send"></i> </button> </div> </div> </div> </div> -</div> +</form>