Commit d7ad8a11ad25413edef898687562859e6711881b
1 parent
23f1db87
Exists in
master
and in
1 other branch
- using codemirror in textarea questions.
Showing
6 changed files
with
34 additions
and
26 deletions
Show diff stats
BUGS.md
| ... | ... | @@ -59,6 +59,7 @@ ou usar push (websockets?) |
| 59 | 59 | |
| 60 | 60 | # FIXED |
| 61 | 61 | |
| 62 | +- textarea com codemirror | |
| 62 | 63 | - decorador para user 0, evita o "if uid==0" em muitas funcoes. |
| 63 | 64 | - numeric interval deve converter respostas que usam virgulas para pontos decimais |
| 64 | 65 | - self.testapp.get_json_filename_of_test(test_id) retorna None quando test_id nao existe. | ... | ... |
static/css/test.css
static/js/tabkey_in_textarea.js
| ... | ... | @@ -1,18 +0,0 @@ |
| 1 | -$(document).ready(function() { | |
| 2 | - | |
| 3 | - $("textarea").keydown(function(e) { | |
| 4 | - if(e.keyCode === 9) { // tab was pressed | |
| 5 | - // get caret position/selection | |
| 6 | - var start = this.selectionStart; | |
| 7 | - var end = this.selectionEnd; | |
| 8 | - var value = $(this).val(); | |
| 9 | - | |
| 10 | - // set textarea value to: text before caret + tab + text after caret | |
| 11 | - $(this).val(value.substring(0, start) + " " + value.substring(end)); | |
| 12 | - | |
| 13 | - // put caret at right position again (add one for the tab) | |
| 14 | - this.selectionStart = this.selectionEnd = start + 4; | |
| 15 | - e.preventDefault(); // prevent the focus lose | |
| 16 | - } | |
| 17 | - }); | |
| 18 | -}); |
templates/question-textarea.html
templates/test.html
| ... | ... | @@ -16,22 +16,26 @@ |
| 16 | 16 | </script> |
| 17 | 17 | <script type="text/javascript" src="/static/MathJax/MathJax.js?config=TeX-AMS_CHTML-full"></script> |
| 18 | 18 | |
| 19 | -<!-- Styles --> | |
| 20 | - <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css"> | |
| 21 | - <link rel="stylesheet" href="/static/css/github.css"> <!-- syntax highlight --> | |
| 22 | - <link rel="stylesheet" href="/static/css/test.css"> | |
| 23 | - | |
| 24 | 19 | <!-- Scripts --> |
| 25 | - <script defer src="/static/jquery.min.js"></script> | |
| 20 | + <script src="/static/jquery.min.js"></script> | |
| 26 | 21 | <script defer src="/static/popper.min.js"></script> |
| 27 | 22 | <script defer src="/static/bootstrap/js/bootstrap.min.js"></script> |
| 28 | 23 | <script defer src="/static/fontawesome.min.js"></script> |
| 24 | + <script src="/static/codemirror/lib/codemirror.js"></script> | |
| 25 | + <script src="/static/codemirror/addon/selection/active-line.js"></script> | |
| 26 | + <script src="/static/codemirror/addon/edit/matchbrackets.js"></script> | |
| 27 | + | |
| 28 | +<!-- Styles --> | |
| 29 | + <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css"> | |
| 30 | + <link rel="stylesheet" href="/static/css/github.css"> <!-- syntax highlight --> | |
| 31 | + <link rel="stylesheet" href="/static/codemirror/lib/codemirror.css"> | |
| 32 | + <link rel="stylesheet" href="/static/codemirror/theme/darcula.css"> | |
| 33 | + <link rel="stylesheet" href="/static/css/test.css"> | |
| 29 | 34 | |
| 30 | 35 | <!-- My scripts --> |
| 31 | 36 | <!-- <script src="/static/js/detect_unfocus.js"></script> --> |
| 32 | 37 | <script defer src="/static/js/question_disabler.js"></script> |
| 33 | 38 | <script defer src="/static/js/prevent_enter_submit.js"></script> |
| 34 | - <script defer src="/static/js/tabkey_in_textarea.js"></script> | |
| 35 | 39 | <script defer src="/static/js/clock.js"></script> |
| 36 | 40 | </head> |
| 37 | 41 | <!-- ===================================================================== --> |
| ... | ... | @@ -126,5 +130,18 @@ |
| 126 | 130 | </div> |
| 127 | 131 | </div> |
| 128 | 132 | </div> |
| 133 | + | |
| 134 | +<script> | |
| 135 | + $("textarea").each(function(i, ta) { | |
| 136 | + CodeMirror.fromTextArea(ta, { | |
| 137 | + lineNumbers: true, | |
| 138 | + theme: "darcula", | |
| 139 | + viewportMargin: Infinity, | |
| 140 | + matchBrackets: true, | |
| 141 | + styleActiveLine: true, | |
| 142 | + }); | |
| 143 | + }); | |
| 144 | +</script> | |
| 145 | + | |
| 129 | 146 | </body> |
| 130 | 147 | </html> | ... | ... |