diff --git a/lms/djangoapps/course_wiki/editors.py b/lms/djangoapps/course_wiki/editors.py index a6583a8d98..c1f5b733ad 100644 --- a/lms/djangoapps/course_wiki/editors.py +++ b/lms/djangoapps/course_wiki/editors.py @@ -4,9 +4,12 @@ from django.utils.encoding import force_unicode from django.utils.html import conditional_escape from django.utils.safestring import mark_safe +from django.template.loader import render_to_string + from wiki.editors.base import BaseEditor from wiki.editors.markitup import MarkItUpAdminWidget + class CodeMirrorWidget(forms.Widget): def __init__(self, attrs=None): # The 'rows' and 'cols' attributes are required for HTML correctness. @@ -18,9 +21,15 @@ class CodeMirrorWidget(forms.Widget): def render(self, name, value, attrs=None): if value is None: value = '' + final_attrs = self.build_attrs(attrs, name=name) - return mark_safe(u'
%s
' % (flatatt(final_attrs), - conditional_escape(force_unicode(value)))) + + # TODO use the help_text field of edit form instead of rendering a template + + return render_to_string('wiki/includes/editor_widget.html', + {'attrs': mark_safe(flatatt(final_attrs)), + 'content': conditional_escape(force_unicode(value)), + }) class CodeMirror(BaseEditor): @@ -50,5 +59,6 @@ class CodeMirror(BaseEditor): "js/vendor/CodeMirror/xml.js", "js/vendor/CodeMirror/mitx_markdown.js", "js/wiki/CodeMirror.init.js", + "js/wiki/cheatsheet.js", ) diff --git a/lms/static/js/wiki/cheatsheet.js b/lms/static/js/wiki/cheatsheet.js new file mode 100644 index 0000000000..e6c8e3cdaf --- /dev/null +++ b/lms/static/js/wiki/cheatsheet.js @@ -0,0 +1,9 @@ +$(document).ready(function () { + $('#cheatsheetLink').click(function() { + $('#cheatsheetModal').modal('show'); + }); + + $('#cheatsheetModal .close-btn').click(function(e) { + $('#cheatsheetModal').modal('hide'); + }); +}); \ No newline at end of file diff --git a/lms/static/sass/course/wiki/_wiki.scss b/lms/static/sass/course/wiki/_wiki.scss index a58b8fa06c..1bc38abd9a 100644 --- a/lms/static/sass/course/wiki/_wiki.scss +++ b/lms/static/sass/course/wiki/_wiki.scss @@ -391,6 +391,18 @@ section.wiki { line-height: 1.4em; } + #div_id_content { + position: relative; + } + + #hint_id_content { + position: absolute; + top: 10px; + right: 0%; + font-size: 12px; + text-align:right; + } + .CodeMirror { background: #fafafa; border: 1px solid #c8c8c8; @@ -567,13 +579,6 @@ section.wiki { background: #f00 !important; } - .cheatsheet { - float: right; - position: relative; - top: -26px; - font-size: 12px; - } - #cheatsheetLink { text-align: right; display: float; diff --git a/lms/templates/wiki/base.html b/lms/templates/wiki/base.html index 1c1bbc4a63..8a9686f546 100644 --- a/lms/templates/wiki/base.html +++ b/lms/templates/wiki/base.html @@ -39,18 +39,6 @@ {% with mathjax_mode='wiki' %} {% include "mathjax_include.html" %} {% endwith %} - {% endaddtoblock %} {% endblock %} @@ -81,8 +69,6 @@ {% endblock %} - {% include "wiki/includes/cheatsheet.html" %} - {% endblock %} diff --git a/lms/templates/wiki/create.html b/lms/templates/wiki/create.html index 886764ba84..745be08cf8 100644 --- a/lms/templates/wiki/create.html +++ b/lms/templates/wiki/create.html @@ -42,6 +42,7 @@ {% trans "Go back" %} + {% include "wiki/includes/cheatsheet.html" %} diff --git a/lms/templates/wiki/edit.html b/lms/templates/wiki/edit.html index f4bd7d138f..65378da4e4 100644 --- a/lms/templates/wiki/edit.html +++ b/lms/templates/wiki/edit.html @@ -40,7 +40,10 @@ + {% include "wiki/includes/cheatsheet.html" %} {% endblock %} + + diff --git a/lms/templates/wiki/includes/cheatsheet.html b/lms/templates/wiki/includes/cheatsheet.html index 429c1ea22e..6f5170e601 100644 --- a/lms/templates/wiki/includes/cheatsheet.html +++ b/lms/templates/wiki/includes/cheatsheet.html @@ -1,4 +1,4 @@ - + diff --git a/lms/templates/wiki/includes/editor_widget.html b/lms/templates/wiki/includes/editor_widget.html new file mode 100644 index 0000000000..2f5dd7ce68 --- /dev/null +++ b/lms/templates/wiki/includes/editor_widget.html @@ -0,0 +1,4 @@ + +

+ Markdown syntax is allowed. See the cheatsheet for help. +