From 651609b673ac6631bb3e009208e51e41219ec91b Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Sat, 30 Apr 2016 14:25:47 +0200 Subject: [PATCH] Only show request for comments button after a delay --- app/assets/javascripts/editor.js.erb | 9 ++++++++- app/views/exercises/_editor_frame.html.slim | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/editor.js.erb b/app/assets/javascripts/editor.js.erb index 097c0250..b663548f 100644 --- a/app/assets/javascripts/editor.js.erb +++ b/app/assets/javascripts/editor.js.erb @@ -13,6 +13,7 @@ $(function() { var THEME = 'ace/theme/textmate'; var REMEMBER_TAB = false; var AUTOSAVE_INTERVAL = 15 * 1000; + var REQUEST_FOR_COMMENTS_DELAY = 5 * 60 * 1000; var NONE = 0; var WEBSOCKET = 1; var SERVER_SEND_EVENT = 2; @@ -477,11 +478,17 @@ $(function() { }; var initializeRequestForComments = function () { - $('#requestCommentsButton').on('click', function() { + var button = $('#requestCommentsButton'); + button.hide(); + button.on('click', function() { $('#comment-modal').modal('show'); }); $('#askForCommentsButton').on('click', requestComments); + + setTimeout(function() { + button.fadeIn(); + }, REQUEST_FOR_COMMENTS_DELAY); }; var isActiveFileBinary = function() { diff --git a/app/views/exercises/_editor_frame.html.slim b/app/views/exercises/_editor_frame.html.slim index 29c78bd3..9c3cc738 100644 --- a/app/views/exercises/_editor_frame.html.slim +++ b/app/views/exercises/_editor_frame.html.slim @@ -14,6 +14,6 @@ .editor-content.hidden data-file-id=file.ancestor_id = file.content .editor data-file-id=file.ancestor_id data-indent-size=file.file_type.indent_size data-mode=file.file_type.editor_mode data-read-only=file.read_only data-id=file.id - button.btn class='btn-primary' id='requestCommentsButton' type='button' + button.btn.btn-primary id='requestCommentsButton' type='button' i.fa.fa-comment-o = t('exercises.editor.requestComments') \ No newline at end of file