Skip to content
Snippets Groups Projects
Commit 4df0c1fb authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[fix] Comment: submit when press Ctrl+Enter

parent df27b4e1
No related branches found
No related tags found
No related merge requests found
...@@ -214,6 +214,14 @@ function ESCommentsController($scope, $filter, $state, $focus, UIUtils) { ...@@ -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() { $scope.save = function() {
if (!$scope.formData.message || !$scope.formData.message.length) return; if (!$scope.formData.message || !$scope.formData.message.length) return;
......
<div class="comments" ng-controller="ESCommentsCtrl"> <form class="comments" ng-controller="ESCommentsCtrl" ng-submit="save()">
<div class="item item-divider"> <div class="item item-divider">
<i class="icon ion-chatboxes"></i> <i class="icon ion-chatboxes"></i>
...@@ -48,10 +48,11 @@ ...@@ -48,10 +48,11 @@
id="comment-form-textarea" id="comment-form-textarea"
rows="3" rows="3"
placeholder="{{formData.replyTo ? 'COMMENTS.COMMENT_HELP_REPLY_TO' : 'COMMENTS.COMMENT_HELP'|translate}}" 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> </textarea>
<div class="card-footer text-right"> <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-class="{'button-positive': formData.message.length}"
ng-if="!formData.id" ng-if="!formData.id"
ng-click="save()" translate> ng-click="save()" translate>
...@@ -59,11 +60,11 @@ ...@@ -59,11 +60,11 @@
</button> </button>
<!-- Edit buttons --> <!-- Edit buttons -->
<ng-if ng-if="formData.id"> <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> ng-click="cancel()" translate>
COMMON.BTN_CANCEL COMMON.BTN_CANCEL
</button> </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> ng-click="save()" translate>
COMMON.BTN_SAVE COMMON.BTN_SAVE
</button> </button>
...@@ -105,11 +106,11 @@ ...@@ -105,11 +106,11 @@
placeholder="{{'COMMENTS.COMMENT_HELP'|translate}}" placeholder="{{'COMMENTS.COMMENT_HELP'|translate}}"
on-return="save();" on-return="save();"
ng-model="formData.message"/> 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> <i class="icon ion-android-send"></i>
</button> </button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </form>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment