Commit 4df0c1fb authored by Benoit Lavenier's avatar Benoit Lavenier

[fix] Comment: submit when press Ctrl+Enter

parent df27b4e1
......@@ -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;
......
<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>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment