Skip to content

Commit

Permalink
Resize editor when showing warning or error; add X to close warning o…
Browse files Browse the repository at this point in the history
…r error.
  • Loading branch information
fpereiro committed Feb 11, 2021
1 parent e384a75 commit c85ad11
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion static/css/generated.css

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

// *** EDITOR SETUP ***

var editor = ace.edit("editor");
// We expose the editor globally so it's available to other functions for resizing
var editor = window.editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
// editor.session.setMode("ace/mode/javascript");

Expand Down Expand Up @@ -287,18 +288,21 @@ var error = {
hide() {
$('#errorbox').hide();
$('#warningbox').hide();
editor.resize ();
},

showWarning(caption, message) {
$('#warningbox .caption').text(caption);
$('#warningbox .details').text(message);
$('#warningbox').show();
editor.resize ();
},

show(caption, message) {
$('#errorbox .caption').text(caption);
$('#errorbox .details').text(message);
$('#errorbox').show();
editor.resize ();
}
};

Expand Down
14 changes: 14 additions & 0 deletions tailwind/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,17 @@ table.users td {
.bg-gray-400 {
background-color: #cbd5e0;
}

/* EDITOR WARNINGS & ERRORS */

div#errorbox, div#warningbox {
position: relative;
}

p.close-dialog {
font-weight: bold;
position: absolute;
top: 5px;
right: 5px;
cursor: pointer;
}
2 changes: 2 additions & 0 deletions templates/code-page.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h2 class="mt-4">{{assignment_header}}</h2>
<!-- errorbox -->
<div id="errorbox" class="flex-0 mt-0 bg-red-100 border-t-4 border-red-500 rounded-b text-red-900 px-4 py-3 shadow-md"
role="alert" style="display: none;">
<p class="close-dialog" onclick="$ ('#errorbox').hide ()">X</p>
<div class="flex">
<div class="py-1">
<svg class="fill-current h-6 w-6 text-red-500 mr-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
Expand All @@ -51,6 +52,7 @@ <h2 class="mt-4">{{assignment_header}}</h2>
<!-- warningbox -->
<div id="warningbox" class="flex-0 mt-0 bg-yellow-100 border-t-4 border-yellow-500 rounded-b text-yellow-900 px-4 py-3 shadow-md"
role="alert" style="display: none;">
<p class="close-dialog" onclick="$ ('#warningbox').hide ()">X</p>
<div class="flex">
<div class="py-1">
<svg class="fill-current h-6 w-6 text-yellow-500 mr-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20">
Expand Down

0 comments on commit c85ad11

Please sign in to comment.