summaryrefslogtreecommitdiffstats
path: root/apps/comments/js/commentstabview.js
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-02-02 12:06:12 +0100
committerVincent Petry <pvince81@owncloud.com>2016-02-02 18:01:15 +0100
commit9028457ea2a150a586e63421382379f14cebd648 (patch)
tree8420038f217635d92d7d6d0be00542611bd07632 /apps/comments/js/commentstabview.js
parentd81c00304f8af4cdbc5739d1471f0261bcca6ccf (diff)
downloadnextcloud-server-9028457ea2a150a586e63421382379f14cebd648.tar.gz
nextcloud-server-9028457ea2a150a586e63421382379f14cebd648.zip
Add spinner when submitting comments
Diffstat (limited to 'apps/comments/js/commentstabview.js')
-rw-r--r--apps/comments/js/commentstabview.js35
1 files changed, 30 insertions, 5 deletions
diff --git a/apps/comments/js/commentstabview.js b/apps/comments/js/commentstabview.js
index bc496f2e599..fd6b7b07dcb 100644
--- a/apps/comments/js/commentstabview.js
+++ b/apps/comments/js/commentstabview.js
@@ -20,6 +20,7 @@
' <form class="newCommentForm">' +
' <textarea class="message" placeholder="{{newMessagePlaceholder}}"></textarea>' +
' <input class="submit" type="submit" value="{{submitText}}" />' +
+ ' <div class="submitLoading icon-loading-small hidden"></div>'+
' </form>' +
' <ul class="comments">' +
' </ul>' +
@@ -125,7 +126,6 @@
altDate: OC.Util.formatDate(timestamp),
formattedMessage: this._formatMessage(commentModel.get('message'))
}, commentModel.attributes);
- // TODO: format
return data;
},
@@ -188,9 +188,22 @@
},
_onSubmitComment: function(e) {
+ var $form = $(e.target);
var currentUser = OC.getCurrentUser();
- var $textArea = $(e.target).find('textarea');
+ var $submit = $form.find('.submit');
+ var $loading = $form.find('.submitLoading');
+ var $textArea = $form.find('textarea');
+ var message = $textArea.val().trim();
e.preventDefault();
+
+ if (!message.length) {
+ return;
+ }
+
+ $textArea.prop('disabled', true);
+ $submit.addClass('hidden');
+ $loading.removeClass('hidden');
+
this.collection.create({
actorId: currentUser.uid,
actorDisplayName: currentUser.displayName,
@@ -198,10 +211,22 @@
verb: 'comment',
message: $textArea.val(),
creationDateTime: (new Date()).getTime()
- }, {at: 0});
+ }, {
+ at: 0,
+ success: function() {
+ $submit.removeClass('hidden');
+ $loading.addClass('hidden');
+ $textArea.val('').prop('disabled', false);
+ },
+ error: function(msg) {
+ $submit.removeClass('hidden');
+ $loading.addClass('hidden');
+ $textArea.prop('disabled', false);
+
+ OC.Notification.showTemporary(msg);
+ }
+ });
- // TODO: spinner/disable field?
- $textArea.val('');
return false;
}
});