From ff9fb8d491f698da817bdf2cab3287af9b989d2a Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Wed, 14 Jun 2017 13:57:51 +0200 Subject: [PATCH 1/4] Remove unnecessary js.coffee file --- app/assets/javascripts/file_templates.js.coffee | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 app/assets/javascripts/file_templates.js.coffee diff --git a/app/assets/javascripts/file_templates.js.coffee b/app/assets/javascripts/file_templates.js.coffee deleted file mode 100644 index 24f83d18..00000000 --- a/app/assets/javascripts/file_templates.js.coffee +++ /dev/null @@ -1,3 +0,0 @@ -# Place all the behaviors and hooks related to the matching controller here. -# All this logic will automatically be available in application.js. -# You can use CoffeeScript in this file: http://coffeescript.org/ From e739749828d8efca7464431deda3abdb5fdc25a5 Mon Sep 17 00:00:00 2001 From: Maximilian Grundke Date: Fri, 23 Jun 2017 12:19:27 +0200 Subject: [PATCH 2/4] Implement better flash behavior --- app/views/application/_flash.html.slim | 6 ++++-- lib/assets/javascripts/flash.js | 20 +++++++++++++++++--- lib/assets/stylesheets/flash.css.scss | 17 +++++++---------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/app/views/application/_flash.html.slim b/app/views/application/_flash.html.slim index a391ee23..cbb88634 100644 --- a/app/views/application/_flash.html.slim +++ b/app/views/application/_flash.html.slim @@ -1,3 +1,5 @@ -#flash.fixed_error_messages.clickthrough data-message-failure=t('shared.message_failure') +#flash.fixed_error_messages data-message-failure=t('shared.message_failure') - %w[alert danger info notice success warning].each do |severity| - p.alert.flash class="alert-#{{'alert' => 'warning', 'notice' => 'success'}.fetch(severity, severity)}" id="flash-#{severity}" = flash[severity] + div.alert.flash class="alert-#{{'alert' => 'warning', 'notice' => 'success'}.fetch(severity, severity)}" id="flash-#{severity}" + p = flash[severity] + span.fa.fa-times \ No newline at end of file diff --git a/lib/assets/javascripts/flash.js b/lib/assets/javascripts/flash.js index cd5cb72d..fa79e71d 100644 --- a/lib/assets/javascripts/flash.js +++ b/lib/assets/javascripts/flash.js @@ -24,11 +24,25 @@ var showFlashes = function() { $('.flash').each(function() { - if ($(this).html() !== '') { - $(this).slideDown().delay(DURATION).slideUp(function() { - $(this).html(''); + var container = $(this); + var message = container.children().first(); + var button = container.children().last(); + + var hide = function() { + container.slideUp(function () { + message.html(''); }); + }; + + if (message.html() !== '') { + container.slideDown(); + container.animation = setTimeout(hide, DURATION); } + + button.on('click', function () { + clearTimeout(container.animation); + hide(); + }); }); }; diff --git a/lib/assets/stylesheets/flash.css.scss b/lib/assets/stylesheets/flash.css.scss index 661526e8..df52993a 100644 --- a/lib/assets/stylesheets/flash.css.scss +++ b/lib/assets/stylesheets/flash.css.scss @@ -1,5 +1,12 @@ .flash { display: none; + + span.fa-times { + position: relative; + top: -1.2em; + float: right; + cursor: pointer; + } } .fixed_error_messages { @@ -13,14 +20,4 @@ padding-top: 0; } -.clickthrough { - pointer-events: none; - - /* fixes for IE */ - /* - background:white; - opacity:0; - filter:Alpha(opacity=0); - */ -} From 56aa9f44951a8cd27660e1e16e1a6355e50bcba3 Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Mon, 3 Jul 2017 14:54:51 +0200 Subject: [PATCH 3/4] tidy up the autosave timer when exiting the page --- app/assets/javascripts/editor/submissions.js.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/editor/submissions.js.erb b/app/assets/javascripts/editor/submissions.js.erb index 48cead80..467c2cd7 100644 --- a/app/assets/javascripts/editor/submissions.js.erb +++ b/app/assets/javascripts/editor/submissions.js.erb @@ -196,6 +196,7 @@ CodeOceanEditorSubmissions = { unloadAutoSave: function() { if(this.autosaveTimer != null){ this.autosave(); + clearTimeout(this.autosaveTimer); } }, From ae04a5adc5e2311f253d0b2177fab4e7a60d75cc Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Mon, 3 Jul 2017 14:57:08 +0200 Subject: [PATCH 4/4] this should fix the "zombie file" bug. Turned out that the CodeOceanEditor object is not destroyed when navigating back and forth within the exercise context ( from an exercise back to the exercise index and forward to another exercise). Therefore, CodeOceanEditor.editors[] kept all "old" editors and added the new ones behind the old ones. On next autosave, they were persisted into a submission. --- app/assets/javascripts/editor/editor.js.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/editor/editor.js.erb b/app/assets/javascripts/editor/editor.js.erb index 2ac499c4..e3e34462 100644 --- a/app/assets/javascripts/editor/editor.js.erb +++ b/app/assets/javascripts/editor/editor.js.erb @@ -182,6 +182,7 @@ configureEditors: function () { }, initializeEditors: function () { + this.editors = []; $('.editor').each(function (index, element) { // Resize frame on load